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
r1563 - in branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler: . decorators generators
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 16:23:35 +0200 (Wed, 07 Oct 2009)
New Revision: 1563
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.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/GeneratorManager.java
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/SwingGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java
Log:
refactor jaxx 2.x
Added: 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 (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,155 @@
+package jaxx.compiler;
+
+import java.io.File;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.runtime.context.JAXXContext;
+
+/**
+ * TODO javadoc.
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public interface CompilerConfiguration {
+
+ /**
+ *
+ * @return
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ *
+ * @return
+ */
+ Class<? extends JAXXCompiler> getCompilerClass();
+
+ /**
+ *
+ * @return
+ */
+ Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass();
+
+ /**
+ *
+ * @return
+ */
+ Class<?> getDefaultErrorUI();
+
+ /**
+ *
+ * @return
+ */
+ String[] getExtraImports();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpBrokerFQN();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpSetName();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetI18nPrefix();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetIndexI18nSuffix();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetTitleI18nSuffix();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetTocI18nSuffix();
+
+ /**
+ *
+ * @return
+ */
+ Class<? extends JAXXContext> getJaxxContextClass();
+
+ /**
+ * Returns whether or not optimization should be performed.
+ *
+ * @return whether or not optimizations should be performed
+ */
+ boolean getOptimize();
+
+ /**
+ * Returns the target directory, generally specified with the "-d" option on the command line.
+ *
+ * @return the target directory
+ * @see #setTargetDirectory
+ */
+ File getTargetDirectory();
+
+ /**
+ *
+ * @return
+ */
+ Class<?> getValidatorClass();
+
+ /**
+ *
+ * @return
+ */
+ boolean isAddLogger();
+
+ /**
+ *
+ * @return
+ */
+ boolean isGenerateHelp();
+
+ /**
+ *
+ * @return
+ */
+ boolean isI18nable();
+
+ /**
+ *
+ * @return
+ */
+ boolean isOptimize();
+
+ /**
+ *
+ * @return
+ */
+ boolean isProfile();
+
+ /**
+ *
+ * @return
+ */
+ boolean isResetAfterCompile();
+
+ /**
+ *
+ * @return
+ */
+ boolean isUseUIManagerForIcon();
+
+ /**
+ *
+ * @return
+ */
+ boolean isVerbose();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,30 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompiledObject.ChildRef;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaFile;
+import jaxx.runtime.SwingUtil;
+
+/**
+ * A decorator to surround a compiled object (should be a component at least)
+ * with a JXLayer.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+ CompiledObject parent = object.getParent();
+ for (ChildRef child : parent.getChilds()) {
+ if (child.getChild() == object) {
+ String javaCode = child.getChildJavaCode();
+ child.setChildJavaCode(SwingUtil.class.getName() + ".boxComponentWithJxLayer(" + javaCode + ")");
+ break;
+ }
+ }
+ super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,26 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaFile;
+
+/**
+ *
+ * Contract of compiled object decorator at generation time.
+ *
+ * Note : The implementation of this class must be stateless.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public interface CompiledObjectDecorator {
+
+ String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings);
+
+ boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall);
+
+ void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName);
+
+ String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException;
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,59 @@
+package jaxx.compiler.decorators;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public class CompiledObjectDecoratorManager {
+
+ protected static Map<String, CompiledObjectDecorator> cache;
+
+ public static void registerDecorator(String key, Class<? extends CompiledObjectDecorator> klass) {
+ synchronized (getCache()) {
+ if (getCache().containsKey(key)) {
+ throw new IllegalArgumentException("the decorator with key [" + key + "] is already registred! use another key name");
+ }
+ try {
+ getCache().put(key, klass.newInstance());
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ public static CompiledObjectDecorator getDecorator(String name) {
+ CompiledObjectDecorator decorator = getCache().get(name);
+ if (decorator == null) {
+ throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + getCache().keySet());
+ }
+ return decorator;
+ }
+
+ public static CompiledObjectDecorator getDecorator(Class<?> type) {
+ for (CompiledObjectDecorator decorator : getCache().values()) {
+ if (type == decorator.getClass()) {
+ return decorator;
+ }
+ }
+ return null;
+ }
+
+ protected static synchronized Map<String, CompiledObjectDecorator> getCache() {
+ if (cache == null) {
+ cache = new TreeMap<String, CompiledObjectDecorator>();
+ }
+ return cache;
+ }
+
+ public static void reset() {
+ if (cache != null) {
+ cache.clear();
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,131 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaField;
+import jaxx.compiler.JavaFile;
+import jaxx.compiler.JavaMethod;
+import jaxx.compiler.ScriptInitializer;
+import jaxx.compiler.types.TypeManager;
+
+import java.lang.reflect.Modifier;
+import java.util.Map.Entry;
+
+/**
+ * The default compiledObjectDecorator.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class DefaultCompiledObjectDecorator implements CompiledObjectDecorator {
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+
+ if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
+ String id = object.getId();
+ int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
+ if (object == root) {
+ javaFile.addField(new JavaField(access, fullClassName, id, "this"));
+ } else {
+ //TC -20081017 can have generic on compiled Object
+ javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
+ }
+ }
+
+ if (!compiler.inlineCreation(object) && object != root) {
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
+ }
+ }
+
+ @Override
+ public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
+ if (object instanceof ScriptInitializer) {
+ return object.getInitializationCode(compiler);
+ }
+ StringBuffer result = new StringBuffer();
+ if (object.isOverride() && object.getOverrideType() == object.getObjectClass()) {
+ //TC-20090309 on utilise le super code quand l'objet est de meme type
+ result.append("super.").append(object.getCreationMethodName()).append("();");
+ } else {
+ result.append(object.getId());
+ result.append(" = ");
+ if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
+ result.append(object.getJavaBeanInitCode()).append(";");
+ } else {
+ String constructorParams = object.getConstructorParams();
+ if (constructorParams != null) {
+ //TC - 20081017 compiledObject can have generics
+ result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
+ //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ } else {
+ //TC - 20081017 compiledObject can have generics
+ result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ }
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ String initCode = object.getInitializationCode(compiler);
+ if (initCode != null && initCode.length() > 0) {
+ result.append(initCode);
+ }
+
+ return result.toString();
+ }
+
+ @Override
+ public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) {
+ StringBuffer code = new StringBuffer();
+ //TC-20090327 generate client properties
+ if (object.hasClientProperties()) {
+ // generate putClientProperty invocations
+ for (Entry<String, String> entry : object.getClientProperties().entrySet()) {
+ object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");");
+ }
+
+ }
+ //TC - 20081017 only generate the method if not empty ?
+ if (object.getId().startsWith("$")) {
+ code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
+ } else {
+ String additionCode = object.getAdditionCode();
+ if (additionCode.length() > 0) {
+ code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
+ additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
+ }
+ }
+ //code.append(getLineSeparator());
+ return code.toString();
+ }
+
+ @Override
+ public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) {
+ if (object == root) {
+ String rootCode = root.getInitializationCode(compiler);
+ if (rootCode != null && rootCode.length() > 0) {
+ code.append(rootCode);
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ } else {
+ if (!object.isOverride()) {
+ if (compiler.inlineCreation(object)) {
+ if (lastWasMethodCall) {
+ lastWasMethodCall = false;
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append(getCreationCode(compiler, object));
+ code.append(JAXXCompiler.getLineSeparator());
+ } else {
+ code.append(object.getCreationMethodName()).append("();");
+ code.append(JAXXCompiler.getLineSeparator());
+ lastWasMethodCall = true;
+ }
+ }
+ }
+ return lastWasMethodCall;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,100 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompilerConfiguration;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaArgument;
+import jaxx.compiler.JavaFile;
+import jaxx.compiler.JavaMethod;
+
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * A decorator to place on a root compiled object to process javaHelp on the file.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
+
+ /**
+ * the list of discovered helpId
+ */
+ protected static Set<String> helpIds = new java.util.HashSet<String>();
+
+ protected String getBrokerFQN(JAXXCompiler compiler) {
+ String helpBrokerFQN = compiler.getConfiguration().getHelpBrokerFQN();
+ return helpBrokerFQN;
+ }
+
+ protected String getHelpId(CompiledObject o) {
+ String helpID = null;
+ if (o.hasClientProperties()) {
+ helpID = o.getClientProperty("help");
+ }
+ return helpID;
+ }
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+ super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+ CompilerConfiguration options = compiler.getConfiguration();
+
+ if (options.isGenerateHelp()) {
+
+ // add JaxxHelpUI interface
+ Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
+ String helpBrokerFQN = getBrokerFQN(compiler);
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "registerHelpId",
+ "broker.installUI(component, helpId);",
+ new JavaArgument(helpBrokerFQN, "broker"),
+ new JavaArgument("Component", "component"),
+ new JavaArgument("String", "helpId")));
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "showHelp",
+ "getBroker().showHelp(this, helpId);",
+ new JavaArgument("String", "helpId")));
+
+ StringBuilder buffer = new StringBuilder();
+
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+
+ if (options.isGenerateHelp()) {
+
+ // add code to init javax help system
+ Iterator<CompiledObject> itr = compiler.getObjectCreationOrder();
+
+ for (; itr.hasNext();) {
+ CompiledObject o = itr.next();
+ String helpID = getHelpId(o);
+ if (helpID != null) {
+ buffer.append(lineSeparator);
+ // detects a helpId to register
+ buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");");
+ //keep the helpID for helpSet generation
+ helpIds.add(helpID);
+ }
+ }
+ }
+ if (buffer.length() > 0) {
+
+ StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();");
+
+ buffer.append(lineSeparator).append("_broker.prepareUI(this);");
+ buffer.append(lineSeparator);
+
+ // add the calls
+ compiler.appendLateInitializer(extraCode.toString());
+ compiler.appendLateInitializer(buffer.toString());
+ }
+ }
+ }
+
+ public static Set<String> getHelpIds() {
+ return helpIds;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,42 @@
+package jaxx.compiler.generators;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public class GeneratorManager {
+
+ protected static List<Generator> generators;
+
+ public static List<Generator> getGenerators() {
+ if (generators == null) {
+ loadGenerators();
+ }
+ return generators;
+ }
+
+ public static void addGenerator(Generator g) {
+ getGenerators().add(g);
+ }
+
+ public static void clear() {
+ if (generators != null) {
+ generators.clear();
+ generators = null;
+ }
+ }
+
+ protected static void loadGenerators() {
+ if (generators == null) {
+ generators = new ArrayList<Generator>();
+ for (Generator generator : ServiceLoader.load(Generator.class)) {
+ generators.add(generator);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,604 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.*;
+import jaxx.runtime.Base64Coder;
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXObjectDescriptor;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import static java.lang.reflect.Modifier.FINAL;
+import static java.lang.reflect.Modifier.PROTECTED;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}.
+ * <p/>
+ * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the
+ * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files.
+ *
+ * @author chemit
+ */
+public class JAXXObjectGenerator implements Generator {
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(JAXXObjectGenerator.class);
+ protected static final JavaField ACTIVE_BINDINGS_FIELD = JavaField.newField(PROTECTED,
+ "java.util.List<Object>", "$activeBindings", "new ArrayList<Object>()");
+ protected static final JavaField BINDING_SOURCES_FIELD = JavaField.newField(PROTECTED,
+ "java.util.Map<String,Object>", "$bindingSources", "new HashMap<String,Object>()");
+ protected static final JavaField OBJECT_MAP_FIELD = JavaField.newField(PROTECTED,
+ "Map<String,Object>", "$objectMap", "new HashMap<String,Object>()");
+ protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
+ "boolean", "allComponentsCreated");
+ protected static final JavaField CONTEXT_INITIALIZED = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
+ "boolean", "contextInitialized", "true");
+ protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
+ "java.util.Map", "$previousValues", "new java.util.HashMap()");
+ protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED,
+ "jaxx.runtime.context.JAXXContext", "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",
+ "return delegateContext.getContextValue(clazz, null);",
+ new JavaArgument("Class<T>", "clazz"));
+ protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
+ "return delegateContext.getContextValue(clazz, name);",
+ new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
+ protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
+ "delegateContext.setContextValue(o, name);",
+ new JavaArgument("T", "o"), new JavaArgument("String", "name"));
+ protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
+ "delegateContext.setContextValue(o, null);",
+ new JavaArgument("T", "o"));
+ protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
+ "delegateContext.removeContextValue(clazz, name);",
+ new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
+ protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
+ "delegateContext.removeContextValue(clazz, null);",
+ new JavaArgument("Class<T>", "clazz"));
+ protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
+ "return delegateContext.getParentContainer(source, clazz);",
+ new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz"));
+ protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
+ "return delegateContext.getParentContainer(clazz);",
+ new JavaArgument("Class<O>", "clazz"));
+ protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "java.lang.Object", "getObjectById",
+ "return $objectMap.get(id);",
+ new JavaArgument("String", "id"));
+ protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC, "jaxx.runtime.JAXXObjectDescriptor", "$getJAXXObjectDescriptor",
+ "return jaxx.runtime.Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);");
+ protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "processDataBinding",
+ "processDataBinding(dest, false);",
+ new JavaArgument("String", "dest"));
+ protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
+ "super.firePropertyChange(propertyName, oldValue, newValue);",
+ new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
+ protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
+ "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);",
+ new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
+ protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(0, "java.beans.PropertyChangeSupport", "$getPropertyChangeSupport",
+ "if ($propertyChangeSupport == null)\n" +
+ " $propertyChangeSupport = new PropertyChangeSupport(this);\n" +
+ "return $propertyChangeSupport;");
+ protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
+ "$getPropertyChangeSupport().addPropertyChangeListener(listener);",
+ new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+ protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
+ "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);",
+ new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+ protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
+ "$getPropertyChangeSupport().removePropertyChangeListener(listener);",
+ new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+ protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
+ "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);",
+ new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+
+ @Override
+ public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
+
+ String fullClassName = packageName != null ? packageName + "." + className : className;
+ if (root == null) {
+ throw new CompilerException("root tag must be a class tag");
+ }
+ //Map<String, CompiledObject> objects = compiler.getObjects();
+ ClassDescriptor superclass = root.getObjectClass();
+ boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass);
+ javaFile.setModifiers(Modifier.PUBLIC);
+ javaFile.setClassName(fullClassName);
+ javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass));
+ javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject);
+
+ javaFile.addInterfaces(compiler.getExtraInterfaces());
+ javaFile.setAbstractClass(compiler.isAbstractClass());
+ javaFile.setGenericType(compiler.getGenericType());
+ javaFile.setSuperGenericType(compiler.getSuperGenericType());
+
+ for (CompiledObject object : compiler.getObjects().values()) {
+ CompiledObjectDecorator decorator = object.getDecorator();
+ decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+
+ /*if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
+ String id = object.getId();
+ int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
+ if (object == root) {
+ javaFile.addField(new JavaField(access, fullClassName, id, "this"));
+ } else {
+ //TC -20081017 can have generic on compiled Object
+ javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
+ }
+ }
+
+ if (!compiler.inlineCreation(object) && object != root) {
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
+ }*/
+ }
+
+ // DataBinding
+ for (DataBinding dataBinding : compiler.getDataBindings()) {
+ if (dataBinding.compile(true)) {
+ compiler.getInitDataBindings().append("applyDataBinding(").append(TypeManager.getJavaCode(dataBinding.getId())).append(");").append(JAXXCompiler.getLineSeparator());
+ }
+ }
+
+ if (superclassIsJAXXObject) {
+ boolean hasBind = compiler.getApplyDataBinding().length() > 0;
+ if (hasBind) {
+ compiler.appendApplyDataBinding(" else {");
+ compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
+ compiler.appendApplyDataBinding(" ");
+ }
+ compiler.appendApplyDataBinding("super.applyDataBinding($binding);");
+ compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
+
+ if (hasBind) {
+ compiler.appendApplyDataBinding(" return;");
+ compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
+ compiler.appendApplyDataBinding("}");
+ }
+
+
+ hasBind = compiler.getRemoveDataBinding().length() > 0;
+ if (hasBind) {
+ compiler.appendRemoveDataBinding(" else {");
+ compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
+ compiler.appendRemoveDataBinding(" ");
+ }
+ compiler.appendRemoveDataBinding("super.removeDataBinding($binding);");
+ compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
+
+ if (hasBind) {
+ compiler.appendRemoveDataBinding("}");
+ }
+ } else {
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(JAXXObject.class));
+ }
+ }
+
+ @Override
+ public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
+
+ String fullClassName = javaFile.getClassName();
+
+ String jaxxContextImplementorClass = compiler.getConfiguration().getJaxxContextClass().getName();
+ boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject();
+ if (!superclassIsJAXXObject) {
+ // add logger
+ if (compiler.getConfiguration().isAddLogger()) {
+ javaFile.addImport(Log.class);
+ javaFile.addImport(LogFactory.class);
+ javaFile.addField(JavaField.newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)"));
+ }
+
+ // JAXXObject
+ javaFile.addField(OBJECT_MAP_FIELD);
+ javaFile.addMethod(GET_OBJECT_BY_ID_METHOD);
+ javaFile.addField(BINDING_SOURCES_FIELD);
+ javaFile.addField(ACTIVE_BINDINGS_FIELD);
+
+ // JAXXContext
+ javaFile.addField(JavaField.newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", "new " + jaxxContextImplementorClass + "(this);"));
+ javaFile.addMethod(SET_CONTEXT_VALUE_METHOD);
+ javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD);
+ javaFile.addMethod(GET_CONTEXT_VALUE_METHOD);
+ javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD);
+ javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD);
+ javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD);
+ javaFile.addMethod(GET_PARENT_CONTAINER_METHOD);
+ javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD);
+
+ // PropertyChangeSupport
+ addPropertyChangeSupport(root, javaFile);
+
+ // DataBinding
+ javaFile.addMethod(PROCESS_DATA_BINDING_METHOD);
+ }
+
+ javaFile.addField(ALL_COMPONENTS_CREATED_FIELD);
+ boolean overrideContextInitialized = false;
+ FieldDescriptor[] scriptFields = compiler.getScriptFields();
+ for (FieldDescriptor f : scriptFields) {
+ if ("contextInitialized".equals(f.getName())) {
+ overrideContextInitialized = true;
+ break;
+ }
+ }
+ if (!overrideContextInitialized) {
+ javaFile.addField(CONTEXT_INITIALIZED);
+ }
+ javaFile.addField(createJAXXObjectDescriptorField(compiler, javaFile));
+
+ if (compiler.getStylesheet() != null) {
+ javaFile.addField(PREVIOUS_VALUES_FIELD);
+ }
+ /*for (CompiledObject object : compiler.getObjects().values()) {
+ List<CompiledObject.ChildRef> refList = object.getChilds();
+ if (refList==null || refList.isEmpty()) {
+ continue;
+ }
+ for (ChildRef childRef : refList) {
+ childRef.addToAdditionCode(buffer);
+ }
+ }*/
+ //TC 20090228 - only generate constructors if not done in scripts
+ boolean constructorDetected = false;
+ MethodDescriptor[] methods = compiler.getScriptMethods();
+ for (MethodDescriptor m : methods) {
+ try {
+ m.getReturnType();
+ if (className.equals(m.getName())) {
+ constructorDetected = true;
+ break;
+ }
+ } catch (Exception e) {
+ log.warn("could not find return type " + m);
+ }
+ }
+ if (!constructorDetected) {
+ javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject));
+ javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject));
+ }
+
+ javaFile.addMethod(createInitializer(compiler));
+ javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD);
+
+ javaFile.addBodyCode(compiler.getBodyCode().toString());
+
+ javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, compiler.getInitDataBindings()));
+
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "applyDataBinding",
+ compiler.getApplyDataBinding().toString() + JAXXCompiler.getLineSeparator() + "processDataBinding($binding);",
+ new JavaArgument("String", "$binding")));
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "removeDataBinding",
+ compiler.getRemoveDataBinding().toString(), new JavaArgument("String", "$binding")));
+
+ javaFile.addMethod(createProcessDataBindingMethod(compiler, superclassIsJAXXObject));
+
+ addEventHandlers(compiler, javaFile);
+
+ }
+
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- Create fields ----------------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+ protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) {
+ try {
+ JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor();
+ String data = Base64Coder.serialize(descriptor, true);
+ /*ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer));
+ out.writeObject(descriptor);
+ out.close();
+ // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String
+ // in the compiled class file, since byte array initialization is horribly inefficient compared to
+ // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1
+ // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely
+ // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String
+ // type, but if we could efficiently store a byte[] we wouldn't have to do this.
+ String data = new String(buffer.toByteArray(), 0);*/
+
+ int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit
+ if (data.length() < sizeLimit) {
+ return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", TypeManager.getJavaCode(data));
+ } else {
+ StringBuffer initializer = new StringBuffer();
+ for (int i = 0; i < data.length(); i += sizeLimit) {
+ String name = "$jaxxObjectDescriptor" + i;
+ javaFile.addField(new JavaField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", name,
+ TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length())))));
+ if (initializer.length() > 0) {
+ initializer.append(" + ");
+ }
+ initializer.append("String.valueOf(").append(name).append(")");
+ }
+ return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", initializer.toString());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Internal error: can't-happen error", e);
+ }
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- Create methods ---------------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+ protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) {
+ ClassDescriptor currentClass = root.getObjectClass();
+ MethodDescriptor firePropertyChange = null;
+ while (firePropertyChange == null && currentClass != null) {
+ try {
+ firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class),
+ ClassDescriptorLoader.getClassDescriptor(Object.class),
+ ClassDescriptorLoader.getClassDescriptor(Object.class));
+
+ } catch (NoSuchMethodException e) {
+ currentClass = currentClass.getSuperclass();
+ }
+ }
+
+ int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0;
+ if (Modifier.isPublic(modifiers)) {
+ // we have all the support we need
+ }
+ if (Modifier.isProtected(modifiers)) {
+ // there is property change support but the firePropertyChange method is protected
+ javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD);
+ } else {
+ // either no support at all or firePropertyChange isn't accessible
+ javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD);
+ javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD);
+ javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD);
+ javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
+ javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD);
+ javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
+ javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD);
+ }
+ }
+
+ protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) {
+ for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) {
+ // outer loop is iterating over different objects (well, technically, different Java expressions)
+ for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) {
+ // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.)
+ for (EventHandler handler : e2.getValue()) {
+ // iterate over individual event handlers of a single type
+ String methodName = compiler.getEventHandlerMethodName(handler);
+ MethodDescriptor listenerMethod = handler.getListenerMethod();
+ if (listenerMethod.getParameterTypes().length != 1) {
+ throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument");
+ }
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", methodName, handler.getJavaCode(),
+ new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event")));
+ }
+ }
+ }
+ }
+
+ protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
+ StringBuffer code = new StringBuffer();
+ String constructorParams = compiler.getRootObject().getConstructorParams();
+ if (constructorParams != null) {
+ code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
+ } else {
+ if (superclassIsJAXXObject) {
+ code.append(" super();").append(JAXXCompiler.getLineSeparator());
+ }
+ }
+ code.append("$initialize();");
+ code.append(JAXXCompiler.getLineSeparator());
+ return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString());
+ }
+
+ protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
+ StringBuffer code = new StringBuffer();
+ String constructorParams = compiler.getRootObject().getConstructorParams();
+ if (constructorParams != null) {
+ code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
+ } else {
+ if (superclassIsJAXXObject) {
+ code.append(" super(parentContext);").append(JAXXCompiler.getLineSeparator());
+ }
+ }
+ if (!superclassIsJAXXObject) {
+ code.append(Util.class.getName() + ".initContext(this, parentContext);");
+ code.append(JAXXCompiler.getLineSeparator());
+
+// code.append("if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) {");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append(" ((jaxx.runtime.context.JAXXInitialContext)parentContext).to(this);");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append("} else {");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append(" setContextValue(parentContext);");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append("}");
+// code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append("$initialize();");
+ code.append(JAXXCompiler.getLineSeparator());
+ return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.context.JAXXContext", "parentContext"));
+ }
+
+ public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
+ StringBuffer code = new StringBuffer();
+ CompiledObject root = compiler.getRootObject();
+ code.append("if (allComponentsCreated || !contextInitialized) {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" return;");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);");
+ code.append(JAXXCompiler.getLineSeparator());
+
+ Iterator<CompiledObject> i = compiler.getObjectCreationOrder();
+ boolean lastWasMethodCall = false;
+ while (i.hasNext()) {
+ CompiledObject object = i.next();
+ if (object == root) {
+ continue;
+ }
+ CompiledObjectDecorator decorator = object.getDecorator();
+ lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall);
+ /*if (object != root && !object.isOverride()) {
+ if (compiler.inlineCreation(object)) {
+ if (lastWasMethodCall) {
+ lastWasMethodCall = false;
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append(getCreationCode(compiler, object));
+ code.append(JAXXCompiler.getLineSeparator());
+ } else {
+ code.append(object.getCreationMethodName()).append("();");
+ code.append(JAXXCompiler.getLineSeparator());
+ lastWasMethodCall = true;
+ }
+ }*/
+ }
+ root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall);
+ /*String rootCode = root.getInitializationCode(compiler);
+ if (rootCode != null && rootCode.length() > 0) {
+ code.append(rootCode);
+ code.append(JAXXCompiler.getLineSeparator());
+ }*/
+ code.append(JAXXCompiler.getLineSeparator());
+ if (compiler.getInitializer().length() > 0) {
+ code.append(compiler.getInitializer());
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append("$completeSetup();");
+ code.append(JAXXCompiler.getLineSeparator());
+ return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$initialize", code.toString());
+ }
+
+ protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, StringBuffer initDataBindings) {
+ StringBuffer code = new StringBuffer();
+ code.append("allComponentsCreated = true;");
+ code.append(JAXXCompiler.getLineSeparator());
+ for (CompiledObject object : compiler.getObjects().values()) {
+ CompiledObjectDecorator decorator = object.getDecorator();
+ code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile, initDataBindings));
+
+ /*//TC - 20081017 only generate the method if not empty ?
+ if (object.getId().startsWith("$")) {
+ code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
+ } else {
+ String additionCode = object.getAdditionCode();
+ if (additionCode.length() > 0) {
+ code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
+ additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
+ }
+ }*/
+ //code.append(getLineSeparator());
+ }
+
+ code.append(initDataBindings);
+
+ if (compiler.getLateInitializer().length() > 0) {
+ code.append(compiler.getLateInitializer());
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ //TC-20090313 add an extra method after complete setup
+ MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup");
+ if (method != null) {
+ code.append("$afterCompleteSetup();").append(JAXXCompiler.getLineSeparator());
+ }
+ return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString());
+ }
+
+ protected JavaMethod createProcessDataBindingMethod(JAXXCompiler compiler, boolean superclassIsJAXXObject) {
+ StringBuffer code = new StringBuffer();
+ //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass());
+ // the force parameter forces the update to happen even if it is already in activeBindings. This
+ // is used on superclass invocations b/c by the time the call gets to the superclass, it is already
+ // marked active and would otherwise be skipped
+ if (compiler.getProcessDataBinding().length() > 0) {
+ code.append(" if (!$force && $activeBindings.contains($dest)) { ");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" return;");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("$activeBindings.add($dest);");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("try {");
+ code.append(JAXXCompiler.getLineSeparator());
+ if (compiler.getProcessDataBinding().length() > 0) {
+ code.append(compiler.getProcessDataBinding().toString());
+ //code.append(JAXXCompiler.getLineSeparator());
+ }
+ if (superclassIsJAXXObject) {
+ code.append(" else {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" super.processDataBinding($dest, true);");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" }");
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append("} finally {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" $activeBindings.remove($dest);");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
+ } else if (superclassIsJAXXObject) {
+ code.append("super.processDataBinding($dest, true);");
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ return JavaMethod.newMethod(Modifier.PUBLIC, "void", "processDataBinding", code.toString(),
+ new JavaArgument("String", "$dest"), new JavaArgument("boolean", "$force"));
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- Create methods code ----------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+
+ /* protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
+ if (object instanceof ScriptInitializer) {
+ return object.getInitializationCode(compiler);
+ }
+ CompiledObjectDecorator decorator = object.getDecorator();
+ String result = decorator.getCreationCode(compiler, object);
+ return result;*/
+ /*StringBuffer result = new StringBuffer();
+ result.append(object.getId());
+ result.append(" = ");
+ if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
+ result.append(object.getJavaBeanInitCode()).append(";");
+ } else {
+ String constructorParams = object.getConstructorParams();
+ if (constructorParams != null) {
+ //TC - 20081017 compiledObject can have generics
+ result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
+ //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ } else {
+ //TC - 20081017 compiledObject can have generics
+ result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ }
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ String initCode = object.getInitializationCode(compiler);
+ if (initCode != null && initCode.length() > 0) {
+ result.append(initCode);
+ }
+ result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
+
+ return result.toString();*/
+// }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,27 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.*;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Application;
+
+import java.lang.reflect.Modifier;
+
+/** @author chemit */
+public class SwingGenerator implements Generator {
+
+ @Override
+ public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
+ }
+
+ @Override
+ public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
+
+ //TODO : move this to jaxx-compiler-swing generator
+ if (ClassDescriptorLoader.getClassDescriptor(Application.class.getName()).isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) {
+ // TODO: check for existing main method first
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC | Modifier.STATIC, "void", "main",
+ "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });",
+ new JavaArgument("String[]", "arg")));
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,88 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.*;
+import jaxx.compiler.CompiledObject.ChildRef;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.validator.BeanValidatorHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import jaxx.compiler.types.TypeManager;
+
+import java.util.List;
+import jaxx.runtime.SwingUtil;
+
+/** @author chemit */
+public class ValidatorGenerator implements Generator {
+
+ protected static final JavaField VALIDATOR_IDS_FIELD = JavaField.newField(java.lang.reflect.Modifier.PROTECTED,
+ "java.util.List<String>", "validatorIds", "new ArrayList<String>()");
+
+ @Override
+ public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
+
+ if (!BeanValidatorHandler.hasValidator(compiler)) {
+ return;
+ }
+
+ for (CompiledObject object : compiler.getObjects().values()) {
+ List<ChildRef> childs = object.getChilds();
+ if (childs == null || childs.isEmpty()) {
+ continue;
+ }
+ for (ChildRef child : childs) {
+ String javaCode = child.getChildJavaCode();
+ // some validators are defined on this object
+ boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId());
+ if (found) {
+ // box the child component in a JxLayer
+ child.setChildJavaCode(SwingUtil.class.getName() + ".boxComponentWithJxLayer(" + javaCode + ")");
+ }
+ }
+ }
+ // register validator
+ for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) {
+ String id = TypeManager.getJavaCode(validator.getId());
+ compiler.appendLateInitializer("validatorIds.add(" + id + ");");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ compiler.appendLateInitializer("getValidator(" + id + ").installUIs();");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();");
+ //compiler.appendLateInitializer("getValidator(" + id + ").validate();");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ }
+ compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ }
+
+ @Override
+ public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
+ if (!BeanValidatorHandler.hasValidator(compiler)) {
+ return;
+ }
+ Class<?> validatorClass = compiler.getConfiguration().getValidatorClass();
+ String validatorFQN = validatorClass.getName();
+ javaFile.addImport(validatorFQN);
+
+ //TODO use the specific JAXXValidator interface (swing, gwt,...)
+ Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class;
+
+ if (javaFile.isSuperclassIsJAXXObject()) {
+ ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass());
+ boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass);
+
+ if (parentIsValidator) {
+ // nothing to generate (use the parent directly)
+ return;
+ }
+ }
+
+ // add JAXXValidator interface
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface));
+
+ // implements JAXXValidator
+ javaFile.addField(VALIDATOR_IDS_FIELD);
+ javaFile.addMethod(JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, validatorFQN + "<?>", "getValidator",
+ "return (" + validatorFQN + ") (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);",
+ new JavaArgument("String", "validatorId")));
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2009-10-07 16:22:07 +0200 (Wed, 07 Oct 2009)
New Revision: 1562
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.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/StylesheetHelper.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/UnsupportedTagException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.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-compiler/src/main/java/jaxx/compiler/generators/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx
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/Movie.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/
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/JAXXContext.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/css/Rule.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.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/navigation/NavigationTreeNodeRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.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/
Removed:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/spi/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.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/JAXXContextEntryDef.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.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/JAXXCompiler.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/JavaArgument.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.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/DemoUI.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.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/JAXXObjectDescriptor.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/css/DataBinding.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.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/LocaleListCellRenderer.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/swing/navigation/NavigationTreeModelTest.java
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/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
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/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.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/JaxxBaseTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml
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/Errors.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml
branches/jaxx-2.X/src/site/rst/JAXXContext.rst
Log:
refactor jaxx 2.x
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,96 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps
- * in that it takes subclasses into account; mapping a class to a value also maps all subclasses of
- * that class to the value.
- * <p/>
- * A <code>get</code> operation will return the value associated with the class itself, or failing
- * that, with its nearest ancestor for which there exists a mapping.
- * @param <T> type of the class
- */
-public class ClassMap<T> extends HashMap<ClassDescriptor, T> {
- /** log */
- protected static final Log log = LogFactory.getLog(ClassMap.class);
-
- /**
- * Keeps track of automatically-added Classes so we can distinguish them from user-added
- * Classes. Unknown Classes are automatically added to the map during <code>get</code>
- * calls to speed up subsequent requests, but they must be updated when the mappings
- * for their superclasses are modified.
- */
- private List<ClassDescriptor> autoKeys = new ArrayList<ClassDescriptor>();
- private static final long serialVersionUID = 5149779660675529037L;
-
-
- /**
- * Returns the value associated with the key <code>Class</code>. If the class itself does not have
- * a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is
- * located. If none of the class' ancestors have a mapping, <code>null</code> is returned.
- *
- * @param key the class to check
- * @return the mapping for the class
- */
- @Override
- public T get(Object key) {
- T result = null;
- ClassDescriptor c = (ClassDescriptor) key;
- while (c != null) {
- result = super.get(c);
- if (result != null) {
- break;
- }
- c = c.getSuperclass();
- }
-
- if (result == null && ((ClassDescriptor) key).isInterface()) {
- result = get(ClassDescriptorLoader.getClassDescriptor(Object.class));
- }
-
- if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass
- put((ClassDescriptor) key, result);
- autoKeys.add((ClassDescriptor) key);
- }
- return result;
- }
-
-
- /**
- * Associates a value with a class and all of its descendents.
- *
- * @param key the class to map
- * @param value the value to map to the class
- * @return the old value associated with the class
- */
- @Override
- public T put(ClassDescriptor key, T value) {
- //if (!(key instanceof ClassDescriptor)) {
- // throw new IllegalArgumentException("expected ClassDescriptor, got " + key);
- //}
- if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified
- Iterator<ClassDescriptor> i = autoKeys.iterator();
- while (i.hasNext()) {
- ClassDescriptor auto = i.next();
- if (key.isAssignableFrom(auto)) {
- i.remove();
- remove(auto);
- }
- }
- }
- return super.put(key, value);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/** Thrown by the compiler when an error occurs. */
-public class CompilerException extends RuntimeException {
- private static final long serialVersionUID = -9099889519671482440L;
-
- /** Creates a new <code>ParseException</code>. */
- public CompilerException() {
- }
-
-
- /**
- * Creates a new <code>ParseException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public CompilerException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>ParseException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public CompilerException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>ParseException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public CompilerException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-
-
- public void printStackTrace() {
- super.printStackTrace();
- System.err.println("CompilerException printed from:");
- Thread.dumpStack();
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultComponentHandler;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.ScriptHandler;
-import jaxx.tags.StyleHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.PrimitiveConverter;
-import jaxx.types.TypeManager;
-
-import java.awt.Component;
-import jaxx.compiler.CompiledObjectDecorator;
-import jaxx.compiler.DefaultCompiledObjectDecorator;
-
-/** Initializes support for java. */
-public class DefaultInitializer implements jaxx.spi.Initializer {
-
- @Override
- public void initialize() {
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Object.class), DefaultObjectHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Component.class), DefaultComponentHandler.class);
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler());
-
- PrimitiveConverter primitiveConverter = new PrimitiveConverter();
- TypeManager.registerTypeConverter(boolean.class, primitiveConverter);
- TypeManager.registerTypeConverter(Boolean.class, primitiveConverter);
- TypeManager.registerTypeConverter(byte.class, primitiveConverter);
- TypeManager.registerTypeConverter(Byte.class, primitiveConverter);
- TypeManager.registerTypeConverter(short.class, primitiveConverter);
- TypeManager.registerTypeConverter(Short.class, primitiveConverter);
- TypeManager.registerTypeConverter(int.class, primitiveConverter);
- TypeManager.registerTypeConverter(Integer.class, primitiveConverter);
- TypeManager.registerTypeConverter(long.class, primitiveConverter);
- TypeManager.registerTypeConverter(Long.class, primitiveConverter);
- TypeManager.registerTypeConverter(float.class, primitiveConverter);
- TypeManager.registerTypeConverter(Float.class, primitiveConverter);
- TypeManager.registerTypeConverter(double.class, primitiveConverter);
- TypeManager.registerTypeConverter(Double.class, primitiveConverter);
- TypeManager.registerTypeConverter(char.class, primitiveConverter);
- TypeManager.registerTypeConverter(Character.class, primitiveConverter);
- TypeManager.registerTypeConverter(String.class, primitiveConverter);
-
- CompiledObjectDecorator.registerDecorator("default", DefaultCompiledObjectDecorator.class);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,118 +0,0 @@
-package jaxx;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.introspection.JAXXPropertyDescriptor;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-
-/** Generates information about a tag for use on the jaxxframework.org web site. */
-public class PrintTagInfo {
- /**
- * Displays information about the class name in arg[0].
- *
- * @param arg command-line arguments
- * @throws Exception if an error occurs
- */
- public static void main(String[] arg) throws Exception {
- if (arg.length < 1) {
- throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate");
- }
- String firstarg = arg[0];
- boolean toFile = false;
- BufferedWriter w;
- if (firstarg.startsWith("file:")) {
- w = new BufferedWriter(new FileWriter(firstarg.substring(5)));
- toFile = true;
- } else {
- w = new BufferedWriter(new OutputStreamWriter(System.out));
- }
-
- try {
- JAXXCompilerLaunchor.loadLibraries(false);
- for (int i = toFile ? 1 : 0; i < arg.length; i++) {
- String className = arg[i];
- treateClass(w, className);
- }
- } finally {
- w.flush();
- w.close();
- }
-
- }
-
- protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException {
-
- ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className);
- DefaultObjectHandler handler = TagManager.getTagHandler(beanClass);
-
- DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass());
-
- // dump all bean properties
- w.append("Properties in ").append(String.valueOf(beanClass));
- w.newLine();
- JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
- JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
- for (JAXXPropertyDescriptor property : properties) {
- if (property.getWriteMethodDescriptor() == null) {
- continue;
- }
-
- boolean found = false;
- String name = property.getName();
- for (JAXXPropertyDescriptor superProperty : superProperties) {
- if (superProperty.getName().equals(name)) {
- found = true;
- break;
- }
- }
- if (!found) {
- if (property.getPropertyType() == null) {
- System.err.println(name + " has null type");
- } else {
- w.append("{{EquivalentAttribute|");
- w.append(name);
- w.append("|");
- w.append(className.replace('.', '/'));
- w.append("|set");
- w.append(org.apache.commons.lang.StringUtils.capitalize(name));
- w.append("|");
- w.append(JAXXCompiler.getCanonicalName(property.getPropertyType()));
- w.append("}}");
- w.append("|-");
- w.newLine();
- }
- }
- }
-
- w.newLine();
- w.newLine();
-
- // dump all bound methods
- dumpMethods(w, beanClass, handler);
- }
-
- protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException {
- MethodDescriptor[] methods = beanClass.getMethodDescriptors();
- w.append("Bound methods in ").append(String.valueOf(beanClass));
- w.newLine();
- for (MethodDescriptor method : methods) {
- try {
- if (handler.isMemberBound(method.getName())) {
- w.append("* <tt>").append(method.getName()).append("()</tt>");
- w.newLine();
- }
- } catch (Throwable e) {
- // ignore ?
- }
- }
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/** Thrown by the runtime engine when a script error occurs. */
-public class ScriptException extends RuntimeException {
- private static final long serialVersionUID = 5687529939397610336L;
-
- /** Creates a new <code>ScriptException</code>. */
- public ScriptException() {
- }
-
-
- /**
- * Creates a new <code>ScriptException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public ScriptException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>ScriptException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public ScriptException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>ScriptException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public ScriptException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,107 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-import jaxx.beaninfos.BeanInfoUtil;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.BoxedCompiledObjectDecorator;
-import jaxx.compiler.CompiledObjectDecorator;
-import jaxx.compiler.HelpRootCompiledObjectDecorator;
-
-import jaxx.reflect.ClassDescriptorLoader;
-
-import jaxx.runtime.swing.editor.EnumEditor;
-import jaxx.runtime.swing.editor.LocaleEditor;
-
-import jaxx.spi.Initializer;
-
-import jaxx.runtime.swing.*;
-import jaxx.tags.*;
-import jaxx.tags.swing.*;
-import jaxx.types.*;
-
-import java.awt.*;
-import javax.swing.text.JTextComponent;
-import javax.swing.*;
-
-public class SwingInitializer implements Initializer {
-
- @Override
- public void initialize() {
-
- BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos");
-
- //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing
- TagManager.registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
-// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
-
- // check boxes
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
-
- // combo boxes
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class);
-
- // radio boxes
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
-
- // Lists
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JList.class), JListHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JAXXListHandler.class);
-
- // Trees
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTree.class), JTreeHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JAXXTreeHandler.class);
-
- // Windows
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class);
-
- TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*");
- TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JPasswordField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextArea", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextPane", "javax.swing.*");
-
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler());
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Table.class), TableHandler.class);
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTab.class), JAXXTabHandler.class);
-
- TypeManager.registerTypeConverter(Color.class, new ColorConverter());
- TypeManager.registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter());
- TypeManager.registerTypeConverter(Insets.class, new InsetsConverter());
- TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
-
- CompiledObjectDecorator.registerDecorator("boxed", BoxedCompiledObjectDecorator.class);
- CompiledObjectDecorator.registerDecorator("help", HelpRootCompiledObjectDecorator.class);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/**
- * Thrown by <code>TagHandler</code> when an unsupported attribute is encountered.
- *
- * @see jaxx.tags.TagHandler
- */
-public class UnsupportedAttributeException extends CompilerException {
- private static final long serialVersionUID = -6919583037172920343L;
-
- /** Creates a new <code>UnsupportedAttributeException</code>. */
- public UnsupportedAttributeException() {
- }
-
-
- /**
- * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public UnsupportedAttributeException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>UnsupportedAttributeException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public UnsupportedAttributeException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public UnsupportedAttributeException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/** Thrown by the compiler when an unregistered tag is encountered. */
-public class UnsupportedTagException extends CompilerException {
- private static final long serialVersionUID = 3199732135804426699L;
-
- /** Creates a new <code>UnsupportedTagException</code>. */
- public UnsupportedTagException() {
- }
-
-
- /**
- * Creates a new <code>UnsupportedTagException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public UnsupportedTagException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>UnsupportedTagException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public UnsupportedTagException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>UnsupportedTagException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public UnsupportedTagException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,27 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.compiler.CompiledObject.ChildRef;
-import jaxx.runtime.SwingUtil;
-
-/**
- * A decorator to surround a compiled object (should be a component at least)
- * with a JXLayer.
- *
- * @author tony
- * @since 1.2
- */
-public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
-
- @Override
- public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
- CompiledObject parent = object.getParent();
- for (ChildRef child : parent.getChilds()) {
- if (child.getChild() == object) {
- String javaCode = child.getChildJavaCode();
- child.setChildJavaCode(SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")");
- break;
- }
- }
- super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
- }
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps
+ * in that it takes subclasses into account; mapping a class to a value also maps all subclasses of
+ * that class to the value.
+ * <p/>
+ * A <code>get</code> operation will return the value associated with the class itself, or failing
+ * that, with its nearest ancestor for which there exists a mapping.
+ * @param <T> type of the class
+ */
+public class ClassMap<T> extends HashMap<ClassDescriptor, T> {
+
+ private static final long serialVersionUID = 5149779660675529037L;
+ /**
+ * Logger
+ */
+ protected static final Log log = LogFactory.getLog(ClassMap.class);
+ /**
+ * Keeps track of automatically-added Classes so we can distinguish them from user-added
+ * Classes. Unknown Classes are automatically added to the map during <code>get</code>
+ * calls to speed up subsequent requests, but they must be updated when the mappings
+ * for their superclasses are modified.
+ */
+ private List<ClassDescriptor> autoKeys = new ArrayList<ClassDescriptor>();
+
+ /**
+ * Returns the value associated with the key <code>Class</code>. If the class itself does not have
+ * a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is
+ * located. If none of the class' ancestors have a mapping, <code>null</code> is returned.
+ *
+ * @param key the class to check
+ * @return the mapping for the class
+ */
+ @Override
+ public T get(Object key) {
+ T result = null;
+ ClassDescriptor c = (ClassDescriptor) key;
+ while (c != null) {
+ result = super.get(c);
+ if (result != null) {
+ break;
+ }
+ c = c.getSuperclass();
+ }
+
+ if (result == null && ((ClassDescriptor) key).isInterface()) {
+ result = get(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ }
+
+ if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass
+ put((ClassDescriptor) key, result);
+ autoKeys.add((ClassDescriptor) key);
+ }
+ return result;
+ }
+
+ /**
+ * Associates a value with a class and all of its descendents.
+ *
+ * @param key the class to map
+ * @param value the value to map to the class
+ * @return the old value associated with the class
+ */
+ @Override
+ public T put(ClassDescriptor key, T value) {
+ //if (!(key instanceof ClassDescriptor)) {
+ // throw new IllegalArgumentException("expected ClassDescriptor, got " + key);
+ //}
+ if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified
+ Iterator<ClassDescriptor> i = autoKeys.iterator();
+ while (i.hasNext()) {
+ ClassDescriptor auto = i.next();
+ if (key.isAssignableFrom(auto)) {
+ i.remove();
+ remove(auto);
+ }
+ }
+ }
+ return super.put(key, value);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,14 +4,14 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.DefaultComponentHandler;
-import jaxx.tags.TagHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.TypeManager;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.types.TypeManager;
import java.awt.Container;
import java.lang.reflect.Method;
@@ -69,13 +69,13 @@
/** the type of the override object (can be null if no oveeride) */
private ClassDescriptor overrideType;
/**
- * the decorator (if null will use {@link DefaultCompiledObjectDecorator}).
+ * the decorator
*/
private CompiledObjectDecorator decorator;
/**
* client properties
*/
- private Map<String,String> clientProperties;
+ private Map<String, String> clientProperties;
public class ChildRef {
@@ -459,14 +459,13 @@
return clientProperties;
}
-
/**
* Returns all properties which have been set for this object.
*
* @return a <code>Map</code> containing all properties defined for this object
* @see #addProperty
*/
- public Map/*<String, String>*/ getProperties() {
+ public Map<?, ?>/*<String, String>*/ getProperties() {
return properties;
}
@@ -558,6 +557,7 @@
public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException {
compiler.registerDataBinding(src, getId() + "." + property, assignment);
}
+
public String getGenericTypes() {
if (getGenericTypesLength() == 0) {
// not using it
@@ -635,4 +635,4 @@
public int getGenericTypesLength() {
return genericTypes == null ? 0 : genericTypes.length;
}
-}
\ No newline at end of file
+}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,76 +0,0 @@
-package jaxx.compiler;
-
-import java.util.Map;
-import java.util.TreeMap;
-import jaxx.CompilerException;
-
-/**
- *
- * A class to decorate a compiled object at generation time.
- *
- * Contains also a cache of decorator in a dictonnary indexed by fqn of decorator.
- *
- * Use the {@link #getDecorator(java.lang.String)} to obtain the cached decorator.
- *
- * Note : The implementation of this class must be stateless.
- *
- * @author tony
- * @since 1.2
- */
-public abstract class CompiledObjectDecorator {
-
- protected static Map<String, CompiledObjectDecorator> cache;
-
- public static void registerDecorator(String key, Class<? extends CompiledObjectDecorator> klass) {
- synchronized (getCache()) {
- if (getCache().containsKey(key)) {
- throw new IllegalArgumentException("the decorator with key [" + key + "] is already registred! use another key name");
- }
- try {
- getCache().put(key, klass.newInstance());
- } catch (InstantiationException ex) {
- throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
- }
- }
- }
-
- public static CompiledObjectDecorator getDecorator(String name) {
- CompiledObjectDecorator decorator = getCache().get(name);
- if (decorator == null) {
- throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + getCache().keySet());
- }
- return decorator;
- }
-
- public static CompiledObjectDecorator getDecorator(Class<?> type) {
- for (CompiledObjectDecorator decorator : getCache().values()) {
- if (type == decorator.getClass()) {
- return decorator;
- }
- }
- return null;
- }
-
- protected static synchronized Map<String, CompiledObjectDecorator> getCache() {
- if (cache == null) {
- cache = new TreeMap<String, CompiledObjectDecorator>();
- }
- return cache;
- }
-
- public static void reset() {
- if (cache != null) {
- cache.clear();
- }
- }
-
- public abstract void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName);
-
- public abstract String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException;
-
- public abstract boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall);
-
- public abstract String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings);
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+/** Thrown by the compiler when an error occurs. */
+public class CompilerException extends RuntimeException {
+
+ private static final long serialVersionUID = -9099889519671482440L;
+
+ /** Creates a new <code>ParseException</code>. */
+ public CompilerException() {
+ }
+
+ /**
+ * Creates a new <code>ParseException</code> with the specified detail message.
+ *
+ * @param msg the exception's detail message
+ */
+ public CompilerException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a new <code>ParseException</code> with the specified cause.
+ *
+ * @param initCause the exception's initCause
+ */
+ public CompilerException(Throwable initCause) {
+ super(initCause);
+ }
+
+ /**
+ * Creates a new <code>ParseException</code> with the specified detail message and cause.
+ *
+ * @param msg the exception's detail message
+ * @param initCause the exception's initCause
+ */
+ public CompilerException(String msg, Throwable initCause) {
+ super(msg, initCause);
+ }
+
+ @Override
+ public void printStackTrace() {
+ super.printStackTrace();
+ System.err.println("CompilerException printed from:");
+ Thread.dumpStack();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,406 +0,0 @@
-package jaxx.compiler;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-import java.io.File;
-
-/**
- * Stores options which affect the jaxxc tool's operation. These options are generally specified by the
- * user on the command line.
- */
-public class CompilerOptions {
- private File targetDirectory;
- private File javacTargetDirectory;
- private String classPath;
- private String javacOpts;
- private boolean keepJavaFiles;
- private boolean optimize;
- private boolean verbose;
- private boolean profile;
- /** a flag to enable or disable i18n generation */
- private boolean i18nable;
-
- /** a flag to add or not logger on generated jaxx files */
- private boolean addLogger;
-
- /** a flag to not reset compiler after a compile */
- private boolean resetAfterCompile;
-
- /** the name of implementation of {@link jaxx.runtime.JAXXContext} to be used on {@link jaxx.runtime.JAXXObject}. */
- protected String jaxxContextImplementorClass;
-
- /** list of fqn of class toimport for all generated jaxx files */
- protected String[] extraImports;
-
- /** default error ui */
- private Class<?> defaultErrorUI;
-
- private ClassLoader classLoader;
-
- private Class<? extends JAXXCompiler> compilerClass;
-
- /**
- * @deprecated prefer use {@link #validatorClass}
- */
- @Deprecated
- private String validatorFQN;
- /**
- * the validator class to use.
- *
- * @since 1.6.0
- */
- private Class<?> validatorClass;
-
- /** a flag to use {@link javax.swing.UIManager} to retreave icons. */
- private boolean useUIManagerForIcon;
-
- /** a flag to generate javax help for any */
- private boolean generateHelp;
-
- private String helpBrokerFQN;
- /**
- * The prefix to add to i18n key for any help i18n key.
- *
- * @since 1.3
- */
- protected String helpsetI18nPrefix;
- /**
- * The suffix to add to i18n key for an help Id.
- *
- * @since 1.3
- */
- protected String helpsetTitleI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetTocI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetIndexI18nSuffix;
- /**
- * The helpset name
- *
- * @since 1.3
- */
- protected String helpSetName;
- /** the default compiled object decorator to use if none specifed via decorator attribute */
- private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
-
- /**
- * Returns the target directory, generally specified with the "-d" option on the command line.
- *
- * @return the target directory
- * @see #setTargetDirectory
- */
- public File getJavacTargetDirectory() {
- if (javacTargetDirectory == null) {
- // to use the old way : if javacTargetDirectory not specified,
- // use same directory as targetDirectory (says where the java sources
- // are generated)
- return targetDirectory;
- }
- return javacTargetDirectory;
- }
-
- /**
- * Returns the target directory, generally specified with the "-d" option on the command line.
- *
- * @return the target directory
- * @see #setTargetDirectory
- */
- public File getTargetDirectory() {
- return targetDirectory;
- }
-
-
- /**
- * Sets the target directory into which compiled classes will be placed.
- *
- * @param targetDirectory the target directory
- * @see #getTargetDirectory
- */
- public void setTargetDirectory(File targetDirectory) {
- this.targetDirectory = targetDirectory;
- }
-
- public void setJavacTargetDirectory(File javacTargetDirectory) {
- this.javacTargetDirectory = javacTargetDirectory;
- }
-
- /**
- * Returns the class path to be used during compilation.
- *
- * @return the class path to be used during compilation
- * @see #setClassPath
- */
- public String getClassPath() {
- return classPath;
- }
-
- /**
- * Sets the class path to be used during compilation.
- *
- * @param classPath the compilation class path
- * @see #getClassPath
- */
- public void setClassPath(String classPath) {
- this.classPath = classPath;
- }
-
-
- /**
- * Returns the options to be passed into <code>javac</code>.
- *
- * @return options to be passed into <code>javac</code>
- * @see #setJavacOpts
- */
- public String getJavacOpts() {
- return javacOpts;
- }
-
-
- /**
- * Sets options to be passed into <code>javac</code>.
- *
- * @param javacOpts options to be passed into <code>javac</code>
- * @see #getJavacOpts
- */
- public void setJavacOpts(String javacOpts) {
- this.javacOpts = javacOpts;
- }
-
-
- /**
- * Returns whether or not generated Java files should be preserved after compilation.
- *
- * @return <code>true</code> if generated Java files should be preserved, <code>false</code> to delete
- * @see #setKeepJavaFiles
- */
- public boolean getKeepJavaFiles() {
- return keepJavaFiles;
- }
-
-
- /**
- * Sets whether or not generated Java files should be preserved after compilation.
- *
- * @param keepJavaFiles <code>true</code> if generated Java files should be preserved, <code>false</code> to delete
- * @see #getKeepJavaFiles
- */
- public void setKeepJavaFiles(boolean keepJavaFiles) {
- this.keepJavaFiles = keepJavaFiles;
- }
-
-
- /**
- * Returns whether or not optimization should be performed.
- *
- * @return whether or not optimizations should be performed
- */
- public boolean getOptimize() {
- return optimize;
- }
-
-
- /**
- * Sets whether or not optimizations should be performed.
- *
- * @param optimize <code>true</code> to perform optimizations during compilation
- * @see #getOptimize
- */
- public void setOptimize(boolean optimize) {
- this.optimize = optimize;
- }
-
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public boolean isI18nable() {
- return i18nable;
- }
-
- public boolean isUseUIManagerForIcon() {
- return useUIManagerForIcon;
- }
-
- public void setI18nable(boolean i18nable) {
- this.i18nable = i18nable;
- }
-
- public boolean isAddLogger() {
- return addLogger;
- }
-
- public void setAddLogger(boolean addLogger) {
- this.addLogger = addLogger;
- }
-
- public String getJaxxContextImplementorClass() {
- return jaxxContextImplementorClass;
- }
-
- public void setJaxxContextImplementorClass(String jaxxContextImplementorClass) {
- this.jaxxContextImplementorClass = jaxxContextImplementorClass;
- }
-
- public String[] getExtraImports() {
- return extraImports;
- }
-
- public void setExtraImports(String[] extraImports) {
- this.extraImports = extraImports;
- }
-
- public boolean isResetAfterCompile() {
- return resetAfterCompile;
- }
-
- public void setResetAfterCompile(boolean resetAfterCompile) {
- this.resetAfterCompile = resetAfterCompile;
- }
-
- public void setUseUIManagerForIcon(boolean useUIManagerForIcon) {
- this.useUIManagerForIcon = useUIManagerForIcon;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this);
- }
-
-
- public void setDefaultErrorUI(Class<?> defaultErrorUI) {
- this.defaultErrorUI = defaultErrorUI;
- }
-
- public boolean isKeepJavaFiles() {
- return keepJavaFiles;
- }
-
- public boolean isOptimize() {
- return optimize;
- }
-
- public Class<?> getDefaultErrorUI() {
- return defaultErrorUI;
- }
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public Class<? extends JAXXCompiler> getCompilerClass() {
- return compilerClass;
- }
-
- public void setCompilerClass(Class<? extends JAXXCompiler> compilerClass) {
- this.compilerClass = compilerClass;
- }
-
- @Deprecated
- public String getValidatorFQN() {
- return validatorClass.getName();
- }
-
- @Deprecated
- public void setValidatorFQN(String validatorFQN) {
- this.validatorFQN = validatorFQN;
- }
-
- public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
- return defaultDecoratorClass;
- }
-
- public void setDefaultDecoratorClass(Class<? extends CompiledObjectDecorator> defaultDecoratorClass) {
- this.defaultDecoratorClass = defaultDecoratorClass;
- }
-
- public boolean isProfile() {
- return profile;
- }
-
- public void setProfile(boolean profile) {
- this.profile = profile;
- }
-
- public boolean isGenerateHelp() {
- return generateHelp;
- }
-
- public void setGenerateHelp(boolean generateHelp) {
- this.generateHelp = generateHelp;
- }
-
- public String getHelpBrokerFQN() {
- return helpBrokerFQN;
- }
-
- public void setHelpBrokerFQN(String helpBrokerFQN) {
- this.helpBrokerFQN = helpBrokerFQN;
- }
-
- public String getHelpsetIndexI18nSuffix() {
- return helpsetIndexI18nSuffix;
- }
-
- public void setHelpsetIndexI18nSuffix(String helpsetIndexI18nSuffix) {
- this.helpsetIndexI18nSuffix = helpsetIndexI18nSuffix;
- }
-
- public String getHelpsetTitleI18nSuffix() {
- return helpsetTitleI18nSuffix;
- }
-
- public void setHelpsetTitleI18nSuffix(String helpsetTitleI18nSuffix) {
- this.helpsetTitleI18nSuffix = helpsetTitleI18nSuffix;
- }
-
- public String getHelpsetTocI18nSuffix() {
- return helpsetTocI18nSuffix;
- }
-
- public void setHelpsetTocI18nSuffix(String helpsetTocI18nSuffix) {
- this.helpsetTocI18nSuffix = helpsetTocI18nSuffix;
- }
-
- public String getHelpSetName() {
- return helpSetName;
- }
-
- public void setHelpSetName(String helpSetName) {
- this.helpSetName = helpSetName;
- }
-
- public String getHelpsetI18nPrefix() {
- return helpsetI18nPrefix;
- }
-
- public void setHelpsetI18nPrefix(String helpsetI18nPrefix) {
- this.helpsetI18nPrefix = helpsetI18nPrefix;
- }
-
- public Class<?> getValidatorClass() {
- return validatorClass;
- }
-
- public void setValidatorClass(Class<?> validatorClass) {
- this.validatorClass = validatorClass;
- }
-
-
-
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,32 +4,27 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.types.TypeManager;
+import jaxx.compiler.types.TypeManager;
/**
* Represents a data binding in a JAXX file. <code>DataBinding</code> uses {@link DataSource} to
* track changes to a source expression and update the destination.
*/
public class DataBinding {
- private String id;
+ private String id;
/** The DatSource which tracks source expression changes. */
private DataSource dataSource;
-
/** The data binding destination in the form <code><id>.<propertyName></code>. */
private String dest;
-
/**
* A Java snippet which will cause the destination property to be updated with the current value of
* the binding.
*/
private String assignment;
-
/** The current <code>JAXXCompiler</code>. */
private JAXXCompiler compiler;
-
/**
* Creates a new data binding.
*
@@ -46,12 +41,10 @@
this.compiler = compiler;
}
-
public String getId() {
return id;
}
-
/**
* Compiles the data binding expression. This method calls methods in <code>JAXXCompiler</code>
* to add the Java code that performs the data binding setup.
@@ -89,4 +82,4 @@
compiler.appendProcessDataBinding(JAXXCompiler.getLineSeparator() + " }");
return true;
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,19 +4,17 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.UnsupportedAttributeException;
-import jaxx.parser.JavaParser;
-import jaxx.parser.JavaParserConstants;
-import jaxx.parser.JavaParserTreeConstants;
-import jaxx.parser.SimpleNode;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.TypeManager;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserConstants;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.types.TypeManager;
import java.beans.Introspector;
import java.beans.PropertyChangeListener;
@@ -34,24 +32,19 @@
* changed but no event was fired).
*/
public class DataSource {
+
private class NULL {
} // type attached to "null" constants in parsed expressions
-
private String id;
-
/** The Java source code for the expression. */
private String source;
-
/** The current <code>JAXXCompiler</code>. */
private JAXXCompiler compiler;
-
/** List of symbols which this data source expression depends on. */
private List<String> dependencySymbols = new ArrayList<String>();
-
private StringBuffer addListenerCode = new StringBuffer();
private StringBuffer removeListenerCode = new StringBuffer();
private boolean compiled;
-
/** the delegate of property to be required */
private String objectCode;
@@ -69,7 +62,6 @@
this.compiler = compiler;
}
-
public String getId() {
return id;
}
@@ -97,17 +89,17 @@
if (compiled) {
throw new IllegalStateException(this + " has already been compiled");
}
- String id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(getClass()));
+ String autoId = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(getClass()));
JavaParser p = new JavaParser(new StringReader(source + ";"));
while (!p.Line()) {
SimpleNode node = p.popNode();
- scanNode(node, id);
+ scanNode(node, autoId);
}
if (dependencySymbols.size() > 0) {
//TC 20081108 prefer add a real JavaField instead of raw code
//compiler.appendBodyCode("private PropertyChangeListener " + id + " = " + propertyChangeListenerCode + ";\n");
- compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getName(), id, propertyChangeListenerCode));
+ compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getName(), autoId, propertyChangeListenerCode));
}
compileListeners();
@@ -126,7 +118,7 @@
*
* @param node node to scan
* @param listenerId id of listener
- * @throws jaxx.CompilerException ?
+ * @throws CompilerException ?
*/
private void scanNode(SimpleNode node, String listenerId) throws CompilerException {
switch (node.getId()) {
@@ -147,17 +139,17 @@
private ClassDescriptor determineLiteralType(SimpleNode node) {
assert node.getId() == JavaParserTreeConstants.JJTLITERAL;
if (node.jjtGetNumChildren() == 1) {
- int id = node.getChild(0).getId();
- if (id == JavaParserTreeConstants.JJTBOOLEANLITERAL) {
+ int childId = node.getChild(0).getId();
+ if (childId == JavaParserTreeConstants.JJTBOOLEANLITERAL) {
return ClassDescriptorLoader.getClassDescriptor(boolean.class);
}
- if (id == JavaParserTreeConstants.JJTNULLLITERAL) {
+ if (childId == JavaParserTreeConstants.JJTNULLLITERAL) {
return ClassDescriptorLoader.getClassDescriptor(NULL.class);
}
- throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[id]);
+ throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[childId]);
}
- int id = node.firstToken.kind;
- switch (id) {
+ int nodeId = node.firstToken.kind;
+ switch (nodeId) {
case JavaParserConstants.INTEGER_LITERAL:
if (node.firstToken.image.toLowerCase().endsWith("l")) {
return ClassDescriptorLoader.getClassDescriptor(long.class);
@@ -173,7 +165,7 @@
case JavaParserConstants.STRING_LITERAL:
return ClassDescriptorLoader.getClassDescriptor(String.class);
default:
- throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[id]);
+ throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[nodeId]);
}
}
@@ -221,8 +213,7 @@
currentSymbol.setLength(0);
accepted = true;
recognizeClassNames = false;
- }
- catch (NoSuchFieldException e) {
+ } catch (NoSuchFieldException e) {
if (j == 0 || j == 1 && tokens[0].equals(compiler.getRootObject().getId())) { // still in root context
FieldDescriptor[] newFields = compiler.getScriptFields();
for (FieldDescriptor newField : newFields) {
@@ -301,20 +292,19 @@
return null;
}
int dotPos = lastNode.lastIndexOf(".");
- String objectCode = dotPos == -1 ? "" : lastNode.substring(0, dotPos);
+ String code = dotPos == -1 ? "" : lastNode.substring(0, dotPos);
for (int j = i - 2; j >= 0; j--) {
- objectCode = expression.getChild(j).getText() + objectCode;
+ code = expression.getChild(j).getText() + code;
}
- if (objectCode.length() == 0) {
- objectCode = compiler.getRootObject().getJavaCode();
+ if (code.length() == 0) {
+ code = compiler.getRootObject().getJavaCode();
}
String methodName = lastNode.substring(dotPos + 1).trim();
try {
MethodDescriptor method = contextClass.getMethodDescriptor(methodName);
- trackMemberIfPossible(objectCode, contextClass, method.getName(), true, listenerId);
+ trackMemberIfPossible(code, contextClass, method.getName(), true, listenerId);
return method.getReturnType();
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
// happens for methods defined in the current JAXX file via scripts
String propertyName = null;
if (methodName.startsWith("is")) {
@@ -361,8 +351,7 @@
handler.getAddMemberListenerCode(objectCode, id, memberName, listenerId, compiler),
handler.getRemoveMemberListenerCode(objectCode, id, memberName, listenerId, compiler));
}
- }
- catch (UnsupportedAttributeException e) {
+ } catch (UnsupportedAttributeException e) {
// ignore -- this is thrown for methods like toString(), for which there is no tracking and
// no setting support
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,128 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package jaxx.compiler;
-
-import java.lang.reflect.Modifier;
-import java.util.Map.Entry;
-import jaxx.CompilerException;
-import jaxx.types.TypeManager;
-
-/**
- * The default compiledObjectDecorator.
- *
- * @author tony
- * @since 1.2
- */
-public class DefaultCompiledObjectDecorator extends CompiledObjectDecorator {
-
- @Override
- public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
-
- if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
- String id = object.getId();
- int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
- if (object == root) {
- javaFile.addField(new JavaField(access, fullClassName, id, "this"));
- } else {
- //TC -20081017 can have generic on compiled Object
- javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
- }
- }
-
- if (!compiler.inlineCreation(object) && object != root) {
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
- }
- }
-
- @Override
- public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
- if (object instanceof ScriptInitializer) {
- return object.getInitializationCode(compiler);
- }
- StringBuffer result = new StringBuffer();
- if (object.isOverride() && object.getOverrideType()==object.getObjectClass()) {
- //TC-20090309 on utilise le super code quand l'objet est de meme type
- result.append("super.").append(object.getCreationMethodName()).append("();");
- } else {
- result.append(object.getId());
- result.append(" = ");
- if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
- result.append(object.getJavaBeanInitCode()).append(";");
- } else {
- String constructorParams = object.getConstructorParams();
- if (constructorParams != null) {
- //TC - 20081017 compiledObject can have generics
- result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
- //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
- } else {
- //TC - 20081017 compiledObject can have generics
- result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
- }
- }
- result.append(JAXXCompiler.getLineSeparator());
- result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
- }
- result.append(JAXXCompiler.getLineSeparator());
- String initCode = object.getInitializationCode(compiler);
- if (initCode != null && initCode.length() > 0) {
- result.append(initCode);
- }
-
- return result.toString();
- }
-
- @Override
- public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) {
- StringBuffer code = new StringBuffer();
- //TC-20090327 generate client properties
- if (object.hasClientProperties()) {
- // generate putClientProperty invocations
- for (Entry<String,String> entry : object.getClientProperties().entrySet()) {
- object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");");
- }
-
- }
- //TC - 20081017 only generate the method if not empty ?
- if (object.getId().startsWith("$")) {
- code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
- } else {
- String additionCode = object.getAdditionCode();
- if (additionCode.length() > 0) {
- code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
- additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
- }
- }
- //code.append(getLineSeparator());
- return code.toString();
- }
-
- @Override
- public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) {
- if (object == root) {
- String rootCode = root.getInitializationCode(compiler);
- if (rootCode != null && rootCode.length() > 0) {
- code.append(rootCode);
- code.append(JAXXCompiler.getLineSeparator());
- }
- } else {
- if (!object.isOverride()) {
- if (compiler.inlineCreation(object)) {
- if (lastWasMethodCall) {
- lastWasMethodCall = false;
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append(getCreationCode(compiler, object));
- code.append(JAXXCompiler.getLineSeparator());
- } else {
- code.append(object.getCreationMethodName()).append("();");
- code.append(JAXXCompiler.getLineSeparator());
- lastWasMethodCall = true;
- }
- }
- }
- return lastWasMethodCall;
- }
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,247 @@
+package jaxx.compiler;
+
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import java.io.File;
+import jaxx.runtime.context.JAXXContext;
+
+/**
+ * Options of the {@link JAXXCompiler} and {@link JAXXCompilerLaunchor}.
+ *
+ */
+public class DefaultCompilerConfiguration implements CompilerConfiguration {
+
+// private File javacTargetDirectory;
+// private String classPath;
+// private String javacOpts;
+// private boolean keepJavaFiles;
+ /**
+ *
+ */
+ private File targetDirectory;
+ /**
+ *
+ */
+ private boolean optimize;
+ /**
+ *
+ */
+ private boolean verbose;
+ /**
+ *
+ */
+ private boolean profile;
+ /**
+ * a flag to enable or disable i18n generation
+ */
+ private boolean i18nable;
+ /**
+ * a flag to add or not logger on generated jaxx files
+ */
+ private boolean addLogger;
+ /**
+ * a flag to not reset compiler after a compile
+ */
+ private boolean resetAfterCompile;
+ /**
+ * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * to be used on {@link jaxx.runtime.JAXXObject}.
+ */
+ protected Class<? extends JAXXContext> jaxxContextClass;
+ /**
+ * list of fqn of class to import for all generated jaxx files
+ */
+ protected String[] extraImports;
+ /**
+ * default error ui
+ */
+ private Class<?> defaultErrorUI;
+ /**
+ *
+ */
+ private ClassLoader classLoader;
+ /**
+ *
+ */
+ private Class<? extends JAXXCompiler> compilerClass;
+ /**
+ * the validator class to use.
+ *
+ * @since 1.6.0
+ */
+ private Class<?> validatorClass;
+ /**
+ * the default compiled object decorator to use if none specifed via
+ * decorator attribute
+ */
+ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
+ /**
+ * a flag to use {@link javax.swing.UIManager} to retreave icons.
+ */
+ private boolean useUIManagerForIcon;
+ /**
+ * a flag to generate javax help for any
+ */
+ private boolean generateHelp;
+ /**
+ * Fully qualified name of help broker, can not use a class here
+ * 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() {
+ return targetDirectory;
+ }
+
+ @Override
+ public boolean getOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ @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 defaultErrorUI;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ @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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,10 +4,11 @@
*/
package jaxx.compiler;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.MethodDescriptor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
public class EventHandler {
+
private String eventId;
private String objectCode;
private ClassDescriptor listenerClass;
@@ -24,38 +25,32 @@
this.javaCode = javaCode;
}
-
public String getEventId() {
return eventId;
}
-
public String getObjectCode() {
return objectCode;
}
-
public MethodDescriptor getAddMethod() {
return addMethod;
}
-
public ClassDescriptor getListenerClass() {
return listenerClass;
}
-
public MethodDescriptor getListenerMethod() {
return listenerMethod;
}
-
public String getJavaCode() {
return javaCode;
}
-
+ @Override
public String toString() {
return "EventHandler[" + eventId + ", " + listenerClass.getName() + ", " + objectCode + ", " + javaCode + "]";
}
-}
\ No newline at end of file
+}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,14 +0,0 @@
-package jaxx.compiler;
-
-/**
- * TODO javadoc!
- *
- * @author chemit
- */
-public interface Generator {
-
- void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className);
-
- void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException;
-
-}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,93 +0,0 @@
-package jaxx.compiler;
-
-import java.lang.reflect.Modifier;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * A decorator to place on a root compiled object to process javaHelp on the file.
- *
- * @author tony
- * @since 1.2
- */
-public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
-
- /**
- * the list of discovered helpId
- */
- protected static Set<String> helpIds = new java.util.HashSet<String>();
-
- protected String getBrokerFQN(JAXXCompiler compiler) {
- String helpBrokerFQN = compiler.getOptions().getHelpBrokerFQN();
- return helpBrokerFQN;
- }
-
- protected String getHelpId(CompiledObject o) {
- String helpID = null;
- if (o.hasClientProperties()) {
- helpID = o.getClientProperty("help");
- }
- return helpID;
- }
-
- @Override
- public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
- super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
- CompilerOptions options = compiler.getOptions();
-
- if (options.isGenerateHelp()) {
-
- // add JaxxHelpUI interface
- Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
- String helpBrokerFQN = getBrokerFQN(compiler);
- javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "registerHelpId",
- "broker.installUI(component, helpId);",
- new JavaArgument(helpBrokerFQN, "broker"),
- new JavaArgument("Component", "component"),
- new JavaArgument("String", "helpId")));
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "showHelp",
- "getBroker().showHelp(this, helpId);",
- new JavaArgument("String", "helpId")));
-
- StringBuilder buffer = new StringBuilder();
-
- String lineSeparator = JAXXCompiler.getLineSeparator();
-
- if (options.isGenerateHelp()) {
-
- // add code to init javax help system
- Iterator<CompiledObject> itr = compiler.getObjectCreationOrder();
-
- for (; itr.hasNext();) {
- CompiledObject o = itr.next();
- String helpID = getHelpId(o);
- if (helpID != null) {
- buffer.append(lineSeparator);
- // detects a helpId to register
- buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");");
- //keep the helpID for helpSet generation
- helpIds.add(helpID);
- }
- }
- }
- if (buffer.length() > 0) {
-
- StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();");
-
- buffer.append(lineSeparator).append("_broker.prepareUI(this);");
- buffer.append(lineSeparator);
-
- // add the calls
- compiler.appendLateInitializer(extraCode.toString());
- compiler.appendLateInitializer(buffer.toString());
- }
- }
- }
-
- public static Set<String> getHelpIds() {
- return helpIds;
- }
-}
Modified: 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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,5 @@
package jaxx.compiler;
-import jaxx.tags.DefaultComponentHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -16,8 +15,7 @@
*/
public class I18nHelper {
- protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
-
+ protected static final Log log = LogFactory.getLog(I18nHelper.class);
public static final List<String> I18N_ATTRIBUTES = Arrays.asList("text", "title", "toolTipText");
/**
@@ -28,7 +26,7 @@
* @return <code>true</code> if wa have an active i18n attribute, <code>false</code> otherwise.
*/
public static boolean isI18nableAttribute(String attributeName, JAXXCompiler compiler) {
- return compiler.getOptions().isI18nable() && isI18nAttribute(attributeName);
+ return compiler.getConfiguration().isI18nable() && isI18nAttribute(attributeName);
}
/**
@@ -40,6 +38,7 @@
public static boolean isI18nAttribute(String attributeName) {
return I18N_ATTRIBUTES.contains(attributeName);
}
+
/**
* Add the i18n on a attribute.
* <p/>
@@ -60,7 +59,7 @@
log.debug(" try i18n support for [" + widgetId + ":" + attributeName + "] : " + attributeValueCode);
}
if (attributeValueCode.contains("_(") && attributeValueCode.contains(")")) {
- compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + attributeName + "' in component '" + widgetId + "' : ["+attributeValueCode+"]");
+ compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + attributeName + "' in component '" + widgetId + "' : [" + attributeValueCode + "]");
} else {
attributeValueCode = "_(" + attributeValueCode + ")";
}
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,22 +4,21 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.UnsupportedAttributeException;
-import jaxx.UnsupportedTagException;
-import jaxx.css.Rule;
-import jaxx.css.Stylesheet;
-import jaxx.css.StylesheetHelper;
-import jaxx.parser.ParseException;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.generators.Generator;
+import jaxx.compiler.parser.java.ParseException;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.TagManager;
import jaxx.runtime.ComponentDescriptor;
import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagHandler;
-import jaxx.tags.TagManager;
+import jaxx.runtime.css.Rule;
+import jaxx.runtime.css.Stylesheet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
@@ -50,9 +49,7 @@
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Modifier;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
@@ -76,7 +73,6 @@
/** log */
protected static final Log log = LogFactory.getLog(JAXXCompiler.class);
-
/**
* True to throw exceptions when we encounter unresolvable classes, false to ignore.
* This is currently set to false until JAXX has full support for inner classes
@@ -84,158 +80,225 @@
* generally compile without error anyway).
*/
public static final boolean STRICT_CHECKS = false;
+ /**
+ *
+ */
public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/";
+ /**
+ *
+ */
public static final String JAXX_INTERNAL_NAMESPACE = "http://www.jaxxframework.org/internal";
-
- /** Maximum length of an inlinable creation method. */
+ /**
+ * Maximum length of an inlinable creation method.
+ */
public static final int INLINE_THRESHOLD = 300;
-
+ /**
+ *
+ */
protected final DefaultObjectHandler firstPassClassTagHandler;
-
+ /**
+ *
+ */
protected List<String> staticImports = new ArrayList<String>();
/*---------------------------------------------------------------------------------*/
/*-- compiler fields --------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
- /** flag to detec if an error occurs while compiling jaxx file */
+ /**
+ * flag to detec if an error occurs while compiling jaxx file
+ */
protected boolean failed;
-
- /** Object corresponding to the root tag in the document. */
+ /**
+ * Object corresponding to the root tag in the document.
+ */
protected CompiledObject root;
-
- /** Contains strings of the form "javax.swing." */
+ /**
+ * Contains strings of the form "javax.swing."
+ */
protected Set<String> importedPackages = new HashSet<String>();
-
- /** Contains strings of the form "javax.swing.Timer" */
+ /**
+ * Contains strings of the form "javax.swing.Timer"
+ */
protected Set<String> importedClasses = new HashSet<String>();
-
- /** Keeps track of open components (components still having children added). */
+ /**
+ * Keeps track of open components (components still having children added).
+ */
protected Stack<CompiledObject> openComponents = new Stack<CompiledObject>();
-
- /** Sequence number used to create automatic variable names. */
+ /**
+ * Sequence number used to create automatic variable names.
+ */
protected int autogenID = 0;
-
+ /**
+ *
+ */
protected List<DataBinding> dataBindings = new ArrayList<DataBinding>();
-
+ /**
+ *
+ */
protected SymbolTable symbolTable = new SymbolTable();
-
- /** Base directory used for path resolution (normally the directory in which the .jaxx file resides). */
+ /**
+ * Base directory used for path resolution (normally the directory in
+ * which the .jaxx file resides).
+ */
protected File baseDir;
-
- /** .jaxx file being compiled. */
+ /**
+ * .jaxx file being compiled.
+ */
protected File src;
-
- /** Parsed XML of src file. */
+ /**
+ * Parsed XML of src file.
+ */
protected Document document;
-
- /** Name of class being compiled. */
+ /**
+ * Name of class being compiled.
+ */
protected String outputClassName;
-
+ /**
+ *
+ */
protected ScriptManager scriptManager = new ScriptManager(this);
-
- /** Combination of all stylesheets registered using {@link #registerStylesheet}. */
+ /**
+ * Combination of all stylesheets registered using
+ * {@link #registerStylesheet}.
+ */
protected Stylesheet stylesheet;
-
- /** Contains all attributes defined inline on class tags. */
+ /**
+ * Contains all attributes defined inline on class tags.
+ */
protected List<Rule> inlineStyles = new ArrayList<Rule>();
-
/**
* Maps objects (expressed in Java code) to event listener classes (e.g. MouseListener) to Lists of EventHandlers. The final list
* contains all event handlers of a particular type attached to a particular object (again, as represented by a Java expression).
*/
protected Map<String, Map<ClassDescriptor, List<EventHandler>>> eventHandlers = new HashMap<String, Map<ClassDescriptor, List<EventHandler>>>();
-
- /** Maps of uniqued id for objects used in compiler */
+ /**
+ * Maps of uniqued id for objects used in compiler
+ */
protected Map<Object, String> uniqueIds = new HashMap<Object, String>();
-
- /** Map of event handler method names used in compiler */
+ /**
+ * Map of event handler method names used in compiler
+ */
protected Map<EventHandler, String> eventHandlerMethodNames = new HashMap<EventHandler, String>();
-
- /** ClassLoader which searches the user-specified class path in addition to the normal class path */
+ /**
+ * ClassLoader which searches the user-specified class path in addition to the normal class path
+ */
protected ClassLoader classLoader;
-
/**
* A list of Runnables which will be run after the first compilation pass. This is primarily used
* to trigger the creation of CompiledObjects, which cannot be created during the first pass and must be
* created in document order.
*/
protected List<Runnable> initializers = new ArrayList<Runnable>();
-
- /** left brace matcher */
+ /**
+ * left brace matcher
+ */
protected Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher("");
-
- /** right brace matcher */
+ /**
+ * right brace matcher
+ */
protected Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher("");
-
- /** extra interfaces which can by passed to root object via the 'implements' attribute */
+ /**
+ * extra interfaces which can by passed to root object via the 'implements' attribute
+ */
private String[] extraInterfaces;
-
- /** a flag to generate a abstract class */
+ /**
+ * a flag to generate a abstract class
+ */
private boolean abstractClass;
-
- /** the possible generic type of the class */
+ /**
+ * the possible generic type of the class
+ */
private String genericType;
-
- /** thepossible generic type of the super class */
+ /**
+ * the possible generic type of the super class
+ */
private String superGenericType;
-
- /** Extra code to be added to the instance initializer. */
+ /**
+ * Extra code to be added to the instance initializer.
+ */
protected StringBuffer initializer = new StringBuffer();
-
- /** Extra code to be added at the end of the instance initializer. */
+ /**
+ * Extra code to be added at the end of the instance initializer.
+ */
protected StringBuffer lateInitializer = new StringBuffer();
-
- /** Extra code to be added to the class body. */
+ /**
+ * Extra code to be added to the class body.
+ */
protected StringBuffer bodyCode = new StringBuffer();
-
- /** Code to initialize data bindings. */
+ /**
+ * Code to initialize data bindings.
+ */
protected StringBuffer initDataBindings = new StringBuffer();
-
- /** Body of the applyDataBinding method. */
+ /**
+ * Body of the applyDataBinding method.
+ */
protected StringBuffer applyDataBinding = new StringBuffer();
-
- /** Body of the removeDataBinding method. */
+ /**
+ * Body of the removeDataBinding method.
+ */
protected StringBuffer removeDataBinding = new StringBuffer();
-
- /** Body of the processDataBinding method. */
+ /**
+ * Body of the processDataBinding method.
+ */
protected StringBuffer processDataBinding = new StringBuffer();
-
- /** true if a main() method has been declared in a script */
+ /**
+ * true if a main() method has been declared in a script
+ */
protected boolean mainDeclared;
-
- /** the file to be generated */
+ /**
+ * the file to be generated
+ */
protected JavaFile javaFile;
-
-
- protected CompilerOptions options;
-
- /** Used for error reporting purposes, so we can report the right line number. */
+ /**
+ *
+ */
+ protected CompilerConfiguration configuration;
+ /**
+ * Used for error reporting purposes, so we can report the right line number.
+ */
protected Stack<Element> tagsBeingCompiled = new Stack<Element>();
-
- /** Used for error reporting purposes, so we can report the right source file. */
+ /**
+ * Used for error reporting purposes, so we can report the right source file.
+ */
protected Stack<File> sourceFiles = new Stack<File>();
-
- /** Maps object ID strings to the objects themselves. These are created during the second compilation pass. */
+ /**
+ * Maps object ID strings to the objects themselves. These are created during the second compilation pass.
+ */
protected Map<String, CompiledObject> objects = new LinkedHashMap<String, CompiledObject>();
-
- /** Maps objects to their ID strings. These are created during the second compilation pass. */
+ /**
+ * Maps objects to their ID strings. These are created during the second compilation pass.
+ */
protected Map<CompiledObject, String> ids = new LinkedHashMap<CompiledObject, String>();
+ /**
+ *
+ */
+ protected CompiledObjectDecorator defaultDecorator;
- protected CompiledObjectDecorator defaultDecorator;
-
/*---------------------------------------------------------------------------------*/
/*-- Constructor methods ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
+ protected JAXXCompiler(ClassLoader classLoader) {
- protected JAXXCompiler(ClassLoader classLoader, DefaultObjectHandler firstPassClassTagHandler, String... staticImports) {
- this.firstPassClassTagHandler = firstPassClassTagHandler;
- this.options = new CompilerOptions();
+ this.firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ this.configuration = new DefaultCompilerConfiguration();
this.classLoader = classLoader;
- if (staticImports == null || staticImports.length == 0) {
- staticImports = new String[0];
- }
- this.staticImports = Arrays.asList(staticImports);
+// this.staticImports = Arrays.asList(new String[]{
+// "java.awt.*",
+// "java.awt.event.*",
+// "java.beans.*",
+// "java.io.*",
+// "java.lang.*",
+// "java.util.*",
+// "javax.swing.*",
+// "javax.swing.border.*",
+// "javax.swing.event.*",
+// "jaxx.runtime.swing.JAXXButtonGroup",
+// "jaxx.runtime.swing.HBox",
+// "jaxx.runtime.swing.VBox",
+// "jaxx.runtime.swing.Table",
+// "static org.nuiton.i18n.I18n._",
+// "static jaxx.runtime.Util.createImageIcon"
+// });
addImport("java.lang.*");
}
@@ -245,42 +308,52 @@
* @param baseDir classpath location
* @param src location of file to compile
* @param outputClassName the out file name
- * @param options options to pass to javac
- * @param firstPassClassTagHandler handler to use for first pass
- * @param staticImports statics imports
+ * @param configuration configuration to pass to javac
*/
- protected JAXXCompiler(File baseDir, File src, String outputClassName, CompilerOptions options, DefaultObjectHandler firstPassClassTagHandler, String... staticImports) {
+ public JAXXCompiler(File baseDir, File src, String outputClassName, CompilerConfiguration configuration) {
this.baseDir = baseDir;
this.src = src;
- this.firstPassClassTagHandler = firstPassClassTagHandler;
- this.staticImports = Arrays.asList(staticImports);
+ this.firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ this.staticImports = Arrays.asList(new String[]{
+ "java.awt.*",
+ "java.awt.event.*",
+ "java.beans.*",
+ "java.io.*",
+ "java.lang.*",
+ "java.util.*",
+ "javax.swing.*",
+ "javax.swing.border.*",
+ "javax.swing.event.*",
+ "jaxx.runtime.swing.JAXXButtonGroup",
+ "jaxx.runtime.swing.HBox",
+ "jaxx.runtime.swing.VBox",
+ "jaxx.runtime.swing.Table",
+ "static org.nuiton.i18n.I18n._",
+ "static jaxx.runtime.Util.createImageIcon"
+ });
sourceFiles.push(src);
this.outputClassName = outputClassName;
- this.options = options;
+ this.configuration = configuration;
addImport(outputClassName.substring(0, outputClassName.lastIndexOf(".") + 1) + "*");
- if (staticImports == null || staticImports.length == 0) {
- staticImports = new String[]{"java.lang.*"};
- }
for (Object staticImport : staticImports) {
addImport((String) staticImport);
}
- // add extra imports from options
- if (options.getExtraImports() != null) {
- for (String extraImport : options.getExtraImports()) {
+ // add extra imports from configuration
+ if (configuration.getExtraImports() != null) {
+ for (String extraImport : configuration.getExtraImports()) {
addImport(extraImport);
}
}
- defaultDecorator = CompiledObjectDecorator.getDecorator(options.getDefaultDecoratorClass());
+ defaultDecorator = CompiledObjectDecoratorManager.getDecorator(configuration.getDefaultDecoratorClass());
if (defaultDecorator == null) {
- log.error("could not find default decorator : "+options.getDefaultDecoratorClass());
- throw new IllegalArgumentException("could not find default decorator : " + options.getDefaultDecoratorClass());
+ log.error("could not find default decorator : " + configuration.getDefaultDecoratorClass());
+ throw new IllegalArgumentException("could not find default decorator : " + configuration.getDefaultDecoratorClass());
}
}
/*---------------------------------------------------------------------------------*/
/*-- Initializer methods -----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void runInitializers() {
for (Runnable runnable : initializers) {
if (log.isDebugEnabled()) {
@@ -297,7 +370,6 @@
initializers.clear();
}
-
/**
* Registers a <code>Runnable</code> which will be executed after the first
* compilation pass is complete.
@@ -311,7 +383,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Compile methods --------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void compileFirstPass(final Element tag) throws IOException {
tagsBeingCompiled.push(tag);
@@ -322,13 +393,14 @@
// resolve class tags into fully-qualified class name
if (namespace != null && namespace.endsWith("*")) {
String packageName = namespace.substring(0, namespace.length() - 1);
- if (localName.startsWith(packageName)) // class name is fully-qualified already
- {
+ if (localName.startsWith(packageName)) {
+ // class name is fully-qualified already
fullClassName = TagManager.resolveClassName(localName, this);
- } else { // namespace not included in class name, probably need the namespace to resolve
+ } else {
+ // namespace not included in class name, probably need the namespace to resolve
fullClassName = TagManager.resolveClassName(packageName + localName, this);
- if (fullClassName == null && !namespacePrefix) // it was just a default namespace, try again without using the namespace
- {
+ if (fullClassName == null && !namespacePrefix) {
+ // it was just a default namespace, try again without using the namespace
fullClassName = TagManager.resolveClassName(localName, this);
}
}
@@ -336,7 +408,8 @@
fullClassName = TagManager.resolveClassName(localName, this);
}
- if (fullClassName != null) { // we are definitely dealing with a class tag
+ if (fullClassName != null) {
+ // we are definitely dealing with a class tag
addDependencyClass(fullClassName);
namespace = fullClassName.substring(0, fullClassName.lastIndexOf(".") + 1) + "*";
if (symbolTable.getSuperclassName() == null) {
@@ -369,7 +442,8 @@
}
if (handler == firstPassClassTagHandler) {
final String finalClassName = fullClassName;
- registerInitializer(new Runnable() { // register an initializer which will create the CompiledObject after pass 1
+ registerInitializer(new Runnable() {
+ // register an initializer which will create the CompiledObject after pass 1
@Override
public void run() {
@@ -384,8 +458,7 @@
if (handler != null) {
try {
handler.compileFirstPass(tag, this);
- }
- catch (CompilerException e) {
+ } catch (CompilerException e) {
reportError(e);
}
} else {
@@ -399,7 +472,6 @@
}
}
-
public void compileSecondPass(Element tag) throws IOException {
tagsBeingCompiled.push(tag);
@@ -425,11 +497,9 @@
document = parseDocument(in);
in.close();
compileFirstPass(document.getDocumentElement());
- }
- catch (SAXParseException e) {
+ } catch (SAXParseException e) {
reportError(e.getLineNumber(), "Invalid XML: " + e.getMessage());
- }
- catch (SAXException e) {
+ } catch (SAXException e) {
reportError(null, "Error parsing XML document: " + e);
}
}
@@ -444,7 +514,6 @@
/*---------------------------------------------------------------------------------*/
/*-- CompiledObject methods -------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void openComponent(CompiledObject component) throws CompilerException {
openComponent(component, null);
}
@@ -504,7 +573,6 @@
return objects.get(id);
}
-
public boolean inlineCreation(CompiledObject object) {
return object.getId().startsWith("$") && object.getInitializationCode(this).length() < INLINE_THRESHOLD;
}
@@ -526,8 +594,7 @@
object.setOverride(true);
object.setOverrideType(f.getType());
break;
- }
- catch (NoSuchFieldException e) {
+ } catch (NoSuchFieldException e) {
ancestor = ancestor.getSuperclass();
}
}
@@ -536,7 +603,6 @@
/*---------------------------------------------------------------------------------*/
/*-- DataBinding methods ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
/**
* Examine an attribute value for data binding expressions. Returns a 'cooked' expression which
* can be used to determine the resulting value. It is expected that this expression will be used
@@ -546,7 +612,7 @@
* @param stringValue the string value of the property from the XML
* @param type the type of the property, from the <code>JAXXPropertyDescriptor</code>
* @return a processed version of the expression
- * @throws jaxx.CompilerException ?
+ * @throws CompilerException ?
*/
public String processDataBindings(String stringValue, ClassDescriptor type) throws CompilerException {
int pos = getNextLeftBrace(stringValue, 0);
@@ -596,13 +662,11 @@
return null;
}
-
public void registerDataBinding(String src, String dest, String assignment) {
try {
src = checkJavaCode(src);
dataBindings.add(new DataBinding(src, dest, assignment, this));
- }
- catch (CompilerException e) {
+ } catch (CompilerException e) {
reportError("While parsing data binding for '" + dest.substring(dest.lastIndexOf(".") + 1) + "': " + e.getMessage());
}
}
@@ -626,13 +690,13 @@
public String getEventHandlerMethodName(EventHandler handler) {
String result = eventHandlerMethodNames.get(handler);
if (result == null) {
- if (getOptions().isOptimize()) {
+ if (getConfiguration().isOptimize()) {
result = "$ev" + eventHandlerMethodNames.size();
} else {
//TC-20090309 must get the goal property from the event id
// to make possible inheritance
- String id = handler.getEventId().substring(0,handler.getEventId().indexOf("."));
-
+ String id = handler.getEventId().substring(0, handler.getEventId().indexOf("."));
+
result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id;
//result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + handler.getObjectCode();
}
@@ -644,7 +708,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Script methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void addScriptField(FieldDescriptor field) {
symbolTable.getScriptFields().add(field);
}
@@ -685,7 +748,6 @@
/*---------------------------------------------------------------------------------*/
/*-- StyleSheet methods -----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void applyStylesheets() {
for (Object o : new ArrayList<CompiledObject>(objects.values())) {
CompiledObject object = (CompiledObject) o;
@@ -708,7 +770,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Report methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void reportWarning(String warning) {
Element currentTag = null;
if (!tagsBeingCompiled.isEmpty()) {
@@ -717,7 +778,6 @@
reportWarning(currentTag, warning, 0);
}
-
public void reportWarning(Element tag, String warning, int lineOffset) {
String lineNumber = null;
if (tag != null) {
@@ -729,8 +789,7 @@
File srcFile = sourceFiles.peek();
try {
srcFile = srcFile.getCanonicalFile();
- }
- catch (IOException e) {
+ } catch (IOException e) {
// ignore ?
}
@@ -742,7 +801,6 @@
JAXXCompilerLaunchor.get().warningCount++;
}
-
public void reportError(String error) {
Element currentTag = null;
if (!tagsBeingCompiled.isEmpty()) {
@@ -795,8 +853,7 @@
if (errorFile != null) {
errorFile = errorFile.getCanonicalFile();
}
- }
- catch (IOException e) {
+ } catch (IOException e) {
// ignore ?
}
@@ -812,7 +869,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Getter methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public Map<String, CompiledObject> getObjects() {
return objects;
}
@@ -822,15 +878,14 @@
}
/*public List<CompiledBeanValidator> getValidators() {
- return validators;
+ return validators;
}*/
-
public Map<String, Map<ClassDescriptor, List<EventHandler>>> getEventHandlers() {
return eventHandlers;
}
- public CompilerOptions getOptions() {
- return options;
+ public CompilerConfiguration getConfiguration() {
+ return configuration;
}
public String getOutputClassName() {
@@ -889,10 +944,10 @@
}
public MethodDescriptor getScriptMethod(String methodName) {
- for (MethodDescriptor m :symbolTable.getScriptMethods()) {
- if (methodName.equals(m.getName())) {
- return m;
- }
+ for (MethodDescriptor m : symbolTable.getScriptMethods()) {
+ if (methodName.equals(m.getName())) {
+ return m;
+ }
}
return null;
}
@@ -909,24 +964,24 @@
*/
public ClassLoader getClassLoader() {
if (classLoader == null) {
- if (options.getClassLoader() != null) {
- classLoader = options.getClassLoader();
+ if (configuration.getClassLoader() != null) {
+ classLoader = configuration.getClassLoader();
} else {
- String classPath = options.getClassPath();
- if (classPath == null) {
- classPath = ".";
- }
- String[] paths = classPath.split(File.pathSeparator);
- URL[] urls = new URL[paths.length];
- for (int i = 0; i < paths.length; i++) {
- try {
- urls[i] = new File(paths[i]).toURI().toURL();
- }
- catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
- classLoader = new URLClassLoader(urls, getClass().getClassLoader());
+ throw new NullPointerException("compiler configuration requires a classLoader! :\n" + configuration);
+// String classPath = configuration.getClassPath();
+// if (classPath == null) {
+// classPath = ".";
+// }
+// String[] paths = classPath.split(File.pathSeparator);
+// URL[] urls = new URL[paths.length];
+// for (int i = 0; i < paths.length; i++) {
+// try {
+// urls[i] = new File(paths[i]).toURI().toURL();
+// } catch (MalformedURLException e) {
+// throw new RuntimeException(e);
+// }
+// }
+// classLoader = new URLClassLoader(urls, getClass().getClassLoader());
}
}
@@ -945,7 +1000,8 @@
CompiledObject parent = components[i].getParent();
while (parent != null) {
boolean found = false;
- for (int j = i + 1; j < components.length; j++) { // found parent after component, swap them
+ for (int j = i + 1; j < components.length; j++) {
+ // found parent after component, swap them
if (components[j] == parent) {
components[j] = components[i];
components[i] = parent;
@@ -967,7 +1023,8 @@
}
}
}
- descriptors[i] = new ComponentDescriptor(components[i].getId(), components[i] == root ? outputClassName : components[i].getObjectClass().getName(),
+ descriptors[i] = new ComponentDescriptor(
+ components[i].getId(), components[i] == root ? outputClassName : components[i].getObjectClass().getName(),
components[i].getStyleClass(), parentIndex != -1 ? descriptors[parentIndex] : null);
}
@@ -982,7 +1039,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Setter methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void setFailed(boolean failed) {
this.failed = failed;
}
@@ -990,7 +1046,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Buffer ------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public StringBuffer getInitializer() {
return initializer;
}
@@ -1084,7 +1139,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Other methods ----------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void addImport(String text) {
if (text.endsWith("*")) {
importedPackages.add(text.substring(0, text.length() - 1));
@@ -1098,6 +1152,7 @@
}
public void addDependencyClass(String className) {
+
if (!JAXXCompilerLaunchor.get().jaxxFileClassNames.contains(className)) {
URL jaxxURL = getClassLoader().getResource(className.replace('.', '/') + ".jaxx");
URL classURL = getClassLoader().getResource(className.replace('.', '/') + ".class");
@@ -1108,8 +1163,7 @@
if (classFile.lastModified() > jaxxFile.lastModified()) {
return; // class file is newer, no need to recompile
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
// do nothing
}
}
@@ -1118,8 +1172,7 @@
File jaxxFile = URLtoFile(jaxxURL);
try {
jaxxFile = jaxxFile.getCanonicalFile();
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
// ignore ?
}
assert jaxxFile.getName().equalsIgnoreCase(className.substring(className.lastIndexOf(".") + 1) + ".jaxx") :
@@ -1141,7 +1194,7 @@
*
* @param javaCode the Java code snippet to test
* @return a "cooked" version of the string which has enclosing curly braces removed.
- * @throws jaxx.CompilerException if the code cannot be parsed
+ * @throws CompilerException if the code cannot be parsed
*/
public String checkJavaCode(String javaCode) {
javaCode = scriptManager.trimScript(javaCode);
@@ -1265,7 +1318,7 @@
}
public String getAutoId(ClassDescriptor objectClass) {
- if (options.getOptimize()) {
+ if (configuration.getOptimize()) {
return "$" + Integer.toString(autogenID++, 36);
} else {
String name = objectClass.getName();
@@ -1328,8 +1381,8 @@
public void generateCode(Iterable<Generator> generatorIterator) throws IOException {
File dest;
- if (getOptions().getTargetDirectory() != null) {
- dest = new File(getOptions().getTargetDirectory(), getOutputClassName().replace('.', File.separatorChar) + ".java");
+ if (getConfiguration().getTargetDirectory() != null) {
+ dest = new File(getConfiguration().getTargetDirectory(), getOutputClassName().replace('.', File.separatorChar) + ".java");
} else {
dest = new File(getBaseDir(), getOutputClassName().substring(getOutputClassName().lastIndexOf(".") + 1) + ".java");
}
@@ -1369,7 +1422,6 @@
throw new CompilerException(e);
}
}
-
/** line separator cached value */
protected static String lineSeparator = System.getProperty("line.separator", "\n");
@@ -1471,8 +1523,7 @@
}
try {
return new File(URLDecoder.decode(urlString.replace('/', File.separatorChar), "utf-8"));
- }
- catch (UnsupportedEncodingException e) {
+ } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@@ -1484,11 +1535,9 @@
SAXParser parser;
parser = factory.newSAXParser();
return parser;
- }
- catch (SAXException e) {
+ } catch (SAXException e) {
throw new RuntimeException(e);
- }
- catch (ParserConfigurationException e) {
+ } catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
@@ -1498,6 +1547,7 @@
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setErrorListener(new ErrorListener() {
+
@Override
public void warning(TransformerException ex) throws TransformerException {
throw ex;
@@ -1516,6 +1566,7 @@
DOMResult result = new DOMResult();
transformer.transform(new SAXSource(new XMLFilterImpl(getSAXParser().getXMLReader()) {
+
Locator locator;
@Override
@@ -1531,11 +1582,9 @@
}
}, new InputSource(in)), result);
return (Document) result.getNode();
- }
- catch (TransformerConfigurationException e) {
+ } catch (TransformerConfigurationException e) {
throw new RuntimeException(e);
- }
- catch (TransformerException e) {
+ } catch (TransformerException e) {
Throwable ex = e;
while (ex.getCause() != null) {
ex = ex.getCause();
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,9 +1,7 @@
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.spi.Initializer;
-import jaxx.tags.DefaultObjectHandler;
+import jaxx.compiler.generators.Generator;
+import jaxx.compiler.spi.Initializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -16,6 +14,7 @@
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
+import jaxx.compiler.generators.GeneratorManager;
/** @author chemit */
public class JAXXCompilerLaunchor {
@@ -53,10 +52,10 @@
*
* @param base the directory against which to resolve relative paths
* @param relativePaths a list of relative paths to .jaxx files being compiled
- * @param options the compiler options to use
+ * @param configuration the compiler configuration to use
* @return the new instanciated launchor
*/
- public static synchronized JAXXCompilerLaunchor newLaunchor(File base, String[] relativePaths, CompilerOptions options) {
+ public static synchronized JAXXCompilerLaunchor newLaunchor(File base, String[] relativePaths, CompilerConfiguration configuration) {
File[] files = new File[relativePaths.length];
String[] classNames = new String[relativePaths.length];
for (int i = 0; i < files.length; i++) {
@@ -67,7 +66,7 @@
classNames[i] = classNames[i].replace('\\', '.');
classNames[i] = classNames[i].replace(':', '.');
}
- return newLaunchor(files, classNames, options);
+ return newLaunchor(files, classNames, configuration);
}
/**
@@ -78,14 +77,14 @@
*
* @param files the .jaxx files to compile
* @param classNames the names of the classes being compiled
- * @param options the compiler options to use
+ * @param configuration the compiler configuration to use
* @return the new instanciated launchor
*/
- public static synchronized JAXXCompilerLaunchor newLaunchor(File[] files, String[] classNames, CompilerOptions options) {
+ public static synchronized JAXXCompilerLaunchor newLaunchor(File[] files, String[] classNames, CompilerConfiguration configuration) {
if (singleton != null) {
singleton.reset();
}
- singleton = new JAXXCompilerLaunchor(files, classNames, options);
+ singleton = new JAXXCompilerLaunchor(files, classNames, configuration);
return singleton;
}
@@ -124,8 +123,8 @@
initializer.initialize();
}
}
- /** options of the launchor and underlines compilers */
- protected CompilerOptions options;
+ /** configuration of the launchor and underlines compilers */
+ protected CompilerConfiguration configuration;
/** original list of files to compile */
protected final File[] files;
/** original list of classes to compile */
@@ -144,14 +143,14 @@
protected int compilerCount;
protected JAXXProfile profiler;
- protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerOptions options) {
- this.options = options == null ? new CompilerOptions() : options;
+ protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerConfiguration options) {
+ this.configuration = options == null ? new DefaultCompilerConfiguration() : options;
this.files = files;
this.classNames = classNames;
- if (this.options.isVerbose()) {
+ if (this.configuration.isVerbose()) {
log.info("files : " + Arrays.toString(files));
}
- if (this.options.isProfile()) {
+ if (this.configuration.isProfile()) {
profiler = new JAXXProfile();
}
}
@@ -173,7 +172,7 @@
}
public String getVersion() {
- return "1.0.4";
+ return "2.0.0";
}
/**
@@ -192,7 +191,7 @@
* @return the compiler
*/
public static JAXXCompiler createDummyCompiler(ClassLoader classLoader) {
- return new JAXXCompiler(classLoader, new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class))) {
+ return new JAXXCompiler(classLoader) {
};
}
@@ -262,7 +261,7 @@
throw new CompilerException("Internal error: " + className + " is already being compiled, attempting to compile it again");
}
- File destDir = options.getTargetDirectory();
+ File destDir = configuration.getTargetDirectory();
if (destDir != null) {
int dotPos = className.lastIndexOf(".");
if (dotPos != -1) {
@@ -342,10 +341,7 @@
return false;
}
assert jaxxFiles.size() == jaxxFileClassNames.size();
- List<Generator> generators = new ArrayList<Generator>();
- for (Generator generator : ServiceLoader.load(Generator.class)) {
- generators.add(generator);
- }
+ List<Generator> generators = GeneratorManager.getGenerators();
for (String className : jaxxFileClassNames) {
JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation");
addProfileTime(compiler, currentPass.name() + "_start");
@@ -357,7 +353,7 @@
}
}
- if (options.isProfile()) {
+ if (configuration.isProfile()) {
// profile pass (only if succes compile)
if (!nextStep(LifeCycle.profile_pass, success)) {
return false;
@@ -379,7 +375,7 @@
} finally {
compilerCount = compilers.size();
//TC - 20081018 only reset when no error was detected
- if (options.isResetAfterCompile() && errorCount == 0) {
+ if (configuration.isResetAfterCompile() && errorCount == 0) {
reset();
}
}
@@ -420,8 +416,8 @@
}
protected JAXXCompiler newCompiler(File parentFile, File file, String className) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
- Constructor<? extends JAXXCompiler> cons = options.getCompilerClass().getConstructor(File.class, File.class, String.class, CompilerOptions.class);
- return cons.newInstance(parentFile, file, className, options);
+ Constructor<? extends JAXXCompiler> cons = configuration.getCompilerClass().getConstructor(File.class, File.class, String.class, CompilerConfiguration.class);
+ return cons.newInstance(parentFile, file, className, configuration);
}
public static void addProfileTime(JAXXCompiler compiler, String key) {
@@ -430,22 +426,4 @@
p.addTime(compiler, key);
}
}
-
- protected static void showUsage() {
- System.out.println("Usage: jaxxc <options> <source files>");
- System.out.println();
- System.out.println("Source files must end in extension .jaxx");
- System.out.println("Use JAXX_OPTS environment variable to pass arguments to Java runtime");
- System.out.println();
- System.out.println("Supported options include:");
- System.out.println(" -classpath <paths> paths to search for user classes");
- System.out.println(" -cp <paths> same as -classpath");
- System.out.println(" -d <directory> target directory for generated class files");
- System.out.println(" -java or -j produce .java files, but do not compile them");
- System.out.println(" -keep or -k preserve generated .java files after compilation");
- System.out.println(" -optimize or -o optimize during compilation");
- System.out.println(" -version display version information");
- System.out.println();
- System.out.println("See http://www.jaxxframework.org/ for full documentation.");
- }
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,598 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.Base64Coder;
-import jaxx.CompilerException;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.types.TypeManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.IOException;
-import java.lang.reflect.Modifier;
-import static java.lang.reflect.Modifier.FINAL;
-import static java.lang.reflect.Modifier.PROTECTED;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}.
- * <p/>
- * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the
- * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files.
- *
- * @author chemit
- */
-public class JAXXObjectGenerator implements Generator {
-
- /** log */
- protected static final Log log = LogFactory.getLog(JAXXObjectGenerator.class);
- protected static final JavaField ACTIVE_BINDINGS_FIELD = JavaField.newField(PROTECTED,
- "java.util.List<Object>", "$activeBindings", "new ArrayList<Object>()");
- protected static final JavaField BINDING_SOURCES_FIELD = JavaField.newField(PROTECTED,
- "java.util.Map<String,Object>", "$bindingSources", "new HashMap<String,Object>()");
- protected static final JavaField OBJECT_MAP_FIELD = JavaField.newField(PROTECTED,
- "Map<String,Object>", "$objectMap", "new HashMap<String,Object>()");
- protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
- "boolean", "allComponentsCreated");
- protected static final JavaField CONTEXT_INITIALIZED = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
- "boolean", "contextInitialized", "true");
- protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
- "java.util.Map", "$previousValues", "new java.util.HashMap()");
- protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED,
- "jaxx.runtime.JAXXContext", "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",
- "return delegateContext.getContextValue(clazz, null);",
- new JavaArgument("Class<T>", "clazz"));
- protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
- "return delegateContext.getContextValue(clazz, name);",
- new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
- protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
- "delegateContext.setContextValue(o, name);",
- new JavaArgument("T", "o"), new JavaArgument("String", "name"));
- protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
- "delegateContext.setContextValue(o, null);",
- new JavaArgument("T", "o"));
- protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
- "delegateContext.removeContextValue(clazz, name);",
- new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
- protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
- "delegateContext.removeContextValue(clazz, null);",
- new JavaArgument("Class<T>", "clazz"));
- protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
- "return delegateContext.getParentContainer(source, clazz);",
- new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz"));
- protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
- "return delegateContext.getParentContainer(clazz);",
- new JavaArgument("Class<O>", "clazz"));
- protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "java.lang.Object", "getObjectById",
- "return $objectMap.get(id);",
- new JavaArgument("String", "id"));
- protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC, "jaxx.runtime.JAXXObjectDescriptor", "$getJAXXObjectDescriptor",
- "return jaxx.runtime.Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);");
- protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "processDataBinding",
- "processDataBinding(dest, false);",
- new JavaArgument("String", "dest"));
- protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
- "super.firePropertyChange(propertyName, oldValue, newValue);",
- new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
- protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
- "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);",
- new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
- protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(0, "java.beans.PropertyChangeSupport", "$getPropertyChangeSupport",
- "if ($propertyChangeSupport == null)\n" +
- " $propertyChangeSupport = new PropertyChangeSupport(this);\n" +
- "return $propertyChangeSupport;");
- protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
- "$getPropertyChangeSupport().addPropertyChangeListener(listener);",
- new JavaArgument("java.beans.PropertyChangeListener", "listener"));
- protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
- "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);",
- new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
- protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
- "$getPropertyChangeSupport().removePropertyChangeListener(listener);",
- new JavaArgument("java.beans.PropertyChangeListener", "listener"));
- protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
- "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);",
- new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
-
- @Override
- public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
-
- String fullClassName = packageName != null ? packageName + "." + className : className;
- if (root == null) {
- throw new CompilerException("root tag must be a class tag");
- }
- //Map<String, CompiledObject> objects = compiler.getObjects();
- ClassDescriptor superclass = root.getObjectClass();
- boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass);
- javaFile.setModifiers(Modifier.PUBLIC);
- javaFile.setClassName(fullClassName);
- javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass));
- javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject);
-
- javaFile.addInterfaces(compiler.getExtraInterfaces());
- javaFile.setAbstractClass(compiler.isAbstractClass());
- javaFile.setGenericType(compiler.getGenericType());
- javaFile.setSuperGenericType(compiler.getSuperGenericType());
-
- for (CompiledObject object : compiler.getObjects().values()) {
- CompiledObjectDecorator decorator = object.getDecorator();
- decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
-
- /*if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
- String id = object.getId();
- int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
- if (object == root) {
- javaFile.addField(new JavaField(access, fullClassName, id, "this"));
- } else {
- //TC -20081017 can have generic on compiled Object
- javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
- }
- }
-
- if (!compiler.inlineCreation(object) && object != root) {
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
- }*/
- }
-
- // DataBinding
- for (DataBinding dataBinding : compiler.getDataBindings()) {
- if (dataBinding.compile(true)) {
- compiler.getInitDataBindings().append("applyDataBinding(").append(TypeManager.getJavaCode(dataBinding.getId())).append(");").append(JAXXCompiler.getLineSeparator());
- }
- }
-
- if (superclassIsJAXXObject) {
- boolean hasBind = compiler.getApplyDataBinding().length() > 0;
- if (hasBind) {
- compiler.appendApplyDataBinding(" else {");
- compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
- compiler.appendApplyDataBinding(" ");
- }
- compiler.appendApplyDataBinding("super.applyDataBinding($binding);");
- compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
-
- if (hasBind) {
- compiler.appendApplyDataBinding(" return;");
- compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
- compiler.appendApplyDataBinding("}");
- }
-
-
- hasBind = compiler.getRemoveDataBinding().length() > 0;
- if (hasBind) {
- compiler.appendRemoveDataBinding(" else {");
- compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
- compiler.appendRemoveDataBinding(" ");
- }
- compiler.appendRemoveDataBinding("super.removeDataBinding($binding);");
- compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
-
- if (hasBind) {
- compiler.appendRemoveDataBinding("}");
- }
- } else {
- javaFile.addInterface(JAXXCompiler.getCanonicalName(JAXXObject.class));
- }
- }
-
- @Override
- public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
-
- String fullClassName = javaFile.getClassName();
-
- String jaxxContextImplementorClass = compiler.getOptions().getJaxxContextImplementorClass();
- boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject();
- if (!superclassIsJAXXObject) {
- // add logger
- if (compiler.getOptions().isAddLogger()) {
- javaFile.addImport(Log.class);
- javaFile.addImport(LogFactory.class);
- javaFile.addField(JavaField.newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)"));
- }
-
- // JAXXObject
- javaFile.addField(OBJECT_MAP_FIELD);
- javaFile.addMethod(GET_OBJECT_BY_ID_METHOD);
- javaFile.addField(BINDING_SOURCES_FIELD);
- javaFile.addField(ACTIVE_BINDINGS_FIELD);
-
- // JAXXContext
- javaFile.addField(JavaField.newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", "new " + jaxxContextImplementorClass + "(this);"));
- javaFile.addMethod(SET_CONTEXT_VALUE_METHOD);
- javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD);
- javaFile.addMethod(GET_CONTEXT_VALUE_METHOD);
- javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD);
- javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD);
- javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD);
- javaFile.addMethod(GET_PARENT_CONTAINER_METHOD);
- javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD);
-
- // PropertyChangeSupport
- addPropertyChangeSupport(root, javaFile);
-
- // DataBinding
- javaFile.addMethod(PROCESS_DATA_BINDING_METHOD);
- }
-
- javaFile.addField(ALL_COMPONENTS_CREATED_FIELD);
- boolean overrideContextInitialized = false;
- FieldDescriptor[] scriptFields = compiler.getScriptFields();
- for (FieldDescriptor f : scriptFields) {
- if ("contextInitialized".equals(f.getName())) {
- overrideContextInitialized = true;
- break;
- }
- }
- if (!overrideContextInitialized) {
- javaFile.addField(CONTEXT_INITIALIZED);
- }
- javaFile.addField(createJAXXObjectDescriptorField(compiler, javaFile));
-
- if (compiler.getStylesheet() != null) {
- javaFile.addField(PREVIOUS_VALUES_FIELD);
- }
- /*for (CompiledObject object : compiler.getObjects().values()) {
- List<CompiledObject.ChildRef> refList = object.getChilds();
- if (refList==null || refList.isEmpty()) {
- continue;
- }
- for (ChildRef childRef : refList) {
- childRef.addToAdditionCode(buffer);
- }
- }*/
- //TC 20090228 - only generate constructors if not done in scripts
- boolean constructorDetected = false;
- MethodDescriptor[] methods = compiler.getScriptMethods();
- for (MethodDescriptor m : methods) {
- try {
- m.getReturnType();
- if (className.equals(m.getName())) {
- constructorDetected = true;
- break;
- }
- } catch (Exception e) {
- log.warn("could not find return type " + m);
- }
- }
- if (!constructorDetected) {
- javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject));
- javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject));
- }
-
- javaFile.addMethod(createInitializer(compiler));
- javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD);
-
- javaFile.addBodyCode(compiler.getBodyCode().toString());
-
- javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, compiler.getInitDataBindings()));
-
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "applyDataBinding",
- compiler.getApplyDataBinding().toString() + JAXXCompiler.getLineSeparator() + "processDataBinding($binding);",
- new JavaArgument("String", "$binding")));
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "removeDataBinding",
- compiler.getRemoveDataBinding().toString(), new JavaArgument("String", "$binding")));
-
- javaFile.addMethod(createProcessDataBindingMethod(compiler, superclassIsJAXXObject));
-
- addEventHandlers(compiler, javaFile);
-
- }
-
-
- /*---------------------------------------------------------------------------------*/
- /*-- Create fields ----------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
- protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) {
- try {
- JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor();
- String data = Base64Coder.serialize(descriptor, true);
- /*ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer));
- out.writeObject(descriptor);
- out.close();
- // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String
- // in the compiled class file, since byte array initialization is horribly inefficient compared to
- // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1
- // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely
- // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String
- // type, but if we could efficiently store a byte[] we wouldn't have to do this.
- String data = new String(buffer.toByteArray(), 0);*/
-
- int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit
- if (data.length() < sizeLimit) {
- return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", TypeManager.getJavaCode(data));
- } else {
- StringBuffer initializer = new StringBuffer();
- for (int i = 0; i < data.length(); i += sizeLimit) {
- String name = "$jaxxObjectDescriptor" + i;
- javaFile.addField(new JavaField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", name,
- TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length())))));
- if (initializer.length() > 0) {
- initializer.append(" + ");
- }
- initializer.append("String.valueOf(").append(name).append(")");
- }
- return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", initializer.toString());
- }
- } catch (IOException e) {
- throw new RuntimeException("Internal error: can't-happen error", e);
- }
- }
-
- /*---------------------------------------------------------------------------------*/
- /*-- Create methods ---------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
- protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) {
- ClassDescriptor currentClass = root.getObjectClass();
- MethodDescriptor firePropertyChange = null;
- while (firePropertyChange == null && currentClass != null) {
- try {
- firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class),
- ClassDescriptorLoader.getClassDescriptor(Object.class),
- ClassDescriptorLoader.getClassDescriptor(Object.class));
-
- } catch (NoSuchMethodException e) {
- currentClass = currentClass.getSuperclass();
- }
- }
-
- int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0;
- if (Modifier.isPublic(modifiers)) {
- // we have all the support we need
- }
- if (Modifier.isProtected(modifiers)) {
- // there is property change support but the firePropertyChange method is protected
- javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD);
- } else {
- // either no support at all or firePropertyChange isn't accessible
- javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD);
- javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD);
- javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD);
- javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
- javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD);
- javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
- javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD);
- }
- }
-
- protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) {
- for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) {
- // outer loop is iterating over different objects (well, technically, different Java expressions)
- for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) {
- // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.)
- for (EventHandler handler : e2.getValue()) {
- // iterate over individual event handlers of a single type
- String methodName = compiler.getEventHandlerMethodName(handler);
- MethodDescriptor listenerMethod = handler.getListenerMethod();
- if (listenerMethod.getParameterTypes().length != 1) {
- throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument");
- }
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", methodName, handler.getJavaCode(),
- new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event")));
- }
- }
- }
- }
-
- protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
- StringBuffer code = new StringBuffer();
- String constructorParams = compiler.getRootObject().getConstructorParams();
- if (constructorParams != null) {
- code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
- } else {
- if (superclassIsJAXXObject) {
- code.append(" super();").append(JAXXCompiler.getLineSeparator());
- }
- }
- code.append("$initialize();");
- code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString());
- }
-
- protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
- StringBuffer code = new StringBuffer();
- String constructorParams = compiler.getRootObject().getConstructorParams();
- if (constructorParams != null) {
- code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
- } else {
- if (superclassIsJAXXObject) {
- code.append(" super(parentContext);").append(JAXXCompiler.getLineSeparator());
- }
- }
- if (!superclassIsJAXXObject) {
- code.append("if (parentContext instanceof jaxx.runtime.JAXXInitialContext) {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" ((jaxx.runtime.JAXXInitialContext)parentContext).to(this);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("} else {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" setContextValue(parentContext);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append("$initialize();");
- code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.JAXXContext", "parentContext"));
- }
-
- public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
- StringBuffer code = new StringBuffer();
- CompiledObject root = compiler.getRootObject();
- code.append("if (allComponentsCreated || !contextInitialized) {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" return;");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);");
- code.append(JAXXCompiler.getLineSeparator());
-
- Iterator<CompiledObject> i = compiler.getObjectCreationOrder();
- boolean lastWasMethodCall = false;
- while (i.hasNext()) {
- CompiledObject object = i.next();
- if (object == root) {
- continue;
- }
- CompiledObjectDecorator decorator = object.getDecorator();
- lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall);
- /*if (object != root && !object.isOverride()) {
- if (compiler.inlineCreation(object)) {
- if (lastWasMethodCall) {
- lastWasMethodCall = false;
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append(getCreationCode(compiler, object));
- code.append(JAXXCompiler.getLineSeparator());
- } else {
- code.append(object.getCreationMethodName()).append("();");
- code.append(JAXXCompiler.getLineSeparator());
- lastWasMethodCall = true;
- }
- }*/
- }
- root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall);
- /*String rootCode = root.getInitializationCode(compiler);
- if (rootCode != null && rootCode.length() > 0) {
- code.append(rootCode);
- code.append(JAXXCompiler.getLineSeparator());
- }*/
- code.append(JAXXCompiler.getLineSeparator());
- if (compiler.getInitializer().length() > 0) {
- code.append(compiler.getInitializer());
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append("$completeSetup();");
- code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$initialize", code.toString());
- }
-
- protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, StringBuffer initDataBindings) {
- StringBuffer code = new StringBuffer();
- code.append("allComponentsCreated = true;");
- code.append(JAXXCompiler.getLineSeparator());
- for (CompiledObject object : compiler.getObjects().values()) {
- CompiledObjectDecorator decorator = object.getDecorator();
- code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile, initDataBindings));
-
- /*//TC - 20081017 only generate the method if not empty ?
- if (object.getId().startsWith("$")) {
- code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
- } else {
- String additionCode = object.getAdditionCode();
- if (additionCode.length() > 0) {
- code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
- additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
- }
- }*/
- //code.append(getLineSeparator());
- }
-
- code.append(initDataBindings);
-
- if (compiler.getLateInitializer().length() > 0) {
- code.append(compiler.getLateInitializer());
- code.append(JAXXCompiler.getLineSeparator());
- }
- //TC-20090313 add an extra method after complete setup
- MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup");
- if (method != null) {
- code.append("$afterCompleteSetup();").append(JAXXCompiler.getLineSeparator());
- }
- return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString());
- }
-
- protected JavaMethod createProcessDataBindingMethod(JAXXCompiler compiler, boolean superclassIsJAXXObject) {
- StringBuffer code = new StringBuffer();
- //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass());
- // the force parameter forces the update to happen even if it is already in activeBindings. This
- // is used on superclass invocations b/c by the time the call gets to the superclass, it is already
- // marked active and would otherwise be skipped
- if (compiler.getProcessDataBinding().length() > 0) {
- code.append(" if (!$force && $activeBindings.contains($dest)) { ");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" return;");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("$activeBindings.add($dest);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("try {");
- code.append(JAXXCompiler.getLineSeparator());
- if (compiler.getProcessDataBinding().length() > 0) {
- code.append(compiler.getProcessDataBinding().toString());
- //code.append(JAXXCompiler.getLineSeparator());
- }
- if (superclassIsJAXXObject) {
- code.append(" else {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" super.processDataBinding($dest, true);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" }");
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append("} finally {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" $activeBindings.remove($dest);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- } else if (superclassIsJAXXObject) {
- code.append("super.processDataBinding($dest, true);");
- code.append(JAXXCompiler.getLineSeparator());
- }
- return JavaMethod.newMethod(Modifier.PUBLIC, "void", "processDataBinding", code.toString(),
- new JavaArgument("String", "$dest"), new JavaArgument("boolean", "$force"));
- }
-
- /*---------------------------------------------------------------------------------*/
- /*-- Create methods code ----------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
-
- /* protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
- if (object instanceof ScriptInitializer) {
- return object.getInitializationCode(compiler);
- }
- CompiledObjectDecorator decorator = object.getDecorator();
- String result = decorator.getCreationCode(compiler, object);
- return result;*/
- /*StringBuffer result = new StringBuffer();
- result.append(object.getId());
- result.append(" = ");
- if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
- result.append(object.getJavaBeanInitCode()).append(";");
- } else {
- String constructorParams = object.getConstructorParams();
- if (constructorParams != null) {
- //TC - 20081017 compiledObject can have generics
- result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
- //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
- } else {
- //TC - 20081017 compiledObject can have generics
- result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
- }
- }
- result.append(JAXXCompiler.getLineSeparator());
- String initCode = object.getInitializationCode(compiler);
- if (initCode != null && initCode.length() > 0) {
- result.append(initCode);
- }
- result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
-
- return result.toString();*/
-// }
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -10,11 +10,11 @@
* @see JavaMethod
*/
public class JavaArgument {
+
private String name;
private String type;
private boolean isFinal;
-
/**
* Creates a new <code>JavaArgument</code> with the specified name and type. For example, the method <code>main()</code>
* might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>.
@@ -26,7 +26,6 @@
this(type, name, false);
}
-
/**
* Creates a new <code>JavaArgument</code> with the specified name, type, and finality. For example, the method <code>main()</code>
* might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. The
@@ -42,7 +41,6 @@
this.isFinal = isFinal;
}
-
/**
* Returns the argument's name.
*
@@ -52,7 +50,6 @@
return name;
}
-
/**
* Returns the argument's type as it would be represented in Java source code.
*
@@ -62,7 +59,6 @@
return type;
}
-
/**
* Returns <code>true</code> if the <code>final</code> keyword should appear before the argument.
*
@@ -72,7 +68,6 @@
return isFinal;
}
-
/**
* Returns the Java source code for this argument.
*
@@ -83,4 +78,4 @@
String result = type + ' ' + name;
return isFinal ? "final " + result : result;
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,7 +18,6 @@
private String name;
private String initializer;
-
/**
* Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the
* constants from {@link java.lang.reflect.Modifier}, and the <code>type</code> of the field should be
@@ -32,7 +31,6 @@
this(modifiers, type, name, null);
}
-
/**
* Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the
* constants from <code>java.lang.reflect.Modifier</code>, and the <code>type</code> of the field should be
@@ -52,7 +50,6 @@
this.initializer = initializer;
}
-
/**
* Returns a bit mask describing the modifier keywords which should appear as part of this field's
* declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this
@@ -64,7 +61,6 @@
return modifiers;
}
-
/**
* Returns the field's name.
*
@@ -74,7 +70,6 @@
return name;
}
-
/**
* Returns the field's type, as it would be represented in Java source code.
*
@@ -84,7 +79,6 @@
return type;
}
-
/**
* Returns the Java source code for this field.
*
@@ -102,12 +96,13 @@
return result.toString();
}
+ @Override
public int compareTo(JavaField o) {
return COMPARATOR.compare(this, o);
}
-
public static final Comparator<JavaField> COMPARATOR = new Comparator<JavaField>() {
+ @Override
public int compare(JavaField o1, JavaField o2) {
int result;
@@ -184,4 +179,4 @@
public static JavaField newField(int modifiers, String returnType, String name, String initializer) {
return new JavaField(modifiers, returnType, name, initializer);
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,11 +20,8 @@
public class JavaFile {
protected static final String GETTER_PATTERN = "return %1$s;";
-
protected static final String BOOLEAN_GETTER_PATTERN = "return %1$s !=null && %1$s;";
-
protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(\"%2$s\", oldValue, newValue);";
-
private int modifiers;
private String className;
private List<String> imports = new ArrayList<String>();
@@ -39,16 +36,13 @@
private String genericType;
private String superGenericType;
-
public JavaFile() {
}
-
public JavaFile(int modifiers, String className, String superClass) {
this(modifiers, className, superClass, null);
}
-
public JavaFile(int modifiers, String className, String superClass, List<String> interfaces) {
this.modifiers = modifiers;
this.className = className;
@@ -56,51 +50,42 @@
this.interfaces = interfaces;
}
-
public void addImport(String importString) {
imports.add(importString);
}
- public void addImport(Class importString) {
+ public void addImport(Class<?> importString) {
imports.add(importString.getName());
}
-
public String[] getImports() {
return imports.toArray(new String[imports.size()]);
}
-
public int getModifiers() {
return modifiers;
}
-
public void setModifiers(int modifiers) {
this.modifiers = modifiers;
}
-
public String getClassName() {
return className;
}
-
public void setClassName(String className) {
this.className = className;
}
-
public String getSuperClass() {
return superClass;
}
-
public void setSuperClass(String superClass) {
this.superClass = superClass;
}
-
public List<String> getInterfaces() {
if (interfaces == null) {
interfaces = new ArrayList<String>();
@@ -108,7 +93,6 @@
return interfaces;
}
-
public void setInterfaces(List<String> interfaces) {
this.interfaces = interfaces;
}
@@ -121,7 +105,6 @@
methods.add(method);
}
-
public JavaMethod[] getMethods() {
return methods.toArray(new JavaMethod[methods.size()]);
}
@@ -156,22 +139,18 @@
fields.add(field);
}
-
public JavaField[] getFields() {
return fields.toArray(new JavaField[fields.size()]);
}
-
public static String addIndentation(String source, int indentation, String lineSeparator) {
return indent(source, indentation, false, lineSeparator);
}
-
public static String setIndentation(String source, int indentation, String lineSeparator) {
return indent(source, indentation, true, lineSeparator);
}
-
public static String indent(String source, int indentation, boolean trim, String lineSeparator) {
if (trim) {
source = source.trim();
@@ -190,12 +169,10 @@
return result.toString();
}
-
public void addBodyCode(String bodyCode) {
rawBodyCode.append(bodyCode);
}
-
public String getClassBody(String lineSeparator) {
StringBuffer result = new StringBuffer();
if (fields.size() > 0) {
@@ -237,7 +214,6 @@
return result.toString();
}
-
public String getClassDefinition(String lineSeparator) {
StringBuffer result = new StringBuffer();
result.append(getModifiersText(modifiers));
@@ -258,7 +234,7 @@
result.append(" implements ").append(interfaces.get(0));
for (int i = 1; i < interfaces.size(); i++) {
/*if (i > 0) {
- result.append(", ");
+ result.append(", ");
}*/
result.append(", ").append(interfaces.get(i));
}
@@ -270,7 +246,6 @@
return result.toString();
}
-
public static String getModifiersText(int modifiers) {
if (modifiers == 0) {
return "";
@@ -279,7 +254,6 @@
}
}
-
/**
* Returns the Java source code for this class.
*
@@ -337,8 +311,7 @@
this.abstractClass = abstractClass;
}
-
public void setSuperGenericType(String superGenericType) {
this.superGenericType = superGenericType;
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,6 +20,7 @@
* classes and have a return type of <code>null</code>.
*/
public class JavaMethod implements Comparable<JavaMethod> {
+
private int modifiers;
private String returnType;
private String name;
@@ -27,7 +28,6 @@
private String[] exceptions;
private StringBuffer bodyCode;
-
/**
* Constructs a new no-argument <code>JavaMethod</code> which throws no checked exceptions. The
* <code>modifiers</code> parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier},
@@ -42,8 +42,6 @@
//public JavaMethod(int modifiers, String returnType, String name) {
// this(modifiers, returnType, name, null);
//}
-
-
/**
* Constructs a new <code>JavaMethod</code> which throws no checked exceptions. The <code>modifiers</code>
* parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the
@@ -59,8 +57,6 @@
//public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments) {
// this(modifiers, returnType, name, arguments, null);
//}
-
-
/**
* Constructs a new <code>JavaMethod</code>. The <code>modifiers</code> parameter is a bit mask of the
* constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and <code>exceptions</code>
@@ -77,8 +73,6 @@
//public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions) {
// this(modifiers, returnType, name, arguments, exceptions, null);
//}
-
-
/**
* Constructs a new <code>JavaMethod</code> containing the specified body code. The <code>modifiers</code> parameter
* is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and
@@ -101,7 +95,6 @@
this.bodyCode = new StringBuffer(bodyCode != null ? bodyCode : "");
}
-
/**
* Returns a bit mask describing the modifier keywords which should appear as part of this method's
* declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this
@@ -113,7 +106,6 @@
return modifiers;
}
-
/**
* Returns the method's return type, as it would be represented in Java source code.
*
@@ -123,7 +115,6 @@
return returnType;
}
-
/**
* Returns the method's name.
*
@@ -133,7 +124,6 @@
return name;
}
-
/**
* Returns a list of the method's arguments.
*
@@ -143,7 +133,6 @@
return arguments;
}
-
/**
* Returns a list of exceptions the method can throw.
*
@@ -153,7 +142,6 @@
return exceptions;
}
-
/**
* Returns the Java source code for the method's body.
*
@@ -163,7 +151,6 @@
return bodyCode.toString();
}
-
/**
* Appends additional code to the method's body.
*
@@ -180,7 +167,6 @@
bodyCode.append(extraCode);
}
-
/**
* Returns the Java source code for this method.
*
@@ -217,6 +203,7 @@
return result.toString();
}
+ @Override
public int compareTo(JavaMethod o) {
return COMPARATOR.compare(this, o);
}
@@ -232,118 +219,125 @@
public enum MethodOrder {
statics(Modifier.STATIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Statics methods --------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Statics methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
},
-
constructors(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Constructors -----------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Constructors -----------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return method.returnType == null;
}
},
-
JAXXObject(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- JAXXObject implementation ----------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- JAXXObject implementation ----------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
private List<String> methods = Arrays.asList("applyDataBinding", "firePropertyChange", "getObjectById", "get$objectMap", "processDataBinding", "removeDataBinding");
+ @Override
public boolean accept(JavaMethod method) {
return methods.contains(method.name);
}
},
-
JAXXContext(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- JAXXContext implementation ---------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- JAXXContext implementation ---------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
private List<String> methods = Arrays.asList("getContextValue", "getDelegateContext", "getParentContainer", "removeContextValue", "setContextValue");
+
+ @Override
public boolean accept(JavaMethod method) {
return methods.contains(method.name);
}
},
-
JAXXValidation(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- JAXXValidation implementation ------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- JAXXValidation implementation ------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
private List<String> methods = Arrays.asList("getValidator", "getValidatorIds");
+ @Override
public boolean accept(JavaMethod method) {
return methods.contains(method.name);
}
},
-
events(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Event methods ----------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Event methods ----------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("do") && method.name.indexOf("__") > -1);
}
},
-
publicGetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- public acessor methods -------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- public acessor methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("get") || method.name.startsWith("is"));
}
},
-
publicSetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- public mutator methods -------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- public mutator methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("set"));
}
},
-
otherPublic(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- public mutator methods -------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- public mutator methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
@Override
public boolean accept(int mod) {
return super.accept(mod) && !Modifier.isStatic(mod);
}
},
-
protectedGetters(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- protected acessors methods ---------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- protected acessors methods ---------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("get") || method.name.startsWith("is"));
}
},
-
createMethod(Modifier.PROTECTED | Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- ui creation methods ----------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- ui creation methods ----------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return method.name.startsWith("create") || method.name.startsWith("add") ||
method.name.equals("$completeSetup") ||
method.name.equals("$initialize");
}
},
-
protecteds(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Other protected methods ------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Other protected methods ------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
},
-
packageLocal(0, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Package methods --------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Package methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
@Override
public boolean accept(int mod) {
return !Modifier.isStatic(mod) && !Modifier.isPublic(mod) && !Modifier.isProtected(mod);
- }},
-
+ }
+ },
privates(Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Private methods --------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Private methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
};
-
private final String header;
-
private int modifier;
MethodOrder(int modifier, String header) {
@@ -436,20 +430,20 @@
}
return constants;
}
-
public static final Comparator<JavaMethod> COMPARATOR = new Comparator<JavaMethod>() {
+ @Override
public int compare(JavaMethod o1, JavaMethod o2) {
/*int result;
if ((result = compareStatic(o1, o2)) != 0) {
- return result;
+ return result;
}
if ((result = compareConstructor(o1, o2)) != 0) {
- return result;
+ return result;
}
if ((result = compareVisibility(o1, o2)) != 0) {
- return result;
+ return result;
}*/
return o1.name.compareTo(o2.name);
}
@@ -496,4 +490,4 @@
return 0;
}
};
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,7 +4,7 @@
*/
package jaxx.compiler;
-import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
/**
* A dummy CompiledObject which serves to initialize scripted field. This is handled by
@@ -12,9 +12,10 @@
* ensure that the field is initialized in document order.
*/
public class ScriptInitializer extends CompiledObject {
- public ScriptInitializer(String initializer, JAXXCompiler compiler) {
+
+ public ScriptInitializer(String initializer, JAXXCompiler compiler) {
super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)),
ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class), compiler, false);
appendInitializationCode(initializer);
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,12 +1,11 @@
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.parser.JavaParser;
-import jaxx.parser.JavaParserTreeConstants;
-import jaxx.parser.SimpleNode;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.TagManager;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.TagManager;
import java.io.StringReader;
import java.lang.reflect.Modifier;
@@ -15,14 +14,13 @@
import java.util.List;
public class ScriptManager {
+
private JAXXCompiler compiler;
-
ScriptManager(JAXXCompiler compiler) {
this.compiler = compiler;
}
-
/**
* Strips unnecessary curly braces from around the script, generating a warning if they are found.
*
@@ -38,7 +36,6 @@
return script;
}
-
public void checkParse(String script) throws CompilerException {
script = trimScript(script);
JavaParser p = new JavaParser(new StringReader(script));
@@ -47,7 +44,6 @@
}
}
-
public String preprocessScript(String script) throws CompilerException {
script = trimScript(script);
StringBuffer result = new StringBuffer();
@@ -63,7 +59,6 @@
return result.toString();
}
-
/**
* Scans through a compound symbol (foo.bar.baz) to identify and compile the JAXX class it refers to, if any.
*
@@ -73,8 +68,9 @@
String[] tokens = symbol.split("\\.");
StringBuffer currentSymbol = new StringBuffer();
for (String token : tokens) {
- if (currentSymbol.length() > 0)
+ if (currentSymbol.length() > 0) {
currentSymbol.append('.');
+ }
currentSymbol.append(token.trim());
String contextClass = TagManager.resolveClassName(currentSymbol.toString(), compiler);
@@ -84,17 +80,17 @@
}
}
-
private void preprocessScriptNode(SimpleNode node, boolean staticContext) throws CompilerException {
// identify static methods and initializers -- we can't fire events statically
if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION) {
if (node.getParent().getChild(0).getText().indexOf("static") != -1) {
staticContext = true;
}
- } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER)
+ } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER) {
if (node.getText().trim().startsWith("static")) {
staticContext = true;
}
+ }
int count = node.jjtGetNumChildren();
for (int i = 0; i < count; i++) {
@@ -109,9 +105,7 @@
String lhs = null;
if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || (id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2)) {
lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim();
- }
- else
- if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) {
+ } else if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) {
lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim();
}
if (lhs != null) {
@@ -128,7 +122,6 @@
}
}
-
/**
* Examines a Line to determine its real type. As all tokens returned by the parser are Lines, and
* they are just a tiny wrapper around the real node, this method strips off the wrapper layers to identify
@@ -144,8 +137,7 @@
if (node.jjtGetNumChildren() == 1) {
return node.getChild(0).getId();
}
- } else
- if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) {
+ } else if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) {
int id = node.getChild(0).getId();
if (id == JavaParserTreeConstants.JJTMODIFIERS) {
return node.getChild(1).getId();
@@ -159,7 +151,6 @@
return JavaParserTreeConstants.JJTLINE; // generic value implying that it's okay to put into the initializer block
}
-
private SimpleNode findExplicitConstructorInvocation(SimpleNode parent) {
if (parent.getId() == JavaParserTreeConstants.JJTEXPLICITCONSTRUCTORINVOCATION) {
return parent;
@@ -175,32 +166,28 @@
return null;
}
-
private void processConstructor(String modifiers, SimpleNode node) {
assert node.getId() == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION : "expected node to be ConstructorDeclaration, found " + JavaParserTreeConstants.jjtNodeName[node.getId()] + " instead";
assert node.getChild(0).getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS : "expected node 0 to be FormalParameters, found " + JavaParserTreeConstants.jjtNodeName[node.getChild(1).getId()] + " instead";
String code = "";
if (node.getChild(0).jjtGetNumChildren() == 0) {
compiler.reportError("The default no-argument constructor may not be redefined");
- }
- else {
+ } else {
SimpleNode explicitConstructorInvocation = findExplicitConstructorInvocation(node);
if (explicitConstructorInvocation == null || explicitConstructorInvocation.getText().trim().startsWith("super(")) {
code = "$initialize();" + JAXXCompiler.getLineSeparator();
if (explicitConstructorInvocation == null) {
node.getChild(1).firstToken.image = node.getChild(1).firstToken.image;
- }
- else {
+ } else {
explicitConstructorInvocation.lastToken.image += code;
}
}
}
- compiler.appendBodyCode(modifiers + " "+ node.getText().substring(0,node.getText().length()-1) + code + "}");
+ compiler.appendBodyCode(modifiers + " " + node.getText().substring(0, node.getText().length() - 1) + code + "}");
//compiler.bodyCode.append(";\n");
}
-
private void scanScriptNode(SimpleNode node) throws CompilerException {
int nodeType = getLineType(node);
if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { // have to handle imports early so the preprocessing takes them into account
@@ -234,13 +221,11 @@
// FIXME: this check fails for inner classes defined in this file
//if (returnType == null)
// throw new CompilerException("could not find class '" + rawReturnType + "'");
- } else
- if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) {
+ } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) {
name = child.firstToken.image.trim();
SimpleNode formalParameters = child.getChild(0);
assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS;
- for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++)
- {
+ for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) {
SimpleNode parameter = formalParameters.getChild(j);
String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]");
String parameterType = TagManager.resolveClassName(rawParameterType, compiler);
@@ -255,26 +240,23 @@
compiler.appendBodyCode(node.getText());
//compiler.bodyCode.append(";\n");
compiler.addScriptMethod(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader()));
- } else
- if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION ||
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION ||
nodeType == JavaParserTreeConstants.JJTINITIALIZER) {
String str = node.getText().trim();
if (str.endsWith(";")) {
- str+=";";
+ str += ";";
}
compiler.appendBodyCode(str);
//compiler.bodyCode.append(";\n");
- } else
- if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) {
+ } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) {
processConstructor(node.getChild(0).getChild(0).getText(), node.getChild(0).getChild(1));
- } else
- if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) {
+ } else if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) {
// the "local" variable declarations in this expression aren't actually local -- they are flagged local
// just because there isn't an enclosing class scope visible to the parser. "Real" local variable
// declarations won't show up here, because they will be buried inside of methods.
String text = node.getText().trim();
if (!text.endsWith(";")) {
- text+=";";
+ text += ";";
}
String declaration = text;
int equals = text.indexOf("=");
@@ -301,6 +283,8 @@
}
final String finalInitializer = name + " = " + initializer;
compiler.registerInitializer(new Runnable() {
+
+ @Override
public void run() {
compiler.registerCompiledObject(new ScriptInitializer(finalInitializer, compiler));
}
@@ -322,7 +306,6 @@
}
}
-
public void registerScript(String script) throws CompilerException {
JavaParser p = new JavaParser(new StringReader(script));
//JavaParser p = new JavaParser(new StringReader(script + ";"));
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/StylesheetHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,559 @@
+package jaxx.compiler;
+
+import jaxx.runtime.css.Selector;
+import jaxx.runtime.css.Rule;
+import jaxx.runtime.css.Stylesheet;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.types.TypeManager;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A helper class to compute {@link Stylesheet}, {@link Rule} and {@link Selector}
+ * and extract all the compiler logic from this class.
+ * <p/>
+ * In that way we can make the compiler as a single module and a runtime as another module.
+ *
+ * @author chemit
+ */
+public class StylesheetHelper {
+
+ public static void applyTo(CompiledObject object, JAXXCompiler compiler, Stylesheet stylesheet, Stylesheet overrides) throws CompilerException {
+ Map<String, String> overriddenProperties;
+ if (overrides != null) {
+ overriddenProperties = getApplicableProperties(overrides, object);
+ //overriddenProperties = overrides.getApplicableProperties(s,object);
+ } else {
+ overriddenProperties = null;
+ }
+
+ Map<String, String> properties = getApplicableProperties(stylesheet, object);
+ if (properties != null) {
+ if (overriddenProperties != null) {
+ properties.keySet().removeAll(overriddenProperties.keySet());
+ }
+ DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass());
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ String value = e.getValue();
+ if (value.equals(Rule.INLINE_ATTRIBUTE) || value.equals(Rule.DATA_BINDING)) {
+ continue;
+ }
+ handler.setAttribute(object, e.getKey(), e.getValue(), false, compiler);
+ }
+ }
+
+ Rule[] pseudoClasses = getApplicablePseudoClasses(stylesheet, object);
+ if (pseudoClasses != null) {
+ Map<String, Map<String, String>> combinedPseudoClasses = new LinkedHashMap<String, Map<String, String>>();
+ for (Rule pseudoClass1 : pseudoClasses) {
+ Selector[] selectors = pseudoClass1.getSelectors();
+ for (Selector selector : selectors) {
+ if (appliesTo(selector, object) == Selector.PSEUDOCLASS_APPLIES) {
+ properties = pseudoClass1.getProperties();
+ String pseudoClass = selector.getPseudoClass();
+ // TODO: overrides by downstream pseudoclasses are not handled
+ Map<String, String> combinedProperties = combinedPseudoClasses.get(pseudoClass);
+ if (combinedProperties == null) {
+ combinedProperties = new HashMap<String, String>();
+ combinedPseudoClasses.put(pseudoClass, combinedProperties);
+ }
+ combinedProperties.putAll(properties);
+ }
+ }
+ }
+
+ int count = 0;
+ for (Map.Entry<String, Map<String, String>> e : combinedPseudoClasses.entrySet()) {
+ applyPseudoClass(e.getKey(), e.getValue(), object, compiler, count++);
+ }
+ }
+ }
+
+ /**
+ * Replaces all references to the variable "object" with the actual object ID.
+ *
+ * @param code ?
+ * @param id ?
+ * @return ?
+ * @throws CompilerException ?
+ */
+ public static String replaceObjectReferences(String code, String id) throws CompilerException {
+ JavaParser p = new JavaParser(new StringReader(code + ";"));
+ p.Expression();
+ jaxx.compiler.parser.java.SimpleNode node = p.popNode();
+ scanNode(node, id);
+ return node.getText();
+ }
+
+ public static void scanNode(SimpleNode node, String id) {
+ if (node.getId() == JavaParserTreeConstants.JJTNAME) {
+ String name = node.getText();
+ if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) {
+ node.firstToken.image = id;
+ }
+ } else {
+ int count = node.jjtGetNumChildren();
+ for (int i = 0; i < count; i++) {
+ scanNode(node.getChild(i), id);
+ }
+ }
+ }
+
+ public static void compilePseudoClassAdd(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException {
+
+ if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".add";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { " + propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");");
+ return;
+ }
+
+ MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass);
+
+ String property = null;
+ switch (constant) {
+ case mousedown:
+ property = "mousePressed";
+ break;
+ case mouseout:
+ property = "mouseExited";
+ break;
+ case mouseover:
+ property = "mouseEntered";
+ break;
+ case mouseup:
+ property = "mouseReleased";
+ break;
+ }
+
+ ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class);
+ ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class);
+
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor);
+ MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor);
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener, methodDescriptor, propertyCode, compiler);
+
+ } catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+
+ /*if (pseudoClass.equals("mouseover")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseEntered",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseout")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseExited",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ compiler.appendInitDataBindings("{" + propertyCode + "}");
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseout pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mousedown")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mousePressed",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mousedown pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseup")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseReleased",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ compiler.appendInitDataBindings("{" + propertyCode + "}");
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseup pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".add";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { "+ propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding("+ destCode + ");");
+ } else
+ throw new IllegalArgumentException("unrecognized pseudoclass: " + pseudoClass);*/
+ }
+
+ public static void compilePseudoClassRemove(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException {
+ if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".remove";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");");
+ return;
+ }
+
+ MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass);
+
+ String property = null;
+ switch (constant) {
+ case mousedown:
+ property = "mousePressed";
+ break;
+ case mouseout:
+ property = "mouseReleased";
+ break;
+ case mouseover:
+ property = "mouseExited";
+ break;
+ case mouseup:
+ property = "mousePressed";
+ break;
+ }
+
+ ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class);
+ ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class);
+
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor);
+ MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor);
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener, methodDescriptor, propertyCode, compiler);
+
+ } catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+
+ /*if (pseudoClass.equals("mouseover")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseExited",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseout")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseEntered",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseout pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mousedown")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseReleased",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mousedown pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseup")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mousePressed",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseup pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".remove";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");");
+ } else {
+ throw new IllegalArgumentException("unrecognized pseudoclass: " + pseudoClass);
+ }*/
+ }
+
+ public static String invert(String javaCode) {
+ javaCode = javaCode.trim();
+ return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")";
+ }
+
+ public static String unwrap(ClassDescriptor type, String valueCode) {
+ if (type == ClassDescriptorLoader.getClassDescriptor(boolean.class)) {
+ return "((java.lang.Boolean) " + valueCode + ").booleanValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(byte.class)) {
+ return "((java.lang.Byte) " + valueCode + ").byteValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(short.class)) {
+ return "((java.lang.Short) " + valueCode + ").shortValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(int.class)) {
+ return "((java.lang.Integer) " + valueCode + ").intValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(long.class)) {
+ return "((java.lang.Long) " + valueCode + ").longValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(float.class)) {
+ return "((java.lang.Float) " + valueCode + ").floatValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(double.class)) {
+ return "((java.lang.Double) " + valueCode + ").doubleValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(char.class)) {
+ return "((java.lang.Character) " + valueCode + ").charValue()";
+ } else {
+ return valueCode;
+ }
+ }
+
+ public static void applyPseudoClass(String pseudoClass, Map<String, String> properties,
+ CompiledObject object, JAXXCompiler compiler, int priority) throws CompilerException {
+ if (pseudoClass.indexOf("[") != -1) {
+ pseudoClass = pseudoClass.substring(0, pseudoClass.indexOf("["));
+ }
+ final StringBuffer buffer = new StringBuffer();
+ /*CompiledObject bufferObject = new CompiledObject(object.getId(), object.getJavaCode(), object.getObjectClass(), compiler, true) {
+ public void appendInitializationCode(String code) {
+ buffer.append(code);
+ }
+ public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException {
+ buffer.append(assignment);
+ }
+ };*/
+
+ DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass());
+ boolean valueDeclared = false;
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ String property = e.getKey();
+ ClassDescriptor type = handler.getPropertyType(object, property, compiler);
+ String dataBinding = compiler.processDataBindings(e.getValue(), type);
+ String valueCode;
+ if (dataBinding != null) {
+ valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")";
+ new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(),
+ property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler), compiler).compile(false);
+ } else {
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass));
+ } catch (ClassNotFoundException ex) {
+ compiler.reportError("could not find class " + type.getName());
+ return;
+ }
+ }
+ if (!valueDeclared) {
+ buffer.append("java.lang.Object ");
+ valueDeclared = true;
+ }
+ buffer.append("value = jaxx.runtime.css.Pseudoclasses.applyProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(JAXXCompiler.getLineSeparator());
+ buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(JAXXCompiler.getLineSeparator());
+ String unwrappedValue = unwrap(type, "value");
+ buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) +
+ ") " + unwrappedValue, compiler)).append(JAXXCompiler.getLineSeparator());
+ buffer.append("}").append(JAXXCompiler.getLineSeparator());
+ }
+
+ if (pseudoClass.equals("focused")) {
+ pseudoClass = "{ object.hasFocus() }";
+ } else if (pseudoClass.equals("unfocused")) {
+ pseudoClass = "{ !object.hasFocus() }";
+ } else if (pseudoClass.equals("enabled")) {
+ pseudoClass = "{ object.isEnabled() }";
+ } else if (pseudoClass.equals("disabled")) {
+ pseudoClass = "{ !object.isEnabled() }";
+ } else if (pseudoClass.equals("selected")) {
+ pseudoClass = "{ object.isSelected() }";
+ } else if (pseudoClass.equals("deselected")) {
+ pseudoClass = "{ !object.isSelected() }";
+ }
+
+ compilePseudoClassAdd(pseudoClass, object, buffer.toString(), compiler);
+
+ buffer.setLength(0);
+ valueDeclared = false;
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ String property = e.getKey();
+ ClassDescriptor type = handler.getPropertyType(object, property, compiler);
+ String dataBinding = compiler.processDataBindings(e.getValue(), type);
+ String valueCode;
+ if (dataBinding != null) {
+ valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")";
+ new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(),
+ property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler), compiler).compile(false);
+ } else {
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass));
+ } catch (ClassNotFoundException ex) {
+ compiler.reportError("could not find class " + type.getName());
+ return;
+ }
+ }
+ if (!valueDeclared) {
+ buffer.append("java.lang.Object ");
+ valueDeclared = true;
+ }
+ buffer.append("value = jaxx.runtime.css.Pseudoclasses.removeProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(JAXXCompiler.getLineSeparator());
+ buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(JAXXCompiler.getLineSeparator());
+ String unwrappedValue = unwrap(type, "value");
+ buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) +
+ ") " + unwrappedValue, compiler)).append(JAXXCompiler.getLineSeparator());
+ buffer.append("}").append(JAXXCompiler.getLineSeparator());
+ }
+ compilePseudoClassRemove(pseudoClass, object, buffer.toString(), compiler);
+ }
+
+ public static Map<String, String> getApplicableProperties(Stylesheet s, CompiledObject object) throws CompilerException {
+ DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass());
+ Map<String, String> result = null;
+ for (Rule rule : s.getRules()) {
+ int apply = appliesTo(rule, object);
+ if (apply == Selector.ALWAYS_APPLIES || apply == Selector.ALWAYS_APPLIES_INHERIT_ONLY) {
+ if (result == null) {
+ result = new HashMap<String, String>();
+ }
+ for (Map.Entry<String, String> entry : rule.getProperties().entrySet()) {
+ String property = entry.getKey();
+ if (apply == Selector.ALWAYS_APPLIES || handler.isPropertyInherited(property)) {
+ result.put(property, entry.getValue());
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Rule[] getApplicablePseudoClasses(Stylesheet s, CompiledObject object) throws CompilerException {
+ List<Rule> result = null;
+ for (Rule rule : s.getRules()) {
+ if (appliesTo(rule, object) == Selector.PSEUDOCLASS_APPLIES) {
+ if (result == null) {
+ result = new ArrayList<Rule>();
+ }
+ result.add(rule);
+ }
+ }
+ return result != null ? result.toArray(new Rule[result.size()]) : null;
+ }
+
+ public static Rule inlineAttribute(CompiledObject object, String propertyName, boolean dataBinding) {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put(propertyName, dataBinding ? Rule.DATA_BINDING : Rule.INLINE_ATTRIBUTE);
+ return new Rule(new Selector[]{new Selector(null, null, null, object.getId(), true)}, properties);
+ }
+
+ public static int appliesTo(Rule rule, CompiledObject object) throws CompilerException {
+ int appliesTo = Selector.NEVER_APPLIES;
+ for (Selector selector : rule.getSelectors()) {
+ appliesTo = Math.max(appliesTo(selector, object), appliesTo);
+ if (appliesTo == Selector.ALWAYS_APPLIES || appliesTo == Selector.ALWAYS_APPLIES_INHERIT_ONLY) {
+ break;
+ }
+ }
+ return appliesTo;
+ }
+
+ public static int appliesTo(Selector selector, CompiledObject object) {
+ boolean inheritOnly = false;
+ CompiledObject parent = object;
+ String javaClassName = selector.getJavaClassName();
+ String styleClass = selector.getStyleClass();
+ String pseudoClass = selector.getPseudoClass();
+ String id = selector.getId();
+
+ while (parent != null) {
+ boolean classMatch = (javaClassName == null);
+ if (!classMatch) {
+ ClassDescriptor javaClass = parent.getObjectClass();
+ do {
+ String name = javaClass.getName();
+ if (name.equals(javaClassName) || name.substring(name.lastIndexOf(".") + 1).equals(javaClassName)) {
+ classMatch = true;
+ break;
+ }
+ javaClass = javaClass.getSuperclass();
+ } while (javaClass != null);
+ }
+
+ boolean styleClassMatch = (styleClass == null || styleClass.equals(parent.getStyleClass()));
+
+ String objectId = parent.getId();
+ objectId = objectId.substring(objectId.lastIndexOf(".") + 1);
+ boolean idMatch = (id == null || (' ' + objectId + ' ').indexOf(' ' + id + ' ') > -1);
+
+ if (classMatch && styleClassMatch && idMatch) {
+ if (pseudoClass != null) {
+ return inheritOnly ? Selector.PSEUDOCLASS_APPLIES_INHERIT_ONLY : Selector.PSEUDOCLASS_APPLIES;
+ } else {
+ return inheritOnly ? Selector.ALWAYS_APPLIES_INHERIT_ONLY : Selector.ALWAYS_APPLIES;
+ }
+ }
+
+ parent = parent.getParent();
+ inheritOnly = true;
+ }
+ return Selector.NEVER_APPLIES;
+ }
+
+ public enum MouseEventEnum {
+
+ mouseover,
+ mouseout,
+ mousedown,
+ mouseup
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.compiler;
-
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultObjectHandler;
-
-import java.io.File;
-
-/**
- * Swing JAXX compiler.
- * <p/>
- * todo finish javadoc
- */
-public class SwingCompiler extends JAXXCompiler {
-
- /*---------------------------------------------------------------------------------*/
- /*-- Constructor methods ----------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
-
- public SwingCompiler(ClassLoader classLoader) {
- super(classLoader,
- new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)),
- "java.awt.*",
- "java.awt.event.*",
- "java.beans.*",
- "java.io.*",
- "java.lang.*",
- "java.util.*",
- "javax.swing.*",
- "javax.swing.border.*",
- "javax.swing.event.*",
- "jaxx.runtime.swing.JAXXButtonGroup",
- "jaxx.runtime.swing.HBox",
- "jaxx.runtime.swing.VBox",
- "jaxx.runtime.swing.Table",
- "static org.nuiton.i18n.I18n._",
- "static jaxx.runtime.Util.createImageIcon");
-
-
- }
-
- /**
- * Creates a new SwingCompiler.
- *
- * @param baseDir classpath location
- * @param options options to pass to javac
- * @param src location of file to compile
- * @param outputClassName the out file name
- */
- public SwingCompiler(File baseDir, File src, String outputClassName, CompilerOptions options) {
- super(baseDir, src, outputClassName, options,
- new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)),
- "java.awt.*",
- "java.awt.event.*",
- "java.beans.*",
- "java.io.*",
- "java.lang.*",
- "java.util.*",
- "javax.swing.*",
- "javax.swing.border.*",
- "javax.swing.event.*",
- "jaxx.runtime.swing.JAXXButtonGroup",
- "jaxx.runtime.swing.HBox",
- "jaxx.runtime.swing.VBox",
- "jaxx.runtime.swing.Table",
- "static org.nuiton.i18n.I18n._",
- "static jaxx.runtime.Util.createImageIcon");
- }
-
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,26 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.reflect.ClassDescriptorLoader;
-
-import java.lang.reflect.Modifier;
-
-/** @author chemit */
-public class SwingGenerator implements Generator {
- @Override
- public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
-
- }
-
- @Override
- public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
-
- //TODO : move this to jaxx-compiler-swing generator
- if (ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Application").isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) {
- // TODO: check for existing main method first
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC | Modifier.STATIC, "void", "main",
- "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });",
- new JavaArgument("String[]", "arg"))
- );
- }
- }
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,7 +1,7 @@
package jaxx.compiler;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
@@ -12,27 +12,21 @@
public class SymbolTable {
private String superclass;
-
// maps ID strings to class names -- we can't map directly to CompiledObjects, because we
// can't create those until after the first pass
private Map<String, String> ids = new HashMap<String, String>();
-
private List<FieldDescriptor> scriptFields = new ArrayList<FieldDescriptor>();
-
private List<MethodDescriptor> scriptMethods = new ArrayList<MethodDescriptor>();
-
/** @return the fully-qualified name of the superclass of the class described by this symbol table. */
public String getSuperclassName() {
return superclass;
}
-
public void setSuperclassName(String superclass) {
this.superclass = superclass;
}
-
/**
* @return a map of IDs to class names. Each entry in the map corresponds to a class tag with an
* <code>id</code> attribute. The <code>id</code> is the key, and the fully-qualified class name
@@ -42,15 +36,13 @@
return ids;
}
-
/** @return a list of <code>FieldDescriptors</code> for fields defined in <script> tags. */
public List<FieldDescriptor> getScriptFields() {
return scriptFields;
}
-
/** @return a list of <code>MethodDescriptors</code> for methods defined in <script> tags. */
public List<MethodDescriptor> getScriptMethods() {
return scriptMethods;
}
-}
\ No newline at end of file
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+/**
+ * Thrown by <code>TagHandler</code> when an unsupported attribute is encountered.
+ *
+ * @see jaxx.tags.TagHandler
+ */
+public class UnsupportedAttributeException extends CompilerException {
+
+ private static final long serialVersionUID = -6919583037172920343L;
+
+ /** Creates a new <code>UnsupportedAttributeException</code>. */
+ public UnsupportedAttributeException() {
+ }
+
+ /**
+ * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message.
+ *
+ * @param msg the exception's detail message
+ */
+ public UnsupportedAttributeException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a new <code>UnsupportedAttributeException</code> with the specified cause.
+ *
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedAttributeException(Throwable initCause) {
+ super(initCause);
+ }
+
+ /**
+ * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message and cause.
+ *
+ * @param msg the exception's detail message
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedAttributeException(String msg, Throwable initCause) {
+ super(msg, initCause);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+/** Thrown by the compiler when an unregistered tag is encountered. */
+public class UnsupportedTagException extends CompilerException {
+ private static final long serialVersionUID = 3199732135804426699L;
+
+ /** Creates a new <code>UnsupportedTagException</code>. */
+ public UnsupportedTagException() {
+ }
+
+
+ /**
+ * Creates a new <code>UnsupportedTagException</code> with the specified detail message.
+ *
+ * @param msg the exception's detail message
+ */
+ public UnsupportedTagException(String msg) {
+ super(msg);
+ }
+
+
+ /**
+ * Creates a new <code>UnsupportedTagException</code> with the specified cause.
+ *
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedTagException(Throwable initCause) {
+ super(initCause);
+ }
+
+
+ /**
+ * Creates a new <code>UnsupportedTagException</code> with the specified detail message and cause.
+ *
+ * @param msg the exception's detail message
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedTagException(String msg, Throwable initCause) {
+ super(msg, initCause);
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,89 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.compiler.CompiledObject.ChildRef;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.validator.BeanValidatorHandler;
-import jaxx.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
-import jaxx.types.TypeManager;
-
-import java.util.List;
-
-/** @author chemit */
-public class ValidatorGenerator implements Generator {
-
- protected static final JavaField VALIDATOR_IDS_FIELD = JavaField.newField(java.lang.reflect.Modifier.PROTECTED,
- "java.util.List<String>", "validatorIds", "new ArrayList<String>()"
- );
-
- @Override
- public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
-
- if (!BeanValidatorHandler.hasValidator(compiler)) {
- return;
- }
-
- for (CompiledObject object : compiler.getObjects().values()) {
- List<ChildRef> childs = object.getChilds();
- if (childs == null || childs.isEmpty()) {
- continue;
- }
- for (ChildRef child : childs) {
- String javaCode = child.getChildJavaCode();
- // some validators are defined on this object
- boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId());
- if (found) {
- // box the child component in a JxLayer
- child.setChildJavaCode(jaxx.runtime.SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")");
- }
- }
- }
- // register validator
- for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) {
- String id = TypeManager.getJavaCode(validator.getId());
- compiler.appendLateInitializer("validatorIds.add(" + id + ");");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- compiler.appendLateInitializer("getValidator(" + id + ").installUIs();");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();");
- //compiler.appendLateInitializer("getValidator(" + id + ").validate();");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- }
- compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- }
-
- @Override
- public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
- if (!BeanValidatorHandler.hasValidator(compiler)) {
- return;
- }
- Class<?> validatorClass = compiler.getOptions().getValidatorClass();
- String validatorFQN = validatorClass.getName();
- javaFile.addImport(validatorFQN);
-
- //TODO use the specific JAXXValidator interface (swing, gwt,...)
- Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class;
-
- if (javaFile.isSuperclassIsJAXXObject()) {
- ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass());
- boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass);
-
- if (parentIsValidator) {
- // nothing to generate (use the parent directly)
- return;
- }
- }
-
- // add JAXXValidator interface
- javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface));
-
- // implements JAXXValidator
- javaFile.addField(VALIDATOR_IDS_FIELD);
- javaFile.addMethod(JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, validatorFQN + "<?>", "getValidator",
- "return (" + validatorFQN + ") (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);",
- new JavaArgument("String", "validatorId")
- ));
- }
-
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/beaninfos/BeanInfoUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,36 @@
+package jaxx.compiler.beans;
+
+import java.beans.Introspector;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** @author chemit */
+public class BeanInfoUtil {
+
+ public static String[] originalBeanInfoSearchPath;
+
+ public static void addJaxxBeanInfoPath(String... packageNames) {
+
+ String[] searchPath = Introspector.getBeanInfoSearchPath();
+ if (originalBeanInfoSearchPath == null) {
+ originalBeanInfoSearchPath = searchPath;
+ }
+ List<String> listSearchPath = new ArrayList<String>(Arrays.asList(searchPath));
+ for (String packageName : packageNames) {
+ if (!listSearchPath.contains(packageName)) {
+ listSearchPath.add(packageName);
+ }
+ }
+
+ Introspector.setBeanInfoSearchPath(listSearchPath.toArray(new String[listSearchPath.size()]));
+ }
+
+ public static void reset() {
+ if (originalBeanInfoSearchPath != null) {
+ Introspector.setBeanInfoSearchPath(originalBeanInfoSearchPath);
+ originalBeanInfoSearchPath = null;
+ }
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXBeanDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,15 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+/**
+ * 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},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXBeanDescriptor extends JAXXFeatureDescriptor {
+
+ public JAXXBeanDescriptor(ClassDescriptor beanClass) {
+ super(beanClass, beanClass.getName());
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,33 @@
+package jaxx.compiler.beans;
+
+/**
+ * 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},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXBeanInfo {
+
+ private JAXXBeanDescriptor beanDescriptor;
+ private JAXXPropertyDescriptor[] propertyDescriptors;
+ private JAXXEventSetDescriptor[] eventSetDescriptors;
+
+ public JAXXBeanInfo(JAXXBeanDescriptor beanDescriptor,
+ JAXXPropertyDescriptor[] propertyDescriptors,
+ JAXXEventSetDescriptor[] eventSetDescriptors) {
+ this.beanDescriptor = beanDescriptor;
+ this.propertyDescriptors = propertyDescriptors;
+ this.eventSetDescriptors = eventSetDescriptors;
+ }
+
+ public JAXXBeanDescriptor getJAXXBeanDescriptor() {
+ return beanDescriptor;
+ }
+
+ public JAXXPropertyDescriptor[] getJAXXPropertyDescriptors() {
+ return propertyDescriptors;
+ }
+
+ public JAXXEventSetDescriptor[] getJAXXEventSetDescriptors() {
+ return eventSetDescriptors;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXEventSetDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,36 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+/**
+ * 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},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXEventSetDescriptor extends JAXXFeatureDescriptor {
+
+ private MethodDescriptor addListenerMethod;
+ private MethodDescriptor removeListenerMethod;
+ private MethodDescriptor[] listenerMethods;
+
+ public JAXXEventSetDescriptor(ClassDescriptor classDescriptor, String name, MethodDescriptor addListenerMethod,
+ MethodDescriptor removeListenerMethod, MethodDescriptor[] listenerMethods) {
+ super(classDescriptor, name);
+ this.addListenerMethod = addListenerMethod;
+ this.removeListenerMethod = removeListenerMethod;
+ this.listenerMethods = listenerMethods;
+ }
+
+ public MethodDescriptor getAddListenerMethod() {
+ return addListenerMethod;
+ }
+
+ public MethodDescriptor getRemoveListenerMethod() {
+ return removeListenerMethod;
+ }
+
+ public MethodDescriptor[] getListenerMethods() {
+ return listenerMethods;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXFeatureDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,52 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 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},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXFeatureDescriptor {
+
+ private String name;
+ private Map<String, Object> values;
+ private ClassDescriptor classDescriptor;
+
+ JAXXFeatureDescriptor(ClassDescriptor classDescriptor, String name) {
+ if (name == null || classDescriptor == null) {
+ throw new NullPointerException();
+ }
+ this.name = name;
+ this.classDescriptor = classDescriptor;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ClassDescriptor getClassDescriptor() {
+ return classDescriptor;
+ }
+
+ public Object getValue(String key) {
+ return values != null ? values.get(key) : null;
+ }
+
+ public void setValue(String key, Object value) {
+ if (values == null) {
+ values = new HashMap<String, Object>();
+ }
+ values.put(key, value);
+ }
+
+ public static String capitalize(String name) {
+ if (name.length() == 0) {
+ return name;
+ }
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXIntrospector.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,167 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Performs introspection on a <code>ClassDescriptor</code>. Ideally, I could just have copied Sun's Introspector
+ * and changed a few things, but the licensing terms are incompatible. This implementation is incomplete -- it only
+ * bothers to report info that JAXX actually checks. It also relaxes some of Introspector's rules a bit, but I
+ * 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},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXIntrospector {
+
+ private ClassDescriptor classDescriptor;
+ private Map<String, JAXXPropertyDescriptor> propertyDescriptors = new HashMap<String, JAXXPropertyDescriptor>();
+ private Map<String, JAXXEventSetDescriptor> eventSetDescriptors = new HashMap<String, JAXXEventSetDescriptor>();
+
+ private JAXXIntrospector(ClassDescriptor classDescriptor) {
+ this.classDescriptor = classDescriptor;
+ }
+
+ /**
+ * Returns the <code>JAXXBeanInfo</code> for a given class.
+ *
+ * @param classDescriptor the class to introspect
+ * @return the <code>JAXXBeanInfo</code> for the bean class
+ * @throws IntrospectionException if an error occurs
+ */
+ public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor classDescriptor) throws IntrospectionException {
+ JAXXIntrospector introspector = new JAXXIntrospector(classDescriptor);
+ return introspector.createBeanInfo();
+ }
+
+ private JAXXBeanInfo createBeanInfo() {
+ ClassDescriptor explicitInfoClass = classDescriptor;
+ BeanInfo explicitBeanInfo = null;
+ while (explicitInfoClass != null) {
+ explicitBeanInfo = getExplicitBeanInfo(explicitInfoClass);
+ if (explicitBeanInfo != null) {
+ break;
+ }
+ explicitInfoClass = explicitInfoClass.getSuperclass();
+ }
+
+ if (explicitBeanInfo != null) {
+ PropertyDescriptor[] explicitProperties = explicitBeanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor explicitProperty : explicitProperties) {
+ Class type = explicitProperty.getPropertyType();
+ Method readMethod = explicitProperty.getReadMethod();
+ Method writeMethod = explicitProperty.getWriteMethod();
+ try {
+ ClassDescriptor typeDescriptor = ClassDescriptorLoader.getClassDescriptor(type.getName(), type.getClassLoader());
+ JAXXPropertyDescriptor propertyDescriptor = new JAXXPropertyDescriptor(classDescriptor, explicitProperty.getName(),
+ readMethod != null ? classDescriptor.getMethodDescriptor(readMethod.getName()) : null,
+ writeMethod != null ? classDescriptor.getMethodDescriptor(writeMethod.getName(), typeDescriptor) : null);
+ propertyDescriptor.setBound(explicitProperty.isBound());
+ Enumeration<String> attributeNames = explicitProperty.attributeNames();
+ while (attributeNames.hasMoreElements()) {
+ String name = attributeNames.nextElement();
+ propertyDescriptor.setValue(name, explicitProperty.getValue(name));
+ }
+ propertyDescriptors.put(propertyDescriptor.getName(), propertyDescriptor);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Internal error: Could not find ClassDescriptor corresponding to Java " + type, e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Internal error: Could not find expected MethodDescriptor in " + classDescriptor, e);
+ }
+ }
+ }
+
+ // if the class broadcasts PropertyChangeEvent, assume all properties are bound (java.beans.Introspector
+ // does the same)
+ boolean propertyChangeSource;
+ try {
+ classDescriptor.getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class));
+ propertyChangeSource = true;
+ } catch (NoSuchMethodException e) {
+ propertyChangeSource = false;
+ }
+
+ MethodDescriptor[] methods = classDescriptor.getMethodDescriptors();
+ for (MethodDescriptor method : methods) {
+ String name = method.getName();
+ if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 0) {
+ String propertyName = Introspector.decapitalize(name.substring(3));
+ if (!propertyDescriptors.containsKey(propertyName)) {
+ propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource));
+ }
+ } else if (name.startsWith("is") && name.length() > 2 && Character.isUpperCase(name.charAt(2)) && method.getParameterTypes().length == 0) {
+ String propertyName = Introspector.decapitalize(name.substring(2));
+ if (!propertyDescriptors.containsKey(propertyName)) {
+ propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource));
+ }
+ } else if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 1) {
+ String propertyName = Introspector.decapitalize(name.substring(3));
+ if (!propertyDescriptors.containsKey(propertyName)) {
+ propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, null, method, propertyChangeSource));
+ }
+ } else if (name.startsWith("add") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) {
+ ClassDescriptor[] parameters = method.getParameterTypes();
+ if (parameters.length != 1 || !ClassDescriptorLoader.getClassDescriptor(EventListener.class).isAssignableFrom(parameters[0])) {
+ continue; // not an event listener method
+ }
+ try {
+ String eventSetName = method.getName().substring(3);
+ MethodDescriptor remove = classDescriptor.getMethodDescriptor("remove" + eventSetName, parameters);
+ eventSetDescriptors.put(eventSetName, new JAXXEventSetDescriptor(classDescriptor, eventSetName, method, remove, parameters[0].getMethodDescriptors()));
+ } catch (NoSuchMethodException e) {
+ // no matching remove method, not a valid event
+ }
+ }
+ }
+
+ JAXXBeanDescriptor beanDescriptor = new JAXXBeanDescriptor(classDescriptor);
+ if (explicitBeanInfo != null) {
+ BeanDescriptor explicitBeanDescriptor = explicitBeanInfo.getBeanDescriptor();
+ if (explicitBeanDescriptor != null) {
+ Enumeration/*<String>*/ attributeNames = explicitBeanDescriptor.attributeNames();
+ while (attributeNames.hasMoreElements()) {
+ String name = (String) attributeNames.nextElement();
+ beanDescriptor.setValue(name, explicitBeanDescriptor.getValue(name));
+ }
+ }
+ }
+
+ return new JAXXBeanInfo(beanDescriptor,
+ propertyDescriptors.values().toArray(new JAXXPropertyDescriptor[propertyDescriptors.size()]),
+ eventSetDescriptors.values().toArray(new JAXXEventSetDescriptor[eventSetDescriptors.size()]));
+ }
+
+ private static BeanInfo getExplicitBeanInfo(ClassDescriptor classDescriptor) {
+ try {
+ Class beanClass = Class.forName(classDescriptor.getName(), true, classDescriptor.getClassLoader()); // see if there is a class by that name in this package
+ Method findExplicitBeanInfo = Introspector.class.getDeclaredMethod("findExplicitBeanInfo", new Class[]{Class.class});
+ findExplicitBeanInfo.setAccessible(true);
+ return (BeanInfo) findExplicitBeanInfo.invoke(null, beanClass);
+ } catch (ClassNotFoundException e) {
+ return null; // happens for uncompiled classes
+ } catch (NoClassDefFoundError e) {
+ return null; // wrong case, etc.
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Error: could not find method 'findExplicitBeanInfo' in java.beans.Introspector. You are most likely running a version of Java against which JAXX has not been tested.");
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXPropertyDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,87 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+/**
+ * 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},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXPropertyDescriptor extends JAXXFeatureDescriptor {
+
+ private ClassDescriptor propertyType;
+ private MethodDescriptor readMethod;
+ private MethodDescriptor writeMethod;
+ private boolean bound;
+
+ public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName) {
+ this(classDescriptor, propertyName, null, null);
+ }
+
+ public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName,
+ MethodDescriptor readMethod, MethodDescriptor writeMethod) {
+ this(classDescriptor, propertyName, readMethod, writeMethod, false);
+ }
+
+ public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName,
+ MethodDescriptor readMethod, MethodDescriptor writeMethod,
+ boolean bound) {
+ super(classDescriptor, propertyName);
+ this.readMethod = readMethod;
+ this.writeMethod = writeMethod;
+ this.bound = bound;
+ }
+
+ public MethodDescriptor getReadMethodDescriptor() {
+ if (readMethod == null) {
+ try {
+ readMethod = getClassDescriptor().getMethodDescriptor("get" + capitalize(getName()));
+ } catch (NoSuchMethodException e) {
+ try {
+ readMethod = getClassDescriptor().getMethodDescriptor("is" + capitalize(getName()));
+ } catch (NoSuchMethodException e2) {
+ }
+ }
+ }
+ return readMethod;
+ }
+
+ public MethodDescriptor getWriteMethodDescriptor() {
+ if (writeMethod == null) {
+ try {
+ String methodName = "set" + capitalize(getName());
+ MethodDescriptor read = getReadMethodDescriptor();
+ if (read != null) {
+ writeMethod = getClassDescriptor().getMethodDescriptor(methodName, read.getReturnType());
+ } else {
+ throw new CompilerException("Internal error: requesting 'set' method for property of unknown type: '" + getName() + "' (in " + getClassDescriptor() + ")");
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ return writeMethod;
+ }
+
+ public ClassDescriptor getPropertyType() {
+ if (propertyType == null) {
+ MethodDescriptor read = getReadMethodDescriptor();
+ if (read != null) {
+ propertyType = read.getReturnType();
+ } else {
+ MethodDescriptor write = getWriteMethodDescriptor();
+ propertyType = write.getParameterTypes()[0];
+ }
+ }
+ return propertyType;
+ }
+
+ public boolean isBound() {
+ return bound;
+ }
+
+ public void setBound(boolean bound) {
+ this.bound = bound;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,17 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaFile;
+
+/**
+ * TODO javadoc!
+ *
+ * @author chemit
+ */
+public interface Generator {
+
+ void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className);
+
+ void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException;
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSS.jj)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,587 @@
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. .\CSS.jj */
+/*@egen*//*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+// I would love to have used an existing CSS parser, but all of the ones I could
+// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big
+// fan of the LGPL, unfortunately that won't work.
+options {
+ STATIC = false;
+ JDK_VERSION = "1.4";
+}
+
+PARSER_BEGIN(CSSParser)
+package jaxx.css;
+
+public class CSSParser/*@bgen(jjtree)*/implements CSSParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
+ protected JJTCSSParserState jjtree = new JJTCSSParserState();
+
+/*@egen*/
+ public SimpleNode popNode() {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public static void main(String args[]) {
+ System.out.println("Reading from standard input...");
+ CSSParser css = new CSSParser(System.in);
+ try {
+ SimpleNode n = css.Stylesheet();
+ n.dump("");
+ System.out.println("Thank you.");
+ } catch (Exception e) {
+ System.out.println("Oops.");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+
+PARSER_END(CSSParser)
+
+
+<DEFAULT, IN_RULE> SKIP :
+{
+ " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+<*> TOKEN : /* LITERALS */
+{
+ <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?>
+|
+ <#INTEGER_LITERAL: (["0"-"9"])+>
+}
+
+<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */
+{
+ <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*>
+|
+ <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]>
+|
+ <#DIGIT: ["0"-"9"]>
+}
+
+<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */
+{
+ <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT
+}
+
+<DEFAULT> TOKEN: /* COLON */
+{
+ <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS
+}
+
+<IN_RULE> TOKEN: /* COLON_IN_RULE */
+{
+ <COLON: ":">
+}
+
+<*> TOKEN: /* SEMICOLON */
+{
+ <SEMICOLON: ";">
+}
+
+TOKEN : /* LEFT BRACE */
+{
+ <LEFT_BRACE: "{"> : IN_RULE
+}
+
+<IN_RULE> TOKEN : /* RIGHT BRACE */
+{
+ <RIGHT_BRACE: "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */
+{
+ <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */
+{
+ <JAVA_CODE: (~["}"])+ >
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */
+{
+ <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE
+}
+
+
+<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */
+{
+ <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* STRINGS */
+{
+ <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\"">
+}
+
+<IN_RULE> TOKEN : /* COLORS */
+{
+ <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?>
+|
+ <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]>
+}
+
+
+<IN_RULE> TOKEN : /* EMS */
+{
+ <EMS: <DECIMAL_LITERAL> "em">
+}
+
+
+<IN_RULE> TOKEN : /* EXS */
+{
+ <EXS: <DECIMAL_LITERAL> "ex">
+}
+
+
+<IN_RULE> TOKEN : /* LENGTH */
+{
+ <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")>
+}
+
+
+SimpleNode Stylesheet() : {/*@bgen(jjtree) Stylesheet */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Stylesheet */
+ try {
+/*@egen*/
+ (Rule())*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ { return jjtn000; }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Rule() : {/*@bgen(jjtree) Rule */
+ SimpleNode jjtn000 = new SimpleNode(JJTRULE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Rule */
+ try {
+/*@egen*/
+ Selectors()
+ <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Selectors() : {/*@bgen(jjtree) Selectors */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Selectors */
+ try {
+/*@egen*/
+ Selector() ("," Selector())*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Selector() : {/*@bgen(jjtree) Selector */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Selector */
+ try {
+/*@egen*/
+ JavaClass() (Id())? (Class())? (PseudoClass())?
+|
+ Id() (Class())? (PseudoClass())?
+|
+ Class() (PseudoClass())?
+|
+ PseudoClass()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void JavaClass() : {/*@bgen(jjtree) JavaClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) JavaClass */
+ try {
+/*@egen*/
+ <IDENTIFIER> | "*"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Id() : {/*@bgen(jjtree) Id */
+ SimpleNode jjtn000 = new SimpleNode(JJTID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Id */
+ try {
+/*@egen*/
+ "#" <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Class() : {/*@bgen(jjtree) Class */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Class */
+ try {
+/*@egen*/
+ "." <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void PseudoClass() : {/*@bgen(jjtree) PseudoClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PseudoClass */
+ try {
+/*@egen*/
+ <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())?/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void AnimationProperties() : {/*@bgen(jjtree) AnimationProperties */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnimationProperties */
+ try {
+/*@egen*/
+ "[" AnimationProperty() ("," AnimationProperty())* "]"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void AnimationProperty() : {/*@bgen(jjtree) AnimationProperty */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnimationProperty */
+ try {
+/*@egen*/
+ <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)?/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Declaration() : {/*@bgen(jjtree) Declaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Declaration */
+ try {
+/*@egen*/
+ Property() <COLON> Expression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Property() : {/*@bgen(jjtree) Property */
+ SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Property */
+ try {
+/*@egen*/
+ <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Expression() : {/*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Expression */
+ try {
+/*@egen*/
+ (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> |
+ JavaCode())/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void JavaCode() : {/*@bgen(jjtree) JavaCode */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) JavaCode */
+ try {
+/*@egen*/
+ <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Identifier() : {/*@bgen(jjtree) Identifier */
+ SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Identifier */
+ try {
+/*@egen*/
+ <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSS.jjt)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+// I would love to have used an existing CSS parser, but all of the ones I could
+// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big
+// fan of the LGPL, unfortunately that won't work.
+options {
+ STATIC = false;
+ JDK_VERSION = "1.4";
+ NODE_SCOPE_HOOK = true;
+}
+
+PARSER_BEGIN(CSSParser)
+package jaxx.css;
+
+public class CSSParser {
+ public SimpleNode popNode() {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public static void main(String args[]) {
+ System.out.println("Reading from standard input...");
+ CSSParser css = new CSSParser(System.in);
+ try {
+ SimpleNode n = css.Stylesheet();
+ n.dump("");
+ System.out.println("Thank you.");
+ } catch (Exception e) {
+ System.out.println("Oops.");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+
+PARSER_END(CSSParser)
+
+
+<DEFAULT, IN_RULE> SKIP :
+{
+ " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+<*> TOKEN : /* LITERALS */
+{
+ <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?>
+|
+ <#INTEGER_LITERAL: (["0"-"9"])+>
+}
+
+<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */
+{
+ <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*>
+|
+ <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]>
+|
+ <#DIGIT: ["0"-"9"]>
+}
+
+<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */
+{
+ <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT
+}
+
+<DEFAULT> TOKEN: /* COLON */
+{
+ <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS
+}
+
+<IN_RULE> TOKEN: /* COLON_IN_RULE */
+{
+ <COLON: ":">
+}
+
+<*> TOKEN: /* SEMICOLON */
+{
+ <SEMICOLON: ";">
+}
+
+TOKEN : /* LEFT BRACE */
+{
+ <LEFT_BRACE: "{"> : IN_RULE
+}
+
+<IN_RULE> TOKEN : /* RIGHT BRACE */
+{
+ <RIGHT_BRACE: "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */
+{
+ <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */
+{
+ <JAVA_CODE: (~["}"])+ >
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */
+{
+ <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE
+}
+
+
+<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */
+{
+ <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* STRINGS */
+{
+ <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\"">
+}
+
+<IN_RULE> TOKEN : /* COLORS */
+{
+ <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?>
+|
+ <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]>
+}
+
+
+<IN_RULE> TOKEN : /* EMS */
+{
+ <EMS: <DECIMAL_LITERAL> "em">
+}
+
+
+<IN_RULE> TOKEN : /* EXS */
+{
+ <EXS: <DECIMAL_LITERAL> "ex">
+}
+
+
+<IN_RULE> TOKEN : /* LENGTH */
+{
+ <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")>
+}
+
+
+SimpleNode Stylesheet() : {}
+{
+ (Rule())*
+ { return jjtThis; }
+}
+
+
+void Rule() : {}
+{
+ Selectors()
+ <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE>
+}
+
+
+void Selectors() : {}
+{
+ Selector() ("," Selector())*
+}
+
+
+void Selector() : {}
+{
+ JavaClass() (Id())? (Class())? (PseudoClass())?
+|
+ Id() (Class())? (PseudoClass())?
+|
+ Class() (PseudoClass())?
+|
+ PseudoClass()
+}
+
+
+void JavaClass() : {}
+{
+ <IDENTIFIER> | "*"
+}
+
+
+void Id() : {}
+{
+ "#" <IDENTIFIER>
+}
+
+
+void Class() : {}
+{
+ "." <IDENTIFIER>
+}
+
+
+void PseudoClass() : {}
+{
+ <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())?
+}
+
+
+void AnimationProperties() : {}
+{
+ "[" AnimationProperty() ("," AnimationProperty())* "]"
+}
+
+
+void AnimationProperty() : {}
+{
+ <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)?
+}
+
+
+void Declaration() : {}
+{
+ Property() <COLON> Expression()
+}
+
+
+void Property() : {}
+{
+ <IDENTIFIER>
+}
+
+
+void Expression() : {}
+{
+ (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> |
+ JavaCode())
+}
+
+
+void JavaCode() : {}
+{
+ <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END>
+}
+
+
+void Identifier() : {}
+{
+ <IDENTIFIER>
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParser.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,799 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParser.java */
+package jaxx.compiler.parser.css;
+
+public class CSSParser/*@bgen(jjtree)*/ implements CSSParserTreeConstants, CSSParserConstants {/*@bgen(jjtree)*/
+ protected JJTCSSParserState jjtree = new JJTCSSParserState();
+
+ public SimpleNode popNode() {
+ if (jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode) jjtree.popNode();
+ else
+ return null;
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public static void main(String args[]) {
+ System.out.println("Reading from standard input...");
+ CSSParser css = new CSSParser(System.in);
+ try {
+ SimpleNode n = css.Stylesheet();
+ n.dump("");
+ System.out.println("Thank you.");
+ } catch (Exception e) {
+ System.out.println("Oops.");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ final public SimpleNode Stylesheet() throws ParseException {
+ /*@bgen(jjtree) Stylesheet */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ label_1:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ case PSEUDOCLASS_COLON:
+ case 29:
+ case 30:
+ case 31:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ Rule();
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return jjtn000;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public void Rule() throws ParseException {
+ /*@bgen(jjtree) Rule */
+ SimpleNode jjtn000 = new SimpleNode(JJTRULE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Selectors();
+ jj_consume_token(LEFT_BRACE);
+ Declaration();
+ label_2:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SEMICOLON:
+ ;
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ break label_2;
+ }
+ jj_consume_token(SEMICOLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ Declaration();
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ ;
+ }
+ }
+ jj_consume_token(RIGHT_BRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Selectors() throws ParseException {
+ /*@bgen(jjtree) Selectors */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Selector();
+ label_3:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 28:
+ ;
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ break label_3;
+ }
+ jj_consume_token(28);
+ Selector();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Selector() throws ParseException {
+ /*@bgen(jjtree) Selector */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ case 29:
+ JavaClass();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 30:
+ Id();
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 31:
+ Class();
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ ;
+ }
+ break;
+ case 30:
+ Id();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 31:
+ Class();
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[8] = jj_gen;
+ ;
+ }
+ break;
+ case 31:
+ Class();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[9] = jj_gen;
+ ;
+ }
+ break;
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[10] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void JavaClass() throws ParseException {
+ /*@bgen(jjtree) JavaClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ case 29:
+ jj_consume_token(29);
+ break;
+ default:
+ jj_la1[11] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Id() throws ParseException {
+ /*@bgen(jjtree) Id */
+ SimpleNode jjtn000 = new SimpleNode(JJTID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(30);
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Class() throws ParseException {
+ /*@bgen(jjtree) Class */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(31);
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PseudoClass() throws ParseException {
+ /*@bgen(jjtree) PseudoClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(PSEUDOCLASS_COLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_IDENTIFIER:
+ jj_consume_token(PSEUDOCLASS_IDENTIFIER);
+ break;
+ case PROGRAMMATIC_PSEUDOCLASS:
+ jj_consume_token(PROGRAMMATIC_PSEUDOCLASS);
+ break;
+ default:
+ jj_la1[12] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 32:
+ AnimationProperties();
+ break;
+ default:
+ jj_la1[13] = jj_gen;
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnimationProperties() throws ParseException {
+ /*@bgen(jjtree) AnimationProperties */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(32);
+ AnimationProperty();
+ label_4:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 28:
+ ;
+ break;
+ default:
+ jj_la1[14] = jj_gen;
+ break label_4;
+ }
+ jj_consume_token(28);
+ AnimationProperty();
+ }
+ jj_consume_token(33);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnimationProperty() throws ParseException {
+ /*@bgen(jjtree) AnimationProperty */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(34);
+ jj_consume_token(DECIMAL_LITERAL);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ jj_la1[15] = jj_gen;
+ ;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Declaration() throws ParseException {
+ /*@bgen(jjtree) Declaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Property();
+ jj_consume_token(COLON);
+ Expression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Property() throws ParseException {
+ /*@bgen(jjtree) Property */
+ SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Expression() throws ParseException {
+ /*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case DECIMAL_LITERAL:
+ jj_consume_token(DECIMAL_LITERAL);
+ break;
+ case STRING:
+ jj_consume_token(STRING);
+ break;
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ case HEXCOLOR:
+ jj_consume_token(HEXCOLOR);
+ break;
+ case EMS:
+ jj_consume_token(EMS);
+ break;
+ case EXS:
+ jj_consume_token(EXS);
+ break;
+ case LENGTH:
+ jj_consume_token(LENGTH);
+ break;
+ case JAVA_CODE_START:
+ JavaCode();
+ break;
+ default:
+ jj_la1[16] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void JavaCode() throws ParseException {
+ /*@bgen(jjtree) JavaCode */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(JAVA_CODE_START);
+ jj_consume_token(JAVA_CODE);
+ jj_consume_token(JAVA_CODE_END);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Identifier() throws ParseException {
+ /*@bgen(jjtree) Identifier */
+ SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ public CSSParserTokenManager token_source;
+ SimpleCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private int jj_gen;
+ final private int[] jj_la1 = new int[17];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ }
+
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[]{0xe0002200, 0x8000, 0x200, 0x10000000, 0x40000000, 0x80000000, 0x2000, 0x80000000, 0x2000, 0x2000, 0xe0002200, 0x20000200, 0x201000, 0x0, 0x10000000, 0x200, 0xec40280,};
+ }
+
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,};
+ }
+
+ public CSSParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+
+ public CSSParser(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source = new CSSParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+
+ public void ReInit(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream.ReInit(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public CSSParser(java.io.Reader stream) {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new CSSParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public CSSParser(CSSParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(CSSParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ final public Token getToken(int index) {
+ Token t = token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ final private int jj_ntk() {
+ if ((jj_nt = token.next) == null)
+ return (jj_ntk = (token.next = token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ private java.util.Vector jj_expentries = new java.util.Vector();
+ private int[] jj_expentry;
+ private int jj_kind = -1;
+
+ public ParseException generateParseException() {
+ Token errortok = token.next;
+ int line = errortok.beginLine, column = errortok.beginColumn;
+ String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
+ return new ParseException("Parse error. Encountered: " + mess, line, column);
+ }
+
+ final public void enable_tracing() {
+ }
+
+ final public void disable_tracing() {
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParserConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,72 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserConstants.java */
+package jaxx.compiler.parser.css;
+
+public interface CSSParserConstants {
+
+ int EOF = 0;
+ int DECIMAL_LITERAL = 7;
+ int INTEGER_LITERAL = 8;
+ int IDENTIFIER = 9;
+ int LETTER = 10;
+ int DIGIT = 11;
+ int PSEUDOCLASS_IDENTIFIER = 12;
+ int PSEUDOCLASS_COLON = 13;
+ int COLON = 14;
+ int SEMICOLON = 15;
+ int LEFT_BRACE = 16;
+ int RIGHT_BRACE = 17;
+ int JAVA_CODE_START = 18;
+ int JAVA_CODE = 19;
+ int JAVA_CODE_END = 20;
+ int PROGRAMMATIC_PSEUDOCLASS = 21;
+ int STRING = 22;
+ int HEXCOLOR = 23;
+ int HEXDIGIT = 24;
+ int EMS = 25;
+ int EXS = 26;
+ int LENGTH = 27;
+
+ int DEFAULT = 0;
+ int IN_RULE = 1;
+ int JAVA_CODE_RULE = 2;
+ int IN_PSEUDOCLASS = 3;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "<token of kind 5>",
+ "<token of kind 6>",
+ "<DECIMAL_LITERAL>",
+ "<INTEGER_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ "<PSEUDOCLASS_IDENTIFIER>",
+ "\":\"",
+ "\":\"",
+ "\";\"",
+ "\"{\"",
+ "\"}\"",
+ "<JAVA_CODE_START>",
+ "<JAVA_CODE>",
+ "<JAVA_CODE_END>",
+ "<PROGRAMMATIC_PSEUDOCLASS>",
+ "<STRING>",
+ "<HEXCOLOR>",
+ "<HEXDIGIT>",
+ "<EMS>",
+ "<EXS>",
+ "<LENGTH>",
+ "\",\"",
+ "\"*\"",
+ "\"#\"",
+ "\".\"",
+ "\"[\"",
+ "\"]\"",
+ "\"=\"",
+ };
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParserTokenManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,1152 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserTokenManager.java */
+package jaxx.compiler.parser.css;
+
+public class CSSParserTokenManager implements CSSParserConstants {
+ public java.io.PrintStream debugStream = System.out;
+
+ public void setDebugStream(java.io.PrintStream ds) {
+ debugStream = ds;
+ }
+
+ private int jjStopStringLiteralDfa_0(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_0(int pos, long active0) {
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+ }
+
+ private int jjStopAtPos(int pos, int kind) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+ }
+
+ private int jjStartNfaWithStates_0(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_0(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_0() {
+ switch (curChar) {
+ case 35:
+ return jjStopAtPos(0, 30);
+ case 42:
+ return jjStopAtPos(0, 29);
+ case 44:
+ return jjStopAtPos(0, 28);
+ case 46:
+ return jjStopAtPos(0, 31);
+ case 58:
+ return jjStopAtPos(0, 13);
+ case 59:
+ return jjStopAtPos(0, 15);
+ case 61:
+ return jjStopAtPos(0, 34);
+ case 91:
+ return jjStopAtPos(0, 32);
+ case 93:
+ return jjStopAtPos(0, 33);
+ case 123:
+ return jjStopAtPos(0, 16);
+ default:
+ return jjMoveNfa_0(3, 0);
+ }
+ }
+
+ private void jjCheckNAdd(int state) {
+ if (jjrounds[state] != jjround) {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+ }
+
+ private void jjAddStates(int start, int end) {
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddTwoStates(int state1, int state2) {
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+ }
+
+ private void jjCheckNAddStates(int start, int end) {
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddStates(int start) {
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+ }
+
+ static final long[] jjbitVec0 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+ };
+
+ private int jjMoveNfa_0(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 17;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ } else if (curChar == 47)
+ jjAddStates(0, 1);
+ else if (curChar == 45) {
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(4);
+ }
+ break;
+ case 0:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ break;
+ case 1:
+ if (curChar == 46)
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(2);
+ break;
+ case 4:
+ if ((0x3ff200000000000L & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 47)
+ jjAddStates(0, 1);
+ break;
+ case 6:
+ if (curChar == 47)
+ jjCheckNAddStates(2, 4);
+ break;
+ case 7:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(2, 4);
+ break;
+ case 8:
+ if ((0x2400L & l) != 0L && kind > 5)
+ kind = 5;
+ break;
+ case 9:
+ if (curChar == 10 && kind > 5)
+ kind = 5;
+ break;
+ case 10:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 11:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 12:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 13:
+ if (curChar == 42)
+ jjAddStates(5, 6);
+ break;
+ case 14:
+ if ((0xffff7fffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 15:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 16:
+ if (curChar == 47 && kind > 6)
+ kind = 6;
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ jjAddStates(2, 4);
+ break;
+ case 12:
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 7:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(2, 4);
+ break;
+ case 12:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 17 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjStopStringLiteralDfa_3(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_3(int pos, long active0) {
+ return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1);
+ }
+
+ private int jjStartNfaWithStates_3(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_3(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_3() {
+ switch (curChar) {
+ case 59:
+ return jjStopAtPos(0, 15);
+ default:
+ return jjMoveNfa_3(3, 0);
+ }
+ }
+
+ private int jjMoveNfa_3(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 8;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ } else if (curChar == 45) {
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ }
+ break;
+ case 0:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ break;
+ case 1:
+ if (curChar == 46)
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(2);
+ break;
+ case 4:
+ if ((0x3ff200000000000L & l) == 0L)
+ break;
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ break;
+ case 6:
+ jjAddStates(7, 8);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ if ((0x7fffffe87fffffeL & l) != 0L) {
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ } else if (curChar == 123)
+ jjCheckNAdd(6);
+ break;
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 123)
+ jjCheckNAdd(6);
+ break;
+ case 6:
+ if ((0xdfffffffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(6, 7);
+ break;
+ case 7:
+ if (curChar == 125)
+ kind = 21;
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 6:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(7, 8);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 8 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjStopStringLiteralDfa_1(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_1(int pos, long active0) {
+ return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
+ }
+
+ private int jjStartNfaWithStates_1(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_1(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_1() {
+ switch (curChar) {
+ case 58:
+ return jjStopAtPos(0, 14);
+ case 59:
+ return jjStopAtPos(0, 15);
+ case 125:
+ return jjStopAtPos(0, 17);
+ default:
+ return jjMoveNfa_1(0, 0);
+ }
+ }
+
+ private int jjMoveNfa_1(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 50;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 0:
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddStates(9, 22);
+ } else if (curChar == 47)
+ jjAddStates(23, 24);
+ else if (curChar == 35)
+ jjstateSet[jjnewStateCnt++] = 7;
+ else if (curChar == 34)
+ jjCheckNAddTwoStates(4, 5);
+ else if (curChar == 45) {
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ }
+ break;
+ case 1:
+ if ((0x3ff200000000000L & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ break;
+ case 3:
+ if (curChar == 34)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 4:
+ if ((0xfffffffbffffdbffL & l) != 0L)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 5:
+ if (curChar == 34 && kind > 22)
+ kind = 22;
+ break;
+ case 6:
+ if (curChar == 35)
+ jjstateSet[jjnewStateCnt++] = 7;
+ break;
+ case 7:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 8;
+ break;
+ case 8:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 9:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 23)
+ kind = 23;
+ jjstateSet[jjnewStateCnt++] = 10;
+ break;
+ case 10:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 11:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 12;
+ break;
+ case 12:
+ if ((0x3ff000000000000L & l) != 0L && kind > 23)
+ kind = 23;
+ break;
+ case 13:
+ if (curChar == 47)
+ jjAddStates(23, 24);
+ break;
+ case 14:
+ if (curChar == 47)
+ jjCheckNAddStates(25, 27);
+ break;
+ case 15:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(25, 27);
+ break;
+ case 16:
+ if ((0x2400L & l) != 0L && kind > 5)
+ kind = 5;
+ break;
+ case 17:
+ if (curChar == 10 && kind > 5)
+ kind = 5;
+ break;
+ case 18:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 17;
+ break;
+ case 19:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 20:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 21:
+ if (curChar == 42)
+ jjAddStates(28, 29);
+ break;
+ case 22:
+ if ((0xffff7fffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ case 23:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ case 24:
+ if (curChar == 47 && kind > 6)
+ kind = 6;
+ break;
+ case 25:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddStates(9, 22);
+ break;
+ case 26:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(26, 27);
+ break;
+ case 27:
+ if (curChar == 46)
+ jjCheckNAdd(28);
+ break;
+ case 28:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(28);
+ break;
+ case 29:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(30, 32);
+ break;
+ case 30:
+ if (curChar == 46)
+ jjCheckNAdd(31);
+ break;
+ case 31:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(31, 33);
+ break;
+ case 34:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(33, 35);
+ break;
+ case 35:
+ if (curChar == 46)
+ jjCheckNAdd(36);
+ break;
+ case 36:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(36, 38);
+ break;
+ case 39:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(36, 41);
+ break;
+ case 40:
+ if (curChar == 46)
+ jjCheckNAdd(41);
+ break;
+ case 41:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(42, 46);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 0:
+ if ((0x7fffffe87fffffeL & l) != 0L) {
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ } else if (curChar == 123) {
+ if (kind > 18)
+ kind = 18;
+ }
+ break;
+ case 1:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 123 && kind > 18)
+ kind = 18;
+ break;
+ case 4:
+ if ((0xffffffffefffffffL & l) != 0L)
+ jjAddStates(47, 48);
+ break;
+ case 7:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 8;
+ break;
+ case 8:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 9:
+ if ((0x7e0000007eL & l) == 0L)
+ break;
+ if (kind > 23)
+ kind = 23;
+ jjstateSet[jjnewStateCnt++] = 10;
+ break;
+ case 10:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 11:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 12;
+ break;
+ case 12:
+ if ((0x7e0000007eL & l) != 0L && kind > 23)
+ kind = 23;
+ break;
+ case 15:
+ jjAddStates(25, 27);
+ break;
+ case 20:
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 22:
+ case 23:
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ case 32:
+ if (curChar == 109 && kind > 25)
+ kind = 25;
+ break;
+ case 33:
+ if (curChar == 101)
+ jjstateSet[jjnewStateCnt++] = 32;
+ break;
+ case 37:
+ if (curChar == 120 && kind > 26)
+ kind = 26;
+ break;
+ case 38:
+ if (curChar == 101)
+ jjstateSet[jjnewStateCnt++] = 37;
+ break;
+ case 42:
+ if (curChar == 109 && kind > 27)
+ kind = 27;
+ break;
+ case 43:
+ if (curChar == 109)
+ jjCheckNAdd(42);
+ break;
+ case 44:
+ if (curChar == 99)
+ jjCheckNAdd(42);
+ break;
+ case 45:
+ if (curChar == 110 && kind > 27)
+ kind = 27;
+ break;
+ case 46:
+ if (curChar == 105)
+ jjstateSet[jjnewStateCnt++] = 45;
+ break;
+ case 47:
+ if (curChar == 112)
+ jjAddStates(49, 50);
+ break;
+ case 48:
+ if (curChar == 116 && kind > 27)
+ kind = 27;
+ break;
+ case 49:
+ if (curChar == 99 && kind > 27)
+ kind = 27;
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(47, 48);
+ break;
+ case 15:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(25, 27);
+ break;
+ case 20:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 22:
+ case 23:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 50 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjStopStringLiteralDfa_2(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_2(int pos, long active0) {
+ return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
+ }
+
+ private int jjStartNfaWithStates_2(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_2(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_2() {
+ switch (curChar) {
+ case 59:
+ return jjStartNfaWithStates_2(0, 15, 3);
+ default:
+ return jjMoveNfa_2(4, 0);
+ }
+ }
+
+ private int jjMoveNfa_2(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 5;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ }
+ break;
+ case 0:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ break;
+ case 1:
+ if (curChar == 46)
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(2);
+ break;
+ case 3:
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ if ((0xdfffffffffffffffL & l) != 0L) {
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ } else if (curChar == 125) {
+ if (kind > 20)
+ kind = 20;
+ }
+ break;
+ case 3:
+ if ((0xdfffffffffffffffL & l) == 0L)
+ break;
+ kind = 19;
+ jjCheckNAdd(3);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ case 3:
+ if ((jjbitVec0[i2] & l2) == 0L)
+ break;
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ static final int[] jjnextStates = {
+ 6, 11, 7, 8, 10, 14, 16, 6, 7, 26, 27, 29, 30, 33, 34, 35,
+ 38, 39, 40, 43, 44, 46, 47, 14, 19, 15, 16, 18, 22, 24, 29, 30,
+ 33, 34, 35, 38, 39, 40, 43, 44, 46, 47, 41, 43, 44, 46, 47, 4,
+ 5, 48, 49,
+ };
+ public static final String[] jjstrLiteralImages = {
+ "", null, null, null, null, null, null, null, null, null, null, null, null,
+ "\72", "\72", "\73", "\173", "\175", null, null, null, null, null, null, null, null,
+ null, null, "\54", "\52", "\43", "\56", "\133", "\135", "\75",};
+ public static final String[] lexStateNames = {
+ "DEFAULT",
+ "IN_RULE",
+ "JAVA_CODE_RULE",
+ "IN_PSEUDOCLASS",
+ };
+ public static final int[] jjnewLexState = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3, -1, -1, 1, 0, 2, -1, 1, 0, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ };
+ static final long[] jjtoToken = {
+ 0x7fefff281L,
+ };
+ static final long[] jjtoSkip = {
+ 0x7eL,
+ };
+ protected SimpleCharStream input_stream;
+ private final int[] jjrounds = new int[50];
+ private final int[] jjstateSet = new int[100];
+ protected char curChar;
+
+ public CSSParserTokenManager(SimpleCharStream stream) {
+ if (SimpleCharStream.staticFlag)
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+ input_stream = stream;
+ }
+
+ public CSSParserTokenManager(SimpleCharStream stream, int lexState) {
+ this(stream);
+ SwitchTo(lexState);
+ }
+
+ public void ReInit(SimpleCharStream stream) {
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+ }
+
+ private void ReInitRounds() {
+ int i;
+ jjround = 0x80000001;
+ for (i = 50; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+ }
+
+ public void ReInit(SimpleCharStream stream, int lexState) {
+ ReInit(stream);
+ SwitchTo(lexState);
+ }
+
+ public void SwitchTo(int lexState) {
+ if (lexState >= 4 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+ }
+
+ protected Token jjFillToken() {
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+ }
+
+ int curLexState = 0;
+ int defaultLexState = 0;
+ int jjnewStateCnt;
+ int jjround;
+ int jjmatchedPos;
+ int jjmatchedKind;
+
+ public Token getNextToken() {
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop:
+ for (; ;) {
+ try {
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e) {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ return matchedToken;
+ }
+
+ switch (curLexState) {
+ case 0:
+ try {
+ input_stream.backup(0);
+ while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) {
+ continue EOFLoop;
+ }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ break;
+ case 1:
+ try {
+ input_stream.backup(0);
+ while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) {
+ continue EOFLoop;
+ }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_1();
+ break;
+ case 2:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_2();
+ break;
+ case 3:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_3();
+ break;
+ }
+ if (jjmatchedKind != 0x7fffffff) {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ matchedToken = jjFillToken();
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ return matchedToken;
+ } else {
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ continue EOFLoop;
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try {
+ input_stream.readChar();
+ input_stream.backup(1);
+ }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ } else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParserTreeConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,40 @@
+/* Generated By:JJTree: Do not edit this line. .\CSSParserTreeConstants.java */
+
+package jaxx.compiler.parser.css;
+
+public interface CSSParserTreeConstants {
+ public int JJTSTYLESHEET = 0;
+ public int JJTRULE = 1;
+ public int JJTSELECTORS = 2;
+ public int JJTSELECTOR = 3;
+ public int JJTJAVACLASS = 4;
+ public int JJTID = 5;
+ public int JJTCLASS = 6;
+ public int JJTPSEUDOCLASS = 7;
+ public int JJTANIMATIONPROPERTIES = 8;
+ public int JJTANIMATIONPROPERTY = 9;
+ public int JJTDECLARATION = 10;
+ public int JJTPROPERTY = 11;
+ public int JJTEXPRESSION = 12;
+ public int JJTJAVACODE = 13;
+ public int JJTIDENTIFIER = 14;
+
+
+ public String[] jjtNodeName = {
+ "Stylesheet",
+ "Rule",
+ "Selectors",
+ "Selector",
+ "JavaClass",
+ "Id",
+ "Class",
+ "PseudoClass",
+ "AnimationProperties",
+ "AnimationProperty",
+ "Declaration",
+ "Property",
+ "Expression",
+ "JavaCode",
+ "Identifier",
+ };
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/JJTCSSParserState.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,123 @@
+/* Generated By:JJTree: Do not edit this line. .\JJTCSSParserState.java */
+
+package jaxx.compiler.parser.css;
+
+class JJTCSSParserState {
+ private java.util.Stack<Node> nodes;
+ private java.util.Stack<Integer> marks;
+
+ private int sp; // number of nodes on stack
+ private int mk; // current mark
+ private boolean node_created;
+
+ JJTCSSParserState() {
+ nodes = new java.util.Stack<Node>();
+ marks = new java.util.Stack<Integer>();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Determines whether the current node was actually closed and
+ pushed. This should only be called in the final user action of a
+ node scope. */
+ boolean nodeCreated() {
+ return node_created;
+ }
+
+ /* Call this to reinitialize the node stack. It is called
+automatically by the parser's ReInit() method. */
+ void reset() {
+ nodes.removeAllElements();
+ marks.removeAllElements();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Returns the root node of the AST. It only makes sense to call
+this after a successful parse. */
+ Node rootNode() {
+ return nodes.elementAt(0);
+ }
+
+ /* Pushes a node on to the stack. */
+ void pushNode(Node n) {
+ nodes.push(n);
+ ++sp;
+ }
+
+ /* Returns the node on the top of the stack, and remove it from the
+ stack. */
+ Node popNode() {
+ if (--sp < mk) {
+ mk = marks.pop();
+ }
+ return nodes.pop();
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ Node peekNode() {
+ return nodes.peek();
+ }
+
+ /* Returns the number of children on the stack in the current node
+ scope. */
+ int nodeArity() {
+ return sp - mk;
+ }
+
+
+ void clearNodeScope(Node n) {
+ while (sp > mk) {
+ popNode();
+ }
+ mk = marks.pop();
+ }
+
+
+ void openNodeScope(Node n) {
+ marks.push(mk);
+ mk = sp;
+ n.jjtOpen();
+ }
+
+
+ /* A definite node is constructed from a specified number of
+children. That number of nodes are popped from the stack and
+made the children of the definite node. Then the definite node
+is pushed on to the stack. */
+ void closeNodeScope(Node n, int num) {
+ mk = marks.pop();
+ while (num-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, num);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ }
+
+
+ /* A conditional node is constructed if its condition is true. All
+the nodes that have been pushed since the node was opened are
+made children of the the conditional node, which is then pushed
+on to the stack. If the condition is false the node is not
+constructed and they are left on the stack. */
+ void closeNodeScope(Node n, boolean condition) {
+ if (condition) {
+ int a = nodeArity();
+ mk = marks.pop();
+ while (a-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, a);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ } else {
+ mk = marks.pop();
+ node_created = false;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/Node.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,51 @@
+/* Generated By:JJTree: Do not edit this line. Node.java */
+
+package jaxx.compiler.parser.css;
+
+/* All AST nodes must implement this interface. It provides basic
+ machinery for constructing the parent and child relationships
+ between nodes. */
+
+public interface Node {
+
+ /**
+ * This method is called after the node has been made the current
+ * node. It indicates that child nodes can now be added to it.
+ */
+ public void jjtOpen();
+
+ /**
+ * This method is called after all the child nodes have been
+ * added.
+ */
+ public void jjtClose();
+
+ /**
+ * This pair of methods are used to inform the node of its
+ * parent.
+ *
+ * @param n node
+ */
+ public void jjtSetParent(Node n);
+
+ public Node jjtGetParent();
+
+ /**
+ * This method tells the node to add its argument to the node's
+ * list of children.
+ *
+ * @param n node
+ * @param i pos
+ */
+ public void jjtAddChild(Node n, int i);
+
+ /**
+ * @param i pos
+ * @return a child node. The children are numbered
+ * from zero, left to right.
+ */
+ public Node jjtGetChild(int i);
+
+ /** @return the number of children the node has. */
+ public int jjtGetNumChildren();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/ParseException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,20 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+package jaxx.compiler.parser.css;
+
+public class ParseException extends jaxx.compiler.parser.java.ParseException {
+ private static final long serialVersionUID = 229575674880359031L;
+
+ public ParseException() {
+ super();
+ }
+
+
+ public ParseException(String message) {
+ super(message);
+ }
+
+
+ public ParseException(String message, int line, int column) {
+ super(message, line, column);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/SimpleCharStream.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,398 @@
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */
+package jaxx.compiler.parser.css;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (without unicode processing).
+ */
+
+public class SimpleCharStream {
+ public static final boolean staticFlag = false;
+ int bufsize;
+ int available;
+ int tokenBegin;
+ public int bufpos = -1;
+ protected int bufline[];
+ protected int bufcolumn[];
+
+ protected int column = 0;
+ protected int line = 1;
+
+ protected boolean prevCharIsCR = false;
+ protected boolean prevCharIsLF = false;
+
+ protected java.io.Reader inputStream;
+
+ protected char[] buffer;
+ protected int maxNextCharInd = 0;
+ protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) {
+ tabSize = i;
+ }
+
+ protected int getTabSize(int i) {
+ return tabSize;
+ }
+
+
+ protected void ExpandBuff(boolean wrapAround) {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try {
+ if (wrapAround) {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+ } else {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos -= tokenBegin);
+ }
+ }
+ catch (Throwable t) {
+ throw new Error(t.getMessage());
+ }
+
+
+ bufsize += 2048;
+ available = bufsize;
+ tokenBegin = 0;
+ }
+
+ protected void FillBuff() throws java.io.IOException {
+ if (maxNextCharInd == available) {
+ if (available == bufsize) {
+ if (tokenBegin > 2048) {
+ bufpos = maxNextCharInd = 0;
+ available = tokenBegin;
+ } else if (tokenBegin < 0)
+ bufpos = maxNextCharInd = 0;
+ else
+ ExpandBuff(false);
+ } else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ int i;
+ try {
+ if ((i = inputStream.read(buffer, maxNextCharInd,
+ available - maxNextCharInd)) == -1) {
+ inputStream.close();
+ throw new java.io.IOException();
+ } else
+ maxNextCharInd += i;
+ }
+ catch (java.io.IOException e) {
+ --bufpos;
+ backup(0);
+ if (tokenBegin == -1)
+ tokenBegin = bufpos;
+ throw e;
+ }
+ }
+
+ public char BeginToken() throws java.io.IOException {
+ tokenBegin = -1;
+ char c = readChar();
+ tokenBegin = bufpos;
+
+ return c;
+ }
+
+ protected void UpdateLineColumn(char c) {
+ column++;
+
+ if (prevCharIsLF) {
+ prevCharIsLF = false;
+ line += (column = 1);
+ } else if (prevCharIsCR) {
+ prevCharIsCR = false;
+ if (c == '\n') {
+ prevCharIsLF = true;
+ } else
+ line += (column = 1);
+ }
+
+ switch (c) {
+ case '\r':
+ prevCharIsCR = true;
+ break;
+ case '\n':
+ prevCharIsLF = true;
+ break;
+ case '\t':
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default:
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ public char readChar() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ if (++bufpos >= maxNextCharInd)
+ FillBuff();
+
+ char c = buffer[bufpos];
+
+ UpdateLineColumn(c);
+ return (c);
+ }
+
+ /**
+ * @return ???
+ * @see #getEndColumn
+ * @deprecated
+ */
+
+ public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @return ???
+ * @see #getEndLine
+ * @deprecated
+ */
+
+ public int getLine() {
+ return bufline[bufpos];
+ }
+
+ public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.Reader dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length) {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public String GetImage() {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ public char[] GetSuffix(int len) {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ public void Done() {
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ *
+ * @param newLine ?
+ * @param newCol ?
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol) {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin) {
+ len = bufpos - tokenBegin + inBuf + 1;
+ } else {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k;
+ int nextColDiff, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len) {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len) {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/SimpleNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,122 @@
+/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
+
+package jaxx.compiler.parser.css;
+
+public class SimpleNode implements Node {
+ protected Node parent;
+ protected Node[] children;
+ protected int id;
+ protected CSSParser parser;
+ public Token firstToken;
+ public Token lastToken;
+
+
+ public SimpleNode(int i) {
+ id = i;
+ }
+
+ public SimpleNode(CSSParser p, int i) {
+ this(i);
+ parser = p;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void jjtOpen() {
+ }
+
+ public void jjtClose() {
+ }
+
+ public void jjtSetParent(Node n) {
+ parent = n;
+ }
+
+ public Node jjtGetParent() {
+ return parent;
+ }
+
+ public SimpleNode getParent() {
+ return (SimpleNode) parent;
+ }
+
+ public void jjtAddChild(Node n, int i) {
+ if (children == null) {
+ children = new Node[i + 1];
+ } else if (i >= children.length) {
+ Node c[] = new Node[i + 1];
+ System.arraycopy(children, 0, c, 0, children.length);
+ children = c;
+ }
+ children[i] = n;
+ }
+
+ public Node jjtGetChild(int i) {
+ return children[i];
+ }
+
+ public SimpleNode getChild(int i) {
+ return (SimpleNode) children[i];
+ }
+
+ public int jjtGetNumChildren() {
+ return (children == null) ? 0 : children.length;
+ }
+
+ /* You can override these two methods in subclasses of SimpleNode to
+customize the way the node appears when the tree is dumped. If
+your output uses more than one line you should override
+toString(String), otherwise overriding toString() is probably all
+you need to do. */
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getText() + "]";
+ }
+
+ public String toString(String prefix) {
+ return prefix + toString();
+ }
+
+ /* Override this method if you want to customize how the node dumps
+ out its children. */
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+ if (children != null) {
+ for (Node aChildren : children) {
+ SimpleNode n = (SimpleNode) aChildren;
+ if (n != null) {
+ n.dump(prefix + " ");
+ }
+ }
+ }
+ }
+
+ private void appendSpecialTokens(StringBuffer s, Token st) {
+ if (st != null) {
+ appendSpecialTokens(s, st.specialToken);
+ s.append(st.image);
+ }
+ }
+
+
+ /** @return the text of the tokens comprising this node. */
+ public String getText() {
+ StringBuffer text = new StringBuffer();
+ Token t = firstToken;
+ while (t != null) {
+ appendSpecialTokens(text, t.specialToken);
+ text.append(t.image);
+ if (t == lastToken)
+ break;
+ t = t.next;
+ }
+
+ return text.toString();
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/Token.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,76 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+package jaxx.compiler.parser.css;
+
+/** Describes the input token stream. */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /** The string image of the token. */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /** Returns the image. */
+ public String toString() {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ * <p/>
+ * case MyParserConstants.ID : return new IDToken();
+ * <p/>
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ *
+ * @param ofKind kind of token
+ * @return the new token
+ */
+ public static Token newToken(int ofKind) {
+ switch (ofKind) {
+ default:
+ return new Token();
+ }
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/TokenMgrError.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,126 @@
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+package jaxx.compiler.parser.css;
+
+public class TokenMgrError extends Error {
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /** Lexical error occured. */
+ static final int LEXICAL_ERROR = 0;
+
+ /** An attempt wass made to create a second instance of a static token manager. */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /** Tried to change to an invalid lexical state. */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /** Detected (and bailed out of) an infinite loop in the token manager. */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+ private static final long serialVersionUID = -4308847190164230336L;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ *
+ * @param str text to espace
+ * @return the espaced text
+ */
+ protected static String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i)) {
+ case 0:
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * @param EOFSeen : indicates if EOF caused the lexicl error
+ * @param lexState : lexical state in which this error occured
+ * @param errorLine : line number when the error occured
+ * @param errorColumn : column number when the error occured
+ * @param errorAfter : prefix that was seen before this error occured
+ * @param curChar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ * @return a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return ("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ * <p/>
+ * "Internal Error : Please file a bug report .... "
+ * <p/>
+ * from this method for such cases in the release version of your parser.
+ */
+ @Override
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JJTJavaParserState.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,123 @@
+/* Generated By:JJTree: Do not edit this line. .\JJTJavaParserState.java */
+
+package jaxx.compiler.parser.java;
+
+class JJTJavaParserState {
+ private java.util.Stack<Node> nodes;
+ private java.util.Stack<Integer> marks;
+
+ private int sp; // number of nodes on stack
+ private int mk; // current mark
+ private boolean node_created;
+
+ JJTJavaParserState() {
+ nodes = new java.util.Stack<Node>();
+ marks = new java.util.Stack<Integer>();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Determines whether the current node was actually closed and
+ pushed. This should only be called in the final user action of a
+ node scope. */
+ boolean nodeCreated() {
+ return node_created;
+ }
+
+ /* Call this to reinitialize the node stack. It is called
+automatically by the parser's ReInit() method. */
+ void reset() {
+ nodes.removeAllElements();
+ marks.removeAllElements();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Returns the root node of the AST. It only makes sense to call
+this after a successful parse. */
+ Node rootNode() {
+ return nodes.elementAt(0);
+ }
+
+ /* Pushes a node on to the stack. */
+ void pushNode(Node n) {
+ nodes.push(n);
+ ++sp;
+ }
+
+ /* Returns the node on the top of the stack, and remove it from the
+ stack. */
+ Node popNode() {
+ if (--sp < mk) {
+ mk = marks.pop();
+ }
+ return nodes.pop();
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ Node peekNode() {
+ return nodes.peek();
+ }
+
+ /* Returns the number of children on the stack in the current node
+ scope. */
+ int nodeArity() {
+ return sp - mk;
+ }
+
+
+ void clearNodeScope(Node n) {
+ while (sp > mk) {
+ popNode();
+ }
+ mk = marks.pop();
+ }
+
+
+ void openNodeScope(Node n) {
+ marks.push(mk);
+ mk = sp;
+ n.jjtOpen();
+ }
+
+
+ /* A definite node is constructed from a specified number of
+children. That number of nodes are popped from the stack and
+made the children of the definite node. Then the definite node
+is pushed on to the stack. */
+ void closeNodeScope(Node n, int num) {
+ mk = marks.pop();
+ while (num-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, num);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ }
+
+
+ /* A conditional node is constructed if its condition is true. All
+the nodes that have been pushed since the node was opened are
+made children of the the conditional node, which is then pushed
+on to the stack. If the condition is false the node is not
+constructed and they are left on the stack. */
+ void closeNodeScope(Node n, boolean condition) {
+ if (condition) {
+ int a = nodeArity();
+ mk = marks.pop();
+ while (a-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, a);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ } else {
+ mk = marks.pop();
+ node_created = false;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Java1.5.jj)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,5125 @@
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. ./Java1.5.jj */
+/*@egen*/
+/*
+ * Copyright \u00a9 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements. Use is subject to license terms.
+ * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries. Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited. Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+// Slightly modified version of javacc's reference 1.5 grammar, tweaked for
+// usage with JAXX. There are two main areas of changes: several new
+// nonterminals were added to make identifying certain constructs easier,
+// and the Line nonterminal was added to support JAXX's script tags.
+// Several of the new changes are inefficient and require excess lookahead,
+// but at this point I'd rather have inefficiency than risk breaking it during
+// attempted optimizations.
+
+options {
+ JAVA_UNICODE_ESCAPE = true;
+ ERROR_REPORTING = false;
+ STATIC = false;
+ JDK_VERSION = "1.4";
+}
+
+PARSER_BEGIN(JavaParser)
+package jaxx.parser;
+
+import java.io.*;
+
+/**
+ * Grammar to parse Java version 1.5
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants/*@egen*/
+{/*@bgen(jjtree)*/
+ protected JJTJavaParserState jjtree = new JJTJavaParserState();
+
+/*@egen*/
+ /**
+ * Class to hold modifiers.
+ */
+ static public final class ModifierSet
+ {
+ /* Definitions of the bits in the modifiers field. */
+ public static final int PUBLIC = 0x0001;
+ public static final int PROTECTED = 0x0002;
+ public static final int PRIVATE = 0x0004;
+ public static final int ABSTRACT = 0x0008;
+ public static final int STATIC = 0x0010;
+ public static final int FINAL = 0x0020;
+ public static final int SYNCHRONIZED = 0x0040;
+ public static final int NATIVE = 0x0080;
+ public static final int TRANSIENT = 0x0100;
+ public static final int VOLATILE = 0x0200;
+ public static final int STRICTFP = 0x1000;
+
+ /** A set of accessors that indicate whether the specified modifier
+ is in the set. */
+
+ public boolean isPublic(int modifiers)
+ {
+ return (modifiers & PUBLIC) != 0;
+ }
+
+ public boolean isProtected(int modifiers)
+ {
+ return (modifiers & PROTECTED) != 0;
+ }
+
+ public boolean isPrivate(int modifiers)
+ {
+ return (modifiers & PRIVATE) != 0;
+ }
+
+ public boolean isStatic(int modifiers)
+ {
+ return (modifiers & STATIC) != 0;
+ }
+
+ public boolean isAbstract(int modifiers)
+ {
+ return (modifiers & ABSTRACT) != 0;
+ }
+
+ public boolean isFinal(int modifiers)
+ {
+ return (modifiers & FINAL) != 0;
+ }
+
+ public boolean isNative(int modifiers)
+ {
+ return (modifiers & NATIVE) != 0;
+ }
+
+ public boolean isStrictfp(int modifiers)
+ {
+ return (modifiers & STRICTFP) != 0;
+ }
+
+ public boolean isSynchronized(int modifiers)
+ {
+ return (modifiers & SYNCHRONIZED) != 0;
+ }
+
+ public boolean isTransient(int modifiers)
+ {
+ return (modifiers & TRANSIENT) != 0;
+ }
+
+ public boolean isVolatile(int modifiers)
+ {
+ return (modifiers & VOLATILE) != 0;
+ }
+
+ /**
+ * Removes the given modifier.
+ */
+ static int removeModifier(int modifiers, int mod)
+ {
+ return modifiers & ~mod;
+ }
+ }
+
+ public JavaParser(String fileName)
+ {
+ this(System.in);
+ try { ReInit(new FileInputStream(new File(fileName))); }
+ catch(Exception e) { e.printStackTrace(); }
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public SimpleNode popNode()
+ {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+ public static void main(String args[]) {
+ JavaParser parser;
+ if (args.length == 0) {
+ System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
+ parser = new JavaParser(System.in);
+ } else if (args.length == 1) {
+ System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
+ try {
+ parser = new JavaParser(new java.io.FileInputStream(args[0]));
+ } catch (java.io.FileNotFoundException e) {
+ System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
+ return;
+ }
+ } else {
+ System.out.println("Java Parser Version 1.1: Usage is one of:");
+ System.out.println(" java JavaParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java JavaParser inputfile");
+ return;
+ }
+ try {
+ parser.CompilationUnit();
+ System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
+ }
+ }
+
+}
+
+PARSER_END(JavaParser)
+
+/* COMMENTS */
+
+MORE :
+{
+ <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
+|
+ "/*" : IN_MULTI_LINE_COMMENT
+}
+
+SPECIAL_TOKEN:
+{
+ <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+>
+}
+
+SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?>
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+ <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+ <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+MORE :
+{
+ < ~[] >
+}
+
+/* RESERVED WORDS AND LITERALS */
+
+TOKEN :
+{
+ < ABSTRACT: "abstract" >
+| < ASSERT: "assert" >
+| < BOOLEAN: "boolean" >
+| < BREAK: "break" >
+| < BYTE: "byte" >
+| < CASE: "case" >
+| < CATCH: "catch" >
+| < CHAR: "char" >
+| < CLASS: "class" >
+| < CONST: "const" >
+| < CONTINUE: "continue" >
+| < _DEFAULT: "default" >
+| < DO: "do" >
+| < DOUBLE: "double" >
+| < ELSE: "else" >
+| < ENUM: "enum" >
+| < EXTENDS: "extends" >
+| < FALSE: "false" >
+| < FINAL: "final" >
+| < FINALLY: "finally" >
+| < FLOAT: "float" >
+| < FOR: "for" >
+| < GOTO: "goto" >
+| < IF: "if" >
+| < IMPLEMENTS: "implements" >
+| < IMPORT: "import" >
+| < INSTANCEOF: "instanceof" >
+| < INT: "int" >
+| < INTERFACE: "interface" >
+| < LONG: "long" >
+| < NATIVE: "native" >
+| < NEW: "new" >
+| < NULL: "null" >
+| < PACKAGE: "package">
+| < PRIVATE: "private" >
+| < PROTECTED: "protected" >
+| < PUBLIC: "public" >
+| < RETURN: "return" >
+| < SHORT: "short" >
+| < STATIC: "static" >
+| < STRICTFP: "strictfp" >
+| < SUPER: "super" >
+| < SWITCH: "switch" >
+| < SYNCHRONIZED: "synchronized" >
+| < THIS: "this" >
+| < THROW: "throw" >
+| < THROWS: "throws" >
+| < TRANSIENT: "transient" >
+| < TRUE: "true" >
+| < TRY: "try" >
+| < VOID: "void" >
+| < VOLATILE: "volatile" >
+| < WHILE: "while" >
+}
+
+/* LITERALS */
+
+TOKEN :
+{
+ < INTEGER_LITERAL:
+ <DECIMAL_LITERAL> (["l","L"])?
+ | <HEX_LITERAL> (["l","L"])?
+ | <OCTAL_LITERAL> (["l","L"])?
+ >
+|
+ < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
+|
+ < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
+|
+ < #OCTAL_LITERAL: "0" (["0"-"7"])* >
+|
+ < FLOATING_POINT_LITERAL:
+ <DECIMAL_FLOATING_POINT_LITERAL>
+ | <HEXADECIMAL_FLOATING_POINT_LITERAL>
+ >
+|
+ < #DECIMAL_FLOATING_POINT_LITERAL:
+ (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])?
+ | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"]
+ >
+|
+ < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|
+ < #HEXADECIMAL_FLOATING_POINT_LITERAL:
+ "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ >
+|
+ < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
+|
+ < CHARACTER_LITERAL:
+ "'"
+ ( (~["'","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )
+ "'"
+ >
+|
+ < STRING_LITERAL:
+ "\""
+ ( (~["\"","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )*
+ "\""
+ >
+}
+
+/* IDENTIFIERS */
+
+TOKEN :
+{
+ < IDENTIFIER: <LETTER> (<PART_LETTER>)* >
+|
+ < #LETTER:
+ [ // all chars for which Character.isIdentifierStart is true
+ "$",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u064a",
+ "\u0671"-"\u06d3",
+ "\u06d5",
+ "\u06e5"-"\u06e6",
+ "\u06fa"-"\u06fc",
+ "\u0710",
+ "\u0712"-"\u072c",
+ "\u0780"-"\u07a5",
+ "\u0905"-"\u0939",
+ "\u093d",
+ "\u0950",
+ "\u0958"-"\u0961",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e1",
+ "\u09f0"-"\u09f3",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a72"-"\u0a74",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3d",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c60"-"\u0c61",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d60"-"\u0d61",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0e01"-"\u0e30",
+ "\u0e32"-"\u0e33",
+ "\u0e3f"-"\u0e46",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb0",
+ "\u0eb2"-"\u0eb3",
+ "\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f40"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f88"-"\u0f8b",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u1050"-"\u1055",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17b3",
+ "\u17db",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a8",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u203f"-"\u2040",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u3029",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d",
+ "\ufb1f"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\uff04",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6"
+ ]
+ >
+|
+ < #PART_LETTER:
+ [ // all chars for which Character.isIdentifierPart is true
+ "\u0000"-"\u0008",
+ "\u000e"-"\u001b",
+ "$",
+ "0"-"9",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u007f"-"\u009f",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u0300"-"\u034e",
+ "\u0360"-"\u0362",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u0483"-"\u0486",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u0591"-"\u05a1",
+ "\u05a3"-"\u05b9",
+ "\u05bb"-"\u05bd",
+ "\u05bf",
+ "\u05c1"-"\u05c2",
+ "\u05c4",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u0655",
+ "\u0660"-"\u0669",
+ "\u0670"-"\u06d3",
+ "\u06d5"-"\u06dc",
+ "\u06df"-"\u06e8",
+ "\u06ea"-"\u06ed",
+ "\u06f0"-"\u06fc",
+ "\u070f"-"\u072c",
+ "\u0730"-"\u074a",
+ "\u0780"-"\u07b0",
+ "\u0901"-"\u0903",
+ "\u0905"-"\u0939",
+ "\u093c"-"\u094d",
+ "\u0950"-"\u0954",
+ "\u0958"-"\u0963",
+ "\u0966"-"\u096f",
+ "\u0981"-"\u0983",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09bc",
+ "\u09be"-"\u09c4",
+ "\u09c7"-"\u09c8",
+ "\u09cb"-"\u09cd",
+ "\u09d7",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e3",
+ "\u09e6"-"\u09f3",
+ "\u0a02",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a3c",
+ "\u0a3e"-"\u0a42",
+ "\u0a47"-"\u0a48",
+ "\u0a4b"-"\u0a4d",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a66"-"\u0a74",
+ "\u0a81"-"\u0a83",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abc"-"\u0ac5",
+ "\u0ac7"-"\u0ac9",
+ "\u0acb"-"\u0acd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0ae6"-"\u0aef",
+ "\u0b01"-"\u0b03",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3c"-"\u0b43",
+ "\u0b47"-"\u0b48",
+ "\u0b4b"-"\u0b4d",
+ "\u0b56"-"\u0b57",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b66"-"\u0b6f",
+ "\u0b82"-"\u0b83",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0bbe"-"\u0bc2",
+ "\u0bc6"-"\u0bc8",
+ "\u0bca"-"\u0bcd",
+ "\u0bd7",
+ "\u0be7"-"\u0bef",
+ "\u0c01"-"\u0c03",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c3e"-"\u0c44",
+ "\u0c46"-"\u0c48",
+ "\u0c4a"-"\u0c4d",
+ "\u0c55"-"\u0c56",
+ "\u0c60"-"\u0c61",
+ "\u0c66"-"\u0c6f",
+ "\u0c82"-"\u0c83",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cbe"-"\u0cc4",
+ "\u0cc6"-"\u0cc8",
+ "\u0cca"-"\u0ccd",
+ "\u0cd5"-"\u0cd6",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0ce6"-"\u0cef",
+ "\u0d02"-"\u0d03",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d3e"-"\u0d43",
+ "\u0d46"-"\u0d48",
+ "\u0d4a"-"\u0d4d",
+ "\u0d57",
+ "\u0d60"-"\u0d61",
+ "\u0d66"-"\u0d6f",
+ "\u0d82"-"\u0d83",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0dca",
+ "\u0dcf"-"\u0dd4",
+ "\u0dd6",
+ "\u0dd8"-"\u0ddf",
+ "\u0df2"-"\u0df3",
+ "\u0e01"-"\u0e3a",
+ "\u0e3f"-"\u0e4e",
+ "\u0e50"-"\u0e59",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb9",
+ "\u0ebb"-"\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0ec8"-"\u0ecd",
+ "\u0ed0"-"\u0ed9",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f18"-"\u0f19",
+ "\u0f20"-"\u0f29",
+ "\u0f35",
+ "\u0f37",
+ "\u0f39",
+ "\u0f3e"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f71"-"\u0f84",
+ "\u0f86"-"\u0f8b",
+ "\u0f90"-"\u0f97",
+ "\u0f99"-"\u0fbc",
+ "\u0fc6",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u102c"-"\u1032",
+ "\u1036"-"\u1039",
+ "\u1040"-"\u1049",
+ "\u1050"-"\u1059",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u1369"-"\u1371",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17d3",
+ "\u17db",
+ "\u17e0"-"\u17e9",
+ "\u180b"-"\u180e",
+ "\u1810"-"\u1819",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a9",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u200c"-"\u200f",
+ "\u202a"-"\u202e",
+ "\u203f"-"\u2040",
+ "\u206a"-"\u206f",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u20d0"-"\u20dc",
+ "\u20e1",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u302f",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u3099"-"\u309a",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe20"-"\ufe23",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\ufeff",
+ "\uff04",
+ "\uff10"-"\uff19",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6",
+ "\ufff9"-"\ufffb"
+ ]
+ >
+}
+
+/* SEPARATORS */
+
+TOKEN :
+{
+ < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+| < AT: "@" >
+}
+
+/* OPERATORS */
+
+TOKEN :
+{
+ < ASSIGN: "=" >
+| < LT: "<" >
+| < BANG: "!" >
+| < TILDE: "~" >
+| < HOOK: "?" >
+| < COLON: ":" >
+| < EQ: "==" >
+| < LE: "<=" >
+| < GE: ">=" >
+| < NE: "!=" >
+| < SC_OR: "||" >
+| < SC_AND: "&&" >
+| < INCR: "++" >
+| < DECR: "--" >
+| < PLUS: "+" >
+| < MINUS: "-" >
+| < STAR: "*" >
+| < SLASH: "/" >
+| < BIT_AND: "&" >
+| < BIT_OR: "|" >
+| < XOR: "^" >
+| < REM: "%" >
+| < LSHIFT: "<<" >
+| < PLUSASSIGN: "+=" >
+| < MINUSASSIGN: "-=" >
+| < STARASSIGN: "*=" >
+| < SLASHASSIGN: "/=" >
+| < ANDASSIGN: "&=" >
+| < ORASSIGN: "|=" >
+| < XORASSIGN: "^=" >
+| < REMASSIGN: "%=" >
+| < LSHIFTASSIGN: "<<=" >
+| < RSIGNEDSHIFTASSIGN: ">>=" >
+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
+| < ELLIPSIS: "..." >
+}
+
+/* >'s need special attention due to generics syntax. */
+TOKEN :
+{
+ < RUNSIGNEDSHIFT: ">>>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT;
+ input_stream.backup(2);
+ matchedToken.image = ">";
+ }
+| < RSIGNEDSHIFT: ">>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT;
+ input_stream.backup(1);
+ matchedToken.image = ">";
+ }
+| < GT: ">" >
+}
+
+boolean Line() :
+{/*@bgen(jjtree) Line */
+ SimpleNode jjtn000 = new SimpleNode(JJTLINE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers;
+}
+{/*@bgen(jjtree) Line */
+ try {
+/*@egen*/
+ <EOF>/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return true;
+ }
+|
+ LOOKAHEAD(BlockStatement())
+ BlockStatement()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{")
+ ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false))
+ ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ LOOKAHEAD(Expression())
+ Expression()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ ImportDeclaration()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*****************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ *****************************************/
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit():
+{/*@bgen(jjtree) CompilationUnit */
+ SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) CompilationUnit */
+ try {
+/*@egen*/
+ [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ]
+ ( ImportDeclaration() )*
+ ( TypeDeclaration() )*
+ ( < "\u001a" > )?
+ ( <STUFF_TO_IGNORE: ~[]> )?
+ <EOF>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PackageDeclaration():
+{/*@bgen(jjtree) PackageDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PackageDeclaration */
+ try {
+/*@egen*/
+ Modifiers() "package" Name() ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ImportDeclaration():
+{/*@bgen(jjtree) ImportDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ImportDeclaration */
+ try {
+/*@egen*/
+ "import" [ "static" ] Name() [ "." "*" ] ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+
+int Modifiers():
+{/*@bgen(jjtree) Modifiers */
+ SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers = 0;
+}
+{/*@bgen(jjtree) Modifiers */
+ try {
+/*@egen*/
+ (
+ LOOKAHEAD(2)
+ (
+ "public" { modifiers |= ModifierSet.PUBLIC; }
+ |
+ "static" { modifiers |= ModifierSet.STATIC; }
+ |
+ "protected" { modifiers |= ModifierSet.PROTECTED; }
+ |
+ "private" { modifiers |= ModifierSet.PRIVATE; }
+ |
+ "final" { modifiers |= ModifierSet.FINAL; }
+ |
+ "abstract" { modifiers |= ModifierSet.ABSTRACT; }
+ |
+ "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; }
+ |
+ "native" { modifiers |= ModifierSet.NATIVE; }
+ |
+ "transient" { modifiers |= ModifierSet.TRANSIENT; }
+ |
+ "volatile" { modifiers |= ModifierSet.VOLATILE; }
+ |
+ "strictfp" { modifiers |= ModifierSet.STRICTFP; }
+ |
+ Annotation()
+ )
+ )*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+
+ {
+ return modifiers;
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * Declaration syntax follows.
+ */
+void TypeDeclaration():
+{/*@bgen(jjtree) TypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers;
+}
+{/*@bgen(jjtree) TypeDeclaration */
+ try {
+/*@egen*/
+ ";"
+|
+ modifiers = Modifiers()
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void ClassOrInterfaceDeclaration(int modifiers):
+{/*@bgen(jjtree) ClassOrInterfaceDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ boolean isInterface = false;
+}
+{/*@bgen(jjtree) ClassOrInterfaceDeclaration */
+ try {
+/*@egen*/
+ ( "class" | "interface" { isInterface = true; } )
+ <IDENTIFIER>
+ [ TypeParameters() ]
+ [ ExtendsList(isInterface) ]
+ [ ImplementsList(isInterface) ]
+ ClassOrInterfaceBody(isInterface)/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ExtendsList(boolean isInterface):
+{/*@bgen(jjtree) ExtendsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ boolean extendsMoreThanOne = false;
+}
+{/*@bgen(jjtree) ExtendsList */
+ try {
+/*@egen*/
+ "extends" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ if (extendsMoreThanOne && !isInterface)
+ throw new ParseException("A class cannot extend more than one other class");
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ImplementsList(boolean isInterface):
+{/*@bgen(jjtree) ImplementsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ImplementsList */
+ try {
+/*@egen*/
+ "implements" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() )*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot implement other interfaces");
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EnumDeclaration(int modifiers):
+{/*@bgen(jjtree) EnumDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EnumDeclaration */
+ try {
+/*@egen*/
+ "enum" <IDENTIFIER>
+ [ ImplementsList(false) ]
+ EnumBody()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EnumBody():
+{/*@bgen(jjtree) EnumBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EnumBody */
+ try {
+/*@egen*/
+ "{"
+ [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
+ [ "," ]
+ [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
+ "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EnumConstant():
+{/*@bgen(jjtree) EnumConstant */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EnumConstant */
+ try {
+/*@egen*/
+ Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeParameters():
+{/*@bgen(jjtree) TypeParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeParameters */
+ try {
+/*@egen*/
+ "<" TypeParameter() ( "," TypeParameter() )* ">"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeParameter():
+{/*@bgen(jjtree) TypeParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeParameter */
+ try {
+/*@egen*/
+ <IDENTIFIER> [ TypeBound() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeBound():
+{/*@bgen(jjtree) TypeBound */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeBound */
+ try {
+/*@egen*/
+ "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ClassOrInterfaceBody(boolean isInterface):
+{/*@bgen(jjtree) ClassOrInterfaceBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ClassOrInterfaceBody */
+ try {
+/*@egen*/
+ "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ClassOrInterfaceBodyDeclaration(boolean isInterface):
+{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ boolean isNestedInterface = false;
+ int modifiers;
+}
+{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ Initializer()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot have initializers");
+ }
+|
+ modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do
+ // more checks, pass the modifiers down to the member
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" )
+ ConstructorDeclaration()
+ |
+ LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) )
+ FieldDeclaration(modifiers)
+ |
+ MethodDeclaration(modifiers)
+ )
+|
+ ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void FieldDeclaration(int modifiers):
+{/*@bgen(jjtree) FieldDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) FieldDeclaration */
+ try {
+/*@egen*/
+ // Modifiers are already matched in the caller
+ Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void VariableDeclarator():
+{/*@bgen(jjtree) VariableDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) VariableDeclarator */
+ try {
+/*@egen*/
+ VariableDeclaratorId() [ "=" VariableInitializer() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void VariableDeclaratorId():
+{/*@bgen(jjtree) VariableDeclaratorId */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) VariableDeclaratorId */
+ try {
+/*@egen*/
+ <IDENTIFIER> ( "[" "]" )*/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void VariableInitializer():
+{/*@bgen(jjtree) VariableInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) VariableInitializer */
+ try {
+/*@egen*/
+ ArrayInitializer()
+|
+ Expression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ArrayInitializer():
+{/*@bgen(jjtree) ArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ArrayInitializer */
+ try {
+/*@egen*/
+ "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MethodDeclaration(int modifiers):
+{/*@bgen(jjtree) MethodDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MethodDeclaration */
+ try {
+/*@egen*/
+ // Modifiers already matched in the caller!
+ [ TypeParameters() ]
+ ResultType()
+ MethodDeclarator() [ "throws" NameList() ]
+ ( Block() | ";" )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MethodDeclarator():
+{/*@bgen(jjtree) MethodDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MethodDeclarator */
+ try {
+/*@egen*/
+ <IDENTIFIER> FormalParameters() ( "[" "]" )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void FormalParameters():
+{/*@bgen(jjtree) FormalParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) FormalParameters */
+ try {
+/*@egen*/
+ "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void FormalParameter():
+{/*@bgen(jjtree) FormalParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) FormalParameter */
+ try {
+/*@egen*/
+ Modifiers() Type() [ "..." ] VariableDeclaratorId()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConstructorDeclaration():
+{/*@bgen(jjtree) ConstructorDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConstructorDeclaration */
+ try {
+/*@egen*/
+ [ TypeParameters() ]
+ // Modifiers matched in the caller
+ <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+ "{"
+ [ LOOKAHEAD(ExplicitConstructorInvocation())
+ ExplicitConstructorInvocation()
+ ]
+ ( BlockStatement() )*
+ "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ExplicitConstructorInvocation():
+{/*@bgen(jjtree) ExplicitConstructorInvocation */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ExplicitConstructorInvocation */
+ try {
+/*@egen*/
+ ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ]
+ [ TypeArguments() ] ("this"|"super") Arguments() ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Initializer():
+{/*@bgen(jjtree) Initializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Initializer */
+ try {
+/*@egen*/
+ [ "static" ] Block()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type():
+{/*@bgen(jjtree) Type */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Type */
+ try {
+/*@egen*/
+ LOOKAHEAD(2) ReferenceType()
+ |
+ PrimitiveType()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ReferenceType():
+{/*@bgen(jjtree) ReferenceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ReferenceType */
+ try {
+/*@egen*/
+ PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+
+ |
+ ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ClassOrInterfaceType():
+{/*@bgen(jjtree) ClassOrInterfaceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ClassOrInterfaceType */
+ try {
+/*@egen*/
+ <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ]
+ ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeArguments():
+{/*@bgen(jjtree) TypeArguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeArguments */
+ try {
+/*@egen*/
+ "<" TypeArgument() ( "," TypeArgument() )* ">"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeArgument():
+{/*@bgen(jjtree) TypeArgument */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeArgument */
+ try {
+/*@egen*/
+ ReferenceType()
+ |
+ "?" [ WildcardBounds() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void WildcardBounds():
+{/*@bgen(jjtree) WildcardBounds */
+ SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) WildcardBounds */
+ try {
+/*@egen*/
+ "extends" ReferenceType()
+ |
+ "super" ReferenceType()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void PrimitiveType():
+{/*@bgen(jjtree) PrimitiveType */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimitiveType */
+ try {
+/*@egen*/
+ "boolean"
+|
+ "char"
+|
+ "byte"
+|
+ "short"
+|
+ "int"
+|
+ "long"
+|
+ "float"
+|
+ "double"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ResultType():
+{/*@bgen(jjtree) ResultType */
+ SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ResultType */
+ try {
+/*@egen*/
+ "void"
+|
+ Type()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Name():
+/*
+ * A lookahead of 2 is required below since "Name" can be followed
+ * by a ".*" when used in the context of an "ImportDeclaration".
+ */
+{/*@bgen(jjtree) Name */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAME);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Name */
+ try {
+/*@egen*/
+ <IDENTIFIER>
+ ( LOOKAHEAD(2) "." <IDENTIFIER>
+ )*/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void NameList():
+{/*@bgen(jjtree) NameList */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) NameList */
+ try {
+/*@egen*/
+ Name() ( "," Name() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/*
+ * Expression syntax follows.
+ */
+
+void Expression():
+/*
+ * This expansion has been written this way instead of:
+ * Assignment() | ConditionalExpression()
+ * for performance reasons.
+ * However, it is a weakening of the grammar for it allows the LHS of
+ * assignments to be any conditional expression whereas it can only be
+ * a primary expression. Consider adding a semantic predicate to work
+ * around this.
+ */
+{/*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Expression */
+ try {
+/*@egen*/
+ ConditionalExpression()
+ [
+ LOOKAHEAD(2)
+ AssignmentOperator() Expression()
+ ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AssignmentOperator():
+{/*@bgen(jjtree) AssignmentOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AssignmentOperator */
+ try {
+/*@egen*/
+ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AssignmentExpression():
+{/*@bgen(jjtree) AssignmentExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AssignmentExpression */
+ try {
+/*@egen*/
+ PrimaryExpression() AssignmentOperator() Expression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConditionalExpression():
+{/*@bgen(jjtree) ConditionalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConditionalExpression */
+ try {
+/*@egen*/
+ ConditionalOrExpression() [ "?" Expression() ":" Expression() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConditionalOrExpression():
+{/*@bgen(jjtree) ConditionalOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConditionalOrExpression */
+ try {
+/*@egen*/
+ ConditionalAndExpression() ( "||" ConditionalAndExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConditionalAndExpression():
+{/*@bgen(jjtree) ConditionalAndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConditionalAndExpression */
+ try {
+/*@egen*/
+ InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void InclusiveOrExpression():
+{/*@bgen(jjtree) InclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) InclusiveOrExpression */
+ try {
+/*@egen*/
+ ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ExclusiveOrExpression():
+{/*@bgen(jjtree) ExclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ExclusiveOrExpression */
+ try {
+/*@egen*/
+ AndExpression() ( "^" AndExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AndExpression():
+{/*@bgen(jjtree) AndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AndExpression */
+ try {
+/*@egen*/
+ EqualityExpression() ( "&" EqualityExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EqualityExpression():
+{/*@bgen(jjtree) EqualityExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EqualityExpression */
+ try {
+/*@egen*/
+ InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void InstanceOfExpression():
+{/*@bgen(jjtree) InstanceOfExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) InstanceOfExpression */
+ try {
+/*@egen*/
+ RelationalExpression() [ "instanceof" Type() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void RelationalExpression():
+{/*@bgen(jjtree) RelationalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) RelationalExpression */
+ try {
+/*@egen*/
+ ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ShiftExpression():
+{/*@bgen(jjtree) ShiftExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ShiftExpression */
+ try {
+/*@egen*/
+ AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AdditiveExpression():
+{/*@bgen(jjtree) AdditiveExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AdditiveExpression */
+ try {
+/*@egen*/
+ MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MultiplicativeExpression():
+{/*@bgen(jjtree) MultiplicativeExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MultiplicativeExpression */
+ try {
+/*@egen*/
+ UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void UnaryExpression():
+{/*@bgen(jjtree) UnaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) UnaryExpression */
+ try {
+/*@egen*/
+ ( "+" | "-" ) UnaryExpression()
+|
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PreIncrementExpression():
+{/*@bgen(jjtree) PreIncrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PreIncrementExpression */
+ try {
+/*@egen*/
+ "++" PrimaryExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PreDecrementExpression():
+{/*@bgen(jjtree) PreDecrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PreDecrementExpression */
+ try {
+/*@egen*/
+ "--" PrimaryExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void UnaryExpressionNotPlusMinus():
+{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */
+ try {
+/*@egen*/
+ ( "~" | "!" ) UnaryExpression()
+|
+ LOOKAHEAD( CastLookahead() )
+ CastExpression()
+|
+ PostfixExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+// This production is to determine lookahead only. The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+// this.
+void CastLookahead():
+{/*@bgen(jjtree) CastLookahead */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) CastLookahead */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ "(" PrimitiveType()
+|
+ LOOKAHEAD("(" Type() "[")
+ "(" Type() "[" "]"
+|
+ "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PostfixExpression():
+{/*@bgen(jjtree) PostfixExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PostfixExpression */
+ try {
+/*@egen*/
+ PrimaryExpression() [ PostfixOperator() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PostfixOperator():
+{/*@bgen(jjtree) PostfixOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PostfixOperator */
+ try {
+/*@egen*/
+ "++" | "--"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void CastExpression():
+{/*@bgen(jjtree) CastExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) CastExpression */
+ try {
+/*@egen*/
+ LOOKAHEAD("(" PrimitiveType())
+ "(" Type() ")" UnaryExpression()
+|
+ "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PrimaryExpression():
+{/*@bgen(jjtree) PrimaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimaryExpression */
+ try {
+/*@egen*/
+ PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberSelector():
+{/*@bgen(jjtree) MemberSelector */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberSelector */
+ try {
+/*@egen*/
+ "." TypeArguments() <IDENTIFIER>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PrimaryPrefix():
+{/*@bgen(jjtree) PrimaryPrefix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimaryPrefix */
+ try {
+/*@egen*/
+ Literal()
+|
+ LOOKAHEAD( ( <IDENTIFIER> "." )* "this" )
+ ( <IDENTIFIER> "." )*
+ "this"
+|
+ "super" "." <IDENTIFIER>
+|
+ "(" Expression() ")"
+|
+ AllocationExpression()
+|
+ LOOKAHEAD( ResultType() "." "class" )
+ ResultType() "." "class"
+|
+ Name()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PrimarySuffix():
+{/*@bgen(jjtree) PrimarySuffix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimarySuffix */
+ try {
+/*@egen*/
+ LOOKAHEAD("." "super" ".")
+ "." "super"
+|
+ LOOKAHEAD("." "this")
+ "." "this"
+|
+ LOOKAHEAD(2)
+ "." AllocationExpression()
+|
+ LOOKAHEAD(3)
+ MemberSelector()
+|
+ "[" Expression() "]"
+|
+ "." <IDENTIFIER>
+|
+ Arguments()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Literal():
+{/*@bgen(jjtree) Literal */
+ SimpleNode jjtn000 = new SimpleNode(JJTLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Literal */
+ try {
+/*@egen*/
+ <INTEGER_LITERAL>
+|
+ <FLOATING_POINT_LITERAL>
+|
+ <CHARACTER_LITERAL>
+|
+ <STRING_LITERAL>
+|
+ BooleanLiteral()
+|
+ NullLiteral()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void BooleanLiteral():
+{/*@bgen(jjtree) BooleanLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) BooleanLiteral */
+ try {
+/*@egen*/
+ "true"
+|
+ "false"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void NullLiteral():
+{/*@bgen(jjtree) NullLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) NullLiteral */
+ try {
+/*@egen*/
+ "null"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Arguments():
+{/*@bgen(jjtree) Arguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Arguments */
+ try {
+/*@egen*/
+ "(" [ ArgumentList() ] ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ArgumentList():
+{/*@bgen(jjtree) ArgumentList */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ArgumentList */
+ try {
+/*@egen*/
+ Expression() ( "," Expression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AllocationExpression():
+{/*@bgen(jjtree) AllocationExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AllocationExpression */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ "new" PrimitiveType() ArrayDimsAndInits()
+|
+ "new" ClassOrInterfaceType() [ TypeArguments() ]
+ (
+ ArrayDimsAndInits()
+ |
+ Arguments() [ ClassOrInterfaceBody(false) ]
+ )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimsAndInits():
+{/*@bgen(jjtree) ArrayDimsAndInits */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ArrayDimsAndInits */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+|
+ ( "[" "]" )+ ArrayInitializer()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement():
+{/*@bgen(jjtree) Statement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Statement */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ LabeledStatement()
+|
+ AssertStatement()
+|
+ Block()
+|
+ EmptyStatement()
+|
+ StatementExpression() ";"
+|
+ SwitchStatement()
+|
+ IfStatement()
+|
+ WhileStatement()
+|
+ DoStatement()
+|
+ ForStatement()
+|
+ BreakStatement()
+|
+ ContinueStatement()
+|
+ ReturnStatement()
+|
+ ThrowStatement()
+|
+ SynchronizedStatement()
+|
+ TryStatement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AssertStatement():
+{/*@bgen(jjtree) AssertStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AssertStatement */
+ try {
+/*@egen*/
+ "assert" Expression() [ ":" Expression() ] ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void LabeledStatement():
+{/*@bgen(jjtree) LabeledStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) LabeledStatement */
+ try {
+/*@egen*/
+ <IDENTIFIER> ":" Statement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Block():
+{/*@bgen(jjtree) Block */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCK);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Block */
+ try {
+/*@egen*/
+ "{" ( BlockStatement() )* "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void BlockStatement():
+{/*@bgen(jjtree) BlockStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) BlockStatement */
+ try {
+/*@egen*/
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration() ";"
+|
+ Statement()
+|
+ ClassOrInterfaceDeclaration(0)/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void LocalVariableDeclaration():
+{/*@bgen(jjtree) LocalVariableDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) LocalVariableDeclaration */
+ try {
+/*@egen*/
+ Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EmptyStatement():
+{/*@bgen(jjtree) EmptyStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EmptyStatement */
+ try {
+/*@egen*/
+ ";"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void StatementExpression():
+{/*@bgen(jjtree) StatementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) StatementExpression */
+ try {
+/*@egen*/
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ LOOKAHEAD(PrimaryExpression() AssignmentOperator())
+ AssignmentExpression()
+|
+ PostfixExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SwitchStatement():
+{/*@bgen(jjtree) SwitchStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SwitchStatement */
+ try {
+/*@egen*/
+ "switch" "(" Expression() ")" "{"
+ ( SwitchLabel() ( BlockStatement() )* )*
+ "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SwitchLabel():
+{/*@bgen(jjtree) SwitchLabel */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SwitchLabel */
+ try {
+/*@egen*/
+ "case" Expression() ":"
+|
+ "default" ":"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void IfStatement():
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+{/*@bgen(jjtree) IfStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) IfStatement */
+ try {
+/*@egen*/
+ "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void WhileStatement():
+{/*@bgen(jjtree) WhileStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) WhileStatement */
+ try {
+/*@egen*/
+ "while" "(" Expression() ")" Statement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void DoStatement():
+{/*@bgen(jjtree) DoStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) DoStatement */
+ try {
+/*@egen*/
+ "do" Statement() "while" "(" Expression() ")" ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ForStatement():
+{/*@bgen(jjtree) ForStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ForStatement */
+ try {
+/*@egen*/
+ "for" "("
+
+ (
+ LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
+ Modifiers() Type() <IDENTIFIER> ":" Expression()
+ |
+ [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ]
+ )
+
+ ")" Statement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ForInit():
+{/*@bgen(jjtree) ForInit */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORINIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ForInit */
+ try {
+/*@egen*/
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration()
+|
+ StatementExpressionList()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void StatementExpressionList():
+{/*@bgen(jjtree) StatementExpressionList */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) StatementExpressionList */
+ try {
+/*@egen*/
+ StatementExpression() ( "," StatementExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ForUpdate():
+{/*@bgen(jjtree) ForUpdate */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ForUpdate */
+ try {
+/*@egen*/
+ StatementExpressionList()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void BreakStatement():
+{/*@bgen(jjtree) BreakStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) BreakStatement */
+ try {
+/*@egen*/
+ "break" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ContinueStatement():
+{/*@bgen(jjtree) ContinueStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ContinueStatement */
+ try {
+/*@egen*/
+ "continue" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ReturnStatement():
+{/*@bgen(jjtree) ReturnStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ReturnStatement */
+ try {
+/*@egen*/
+ "return" [ Expression() ] ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ThrowStatement():
+{/*@bgen(jjtree) ThrowStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ThrowStatement */
+ try {
+/*@egen*/
+ "throw" Expression() ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SynchronizedStatement():
+{/*@bgen(jjtree) SynchronizedStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SynchronizedStatement */
+ try {
+/*@egen*/
+ "synchronized" "(" Expression() ")" Block()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TryStatement():
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{/*@bgen(jjtree) TryStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TryStatement */
+ try {
+/*@egen*/
+ "try" Block()
+ ( "catch" "(" FormalParameter() ")" Block() )*
+ [ "finally" Block() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+
+void RUNSIGNEDSHIFT():
+{/*@bgen(jjtree) RUNSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) RUNSIGNEDSHIFT */
+ try {
+/*@egen*/
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} )
+ ">" ">" ">"
+ )/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void RSIGNEDSHIFT():
+{/*@bgen(jjtree) RSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) RSIGNEDSHIFT */
+ try {
+/*@egen*/
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} )
+ ">" ">"
+ )/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/* Annotation syntax follows. */
+
+void Annotation():
+{/*@bgen(jjtree) Annotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Annotation */
+ try {
+/*@egen*/
+ LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" ))
+ NormalAnnotation()
+ |
+ LOOKAHEAD( "@" Name() "(" )
+ SingleMemberAnnotation()
+ |
+ MarkerAnnotation()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void NormalAnnotation():
+{/*@bgen(jjtree) NormalAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) NormalAnnotation */
+ try {
+/*@egen*/
+ "@" Name() "(" [ MemberValuePairs() ] ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MarkerAnnotation():
+{/*@bgen(jjtree) MarkerAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MarkerAnnotation */
+ try {
+/*@egen*/
+ "@" Name()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SingleMemberAnnotation():
+{/*@bgen(jjtree) SingleMemberAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SingleMemberAnnotation */
+ try {
+/*@egen*/
+ "@" Name() "(" MemberValue() ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValuePairs():
+{/*@bgen(jjtree) MemberValuePairs */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValuePairs */
+ try {
+/*@egen*/
+ MemberValuePair() ( "," MemberValuePair() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValuePair():
+{/*@bgen(jjtree) MemberValuePair */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValuePair */
+ try {
+/*@egen*/
+ <IDENTIFIER> "=" MemberValue()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValue():
+{/*@bgen(jjtree) MemberValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValue */
+ try {
+/*@egen*/
+ Annotation()
+ |
+ MemberValueArrayInitializer()
+ |
+ ConditionalExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValueArrayInitializer():
+{/*@bgen(jjtree) MemberValueArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValueArrayInitializer */
+ try {
+/*@egen*/
+ "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/* Annotation Types. */
+
+void AnnotationTypeDeclaration(int modifiers):
+{/*@bgen(jjtree) AnnotationTypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnnotationTypeDeclaration */
+ try {
+/*@egen*/
+ "@" "interface" <IDENTIFIER> AnnotationTypeBody()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AnnotationTypeBody():
+{/*@bgen(jjtree) AnnotationTypeBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnnotationTypeBody */
+ try {
+/*@egen*/
+ "{" ( AnnotationTypeMemberDeclaration() )* "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AnnotationTypeMemberDeclaration():
+{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers;
+}
+{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */
+ try {
+/*@egen*/
+ modifiers = Modifiers()
+ (
+ LOOKAHEAD(Type() <IDENTIFIER> "(")
+ Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";"
+ |
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ |
+ FieldDeclaration(modifiers)
+ )
+ |
+ ( ";" )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void DefaultValue():
+{/*@bgen(jjtree) DefaultValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) DefaultValue */
+ try {
+/*@egen*/
+ "default" MemberValue()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Java1.5.jjt)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,2150 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements. Use is subject to license terms.
+ * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries. Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited. Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+// Slightly modified version of javacc's reference 1.5 grammar, tweaked for
+// usage with JAXX. There are two main areas of changes: several new
+// nonterminals were added to make identifying certain constructs easier,
+// and the Line nonterminal was added to support JAXX's script tags.
+// Several of the new changes are inefficient and require excess lookahead,
+// but at this point I'd rather have inefficiency than risk breaking it during
+// attempted optimizations.
+
+options {
+ JAVA_UNICODE_ESCAPE = true;
+ ERROR_REPORTING = false;
+ STATIC = false;
+ JDK_VERSION = "1.4";
+ NODE_SCOPE_HOOK=true;
+}
+
+PARSER_BEGIN(JavaParser)
+package jaxx.parser;
+
+import java.io.*;
+
+/**
+ * Grammar to parse Java version 1.5
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser
+{
+ /**
+ * Class to hold modifiers.
+ */
+ static public final class ModifierSet
+ {
+ /* Definitions of the bits in the modifiers field. */
+ public static final int PUBLIC = 0x0001;
+ public static final int PROTECTED = 0x0002;
+ public static final int PRIVATE = 0x0004;
+ public static final int ABSTRACT = 0x0008;
+ public static final int STATIC = 0x0010;
+ public static final int FINAL = 0x0020;
+ public static final int SYNCHRONIZED = 0x0040;
+ public static final int NATIVE = 0x0080;
+ public static final int TRANSIENT = 0x0100;
+ public static final int VOLATILE = 0x0200;
+ public static final int STRICTFP = 0x1000;
+
+ /** A set of accessors that indicate whether the specified modifier
+ is in the set. */
+
+ public boolean isPublic(int modifiers)
+ {
+ return (modifiers & PUBLIC) != 0;
+ }
+
+ public boolean isProtected(int modifiers)
+ {
+ return (modifiers & PROTECTED) != 0;
+ }
+
+ public boolean isPrivate(int modifiers)
+ {
+ return (modifiers & PRIVATE) != 0;
+ }
+
+ public boolean isStatic(int modifiers)
+ {
+ return (modifiers & STATIC) != 0;
+ }
+
+ public boolean isAbstract(int modifiers)
+ {
+ return (modifiers & ABSTRACT) != 0;
+ }
+
+ public boolean isFinal(int modifiers)
+ {
+ return (modifiers & FINAL) != 0;
+ }
+
+ public boolean isNative(int modifiers)
+ {
+ return (modifiers & NATIVE) != 0;
+ }
+
+ public boolean isStrictfp(int modifiers)
+ {
+ return (modifiers & STRICTFP) != 0;
+ }
+
+ public boolean isSynchronized(int modifiers)
+ {
+ return (modifiers & SYNCHRONIZED) != 0;
+ }
+
+ public boolean isTransient(int modifiers)
+ {
+ return (modifiers & TRANSIENT) != 0;
+ }
+
+ public boolean isVolatile(int modifiers)
+ {
+ return (modifiers & VOLATILE) != 0;
+ }
+
+ /**
+ * Removes the given modifier.
+ */
+ static int removeModifier(int modifiers, int mod)
+ {
+ return modifiers & ~mod;
+ }
+ }
+
+ public JavaParser(String fileName)
+ {
+ this(System.in);
+ try { ReInit(new FileInputStream(new File(fileName))); }
+ catch(Exception e) { e.printStackTrace(); }
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public SimpleNode popNode()
+ {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+ public static void main(String args[]) {
+ JavaParser parser;
+ if (args.length == 0) {
+ System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
+ parser = new JavaParser(System.in);
+ } else if (args.length == 1) {
+ System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
+ try {
+ parser = new JavaParser(new java.io.FileInputStream(args[0]));
+ } catch (java.io.FileNotFoundException e) {
+ System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
+ return;
+ }
+ } else {
+ System.out.println("Java Parser Version 1.1: Usage is one of:");
+ System.out.println(" java JavaParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java JavaParser inputfile");
+ return;
+ }
+ try {
+ parser.CompilationUnit();
+ System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
+ }
+ }
+
+}
+
+PARSER_END(JavaParser)
+
+/* COMMENTS */
+
+MORE :
+{
+ <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
+|
+ "/*" : IN_MULTI_LINE_COMMENT
+}
+
+SPECIAL_TOKEN:
+{
+ <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+>
+}
+
+SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?>
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+ <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+ <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+MORE :
+{
+ < ~[] >
+}
+
+/* RESERVED WORDS AND LITERALS */
+
+TOKEN :
+{
+ < ABSTRACT: "abstract" >
+| < ASSERT: "assert" >
+| < BOOLEAN: "boolean" >
+| < BREAK: "break" >
+| < BYTE: "byte" >
+| < CASE: "case" >
+| < CATCH: "catch" >
+| < CHAR: "char" >
+| < CLASS: "class" >
+| < CONST: "const" >
+| < CONTINUE: "continue" >
+| < _DEFAULT: "default" >
+| < DO: "do" >
+| < DOUBLE: "double" >
+| < ELSE: "else" >
+| < ENUM: "enum" >
+| < EXTENDS: "extends" >
+| < FALSE: "false" >
+| < FINAL: "final" >
+| < FINALLY: "finally" >
+| < FLOAT: "float" >
+| < FOR: "for" >
+| < GOTO: "goto" >
+| < IF: "if" >
+| < IMPLEMENTS: "implements" >
+| < IMPORT: "import" >
+| < INSTANCEOF: "instanceof" >
+| < INT: "int" >
+| < INTERFACE: "interface" >
+| < LONG: "long" >
+| < NATIVE: "native" >
+| < NEW: "new" >
+| < NULL: "null" >
+| < PACKAGE: "package">
+| < PRIVATE: "private" >
+| < PROTECTED: "protected" >
+| < PUBLIC: "public" >
+| < RETURN: "return" >
+| < SHORT: "short" >
+| < STATIC: "static" >
+| < STRICTFP: "strictfp" >
+| < SUPER: "super" >
+| < SWITCH: "switch" >
+| < SYNCHRONIZED: "synchronized" >
+| < THIS: "this" >
+| < THROW: "throw" >
+| < THROWS: "throws" >
+| < TRANSIENT: "transient" >
+| < TRUE: "true" >
+| < TRY: "try" >
+| < VOID: "void" >
+| < VOLATILE: "volatile" >
+| < WHILE: "while" >
+}
+
+/* LITERALS */
+
+TOKEN :
+{
+ < INTEGER_LITERAL:
+ <DECIMAL_LITERAL> (["l","L"])?
+ | <HEX_LITERAL> (["l","L"])?
+ | <OCTAL_LITERAL> (["l","L"])?
+ >
+|
+ < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
+|
+ < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
+|
+ < #OCTAL_LITERAL: "0" (["0"-"7"])* >
+|
+ < FLOATING_POINT_LITERAL:
+ <DECIMAL_FLOATING_POINT_LITERAL>
+ | <HEXADECIMAL_FLOATING_POINT_LITERAL>
+ >
+|
+ < #DECIMAL_FLOATING_POINT_LITERAL:
+ (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])?
+ | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"]
+ >
+|
+ < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|
+ < #HEXADECIMAL_FLOATING_POINT_LITERAL:
+ "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ >
+|
+ < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
+|
+ < CHARACTER_LITERAL:
+ "'"
+ ( (~["'","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )
+ "'"
+ >
+|
+ < STRING_LITERAL:
+ "\""
+ ( (~["\"","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )*
+ "\""
+ >
+}
+
+/* IDENTIFIERS */
+
+TOKEN :
+{
+ < IDENTIFIER: <LETTER> (<PART_LETTER>)* >
+|
+ < #LETTER:
+ [ // all chars for which Character.isIdentifierStart is true
+ "$",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u064a",
+ "\u0671"-"\u06d3",
+ "\u06d5",
+ "\u06e5"-"\u06e6",
+ "\u06fa"-"\u06fc",
+ "\u0710",
+ "\u0712"-"\u072c",
+ "\u0780"-"\u07a5",
+ "\u0905"-"\u0939",
+ "\u093d",
+ "\u0950",
+ "\u0958"-"\u0961",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e1",
+ "\u09f0"-"\u09f3",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a72"-"\u0a74",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3d",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c60"-"\u0c61",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d60"-"\u0d61",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0e01"-"\u0e30",
+ "\u0e32"-"\u0e33",
+ "\u0e3f"-"\u0e46",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb0",
+ "\u0eb2"-"\u0eb3",
+ "\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f40"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f88"-"\u0f8b",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u1050"-"\u1055",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17b3",
+ "\u17db",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a8",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u203f"-"\u2040",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u3029",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d",
+ "\ufb1f"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\uff04",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6"
+ ]
+ >
+|
+ < #PART_LETTER:
+ [ // all chars for which Character.isIdentifierPart is true
+ "\u0000"-"\u0008",
+ "\u000e"-"\u001b",
+ "$",
+ "0"-"9",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u007f"-"\u009f",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u0300"-"\u034e",
+ "\u0360"-"\u0362",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u0483"-"\u0486",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u0591"-"\u05a1",
+ "\u05a3"-"\u05b9",
+ "\u05bb"-"\u05bd",
+ "\u05bf",
+ "\u05c1"-"\u05c2",
+ "\u05c4",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u0655",
+ "\u0660"-"\u0669",
+ "\u0670"-"\u06d3",
+ "\u06d5"-"\u06dc",
+ "\u06df"-"\u06e8",
+ "\u06ea"-"\u06ed",
+ "\u06f0"-"\u06fc",
+ "\u070f"-"\u072c",
+ "\u0730"-"\u074a",
+ "\u0780"-"\u07b0",
+ "\u0901"-"\u0903",
+ "\u0905"-"\u0939",
+ "\u093c"-"\u094d",
+ "\u0950"-"\u0954",
+ "\u0958"-"\u0963",
+ "\u0966"-"\u096f",
+ "\u0981"-"\u0983",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09bc",
+ "\u09be"-"\u09c4",
+ "\u09c7"-"\u09c8",
+ "\u09cb"-"\u09cd",
+ "\u09d7",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e3",
+ "\u09e6"-"\u09f3",
+ "\u0a02",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a3c",
+ "\u0a3e"-"\u0a42",
+ "\u0a47"-"\u0a48",
+ "\u0a4b"-"\u0a4d",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a66"-"\u0a74",
+ "\u0a81"-"\u0a83",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abc"-"\u0ac5",
+ "\u0ac7"-"\u0ac9",
+ "\u0acb"-"\u0acd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0ae6"-"\u0aef",
+ "\u0b01"-"\u0b03",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3c"-"\u0b43",
+ "\u0b47"-"\u0b48",
+ "\u0b4b"-"\u0b4d",
+ "\u0b56"-"\u0b57",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b66"-"\u0b6f",
+ "\u0b82"-"\u0b83",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0bbe"-"\u0bc2",
+ "\u0bc6"-"\u0bc8",
+ "\u0bca"-"\u0bcd",
+ "\u0bd7",
+ "\u0be7"-"\u0bef",
+ "\u0c01"-"\u0c03",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c3e"-"\u0c44",
+ "\u0c46"-"\u0c48",
+ "\u0c4a"-"\u0c4d",
+ "\u0c55"-"\u0c56",
+ "\u0c60"-"\u0c61",
+ "\u0c66"-"\u0c6f",
+ "\u0c82"-"\u0c83",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cbe"-"\u0cc4",
+ "\u0cc6"-"\u0cc8",
+ "\u0cca"-"\u0ccd",
+ "\u0cd5"-"\u0cd6",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0ce6"-"\u0cef",
+ "\u0d02"-"\u0d03",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d3e"-"\u0d43",
+ "\u0d46"-"\u0d48",
+ "\u0d4a"-"\u0d4d",
+ "\u0d57",
+ "\u0d60"-"\u0d61",
+ "\u0d66"-"\u0d6f",
+ "\u0d82"-"\u0d83",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0dca",
+ "\u0dcf"-"\u0dd4",
+ "\u0dd6",
+ "\u0dd8"-"\u0ddf",
+ "\u0df2"-"\u0df3",
+ "\u0e01"-"\u0e3a",
+ "\u0e3f"-"\u0e4e",
+ "\u0e50"-"\u0e59",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb9",
+ "\u0ebb"-"\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0ec8"-"\u0ecd",
+ "\u0ed0"-"\u0ed9",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f18"-"\u0f19",
+ "\u0f20"-"\u0f29",
+ "\u0f35",
+ "\u0f37",
+ "\u0f39",
+ "\u0f3e"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f71"-"\u0f84",
+ "\u0f86"-"\u0f8b",
+ "\u0f90"-"\u0f97",
+ "\u0f99"-"\u0fbc",
+ "\u0fc6",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u102c"-"\u1032",
+ "\u1036"-"\u1039",
+ "\u1040"-"\u1049",
+ "\u1050"-"\u1059",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u1369"-"\u1371",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17d3",
+ "\u17db",
+ "\u17e0"-"\u17e9",
+ "\u180b"-"\u180e",
+ "\u1810"-"\u1819",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a9",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u200c"-"\u200f",
+ "\u202a"-"\u202e",
+ "\u203f"-"\u2040",
+ "\u206a"-"\u206f",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u20d0"-"\u20dc",
+ "\u20e1",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u302f",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u3099"-"\u309a",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe20"-"\ufe23",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\ufeff",
+ "\uff04",
+ "\uff10"-"\uff19",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6",
+ "\ufff9"-"\ufffb"
+ ]
+ >
+}
+
+/* SEPARATORS */
+
+TOKEN :
+{
+ < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+| < AT: "@" >
+}
+
+/* OPERATORS */
+
+TOKEN :
+{
+ < ASSIGN: "=" >
+| < LT: "<" >
+| < BANG: "!" >
+| < TILDE: "~" >
+| < HOOK: "?" >
+| < COLON: ":" >
+| < EQ: "==" >
+| < LE: "<=" >
+| < GE: ">=" >
+| < NE: "!=" >
+| < SC_OR: "||" >
+| < SC_AND: "&&" >
+| < INCR: "++" >
+| < DECR: "--" >
+| < PLUS: "+" >
+| < MINUS: "-" >
+| < STAR: "*" >
+| < SLASH: "/" >
+| < BIT_AND: "&" >
+| < BIT_OR: "|" >
+| < XOR: "^" >
+| < REM: "%" >
+| < LSHIFT: "<<" >
+| < PLUSASSIGN: "+=" >
+| < MINUSASSIGN: "-=" >
+| < STARASSIGN: "*=" >
+| < SLASHASSIGN: "/=" >
+| < ANDASSIGN: "&=" >
+| < ORASSIGN: "|=" >
+| < XORASSIGN: "^=" >
+| < REMASSIGN: "%=" >
+| < LSHIFTASSIGN: "<<=" >
+| < RSIGNEDSHIFTASSIGN: ">>=" >
+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
+| < ELLIPSIS: "..." >
+}
+
+/* >'s need special attention due to generics syntax. */
+TOKEN :
+{
+ < RUNSIGNEDSHIFT: ">>>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT;
+ input_stream.backup(2);
+ matchedToken.image = ">";
+ }
+| < RSIGNEDSHIFT: ">>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT;
+ input_stream.backup(1);
+ matchedToken.image = ">";
+ }
+| < GT: ">" >
+}
+
+boolean Line() :
+{
+ int modifiers;
+}
+{
+ <EOF> {
+ return true;
+ }
+|
+ LOOKAHEAD(BlockStatement())
+ BlockStatement() {
+ return false;
+ }
+|
+ LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{")
+ ClassOrInterfaceBodyDeclaration(false) {
+ return false;
+ }
+|
+ LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false))
+ ClassOrInterfaceBodyDeclaration(false) {
+ return false;
+ }
+|
+ LOOKAHEAD(Expression())
+ Expression() {
+ return false;
+ }
+|
+ ImportDeclaration() {
+ return false;
+ }
+}
+
+/*****************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ *****************************************/
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit():
+{}
+{
+ [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ]
+ ( ImportDeclaration() )*
+ ( TypeDeclaration() )*
+ ( < "\u001a" > )?
+ ( <STUFF_TO_IGNORE: ~[]> )?
+ <EOF>
+}
+
+void PackageDeclaration():
+{}
+{
+ Modifiers() "package" Name() ";"
+}
+
+void ImportDeclaration():
+{}
+{
+ "import" [ "static" ] Name() [ "." "*" ] ";"
+}
+
+/*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+
+int Modifiers():
+{
+ int modifiers = 0;
+}
+{
+ (
+ LOOKAHEAD(2)
+ (
+ "public" { modifiers |= ModifierSet.PUBLIC; }
+ |
+ "static" { modifiers |= ModifierSet.STATIC; }
+ |
+ "protected" { modifiers |= ModifierSet.PROTECTED; }
+ |
+ "private" { modifiers |= ModifierSet.PRIVATE; }
+ |
+ "final" { modifiers |= ModifierSet.FINAL; }
+ |
+ "abstract" { modifiers |= ModifierSet.ABSTRACT; }
+ |
+ "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; }
+ |
+ "native" { modifiers |= ModifierSet.NATIVE; }
+ |
+ "transient" { modifiers |= ModifierSet.TRANSIENT; }
+ |
+ "volatile" { modifiers |= ModifierSet.VOLATILE; }
+ |
+ "strictfp" { modifiers |= ModifierSet.STRICTFP; }
+ |
+ Annotation()
+ )
+ )*
+
+ {
+ return modifiers;
+ }
+}
+
+/*
+ * Declaration syntax follows.
+ */
+void TypeDeclaration():
+{
+ int modifiers;
+}
+{
+ ";"
+|
+ modifiers = Modifiers()
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ )
+}
+
+
+void ClassOrInterfaceDeclaration(int modifiers):
+{
+ boolean isInterface = false;
+}
+{
+ ( "class" | "interface" { isInterface = true; } )
+ <IDENTIFIER>
+ [ TypeParameters() ]
+ [ ExtendsList(isInterface) ]
+ [ ImplementsList(isInterface) ]
+ ClassOrInterfaceBody(isInterface)
+}
+
+void ExtendsList(boolean isInterface):
+{
+ boolean extendsMoreThanOne = false;
+}
+{
+ "extends" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*
+ {
+ if (extendsMoreThanOne && !isInterface)
+ throw new ParseException("A class cannot extend more than one other class");
+ }
+}
+
+void ImplementsList(boolean isInterface):
+{}
+{
+ "implements" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() )*
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot implement other interfaces");
+ }
+}
+
+void EnumDeclaration(int modifiers):
+{}
+{
+ "enum" <IDENTIFIER>
+ [ ImplementsList(false) ]
+ EnumBody()
+}
+
+void EnumBody():
+{}
+{
+ "{"
+ [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
+ [ "," ]
+ [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
+ "}"
+}
+
+void EnumConstant():
+{}
+{
+ Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]
+}
+
+void TypeParameters():
+{}
+{
+ "<" TypeParameter() ( "," TypeParameter() )* ">"
+}
+
+void TypeParameter():
+{}
+{
+ <IDENTIFIER> [ TypeBound() ]
+}
+
+void TypeBound():
+{}
+{
+ "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*
+}
+
+void ClassOrInterfaceBody(boolean isInterface):
+{}
+{
+ "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"
+}
+
+void ClassOrInterfaceBodyDeclaration(boolean isInterface):
+{
+ boolean isNestedInterface = false;
+ int modifiers;
+}
+{
+ LOOKAHEAD(2)
+ Initializer()
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot have initializers");
+ }
+|
+ modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do
+ // more checks, pass the modifiers down to the member
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" )
+ ConstructorDeclaration()
+ |
+ LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) )
+ FieldDeclaration(modifiers)
+ |
+ MethodDeclaration(modifiers)
+ )
+|
+ ";"
+}
+
+void FieldDeclaration(int modifiers):
+{}
+{
+ // Modifiers are already matched in the caller
+ Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator():
+{}
+{
+ VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId():
+{}
+{
+ <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer():
+{}
+{
+ ArrayInitializer()
+|
+ Expression()
+}
+
+void ArrayInitializer():
+{}
+{
+ "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration(int modifiers):
+{}
+{
+ // Modifiers already matched in the caller!
+ [ TypeParameters() ]
+ ResultType()
+ MethodDeclarator() [ "throws" NameList() ]
+ ( Block() | ";" )
+}
+
+void MethodDeclarator():
+{}
+{
+ <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters():
+{}
+{
+ "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter():
+{}
+{
+ Modifiers() Type() [ "..." ] VariableDeclaratorId()
+}
+
+void ConstructorDeclaration():
+{}
+{
+ [ TypeParameters() ]
+ // Modifiers matched in the caller
+ <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+ "{"
+ [ LOOKAHEAD(ExplicitConstructorInvocation())
+ ExplicitConstructorInvocation()
+ ]
+ ( BlockStatement() )*
+ "}"
+}
+
+void ExplicitConstructorInvocation():
+{}
+{
+ ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ]
+ [ TypeArguments() ] ("this"|"super") Arguments() ";"
+}
+
+void Initializer():
+{}
+{
+ [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type():
+{}
+{
+ LOOKAHEAD(2) ReferenceType()
+ |
+ PrimitiveType()
+}
+
+void ReferenceType():
+{}
+{
+ PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+
+ |
+ ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*
+}
+
+void ClassOrInterfaceType():
+{}
+{
+ <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ]
+ ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*
+}
+
+void TypeArguments():
+{}
+{
+ "<" TypeArgument() ( "," TypeArgument() )* ">"
+}
+
+void TypeArgument():
+{}
+{
+ ReferenceType()
+ |
+ "?" [ WildcardBounds() ]
+}
+
+void WildcardBounds():
+{}
+{
+ "extends" ReferenceType()
+ |
+ "super" ReferenceType()
+}
+
+
+void PrimitiveType():
+{}
+{
+ "boolean"
+|
+ "char"
+|
+ "byte"
+|
+ "short"
+|
+ "int"
+|
+ "long"
+|
+ "float"
+|
+ "double"
+}
+
+void ResultType():
+{}
+{
+ "void"
+|
+ Type()
+}
+
+void Name():
+/*
+ * A lookahead of 2 is required below since "Name" can be followed
+ * by a ".*" when used in the context of an "ImportDeclaration".
+ */
+{}
+{
+ <IDENTIFIER>
+ ( LOOKAHEAD(2) "." <IDENTIFIER>
+ )*
+}
+
+void NameList():
+{}
+{
+ Name() ( "," Name() )*
+}
+
+
+/*
+ * Expression syntax follows.
+ */
+
+void Expression():
+/*
+ * This expansion has been written this way instead of:
+ * Assignment() | ConditionalExpression()
+ * for performance reasons.
+ * However, it is a weakening of the grammar for it allows the LHS of
+ * assignments to be any conditional expression whereas it can only be
+ * a primary expression. Consider adding a semantic predicate to work
+ * around this.
+ */
+{}
+{
+ ConditionalExpression()
+ [
+ LOOKAHEAD(2)
+ AssignmentOperator() Expression()
+ ]
+}
+
+void AssignmentOperator():
+{}
+{
+ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void AssignmentExpression():
+{}
+{
+ PrimaryExpression() AssignmentOperator() Expression()
+}
+
+void ConditionalExpression():
+{}
+{
+ ConditionalOrExpression() [ "?" Expression() ":" Expression() ]
+}
+
+void ConditionalOrExpression():
+{}
+{
+ ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression():
+{}
+{
+ InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression():
+{}
+{
+ ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression():
+{}
+{
+ AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression():
+{}
+{
+ EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression():
+{}
+{
+ InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression():
+{}
+{
+ RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression():
+{}
+{
+ ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression():
+{}
+{
+ AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*
+}
+
+void AdditiveExpression():
+{}
+{
+ MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression():
+{}
+{
+ UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression():
+{}
+{
+ ( "+" | "-" ) UnaryExpression()
+|
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression():
+{}
+{
+ "++" PrimaryExpression()
+}
+
+void PreDecrementExpression():
+{}
+{
+ "--" PrimaryExpression()
+}
+
+void UnaryExpressionNotPlusMinus():
+{}
+{
+ ( "~" | "!" ) UnaryExpression()
+|
+ LOOKAHEAD( CastLookahead() )
+ CastExpression()
+|
+ PostfixExpression()
+}
+
+// This production is to determine lookahead only. The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+// this.
+void CastLookahead():
+{}
+{
+ LOOKAHEAD(2)
+ "(" PrimitiveType()
+|
+ LOOKAHEAD("(" Type() "[")
+ "(" Type() "[" "]"
+|
+ "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )
+}
+
+void PostfixExpression():
+{}
+{
+ PrimaryExpression() [ PostfixOperator() ]
+}
+
+void PostfixOperator():
+{}
+{
+ "++" | "--"
+}
+
+void CastExpression():
+{}
+{
+ LOOKAHEAD("(" PrimitiveType())
+ "(" Type() ")" UnaryExpression()
+|
+ "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression():
+{}
+{
+ PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void MemberSelector():
+{}
+{
+ "." TypeArguments() <IDENTIFIER>
+}
+
+void PrimaryPrefix():
+{}
+{
+ Literal()
+|
+ LOOKAHEAD( ( <IDENTIFIER> "." )* "this" )
+ ( <IDENTIFIER> "." )*
+ "this"
+|
+ "super" "." <IDENTIFIER>
+|
+ "(" Expression() ")"
+|
+ AllocationExpression()
+|
+ LOOKAHEAD( ResultType() "." "class" )
+ ResultType() "." "class"
+|
+ Name()
+}
+
+void PrimarySuffix():
+{}
+{
+ LOOKAHEAD("." "super" ".")
+ "." "super"
+|
+ LOOKAHEAD("." "this")
+ "." "this"
+|
+ LOOKAHEAD(2)
+ "." AllocationExpression()
+|
+ LOOKAHEAD(3)
+ MemberSelector()
+|
+ "[" Expression() "]"
+|
+ "." <IDENTIFIER>
+|
+ Arguments()
+}
+
+void Literal():
+{}
+{
+ <INTEGER_LITERAL>
+|
+ <FLOATING_POINT_LITERAL>
+|
+ <CHARACTER_LITERAL>
+|
+ <STRING_LITERAL>
+|
+ BooleanLiteral()
+|
+ NullLiteral()
+}
+
+void BooleanLiteral():
+{}
+{
+ "true"
+|
+ "false"
+}
+
+void NullLiteral():
+{}
+{
+ "null"
+}
+
+void Arguments():
+{}
+{
+ "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList():
+{}
+{
+ Expression() ( "," Expression() )*
+}
+
+void AllocationExpression():
+{}
+{
+ LOOKAHEAD(2)
+ "new" PrimitiveType() ArrayDimsAndInits()
+|
+ "new" ClassOrInterfaceType() [ TypeArguments() ]
+ (
+ ArrayDimsAndInits()
+ |
+ Arguments() [ ClassOrInterfaceBody(false) ]
+ )
+}
+
+/*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimsAndInits():
+{}
+{
+ LOOKAHEAD(2)
+ ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+|
+ ( "[" "]" )+ ArrayInitializer()
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement():
+{}
+{
+ LOOKAHEAD(2)
+ LabeledStatement()
+|
+ AssertStatement()
+|
+ Block()
+|
+ EmptyStatement()
+|
+ StatementExpression() ";"
+|
+ SwitchStatement()
+|
+ IfStatement()
+|
+ WhileStatement()
+|
+ DoStatement()
+|
+ ForStatement()
+|
+ BreakStatement()
+|
+ ContinueStatement()
+|
+ ReturnStatement()
+|
+ ThrowStatement()
+|
+ SynchronizedStatement()
+|
+ TryStatement()
+}
+
+void AssertStatement():
+{}
+{
+ "assert" Expression() [ ":" Expression() ] ";"
+}
+
+void LabeledStatement():
+{}
+{
+ <IDENTIFIER> ":" Statement()
+}
+
+void Block():
+{}
+{
+ "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement():
+{}
+{
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration() ";"
+|
+ Statement()
+|
+ ClassOrInterfaceDeclaration(0)
+}
+
+void LocalVariableDeclaration():
+{}
+{
+ Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )*
+}
+
+void EmptyStatement():
+{}
+{
+ ";"
+}
+
+void StatementExpression():
+{}
+{
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ LOOKAHEAD(PrimaryExpression() AssignmentOperator())
+ AssignmentExpression()
+|
+ PostfixExpression()
+}
+
+void SwitchStatement():
+{}
+{
+ "switch" "(" Expression() ")" "{"
+ ( SwitchLabel() ( BlockStatement() )* )*
+ "}"
+}
+
+void SwitchLabel():
+{}
+{
+ "case" Expression() ":"
+|
+ "default" ":"
+}
+
+void IfStatement():
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+{}
+{
+ "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement():
+{}
+{
+ "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement():
+{}
+{
+ "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement():
+{}
+{
+ "for" "("
+
+ (
+ LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
+ Modifiers() Type() <IDENTIFIER> ":" Expression()
+ |
+ [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ]
+ )
+
+ ")" Statement()
+}
+
+void ForInit():
+{}
+{
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration()
+|
+ StatementExpressionList()
+}
+
+void StatementExpressionList():
+{}
+{
+ StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate():
+{}
+{
+ StatementExpressionList()
+}
+
+void BreakStatement():
+{}
+{
+ "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement():
+{}
+{
+ "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement():
+{}
+{
+ "return" [ Expression() ] ";"
+}
+
+void ThrowStatement():
+{}
+{
+ "throw" Expression() ";"
+}
+
+void SynchronizedStatement():
+{}
+{
+ "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement():
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+ "try" Block()
+ ( "catch" "(" FormalParameter() ")" Block() )*
+ [ "finally" Block() ]
+}
+
+/* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+
+void RUNSIGNEDSHIFT():
+{}
+{
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} )
+ ">" ">" ">"
+ )
+}
+
+void RSIGNEDSHIFT():
+{}
+{
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} )
+ ">" ">"
+ )
+}
+
+/* Annotation syntax follows. */
+
+void Annotation():
+{}
+{
+ LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" ))
+ NormalAnnotation()
+ |
+ LOOKAHEAD( "@" Name() "(" )
+ SingleMemberAnnotation()
+ |
+ MarkerAnnotation()
+}
+
+void NormalAnnotation():
+{}
+{
+ "@" Name() "(" [ MemberValuePairs() ] ")"
+}
+
+void MarkerAnnotation():
+{}
+{
+ "@" Name()
+}
+
+void SingleMemberAnnotation():
+{}
+{
+ "@" Name() "(" MemberValue() ")"
+}
+
+void MemberValuePairs():
+{}
+{
+ MemberValuePair() ( "," MemberValuePair() )*
+}
+
+void MemberValuePair():
+{}
+{
+ <IDENTIFIER> "=" MemberValue()
+}
+
+void MemberValue():
+{}
+{
+ Annotation()
+ |
+ MemberValueArrayInitializer()
+ |
+ ConditionalExpression()
+}
+
+void MemberValueArrayInitializer():
+{}
+{
+ "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"
+}
+
+
+/* Annotation Types. */
+
+void AnnotationTypeDeclaration(int modifiers):
+{}
+{
+ "@" "interface" <IDENTIFIER> AnnotationTypeBody()
+}
+
+void AnnotationTypeBody():
+{}
+{
+ "{" ( AnnotationTypeMemberDeclaration() )* "}"
+}
+
+void AnnotationTypeMemberDeclaration():
+{
+ int modifiers;
+}
+{
+ modifiers = Modifiers()
+ (
+ LOOKAHEAD(Type() <IDENTIFIER> "(")
+ Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";"
+ |
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ |
+ FieldDeclaration(modifiers)
+ )
+ |
+ ( ";" )
+}
+
+void DefaultValue():
+{}
+{
+ "default" MemberValue()
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaCharStream.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,530 @@
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */
+package jaxx.compiler.parser.java;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (with java-like unicode escape processing).
+ */
+
+public class JavaCharStream {
+ public static final boolean staticFlag = false;
+
+ static int hexval(char c) throws java.io.IOException {
+ switch (c) {
+ case '0':
+ return 0;
+ case '1':
+ return 1;
+ case '2':
+ return 2;
+ case '3':
+ return 3;
+ case '4':
+ return 4;
+ case '5':
+ return 5;
+ case '6':
+ return 6;
+ case '7':
+ return 7;
+ case '8':
+ return 8;
+ case '9':
+ return 9;
+
+ case 'a':
+ case 'A':
+ return 10;
+ case 'b':
+ case 'B':
+ return 11;
+ case 'c':
+ case 'C':
+ return 12;
+ case 'd':
+ case 'D':
+ return 13;
+ case 'e':
+ case 'E':
+ return 14;
+ case 'f':
+ case 'F':
+ return 15;
+ }
+
+ throw new java.io.IOException(); // Should never come here
+ }
+
+ public int bufpos = -1;
+ int bufsize;
+ int available;
+ int tokenBegin;
+ protected int bufline[];
+ protected int bufcolumn[];
+
+ protected int column = 0;
+ protected int line = 1;
+
+ protected boolean prevCharIsCR = false;
+ protected boolean prevCharIsLF = false;
+
+ protected java.io.Reader inputStream;
+
+ protected char[] nextCharBuf;
+ protected char[] buffer;
+ protected int maxNextCharInd = 0;
+ protected int nextCharInd = -1;
+ protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) {
+ tabSize = i;
+ }
+
+ protected int getTabSize(int i) {
+ return tabSize;
+ }
+
+ protected void ExpandBuff(boolean wrapAround) {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try {
+ if (wrapAround) {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ bufpos += (bufsize - tokenBegin);
+ } else {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ bufpos -= tokenBegin;
+ }
+ }
+ catch (Throwable t) {
+ throw new Error(t.getMessage());
+ }
+
+ available = (bufsize += 2048);
+ tokenBegin = 0;
+ }
+
+ protected void FillBuff() throws java.io.IOException {
+ int i;
+ if (maxNextCharInd == 4096)
+ maxNextCharInd = nextCharInd = 0;
+
+ try {
+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
+ 4096 - maxNextCharInd)) == -1) {
+ inputStream.close();
+ throw new java.io.IOException();
+ } else {
+ maxNextCharInd += i;
+ }
+ }
+ catch (java.io.IOException e) {
+ if (bufpos != 0) {
+ --bufpos;
+ backup(0);
+ } else {
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+ throw e;
+ }
+ }
+
+ protected char ReadByte() throws java.io.IOException {
+ if (++nextCharInd >= maxNextCharInd)
+ FillBuff();
+
+ return nextCharBuf[nextCharInd];
+ }
+
+ public char BeginToken() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize) {
+ bufpos = 0;
+ }
+
+ tokenBegin = bufpos;
+ return buffer[bufpos];
+ }
+
+ tokenBegin = 0;
+ bufpos = -1;
+
+ return readChar();
+ }
+
+ protected void AdjustBuffSize() {
+ if (available == bufsize) {
+ if (tokenBegin > 2048) {
+ bufpos = 0;
+ available = tokenBegin;
+ } else
+ ExpandBuff(false);
+ } else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ protected void UpdateLineColumn(char c) {
+ column++;
+
+ if (prevCharIsLF) {
+ prevCharIsLF = false;
+ line += (column = 1);
+ } else if (prevCharIsCR) {
+ prevCharIsCR = false;
+ if (c == '\n') {
+ prevCharIsLF = true;
+ } else
+ line += (column = 1);
+ }
+
+ switch (c) {
+ case '\r':
+ prevCharIsCR = true;
+ break;
+ case '\n':
+ prevCharIsLF = true;
+ break;
+ case '\t':
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default:
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ public char readChar() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ char c;
+
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ if ((buffer[bufpos] = c = ReadByte()) == '\\') {
+ UpdateLineColumn(c);
+
+ int backSlashCnt = 1;
+
+ for (; ;) // Read all the backslashes
+ {
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ try {
+ if ((buffer[bufpos] = c = ReadByte()) != '\\') {
+ UpdateLineColumn(c);
+ // found a non-backslash char.
+ if ((c == 'u') && ((backSlashCnt & 1) == 1)) {
+ if (--bufpos < 0)
+ bufpos = bufsize - 1;
+
+ break;
+ }
+
+ backup(backSlashCnt);
+ return '\\';
+ }
+ }
+ catch (java.io.IOException e) {
+ if (backSlashCnt > 1)
+ backup(backSlashCnt);
+
+ return '\\';
+ }
+
+ UpdateLineColumn(c);
+ backSlashCnt++;
+ }
+
+ // Here, we have seen an odd number of backslash's followed by a 'u'
+ try {
+ while ((c = ReadByte()) == 'u')
+ ++column;
+
+ buffer[bufpos] = c = (char) (hexval(c) << 12 |
+ hexval(ReadByte()) << 8 |
+ hexval(ReadByte()) << 4 |
+ hexval(ReadByte()));
+
+ column += 4;
+ }
+ catch (java.io.IOException e) {
+ throw new Error("Invalid escape character at line " + line +
+ " column " + column + ".");
+ }
+
+ if (backSlashCnt == 1)
+ return c;
+ else {
+ backup(backSlashCnt - 1);
+ return '\\';
+ }
+ } else {
+ UpdateLineColumn(c);
+ return (c);
+ }
+ }
+
+ /**
+ * @return column index
+ * @see #getEndColumn
+ * @deprecated
+ */
+
+ public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @return line type ???
+ * @see #getEndLine
+ * @deprecated
+ */
+
+ public int getLine() {
+ return bufline[bufpos];
+ }
+
+ public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.Reader dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length) {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ nextCharInd = bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public String GetImage() {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ public char[] GetSuffix(int len) {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ public void Done() {
+ nextCharBuf = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ *
+ * @param newLine line number ?
+ * @param newCol column number ?
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol) {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin) {
+ len = bufpos - tokenBegin + inBuf + 1;
+ } else {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k;
+ int nextColDiff, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len) {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len) {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParser.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,10048 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParser.java */
+package jaxx.compiler.parser.java;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * Grammar to parse Java version 1.5
+ *
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, JavaParserConstants {/*@bgen(jjtree)*/
+ protected JJTJavaParserState jjtree = new JJTJavaParserState();
+
+ /** Class to hold modifiers. */
+ static public final class ModifierSet {
+ /* Definitions of the bits in the modifiers field. */
+ public static final int PUBLIC = 0x0001;
+ public static final int PROTECTED = 0x0002;
+ public static final int PRIVATE = 0x0004;
+ public static final int ABSTRACT = 0x0008;
+ public static final int STATIC = 0x0010;
+ public static final int FINAL = 0x0020;
+ public static final int SYNCHRONIZED = 0x0040;
+ public static final int NATIVE = 0x0080;
+ public static final int TRANSIENT = 0x0100;
+ public static final int VOLATILE = 0x0200;
+ public static final int STRICTFP = 0x1000;
+
+ /**
+ * A set of accessors that indicate whether the specified modifier
+ * is in the set.
+ */
+
+ public boolean isPublic(int modifiers) {
+ return (modifiers & PUBLIC) != 0;
+ }
+
+ public boolean isProtected(int modifiers) {
+ return (modifiers & PROTECTED) != 0;
+ }
+
+ public boolean isPrivate(int modifiers) {
+ return (modifiers & PRIVATE) != 0;
+ }
+
+ public boolean isStatic(int modifiers) {
+ return (modifiers & STATIC) != 0;
+ }
+
+ public boolean isAbstract(int modifiers) {
+ return (modifiers & ABSTRACT) != 0;
+ }
+
+ public boolean isFinal(int modifiers) {
+ return (modifiers & FINAL) != 0;
+ }
+
+ public boolean isNative(int modifiers) {
+ return (modifiers & NATIVE) != 0;
+ }
+
+ public boolean isStrictfp(int modifiers) {
+ return (modifiers & STRICTFP) != 0;
+ }
+
+ public boolean isSynchronized(int modifiers) {
+ return (modifiers & SYNCHRONIZED) != 0;
+ }
+
+ public boolean isTransient(int modifiers) {
+ return (modifiers & TRANSIENT) != 0;
+ }
+
+ public boolean isVolatile(int modifiers) {
+ return (modifiers & VOLATILE) != 0;
+ }
+
+ /** Removes the given modifier. */
+ static int removeModifier(int modifiers, int mod) {
+ return modifiers & ~mod;
+ }
+ }
+
+ public JavaParser(String fileName) {
+ this(System.in);
+ try {
+ ReInit(new FileInputStream(new File(fileName)));
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public SimpleNode popNode() {
+ if (jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode) jjtree.popNode();
+ else
+ return null;
+ }
+
+ public static void main(String args[]) {
+ JavaParser parser;
+ if (args.length == 0) {
+ System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
+ parser = new JavaParser(System.in);
+ } else if (args.length == 1) {
+ System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
+ try {
+ parser = new JavaParser(new java.io.FileInputStream(args[0]));
+ } catch (java.io.FileNotFoundException e) {
+ System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
+ return;
+ }
+ } else {
+ System.out.println("Java Parser Version 1.1: Usage is one of:");
+ System.out.println(" java JavaParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java JavaParser inputfile");
+ return;
+ }
+ try {
+ parser.CompilationUnit();
+ System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
+ }
+ }
+
+ final public boolean Line() throws ParseException {
+ /*@bgen(jjtree) Line */
+ SimpleNode jjtn000 = new SimpleNode(JJTLINE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 0:
+ jj_consume_token(0);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return true;
+ }
+ break;
+ default:
+ if (jj_2_1(2147483647)) {
+ BlockStatement();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else if (jj_2_2(2147483647)) {
+ ClassOrInterfaceBodyDeclaration(false);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else if (jj_2_3(2147483647)) {
+ ClassOrInterfaceBodyDeclaration(false);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else if (jj_2_4(2147483647)) {
+ Expression();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPORT:
+ ImportDeclaration();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ /**
+ * **************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ * ***************************************
+ */
+
+/*
+ * Program structuring syntax follows.
+ */
+ final public void CompilationUnit() throws ParseException {
+ /*@bgen(jjtree) CompilationUnit */
+ SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_5(2147483647)) {
+ PackageDeclaration();
+ } else {
+ ;
+ }
+ label_1:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPORT:
+ ;
+ break;
+ default:
+ break label_1;
+ }
+ ImportDeclaration();
+ }
+ label_2:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case CLASS:
+ case ENUM:
+ case FINAL:
+ case INTERFACE:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case SEMICOLON:
+ case AT:
+ ;
+ break;
+ default:
+ break label_2;
+ }
+ TypeDeclaration();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 123:
+ jj_consume_token(123);
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STUFF_TO_IGNORE:
+ jj_consume_token(STUFF_TO_IGNORE);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(0);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PackageDeclaration() throws ParseException {
+ /*@bgen(jjtree) PackageDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ jj_consume_token(PACKAGE);
+ Name();
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ImportDeclaration() throws ParseException {
+ /*@bgen(jjtree) ImportDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IMPORT);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STATIC:
+ jj_consume_token(STATIC);
+ break;
+ default:
+ ;
+ }
+ Name();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case DOT:
+ jj_consume_token(DOT);
+ jj_consume_token(STAR);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+ final public int Modifiers() throws ParseException {
+ /*@bgen(jjtree) Modifiers */
+ SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers = 0;
+ try {
+ label_3:
+ while (true) {
+ if (jj_2_6(2)) {
+ ;
+ } else {
+ break label_3;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PUBLIC:
+ jj_consume_token(PUBLIC);
+ modifiers |= ModifierSet.PUBLIC;
+ break;
+ case STATIC:
+ jj_consume_token(STATIC);
+ modifiers |= ModifierSet.STATIC;
+ break;
+ case PROTECTED:
+ jj_consume_token(PROTECTED);
+ modifiers |= ModifierSet.PROTECTED;
+ break;
+ case PRIVATE:
+ jj_consume_token(PRIVATE);
+ modifiers |= ModifierSet.PRIVATE;
+ break;
+ case FINAL:
+ jj_consume_token(FINAL);
+ modifiers |= ModifierSet.FINAL;
+ break;
+ case ABSTRACT:
+ jj_consume_token(ABSTRACT);
+ modifiers |= ModifierSet.ABSTRACT;
+ break;
+ case SYNCHRONIZED:
+ jj_consume_token(SYNCHRONIZED);
+ modifiers |= ModifierSet.SYNCHRONIZED;
+ break;
+ case NATIVE:
+ jj_consume_token(NATIVE);
+ modifiers |= ModifierSet.NATIVE;
+ break;
+ case TRANSIENT:
+ jj_consume_token(TRANSIENT);
+ modifiers |= ModifierSet.TRANSIENT;
+ break;
+ case VOLATILE:
+ jj_consume_token(VOLATILE);
+ modifiers |= ModifierSet.VOLATILE;
+ break;
+ case STRICTFP:
+ jj_consume_token(STRICTFP);
+ modifiers |= ModifierSet.STRICTFP;
+ break;
+ case AT:
+ Annotation();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return modifiers;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ /*
+ * Declaration syntax follows.
+ */
+ final public void TypeDeclaration() throws ParseException {
+ /*@bgen(jjtree) TypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ case ABSTRACT:
+ case CLASS:
+ case ENUM:
+ case FINAL:
+ case INTERFACE:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case AT:
+ modifiers = Modifiers();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(modifiers);
+ break;
+ case ENUM:
+ EnumDeclaration(modifiers);
+ break;
+ case AT:
+ AnnotationTypeDeclaration(modifiers);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ boolean isInterface = false;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ jj_consume_token(CLASS);
+ break;
+ case INTERFACE:
+ jj_consume_token(INTERFACE);
+ isInterface = true;
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeParameters();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ ExtendsList(isInterface);
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPLEMENTS:
+ ImplementsList(isInterface);
+ break;
+ default:
+ ;
+ }
+ ClassOrInterfaceBody(isInterface);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ExtendsList(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ExtendsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ boolean extendsMoreThanOne = false;
+ try {
+ jj_consume_token(EXTENDS);
+ ClassOrInterfaceType();
+ label_4:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_4;
+ }
+ jj_consume_token(COMMA);
+ ClassOrInterfaceType();
+ extendsMoreThanOne = true;
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ if (extendsMoreThanOne && !isInterface) {
+ if (true)
+ throw new ParseException("A class cannot extend more than one other class");
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ImplementsList(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ImplementsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IMPLEMENTS);
+ ClassOrInterfaceType();
+ label_5:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_5;
+ }
+ jj_consume_token(COMMA);
+ ClassOrInterfaceType();
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ if (isInterface) {
+ if (true)
+ throw new ParseException("An interface cannot implement other interfaces");
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EnumDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) EnumDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(ENUM);
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPLEMENTS:
+ ImplementsList(false);
+ break;
+ default:
+ ;
+ }
+ EnumBody();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EnumBody() throws ParseException {
+ /*@bgen(jjtree) EnumBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case FINAL:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ EnumConstant();
+ label_6:
+ while (true) {
+ if (jj_2_7(2)) {
+ ;
+ } else {
+ break label_6;
+ }
+ jj_consume_token(COMMA);
+ EnumConstant();
+ }
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ jj_consume_token(COMMA);
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ label_7:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOID:
+ case VOLATILE:
+ case IDENTIFIER:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case LT:
+ ;
+ break;
+ default:
+ break label_7;
+ }
+ ClassOrInterfaceBodyDeclaration(false);
+ }
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EnumConstant() throws ParseException {
+ /*@bgen(jjtree) EnumConstant */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LPAREN:
+ Arguments();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ ClassOrInterfaceBody(false);
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeParameters() throws ParseException {
+ /*@bgen(jjtree) TypeParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LT);
+ TypeParameter();
+ label_8:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_8;
+ }
+ jj_consume_token(COMMA);
+ TypeParameter();
+ }
+ jj_consume_token(GT);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeParameter() throws ParseException {
+ /*@bgen(jjtree) TypeParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ TypeBound();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeBound() throws ParseException {
+ /*@bgen(jjtree) TypeBound */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(EXTENDS);
+ ClassOrInterfaceType();
+ label_9:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BIT_AND:
+ ;
+ break;
+ default:
+ break label_9;
+ }
+ jj_consume_token(BIT_AND);
+ ClassOrInterfaceType();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceBody(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ label_10:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOID:
+ case VOLATILE:
+ case IDENTIFIER:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case LT:
+ ;
+ break;
+ default:
+ break label_10;
+ }
+ ClassOrInterfaceBodyDeclaration(isInterface);
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceBodyDeclaration(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ boolean isNestedInterface = false;
+ int modifiers;
+ try {
+ if (jj_2_10(2)) {
+ Initializer();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ if (isInterface) {
+ if (true)
+ throw new ParseException("An interface cannot have initializers");
+ }
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOID:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ case LT:
+ modifiers = Modifiers();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(modifiers);
+ break;
+ case ENUM:
+ EnumDeclaration(modifiers);
+ break;
+ default:
+ if (jj_2_8(2147483647)) {
+ ConstructorDeclaration();
+ } else if (jj_2_9(2147483647)) {
+ FieldDeclaration(modifiers);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case VOID:
+ case IDENTIFIER:
+ case LT:
+ MethodDeclaration(modifiers);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ break;
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void FieldDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) FieldDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Type();
+ VariableDeclarator();
+ label_11:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_11;
+ }
+ jj_consume_token(COMMA);
+ VariableDeclarator();
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void VariableDeclarator() throws ParseException {
+ /*@bgen(jjtree) VariableDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ VariableDeclaratorId();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSIGN:
+ jj_consume_token(ASSIGN);
+ VariableInitializer();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void VariableDeclaratorId() throws ParseException {
+ /*@bgen(jjtree) VariableDeclaratorId */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ label_12:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ;
+ break;
+ default:
+ break label_12;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void VariableInitializer() throws ParseException {
+ /*@bgen(jjtree) VariableInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ ArrayInitializer();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ Expression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ArrayInitializer() throws ParseException {
+ /*@bgen(jjtree) ArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ VariableInitializer();
+ label_13:
+ while (true) {
+ if (jj_2_11(2)) {
+ ;
+ } else {
+ break label_13;
+ }
+ jj_consume_token(COMMA);
+ VariableInitializer();
+ }
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ jj_consume_token(COMMA);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MethodDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) MethodDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeParameters();
+ break;
+ default:
+ ;
+ }
+ ResultType();
+ MethodDeclarator();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case THROWS:
+ jj_consume_token(THROWS);
+ NameList();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ Block();
+ break;
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MethodDeclarator() throws ParseException {
+ /*@bgen(jjtree) MethodDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ FormalParameters();
+ label_14:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ;
+ break;
+ default:
+ break label_14;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void FormalParameters() throws ParseException {
+ /*@bgen(jjtree) FormalParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ FormalParameter();
+ label_15:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_15;
+ }
+ jj_consume_token(COMMA);
+ FormalParameter();
+ }
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void FormalParameter() throws ParseException {
+ /*@bgen(jjtree) FormalParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ Type();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ELLIPSIS:
+ jj_consume_token(ELLIPSIS);
+ break;
+ default:
+ ;
+ }
+ VariableDeclaratorId();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConstructorDeclaration() throws ParseException {
+ /*@bgen(jjtree) ConstructorDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeParameters();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(IDENTIFIER);
+ FormalParameters();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case THROWS:
+ jj_consume_token(THROWS);
+ NameList();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(LBRACE);
+ if (jj_2_12(2147483647)) {
+ ExplicitConstructorInvocation();
+ } else {
+ ;
+ }
+ label_16:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case RETURN:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRANSIENT:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case VOLATILE:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ ;
+ break;
+ default:
+ break label_16;
+ }
+ BlockStatement();
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ExplicitConstructorInvocation() throws ParseException {
+ /*@bgen(jjtree) ExplicitConstructorInvocation */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ label_17:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ break label_17;
+ }
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(DOT);
+ }
+ if (jj_2_13(2)) {
+ jj_consume_token(THIS);
+ jj_consume_token(DOT);
+ } else {
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeArguments();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case THIS:
+ jj_consume_token(THIS);
+ break;
+ case SUPER:
+ jj_consume_token(SUPER);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ Arguments();
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Initializer() throws ParseException {
+ /*@bgen(jjtree) Initializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STATIC:
+ jj_consume_token(STATIC);
+ break;
+ default:
+ ;
+ }
+ Block();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Type, name and expression syntax follows.
+ */
+ final public void Type() throws ParseException {
+ /*@bgen(jjtree) Type */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_14(2)) {
+ ReferenceType();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ PrimitiveType();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ReferenceType() throws ParseException {
+ /*@bgen(jjtree) ReferenceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ PrimitiveType();
+ label_18:
+ while (true) {
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ if (jj_2_15(2)) {
+ ;
+ } else {
+ break label_18;
+ }
+ }
+ break;
+ case IDENTIFIER:
+ ClassOrInterfaceType();
+ label_19:
+ while (true) {
+ if (jj_2_16(2)) {
+ ;
+ } else {
+ break label_19;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceType() throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ if (jj_2_17(2)) {
+ TypeArguments();
+ } else {
+ ;
+ }
+ label_20:
+ while (true) {
+ if (jj_2_18(2)) {
+ ;
+ } else {
+ break label_20;
+ }
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ if (jj_2_19(2)) {
+ TypeArguments();
+ } else {
+ ;
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeArguments() throws ParseException {
+ /*@bgen(jjtree) TypeArguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LT);
+ TypeArgument();
+ label_21:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_21;
+ }
+ jj_consume_token(COMMA);
+ TypeArgument();
+ }
+ jj_consume_token(GT);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeArgument() throws ParseException {
+ /*@bgen(jjtree) TypeArgument */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case IDENTIFIER:
+ ReferenceType();
+ break;
+ case HOOK:
+ jj_consume_token(HOOK);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ case SUPER:
+ WildcardBounds();
+ break;
+ default:
+ ;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void WildcardBounds() throws ParseException {
+ /*@bgen(jjtree) WildcardBounds */
+ SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ jj_consume_token(EXTENDS);
+ ReferenceType();
+ break;
+ case SUPER:
+ jj_consume_token(SUPER);
+ ReferenceType();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimitiveType() throws ParseException {
+ /*@bgen(jjtree) PrimitiveType */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ jj_consume_token(BOOLEAN);
+ break;
+ case CHAR:
+ jj_consume_token(CHAR);
+ break;
+ case BYTE:
+ jj_consume_token(BYTE);
+ break;
+ case SHORT:
+ jj_consume_token(SHORT);
+ break;
+ case INT:
+ jj_consume_token(INT);
+ break;
+ case LONG:
+ jj_consume_token(LONG);
+ break;
+ case FLOAT:
+ jj_consume_token(FLOAT);
+ break;
+ case DOUBLE:
+ jj_consume_token(DOUBLE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ResultType() throws ParseException {
+ /*@bgen(jjtree) ResultType */
+ SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case VOID:
+ jj_consume_token(VOID);
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case IDENTIFIER:
+ Type();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Name() throws ParseException {
+ /*@bgen(jjtree) Name */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAME);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ label_22:
+ while (true) {
+ if (jj_2_20(2)) {
+ ;
+ } else {
+ break label_22;
+ }
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void NameList() throws ParseException {
+ /*@bgen(jjtree) NameList */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Name();
+ label_23:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_23;
+ }
+ jj_consume_token(COMMA);
+ Name();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Expression syntax follows.
+ */
+ final public void Expression() throws ParseException {
+ /*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ConditionalExpression();
+ if (jj_2_21(2)) {
+ AssignmentOperator();
+ Expression();
+ } else {
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AssignmentOperator() throws ParseException {
+ /*@bgen(jjtree) AssignmentOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSIGN:
+ jj_consume_token(ASSIGN);
+ break;
+ case STARASSIGN:
+ jj_consume_token(STARASSIGN);
+ break;
+ case SLASHASSIGN:
+ jj_consume_token(SLASHASSIGN);
+ break;
+ case REMASSIGN:
+ jj_consume_token(REMASSIGN);
+ break;
+ case PLUSASSIGN:
+ jj_consume_token(PLUSASSIGN);
+ break;
+ case MINUSASSIGN:
+ jj_consume_token(MINUSASSIGN);
+ break;
+ case LSHIFTASSIGN:
+ jj_consume_token(LSHIFTASSIGN);
+ break;
+ case RSIGNEDSHIFTASSIGN:
+ jj_consume_token(RSIGNEDSHIFTASSIGN);
+ break;
+ case RUNSIGNEDSHIFTASSIGN:
+ jj_consume_token(RUNSIGNEDSHIFTASSIGN);
+ break;
+ case ANDASSIGN:
+ jj_consume_token(ANDASSIGN);
+ break;
+ case XORASSIGN:
+ jj_consume_token(XORASSIGN);
+ break;
+ case ORASSIGN:
+ jj_consume_token(ORASSIGN);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AssignmentExpression() throws ParseException {
+ /*@bgen(jjtree) AssignmentExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ PrimaryExpression();
+ AssignmentOperator();
+ Expression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConditionalExpression() throws ParseException {
+ /*@bgen(jjtree) ConditionalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ConditionalOrExpression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case HOOK:
+ jj_consume_token(HOOK);
+ Expression();
+ jj_consume_token(COLON);
+ Expression();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConditionalOrExpression() throws ParseException {
+ /*@bgen(jjtree) ConditionalOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ConditionalAndExpression();
+ label_24:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SC_OR:
+ ;
+ break;
+ default:
+ break label_24;
+ }
+ jj_consume_token(SC_OR);
+ ConditionalAndExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConditionalAndExpression() throws ParseException {
+ /*@bgen(jjtree) ConditionalAndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ InclusiveOrExpression();
+ label_25:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SC_AND:
+ ;
+ break;
+ default:
+ break label_25;
+ }
+ jj_consume_token(SC_AND);
+ InclusiveOrExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void InclusiveOrExpression() throws ParseException {
+ /*@bgen(jjtree) InclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ExclusiveOrExpression();
+ label_26:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BIT_OR:
+ ;
+ break;
+ default:
+ break label_26;
+ }
+ jj_consume_token(BIT_OR);
+ ExclusiveOrExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ExclusiveOrExpression() throws ParseException {
+ /*@bgen(jjtree) ExclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ AndExpression();
+ label_27:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case XOR:
+ ;
+ break;
+ default:
+ break label_27;
+ }
+ jj_consume_token(XOR);
+ AndExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AndExpression() throws ParseException {
+ /*@bgen(jjtree) AndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ EqualityExpression();
+ label_28:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BIT_AND:
+ ;
+ break;
+ default:
+ break label_28;
+ }
+ jj_consume_token(BIT_AND);
+ EqualityExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EqualityExpression() throws ParseException {
+ /*@bgen(jjtree) EqualityExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ InstanceOfExpression();
+ label_29:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EQ:
+ case NE:
+ ;
+ break;
+ default:
+ break label_29;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EQ:
+ jj_consume_token(EQ);
+ break;
+ case NE:
+ jj_consume_token(NE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ InstanceOfExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void InstanceOfExpression() throws ParseException {
+ /*@bgen(jjtree) InstanceOfExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ RelationalExpression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INSTANCEOF:
+ jj_consume_token(INSTANCEOF);
+ Type();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void RelationalExpression() throws ParseException {
+ /*@bgen(jjtree) RelationalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ShiftExpression();
+ label_30:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ case LE:
+ case GE:
+ case GT:
+ ;
+ break;
+ default:
+ break label_30;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ jj_consume_token(LT);
+ break;
+ case GT:
+ jj_consume_token(GT);
+ break;
+ case LE:
+ jj_consume_token(LE);
+ break;
+ case GE:
+ jj_consume_token(GE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ ShiftExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ShiftExpression() throws ParseException {
+ /*@bgen(jjtree) ShiftExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ AdditiveExpression();
+ label_31:
+ while (true) {
+ if (jj_2_22(1)) {
+ ;
+ } else {
+ break label_31;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LSHIFT:
+ jj_consume_token(LSHIFT);
+ break;
+ default:
+ if (jj_2_23(1)) {
+ RSIGNEDSHIFT();
+ } else if (jj_2_24(1)) {
+ RUNSIGNEDSHIFT();
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ AdditiveExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AdditiveExpression() throws ParseException {
+ /*@bgen(jjtree) AdditiveExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ MultiplicativeExpression();
+ label_32:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ case MINUS:
+ ;
+ break;
+ default:
+ break label_32;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ jj_consume_token(PLUS);
+ break;
+ case MINUS:
+ jj_consume_token(MINUS);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ MultiplicativeExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MultiplicativeExpression() throws ParseException {
+ /*@bgen(jjtree) MultiplicativeExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ UnaryExpression();
+ label_33:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STAR:
+ case SLASH:
+ case REM:
+ ;
+ break;
+ default:
+ break label_33;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STAR:
+ jj_consume_token(STAR);
+ break;
+ case SLASH:
+ jj_consume_token(SLASH);
+ break;
+ case REM:
+ jj_consume_token(REM);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ UnaryExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void UnaryExpression() throws ParseException {
+ /*@bgen(jjtree) UnaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ case MINUS:
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ jj_consume_token(PLUS);
+ break;
+ case MINUS:
+ jj_consume_token(MINUS);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ UnaryExpression();
+ break;
+ case INCR:
+ PreIncrementExpression();
+ break;
+ case DECR:
+ PreDecrementExpression();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ UnaryExpressionNotPlusMinus();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PreIncrementExpression() throws ParseException {
+ /*@bgen(jjtree) PreIncrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(INCR);
+ PrimaryExpression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PreDecrementExpression() throws ParseException {
+ /*@bgen(jjtree) PreDecrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(DECR);
+ PrimaryExpression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void UnaryExpressionNotPlusMinus() throws ParseException {
+ /*@bgen(jjtree) UnaryExpressionNotPlusMinus */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BANG:
+ case TILDE:
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case TILDE:
+ jj_consume_token(TILDE);
+ break;
+ case BANG:
+ jj_consume_token(BANG);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ UnaryExpression();
+ break;
+ default:
+ if (jj_2_25(2147483647)) {
+ CastExpression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ PostfixExpression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+// This production is to determine lookahead only. The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+
+ // this.
+ final public void CastLookahead() throws ParseException {
+ /*@bgen(jjtree) CastLookahead */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_26(2)) {
+ jj_consume_token(LPAREN);
+ PrimitiveType();
+ } else if (jj_2_27(2147483647)) {
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(RPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case TILDE:
+ jj_consume_token(TILDE);
+ break;
+ case BANG:
+ jj_consume_token(BANG);
+ break;
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ break;
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ case THIS:
+ jj_consume_token(THIS);
+ break;
+ case SUPER:
+ jj_consume_token(SUPER);
+ break;
+ case NEW:
+ jj_consume_token(NEW);
+ break;
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ Literal();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PostfixExpression() throws ParseException {
+ /*@bgen(jjtree) PostfixExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ PrimaryExpression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INCR:
+ case DECR:
+ PostfixOperator();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PostfixOperator() throws ParseException {
+ /*@bgen(jjtree) PostfixOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INCR:
+ jj_consume_token(INCR);
+ break;
+ case DECR:
+ jj_consume_token(DECR);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void CastExpression() throws ParseException {
+ /*@bgen(jjtree) CastExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_28(2147483647)) {
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(RPAREN);
+ UnaryExpression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(RPAREN);
+ UnaryExpressionNotPlusMinus();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimaryExpression() throws ParseException {
+ /*@bgen(jjtree) PrimaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ PrimaryPrefix();
+ label_34:
+ while (true) {
+ if (jj_2_29(2)) {
+ ;
+ } else {
+ break label_34;
+ }
+ PrimarySuffix();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberSelector() throws ParseException {
+ /*@bgen(jjtree) MemberSelector */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(DOT);
+ TypeArguments();
+ jj_consume_token(IDENTIFIER);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimaryPrefix() throws ParseException {
+ /*@bgen(jjtree) PrimaryPrefix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ Literal();
+ break;
+ default:
+ if (jj_2_30(2147483647)) {
+ label_35:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ break label_35;
+ }
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(DOT);
+ }
+ jj_consume_token(THIS);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SUPER:
+ jj_consume_token(SUPER);
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ break;
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ break;
+ case NEW:
+ AllocationExpression();
+ break;
+ default:
+ if (jj_2_31(2147483647)) {
+ ResultType();
+ jj_consume_token(DOT);
+ jj_consume_token(CLASS);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ Name();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimarySuffix() throws ParseException {
+ /*@bgen(jjtree) PrimarySuffix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_32(2147483647)) {
+ jj_consume_token(DOT);
+ jj_consume_token(SUPER);
+ } else if (jj_2_33(2147483647)) {
+ jj_consume_token(DOT);
+ jj_consume_token(THIS);
+ } else if (jj_2_34(2)) {
+ jj_consume_token(DOT);
+ AllocationExpression();
+ } else if (jj_2_35(3)) {
+ MemberSelector();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ jj_consume_token(LBRACKET);
+ Expression();
+ jj_consume_token(RBRACKET);
+ break;
+ case DOT:
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ break;
+ case LPAREN:
+ Arguments();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Literal() throws ParseException {
+ /*@bgen(jjtree) Literal */
+ SimpleNode jjtn000 = new SimpleNode(JJTLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INTEGER_LITERAL:
+ jj_consume_token(INTEGER_LITERAL);
+ break;
+ case FLOATING_POINT_LITERAL:
+ jj_consume_token(FLOATING_POINT_LITERAL);
+ break;
+ case CHARACTER_LITERAL:
+ jj_consume_token(CHARACTER_LITERAL);
+ break;
+ case STRING_LITERAL:
+ jj_consume_token(STRING_LITERAL);
+ break;
+ case FALSE:
+ case TRUE:
+ BooleanLiteral();
+ break;
+ case NULL:
+ NullLiteral();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void BooleanLiteral() throws ParseException {
+ /*@bgen(jjtree) BooleanLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case TRUE:
+ jj_consume_token(TRUE);
+ break;
+ case FALSE:
+ jj_consume_token(FALSE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void NullLiteral() throws ParseException {
+ /*@bgen(jjtree) NullLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(NULL);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Arguments() throws ParseException {
+ /*@bgen(jjtree) Arguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ ArgumentList();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ArgumentList() throws ParseException {
+ /*@bgen(jjtree) ArgumentList */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Expression();
+ label_36:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_36;
+ }
+ jj_consume_token(COMMA);
+ Expression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AllocationExpression() throws ParseException {
+ /*@bgen(jjtree) AllocationExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_36(2)) {
+ jj_consume_token(NEW);
+ PrimitiveType();
+ ArrayDimsAndInits();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case NEW:
+ jj_consume_token(NEW);
+ ClassOrInterfaceType();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeArguments();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ArrayDimsAndInits();
+ break;
+ case LPAREN:
+ Arguments();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ ClassOrInterfaceBody(false);
+ break;
+ default:
+ ;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+ final public void ArrayDimsAndInits() throws ParseException {
+ /*@bgen(jjtree) ArrayDimsAndInits */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_39(2)) {
+ label_37:
+ while (true) {
+ jj_consume_token(LBRACKET);
+ Expression();
+ jj_consume_token(RBRACKET);
+ if (jj_2_37(2)) {
+ ;
+ } else {
+ break label_37;
+ }
+ }
+ label_38:
+ while (true) {
+ if (jj_2_38(2)) {
+ ;
+ } else {
+ break label_38;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ label_39:
+ while (true) {
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ;
+ break;
+ default:
+ break label_39;
+ }
+ }
+ ArrayInitializer();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Statement syntax follows.
+ */
+ final public void Statement() throws ParseException {
+ /*@bgen(jjtree) Statement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_40(2)) {
+ LabeledStatement();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSERT:
+ AssertStatement();
+ break;
+ case LBRACE:
+ Block();
+ break;
+ case SEMICOLON:
+ EmptyStatement();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case INCR:
+ case DECR:
+ StatementExpression();
+ jj_consume_token(SEMICOLON);
+ break;
+ case SWITCH:
+ SwitchStatement();
+ break;
+ case IF:
+ IfStatement();
+ break;
+ case WHILE:
+ WhileStatement();
+ break;
+ case DO:
+ DoStatement();
+ break;
+ case FOR:
+ ForStatement();
+ break;
+ case BREAK:
+ BreakStatement();
+ break;
+ case CONTINUE:
+ ContinueStatement();
+ break;
+ case RETURN:
+ ReturnStatement();
+ break;
+ case THROW:
+ ThrowStatement();
+ break;
+ case SYNCHRONIZED:
+ SynchronizedStatement();
+ break;
+ case TRY:
+ TryStatement();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AssertStatement() throws ParseException {
+ /*@bgen(jjtree) AssertStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(ASSERT);
+ Expression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COLON:
+ jj_consume_token(COLON);
+ Expression();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void LabeledStatement() throws ParseException {
+ /*@bgen(jjtree) LabeledStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(COLON);
+ Statement();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Block() throws ParseException {
+ /*@bgen(jjtree) Block */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCK);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ label_40:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case RETURN:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRANSIENT:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case VOLATILE:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ ;
+ break;
+ default:
+ break label_40;
+ }
+ BlockStatement();
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void BlockStatement() throws ParseException {
+ /*@bgen(jjtree) BlockStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_41(2147483647)) {
+ LocalVariableDeclaration();
+ jj_consume_token(SEMICOLON);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case RETURN:
+ case SHORT:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case INCR:
+ case DECR:
+ Statement();
+ break;
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(0);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void LocalVariableDeclaration() throws ParseException {
+ /*@bgen(jjtree) LocalVariableDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ Type();
+ VariableDeclarator();
+ label_41:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_41;
+ }
+ jj_consume_token(COMMA);
+ VariableDeclarator();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EmptyStatement() throws ParseException {
+ /*@bgen(jjtree) EmptyStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(SEMICOLON);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void StatementExpression() throws ParseException {
+ /*@bgen(jjtree) StatementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INCR:
+ PreIncrementExpression();
+ break;
+ case DECR:
+ PreDecrementExpression();
+ break;
+ default:
+ if (jj_2_42(2147483647)) {
+ AssignmentExpression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ PostfixExpression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SwitchStatement() throws ParseException {
+ /*@bgen(jjtree) SwitchStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(SWITCH);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ jj_consume_token(LBRACE);
+ label_42:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CASE:
+ case _DEFAULT:
+ ;
+ break;
+ default:
+ break label_42;
+ }
+ SwitchLabel();
+ label_43:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case RETURN:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRANSIENT:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case VOLATILE:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ ;
+ break;
+ default:
+ break label_43;
+ }
+ BlockStatement();
+ }
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SwitchLabel() throws ParseException {
+ /*@bgen(jjtree) SwitchLabel */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CASE:
+ jj_consume_token(CASE);
+ Expression();
+ jj_consume_token(COLON);
+ break;
+ case _DEFAULT:
+ jj_consume_token(_DEFAULT);
+ jj_consume_token(COLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void IfStatement() throws ParseException {
+ /*@bgen(jjtree) IfStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IF);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ Statement();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ELSE:
+ jj_consume_token(ELSE);
+ Statement();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void WhileStatement() throws ParseException {
+ /*@bgen(jjtree) WhileStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(WHILE);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ Statement();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void DoStatement() throws ParseException {
+ /*@bgen(jjtree) DoStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(DO);
+ Statement();
+ jj_consume_token(WHILE);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ForStatement() throws ParseException {
+ /*@bgen(jjtree) ForStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(FOR);
+ jj_consume_token(LPAREN);
+ if (jj_2_43(2147483647)) {
+ Modifiers();
+ Type();
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(COLON);
+ Expression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SYNCHRONIZED:
+ case THIS:
+ case TRANSIENT:
+ case TRUE:
+ case VOID:
+ case VOLATILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SYNCHRONIZED:
+ case THIS:
+ case TRANSIENT:
+ case TRUE:
+ case VOID:
+ case VOLATILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case AT:
+ case INCR:
+ case DECR:
+ ForInit();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ Expression();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case INCR:
+ case DECR:
+ ForUpdate();
+ break;
+ default:
+ ;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jj_consume_token(RPAREN);
+ Statement();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ForInit() throws ParseException {
+ /*@bgen(jjtree) ForInit */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORINIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_44(2147483647)) {
+ LocalVariableDeclaration();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case INCR:
+ case DECR:
+ StatementExpressionList();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void StatementExpressionList() throws ParseException {
+ /*@bgen(jjtree) StatementExpressionList */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ StatementExpression();
+ label_44:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_44;
+ }
+ jj_consume_token(COMMA);
+ StatementExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ForUpdate() throws ParseException {
+ /*@bgen(jjtree) ForUpdate */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ StatementExpressionList();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void BreakStatement() throws ParseException {
+ /*@bgen(jjtree) BreakStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(BREAK);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ContinueStatement() throws ParseException {
+ /*@bgen(jjtree) ContinueStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(CONTINUE);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ReturnStatement() throws ParseException {
+ /*@bgen(jjtree) ReturnStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(RETURN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ Expression();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ThrowStatement() throws ParseException {
+ /*@bgen(jjtree) ThrowStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(THROW);
+ Expression();
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SynchronizedStatement() throws ParseException {
+ /*@bgen(jjtree) SynchronizedStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(SYNCHRONIZED);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ Block();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TryStatement() throws ParseException {
+ /*@bgen(jjtree) TryStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(TRY);
+ Block();
+ label_45:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CATCH:
+ ;
+ break;
+ default:
+ break label_45;
+ }
+ jj_consume_token(CATCH);
+ jj_consume_token(LPAREN);
+ FormalParameter();
+ jj_consume_token(RPAREN);
+ Block();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case FINALLY:
+ jj_consume_token(FINALLY);
+ Block();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+ final public void RUNSIGNEDSHIFT() throws ParseException {
+ /*@bgen(jjtree) RUNSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT) {
+
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(GT);
+ jj_consume_token(GT);
+ jj_consume_token(GT);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void RSIGNEDSHIFT() throws ParseException {
+ /*@bgen(jjtree) RSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT) {
+
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(GT);
+ jj_consume_token(GT);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /* Annotation syntax follows. */
+ final public void Annotation() throws ParseException {
+ /*@bgen(jjtree) Annotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_45(2147483647)) {
+ NormalAnnotation();
+ } else if (jj_2_46(2147483647)) {
+ SingleMemberAnnotation();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case AT:
+ MarkerAnnotation();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void NormalAnnotation() throws ParseException {
+ /*@bgen(jjtree) NormalAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ Name();
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ MemberValuePairs();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MarkerAnnotation() throws ParseException {
+ /*@bgen(jjtree) MarkerAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ Name();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SingleMemberAnnotation() throws ParseException {
+ /*@bgen(jjtree) SingleMemberAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ Name();
+ jj_consume_token(LPAREN);
+ MemberValue();
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValuePairs() throws ParseException {
+ /*@bgen(jjtree) MemberValuePairs */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ MemberValuePair();
+ label_46:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_46;
+ }
+ jj_consume_token(COMMA);
+ MemberValuePair();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValuePair() throws ParseException {
+ /*@bgen(jjtree) MemberValuePair */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(ASSIGN);
+ MemberValue();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValue() throws ParseException {
+ /*@bgen(jjtree) MemberValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case AT:
+ Annotation();
+ break;
+ case LBRACE:
+ MemberValueArrayInitializer();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ ConditionalExpression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValueArrayInitializer() throws ParseException {
+ /*@bgen(jjtree) MemberValueArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ MemberValue();
+ label_47:
+ while (true) {
+ if (jj_2_47(2)) {
+ ;
+ } else {
+ break label_47;
+ }
+ jj_consume_token(COMMA);
+ MemberValue();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ jj_consume_token(COMMA);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /* Annotation Types. */
+ final public void AnnotationTypeDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) AnnotationTypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ jj_consume_token(INTERFACE);
+ jj_consume_token(IDENTIFIER);
+ AnnotationTypeBody();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnnotationTypeBody() throws ParseException {
+ /*@bgen(jjtree) AnnotationTypeBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ label_48:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case SEMICOLON:
+ case AT:
+ ;
+ break;
+ default:
+ break label_48;
+ }
+ AnnotationTypeMemberDeclaration();
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnnotationTypeMemberDeclaration() throws ParseException {
+ /*@bgen(jjtree) AnnotationTypeMemberDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ modifiers = Modifiers();
+ if (jj_2_48(2147483647)) {
+ Type();
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(LPAREN);
+ jj_consume_token(RPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case _DEFAULT:
+ DefaultValue();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(modifiers);
+ break;
+ case ENUM:
+ EnumDeclaration(modifiers);
+ break;
+ case AT:
+ AnnotationTypeDeclaration(modifiers);
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case IDENTIFIER:
+ FieldDeclaration(modifiers);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ break;
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void DefaultValue() throws ParseException {
+ /*@bgen(jjtree) DefaultValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(_DEFAULT);
+ MemberValue();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final private boolean jj_2_1(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_1();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_2(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_2();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_3(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_3();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_4(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_4();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_5(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_5();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_6(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_6();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_7(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_7();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_8(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_8();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_9(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_9();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_10(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_10();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_11(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_11();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_12(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_12();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_13(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_13();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_14(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_14();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_15(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_15();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_16(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_16();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_17(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_17();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_18(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_18();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_19(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_19();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_20(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_20();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_21(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_21();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_22(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_22();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_23(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_23();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_24(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_24();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_25(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_25();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_26(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_26();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_27(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_27();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_28(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_28();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_29(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_29();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_30(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_30();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_31(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_31();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_32(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_32();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_33(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_33();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_34(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_34();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_35(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_35();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_36(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_36();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_37(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_37();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_38(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_38();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_39(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_39();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_40(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_40();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_41(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_41();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_42(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_42();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_43(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_43();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_44(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_44();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_45(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_45();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_46(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_46();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_47(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_47();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_48(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_48();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_3R_56() {
+ if (jj_3R_101()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_21()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_135() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_91()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_99() {
+ if (jj_3R_91()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_135()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_20() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_91() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_20()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_122() {
+ if (jj_3R_72()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_86() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(58)) {
+ jj_scanpos = xsp;
+ if (jj_3R_122()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_19() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_83() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(10)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(15)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(12)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(46)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(35)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(37)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(28)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(21)) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_194() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_112()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_290() {
+ if (jj_scan_token(SUPER)) return true;
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_16() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_289() {
+ if (jj_scan_token(EXTENDS)) return true;
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_277() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_289()) {
+ jj_scanpos = xsp;
+ if (jj_3R_290()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_256() {
+ if (jj_3R_277()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_151() {
+ if (jj_scan_token(HOOK)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_256()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3_17() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_112() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_150()) {
+ jj_scanpos = xsp;
+ if (jj_3R_151()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_150() {
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_15() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_78() {
+ if (jj_scan_token(LT)) return true;
+ if (jj_3R_112()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_194()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_18() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_19()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_149() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_17()) jj_scanpos = xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_18()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_111() {
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_16()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_110() {
+ if (jj_3R_83()) return true;
+ Token xsp;
+ if (jj_3_15()) return true;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_15()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_77() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_110()) {
+ jj_scanpos = xsp;
+ if (jj_3R_111()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_13() {
+ if (jj_scan_token(THIS)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_221() {
+ if (jj_scan_token(THROWS)) return true;
+ if (jj_3R_99()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_103() {
+ if (jj_3R_83()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_72() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_14()) {
+ jj_scanpos = xsp;
+ if (jj_3R_103()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_14() {
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_74() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(47)) jj_scanpos = xsp;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_12() {
+ if (jj_3R_76()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_108() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_107() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_252() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_76() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_107()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_3_13()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_108()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(52)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(49)) return true;
+ }
+ if (jj_3R_109()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_134() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_133()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_223() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_222() {
+ if (jj_3R_76()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_220() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_186() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_220()) jj_scanpos = xsp;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_3R_53()) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_221()) jj_scanpos = xsp;
+ if (jj_scan_token(LBRACE)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_222()) jj_scanpos = xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_223()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_11() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_75()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_227() {
+ if (jj_scan_token(THROWS)) return true;
+ if (jj_3R_99()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_98() {
+ if (jj_3R_133()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_134()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_133() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(119)) jj_scanpos = xsp;
+ if (jj_3R_184()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_53() {
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_98()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_48() {
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_226() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_3R_53()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_252()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_228() {
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_225() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_292() {
+ if (jj_3R_75()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_11()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_188() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_225()) jj_scanpos = xsp;
+ if (jj_3R_86()) return true;
+ if (jj_3R_226()) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_227()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_228()) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(81)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_198() {
+ if (jj_scan_token(ASSIGN)) return true;
+ if (jj_3R_75()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_224() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_161()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_47() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_93()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_217() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_147() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_292()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) jj_scanpos = xsp;
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_73() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_106() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_105() {
+ if (jj_3R_147()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_75() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_105()) {
+ jj_scanpos = xsp;
+ if (jj_3R_106()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_184() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_217()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_160() {
+ if (jj_scan_token(LBRACE)) return true;
+ if (jj_3R_93()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_47()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) jj_scanpos = xsp;
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_276() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_275()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_161() {
+ if (jj_3R_184()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_198()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_127() {
+ if (jj_3R_101()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_9() {
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_73()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(85)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(81)) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_126() {
+ if (jj_3R_160()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_71() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_93() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_125()) {
+ jj_scanpos = xsp;
+ if (jj_3R_126()) {
+ jj_scanpos = xsp;
+ if (jj_3R_127()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_125() {
+ if (jj_3R_102()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_8() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_71()) jj_scanpos = xsp;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_187() {
+ if (jj_3R_72()) return true;
+ if (jj_3R_161()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_224()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_275() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(ASSIGN)) return true;
+ if (jj_3R_93()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_140() {
+ if (jj_3R_188()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_139() {
+ if (jj_3R_187()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_249() {
+ if (jj_scan_token(BIT_AND)) return true;
+ if (jj_3R_149()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_138() {
+ if (jj_3R_186()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_255() {
+ if (jj_3R_275()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_276()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_231() {
+ if (jj_3R_255()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_137() {
+ if (jj_3R_185()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_92() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(ASSIGN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_136() {
+ if (jj_3R_130()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_192() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_93()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_286() {
+ if (jj_3R_182()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_100() {
+ if (jj_3R_50()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_136()) {
+ jj_scanpos = xsp;
+ if (jj_3R_137()) {
+ jj_scanpos = xsp;
+ if (jj_3R_138()) {
+ jj_scanpos = xsp;
+ if (jj_3R_139()) {
+ jj_scanpos = xsp;
+ if (jj_3R_140()) return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_193() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_46() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_10() {
+ if (jj_3R_74()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_55() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_10()) {
+ jj_scanpos = xsp;
+ if (jj_3R_100()) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(81)) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_191() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_231()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_45() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_92()) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(76)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_215() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_132() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_131()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_183() {
+ if (jj_3R_216()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_285() {
+ if (jj_3R_109()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_145() {
+ if (jj_3R_193()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_182() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_215()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_144() {
+ if (jj_3R_192()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_113() {
+ return false;
+ }
+
+ final private boolean jj_3R_102() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_143()) {
+ jj_scanpos = xsp;
+ if (jj_3R_144()) {
+ jj_scanpos = xsp;
+ if (jj_3R_145()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_143() {
+ if (jj_3R_191()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_216() {
+ if (jj_scan_token(EXTENDS)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_249()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_131() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_183()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_114() {
+ return false;
+ }
+
+ final private boolean jj_3_7() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_70()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_80() {
+ Token xsp;
+ xsp = jj_scanpos;
+ lookingAhead = true;
+ jj_semLA = getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT;
+ lookingAhead = false;
+ if (!jj_semLA || jj_3R_113()) return true;
+ if (jj_scan_token(GT)) return true;
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_97() {
+ if (jj_scan_token(LT)) return true;
+ if (jj_3R_131()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_132()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_272() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_70() {
+ if (jj_3R_50()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_285()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_286()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_81() {
+ Token xsp;
+ xsp = jj_scanpos;
+ lookingAhead = true;
+ jj_semLA = getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT;
+ lookingAhead = false;
+ if (!jj_semLA || jj_3R_114()) return true;
+ if (jj_scan_token(GT)) return true;
+ if (jj_scan_token(GT)) return true;
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_251() {
+ if (jj_scan_token(SEMICOLON)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_272()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_250() {
+ if (jj_3R_70()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_7()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_246() {
+ if (jj_scan_token(FINALLY)) return true;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_219() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_250()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_251()) jj_scanpos = xsp;
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_245() {
+ if (jj_scan_token(CATCH)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_133()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_212() {
+ if (jj_scan_token(TRY)) return true;
+ if (jj_3R_104()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_245()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_3R_246()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_218() {
+ if (jj_3R_214()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_185() {
+ if (jj_scan_token(ENUM)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_218()) jj_scanpos = xsp;
+ if (jj_3R_219()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_211() {
+ if (jj_scan_token(SYNCHRONIZED)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_244() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_248() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_149()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_214() {
+ if (jj_scan_token(IMPLEMENTS)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_248()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_210() {
+ if (jj_scan_token(THROW)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_271() {
+ if (jj_3R_284()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_299() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_201()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_209() {
+ if (jj_scan_token(RETURN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_244()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_247() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_149()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_213() {
+ if (jj_scan_token(EXTENDS)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_247()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_208() {
+ if (jj_scan_token(CONTINUE)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(72)) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_178() {
+ if (jj_scan_token(INTERFACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_207() {
+ if (jj_scan_token(BREAK)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(72)) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_181() {
+ if (jj_3R_214()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_180() {
+ if (jj_3R_213()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_179() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_284() {
+ if (jj_3R_296()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_270() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_130() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(16)) {
+ jj_scanpos = xsp;
+ if (jj_3R_178()) return true;
+ }
+ if (jj_scan_token(IDENTIFIER)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_179()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_180()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_181()) jj_scanpos = xsp;
+ if (jj_3R_182()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_44() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_296() {
+ if (jj_3R_201()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_299()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_241() {
+ if (jj_scan_token(ELSE)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_295() {
+ if (jj_3R_296()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_43() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_294() {
+ if (jj_3R_128()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_283() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_294()) {
+ jj_scanpos = xsp;
+ if (jj_3R_295()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_269() {
+ if (jj_3R_283()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_243() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_269()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_270()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_271()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_242() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_54() {
+ if (jj_scan_token(THROWS)) return true;
+ if (jj_3R_99()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_206() {
+ if (jj_scan_token(FOR)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_242()) {
+ jj_scanpos = xsp;
+ if (jj_3R_243()) return true;
+ }
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_69() {
+ if (jj_3R_102()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_205() {
+ if (jj_scan_token(DO)) return true;
+ if (jj_3R_129()) return true;
+ if (jj_scan_token(WHILE)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_68() {
+ if (jj_scan_token(STRICTFP)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_67() {
+ if (jj_scan_token(VOLATILE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_66() {
+ if (jj_scan_token(TRANSIENT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_204() {
+ if (jj_scan_token(WHILE)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_65() {
+ if (jj_scan_token(NATIVE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_64() {
+ if (jj_scan_token(SYNCHRONIZED)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_63() {
+ if (jj_scan_token(ABSTRACT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_268() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_203() {
+ if (jj_scan_token(IF)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_129()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_241()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_62() {
+ if (jj_scan_token(FINAL)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_61() {
+ if (jj_scan_token(PRIVATE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_162() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_161()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_60() {
+ if (jj_scan_token(PROTECTED)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_59() {
+ if (jj_scan_token(STATIC)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_58() {
+ if (jj_scan_token(PUBLIC)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_282() {
+ if (jj_scan_token(_DEFAULT)) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_6() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_58()) {
+ jj_scanpos = xsp;
+ if (jj_3R_59()) {
+ jj_scanpos = xsp;
+ if (jj_3R_60()) {
+ jj_scanpos = xsp;
+ if (jj_3R_61()) {
+ jj_scanpos = xsp;
+ if (jj_3R_62()) {
+ jj_scanpos = xsp;
+ if (jj_3R_63()) {
+ jj_scanpos = xsp;
+ if (jj_3R_64()) {
+ jj_scanpos = xsp;
+ if (jj_3R_65()) {
+ jj_scanpos = xsp;
+ if (jj_3R_66()) {
+ jj_scanpos = xsp;
+ if (jj_3R_67()) {
+ jj_scanpos = xsp;
+ if (jj_3R_68()) {
+ jj_scanpos = xsp;
+ if (jj_3R_69()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_281() {
+ if (jj_scan_token(CASE)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_267() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_281()) {
+ jj_scanpos = xsp;
+ if (jj_3R_282()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_50() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_6()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_240() {
+ if (jj_3R_267()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_268()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_42() {
+ if (jj_3R_90()) return true;
+ if (jj_3R_79()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_202() {
+ if (jj_scan_token(SWITCH)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_240()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_239() {
+ if (jj_3R_266()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_57() {
+ if (jj_3R_102()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_52() {
+ if (jj_3R_86()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_238() {
+ if (jj_3R_265()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_5() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_57()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(PACKAGE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_237() {
+ if (jj_3R_264()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_201() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_236()) {
+ jj_scanpos = xsp;
+ if (jj_3R_237()) {
+ jj_scanpos = xsp;
+ if (jj_3R_238()) {
+ jj_scanpos = xsp;
+ if (jj_3R_239()) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_236() {
+ if (jj_3R_263()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_200() {
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_41() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_128() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_3R_161()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_162()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_51() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_235() {
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_96() {
+ if (jj_3R_130()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_95() {
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_4() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_94() {
+ if (jj_3R_128()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_49() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_94()) {
+ jj_scanpos = xsp;
+ if (jj_3R_95()) {
+ jj_scanpos = xsp;
+ if (jj_3R_96()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_146() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_3() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_104() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_146()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_2() {
+ if (jj_3R_50()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_51()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_52()) jj_scanpos = xsp;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_3R_53()) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_54()) jj_scanpos = xsp;
+ if (jj_scan_token(LBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_89() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_1() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_199() {
+ if (jj_scan_token(ASSERT)) return true;
+ if (jj_3R_56()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_235()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_177() {
+ if (jj_3R_212()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_176() {
+ if (jj_3R_211()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_38() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_175() {
+ if (jj_3R_210()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_174() {
+ if (jj_3R_209()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_173() {
+ if (jj_3R_208()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_172() {
+ if (jj_3R_207()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_171() {
+ if (jj_3R_206()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_170() {
+ if (jj_3R_205()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_169() {
+ if (jj_3R_204()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_168() {
+ if (jj_3R_203()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_167() {
+ if (jj_3R_202()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_166() {
+ if (jj_3R_201()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_165() {
+ if (jj_3R_200()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_164() {
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_163() {
+ if (jj_3R_199()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_260() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_40() {
+ if (jj_3R_89()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_129() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_40()) {
+ jj_scanpos = xsp;
+ if (jj_3R_163()) {
+ jj_scanpos = xsp;
+ if (jj_3R_164()) {
+ jj_scanpos = xsp;
+ if (jj_3R_165()) {
+ jj_scanpos = xsp;
+ if (jj_3R_166()) {
+ jj_scanpos = xsp;
+ if (jj_3R_167()) {
+ jj_scanpos = xsp;
+ if (jj_3R_168()) {
+ jj_scanpos = xsp;
+ if (jj_3R_169()) {
+ jj_scanpos = xsp;
+ if (jj_3R_170()) {
+ jj_scanpos = xsp;
+ if (jj_3R_171()) {
+ jj_scanpos = xsp;
+ if (jj_3R_172()) {
+ jj_scanpos = xsp;
+ if (jj_3R_173()) {
+ jj_scanpos = xsp;
+ if (jj_3R_174()) {
+ jj_scanpos = xsp;
+ if (jj_3R_175()) {
+ jj_scanpos = xsp;
+ if (jj_3R_176()) {
+ jj_scanpos = xsp;
+ if (jj_3R_177())
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_279() {
+ if (jj_3R_182()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_291() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_278() {
+ Token xsp;
+ if (jj_3R_291()) return true;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_291()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_3R_147()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_37() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_39() {
+ Token xsp;
+ if (jj_3_37()) return true;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_37()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_38()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_259() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_39()) {
+ jj_scanpos = xsp;
+ if (jj_3R_278()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_262() {
+ if (jj_3R_109()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_279()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_232() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_261() {
+ if (jj_3R_259()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_123() {
+ if (jj_scan_token(NEW)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_260()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_261()) {
+ jj_scanpos = xsp;
+ if (jj_3R_262()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_87() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_36()) {
+ jj_scanpos = xsp;
+ if (jj_3R_123()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_36() {
+ if (jj_scan_token(NEW)) return true;
+ if (jj_3R_83()) return true;
+ if (jj_3R_259()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_148() {
+ if (jj_3R_195()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_195() {
+ if (jj_3R_56()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_232()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_109() {
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_148()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_258() {
+ if (jj_scan_token(NULL)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_257() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(56)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(25)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_234() {
+ if (jj_3R_258()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_233() {
+ if (jj_3R_257()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_196() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(61)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(65)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(70)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(71)) {
+ jj_scanpos = xsp;
+ if (jj_3R_233()) {
+ jj_scanpos = xsp;
+ if (jj_3R_234()) return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_152() {
+ if (jj_3R_196()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_121() {
+ if (jj_3R_109()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_120() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_33() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_119() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_32() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(SUPER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_35() {
+ if (jj_3R_88()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_34() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_3R_87()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_118() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_31() {
+ if (jj_3R_86()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(CLASS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_117() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(SUPER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_84() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_117()) {
+ jj_scanpos = xsp;
+ if (jj_3R_118()) {
+ jj_scanpos = xsp;
+ if (jj_3_34()) {
+ jj_scanpos = xsp;
+ if (jj_3_35()) {
+ jj_scanpos = xsp;
+ if (jj_3R_119()) {
+ jj_scanpos = xsp;
+ if (jj_3R_120()) {
+ jj_scanpos = xsp;
+ if (jj_3R_121()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_85() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_159() {
+ if (jj_3R_91()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_30() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_85()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_158() {
+ if (jj_3R_86()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(CLASS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_157() {
+ if (jj_3R_87()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_156() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_29() {
+ if (jj_3R_84()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_155() {
+ if (jj_scan_token(SUPER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_197() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_154() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_197()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_124() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_153()) {
+ jj_scanpos = xsp;
+ if (jj_3R_154()) {
+ jj_scanpos = xsp;
+ if (jj_3R_155()) {
+ jj_scanpos = xsp;
+ if (jj_3R_156()) {
+ jj_scanpos = xsp;
+ if (jj_3R_157()) {
+ jj_scanpos = xsp;
+ if (jj_3R_158()) {
+ jj_scanpos = xsp;
+ if (jj_3R_159()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_153() {
+ if (jj_3R_196()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_88() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_3R_78()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_280() {
+ if (jj_3R_293()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_28() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_83()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_90() {
+ if (jj_3R_124()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_29()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_319() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_313()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_318() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_317() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_318()) {
+ jj_scanpos = xsp;
+ if (jj_3R_319()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_293() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(97)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(98)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_27() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(LBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_266() {
+ if (jj_3R_90()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_280()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_116() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(88)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(87)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(75)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(72)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(52)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(49)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(39)) {
+ jj_scanpos = xsp;
+ if (jj_3R_152()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_115() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_82() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_26()) {
+ jj_scanpos = xsp;
+ if (jj_3R_115()) {
+ jj_scanpos = xsp;
+ if (jj_3R_116()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_26() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_83()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_25() {
+ if (jj_3R_82()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_24() {
+ if (jj_3R_81()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_316() {
+ if (jj_3R_266()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_315() {
+ if (jj_3R_317()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_314() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(88)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(87)) return true;
+ }
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_313() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_314()) {
+ jj_scanpos = xsp;
+ if (jj_3R_315()) {
+ jj_scanpos = xsp;
+ if (jj_3R_316()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_264() {
+ if (jj_scan_token(DECR)) return true;
+ if (jj_3R_90()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_306() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(99)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(100)) return true;
+ }
+ if (jj_3R_305()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_308() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(101)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(102)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(106)) return true;
+ }
+ }
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_23() {
+ if (jj_3R_80()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_263() {
+ if (jj_scan_token(INCR)) return true;
+ if (jj_3R_90()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_312() {
+ if (jj_3R_313()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_22() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(107)) {
+ jj_scanpos = xsp;
+ if (jj_3_23()) {
+ jj_scanpos = xsp;
+ if (jj_3_24()) return true;
+ }
+ }
+ if (jj_3R_304()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_311() {
+ if (jj_3R_264()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_310() {
+ if (jj_3R_263()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_309() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(99)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(100)) return true;
+ }
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_307() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_309()) {
+ jj_scanpos = xsp;
+ if (jj_3R_310()) {
+ jj_scanpos = xsp;
+ if (jj_3R_311()) {
+ jj_scanpos = xsp;
+ if (jj_3R_312()) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_303() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(86)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(122)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(92)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(93)) return true;
+ }
+ }
+ }
+ if (jj_3R_302()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_301() {
+ if (jj_scan_token(INSTANCEOF)) return true;
+ if (jj_3R_72()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_305() {
+ if (jj_3R_307()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_308()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_298() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(91)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(94)) return true;
+ }
+ if (jj_3R_297()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_304() {
+ if (jj_3R_305()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_306()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_302() {
+ if (jj_3R_304()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_22()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_288() {
+ if (jj_scan_token(BIT_AND)) return true;
+ if (jj_3R_287()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_300() {
+ if (jj_3R_302()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_303()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_254() {
+ if (jj_scan_token(BIT_OR)) return true;
+ if (jj_3R_253()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_297() {
+ if (jj_3R_300()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_301()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_274() {
+ if (jj_scan_token(XOR)) return true;
+ if (jj_3R_273()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_230() {
+ if (jj_scan_token(SC_AND)) return true;
+ if (jj_3R_229()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_287() {
+ if (jj_3R_297()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_298()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_190() {
+ if (jj_scan_token(SC_OR)) return true;
+ if (jj_3R_189()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_273() {
+ if (jj_3R_287()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_288()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_142() {
+ if (jj_scan_token(HOOK)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_253() {
+ if (jj_3R_273()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_274()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_229() {
+ if (jj_3R_253()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_254()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_189() {
+ if (jj_3R_229()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_230()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_141() {
+ if (jj_3R_189()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_190()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_101() {
+ if (jj_3R_141()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_142()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_265() {
+ if (jj_3R_90()) return true;
+ if (jj_3R_79()) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_79() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(85)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(110)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(111)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(115)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(108)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(109)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(116)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(117)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(118)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(112)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(114)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(113))
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_21() {
+ if (jj_3R_79()) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ public JavaParserTokenManager token_source;
+ JavaCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private Token jj_scanpos, jj_lastpos;
+ private int jj_la;
+ public boolean lookingAhead = false;
+ private boolean jj_semLA;
+
+ public JavaParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+
+ public JavaParser(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream = new JavaCharStream(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source = new JavaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ }
+
+ public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+
+ public void ReInit(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream.ReInit(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ }
+
+ public JavaParser(java.io.Reader stream) {
+ jj_input_stream = new JavaCharStream(stream, 1, 1);
+ token_source = new JavaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ }
+
+ public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ }
+
+ public JavaParser(JavaParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ }
+
+ public void ReInit(JavaParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ }
+
+ final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ return token;
+ }
+ token = oldToken;
+ throw generateParseException();
+ }
+
+ static private final class LookaheadSuccess extends java.lang.Error {
+ }
+
+ final private LookaheadSuccess jj_ls = new LookaheadSuccess();
+
+ final private boolean jj_scan_token(int kind) {
+ if (jj_scanpos == jj_lastpos) {
+ jj_la--;
+ if (jj_scanpos.next == null) {
+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
+ } else {
+ jj_lastpos = jj_scanpos = jj_scanpos.next;
+ }
+ } else {
+ jj_scanpos = jj_scanpos.next;
+ }
+ if (jj_scanpos.kind != kind) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
+ return false;
+ }
+
+ final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ return token;
+ }
+
+ final public Token getToken(int index) {
+ Token t = lookingAhead ? jj_scanpos : token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ final private int jj_ntk() {
+ if ((jj_nt = token.next) == null)
+ return (jj_ntk = (token.next = token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ public ParseException generateParseException() {
+ Token errortok = token.next;
+ int line = errortok.beginLine, column = errortok.beginColumn;
+ String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
+ return new ParseException("Unable to parse Java code near token: " + mess, line, column);
+ }
+
+ final public void enable_tracing() {
+ }
+
+ final public void disable_tracing() {
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParserConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,260 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserConstants.java */
+package jaxx.compiler.parser.java;
+
+public interface JavaParserConstants {
+
+ int EOF = 0;
+ int WHITE_SPACE = 3;
+ int SINGLE_LINE_COMMENT = 4;
+ int FORMAL_COMMENT = 5;
+ int MULTI_LINE_COMMENT = 6;
+ int ABSTRACT = 8;
+ int ASSERT = 9;
+ int BOOLEAN = 10;
+ int BREAK = 11;
+ int BYTE = 12;
+ int CASE = 13;
+ int CATCH = 14;
+ int CHAR = 15;
+ int CLASS = 16;
+ int CONST = 17;
+ int CONTINUE = 18;
+ int _DEFAULT = 19;
+ int DO = 20;
+ int DOUBLE = 21;
+ int ELSE = 22;
+ int ENUM = 23;
+ int EXTENDS = 24;
+ int FALSE = 25;
+ int FINAL = 26;
+ int FINALLY = 27;
+ int FLOAT = 28;
+ int FOR = 29;
+ int GOTO = 30;
+ int IF = 31;
+ int IMPLEMENTS = 32;
+ int IMPORT = 33;
+ int INSTANCEOF = 34;
+ int INT = 35;
+ int INTERFACE = 36;
+ int LONG = 37;
+ int NATIVE = 38;
+ int NEW = 39;
+ int NULL = 40;
+ int PACKAGE = 41;
+ int PRIVATE = 42;
+ int PROTECTED = 43;
+ int PUBLIC = 44;
+ int RETURN = 45;
+ int SHORT = 46;
+ int STATIC = 47;
+ int STRICTFP = 48;
+ int SUPER = 49;
+ int SWITCH = 50;
+ int SYNCHRONIZED = 51;
+ int THIS = 52;
+ int THROW = 53;
+ int THROWS = 54;
+ int TRANSIENT = 55;
+ int TRUE = 56;
+ int TRY = 57;
+ int VOID = 58;
+ int VOLATILE = 59;
+ int WHILE = 60;
+ int INTEGER_LITERAL = 61;
+ int DECIMAL_LITERAL = 62;
+ int HEX_LITERAL = 63;
+ int OCTAL_LITERAL = 64;
+ int FLOATING_POINT_LITERAL = 65;
+ int DECIMAL_FLOATING_POINT_LITERAL = 66;
+ int DECIMAL_EXPONENT = 67;
+ int HEXADECIMAL_FLOATING_POINT_LITERAL = 68;
+ int HEXADECIMAL_EXPONENT = 69;
+ int CHARACTER_LITERAL = 70;
+ int STRING_LITERAL = 71;
+ int IDENTIFIER = 72;
+ int LETTER = 73;
+ int PART_LETTER = 74;
+ int LPAREN = 75;
+ int RPAREN = 76;
+ int LBRACE = 77;
+ int RBRACE = 78;
+ int LBRACKET = 79;
+ int RBRACKET = 80;
+ int SEMICOLON = 81;
+ int COMMA = 82;
+ int DOT = 83;
+ int AT = 84;
+ int ASSIGN = 85;
+ int LT = 86;
+ int BANG = 87;
+ int TILDE = 88;
+ int HOOK = 89;
+ int COLON = 90;
+ int EQ = 91;
+ int LE = 92;
+ int GE = 93;
+ int NE = 94;
+ int SC_OR = 95;
+ int SC_AND = 96;
+ int INCR = 97;
+ int DECR = 98;
+ int PLUS = 99;
+ int MINUS = 100;
+ int STAR = 101;
+ int SLASH = 102;
+ int BIT_AND = 103;
+ int BIT_OR = 104;
+ int XOR = 105;
+ int REM = 106;
+ int LSHIFT = 107;
+ int PLUSASSIGN = 108;
+ int MINUSASSIGN = 109;
+ int STARASSIGN = 110;
+ int SLASHASSIGN = 111;
+ int ANDASSIGN = 112;
+ int ORASSIGN = 113;
+ int XORASSIGN = 114;
+ int REMASSIGN = 115;
+ int LSHIFTASSIGN = 116;
+ int RSIGNEDSHIFTASSIGN = 117;
+ int RUNSIGNEDSHIFTASSIGN = 118;
+ int ELLIPSIS = 119;
+ int RUNSIGNEDSHIFT = 120;
+ int RSIGNEDSHIFT = 121;
+ int GT = 122;
+ int STUFF_TO_IGNORE = 124;
+
+ int DEFAULT = 0;
+ int IN_FORMAL_COMMENT = 1;
+ int IN_MULTI_LINE_COMMENT = 2;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "<token of kind 1>",
+ "\"/*\"",
+ "<WHITE_SPACE>",
+ "<SINGLE_LINE_COMMENT>",
+ "\"*/\"",
+ "\"*/\"",
+ "<token of kind 7>",
+ "\"abstract\"",
+ "\"assert\"",
+ "\"boolean\"",
+ "\"break\"",
+ "\"byte\"",
+ "\"case\"",
+ "\"catch\"",
+ "\"char\"",
+ "\"class\"",
+ "\"const\"",
+ "\"continue\"",
+ "\"default\"",
+ "\"do\"",
+ "\"double\"",
+ "\"else\"",
+ "\"enum\"",
+ "\"extends\"",
+ "\"false\"",
+ "\"final\"",
+ "\"finally\"",
+ "\"float\"",
+ "\"for\"",
+ "\"goto\"",
+ "\"if\"",
+ "\"implements\"",
+ "\"import\"",
+ "\"instanceof\"",
+ "\"int\"",
+ "\"interface\"",
+ "\"long\"",
+ "\"native\"",
+ "\"new\"",
+ "\"null\"",
+ "\"package\"",
+ "\"private\"",
+ "\"protected\"",
+ "\"public\"",
+ "\"return\"",
+ "\"short\"",
+ "\"static\"",
+ "\"strictfp\"",
+ "\"super\"",
+ "\"switch\"",
+ "\"synchronized\"",
+ "\"this\"",
+ "\"throw\"",
+ "\"throws\"",
+ "\"transient\"",
+ "\"true\"",
+ "\"try\"",
+ "\"void\"",
+ "\"volatile\"",
+ "\"while\"",
+ "<INTEGER_LITERAL>",
+ "<DECIMAL_LITERAL>",
+ "<HEX_LITERAL>",
+ "<OCTAL_LITERAL>",
+ "<FLOATING_POINT_LITERAL>",
+ "<DECIMAL_FLOATING_POINT_LITERAL>",
+ "<DECIMAL_EXPONENT>",
+ "<HEXADECIMAL_FLOATING_POINT_LITERAL>",
+ "<HEXADECIMAL_EXPONENT>",
+ "<CHARACTER_LITERAL>",
+ "<STRING_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<PART_LETTER>",
+ "\"(\"",
+ "\")\"",
+ "\"{\"",
+ "\"}\"",
+ "\"[\"",
+ "\"]\"",
+ "\";\"",
+ "\",\"",
+ "\".\"",
+ "\"@\"",
+ "\"=\"",
+ "\"<\"",
+ "\"!\"",
+ "\"~\"",
+ "\"?\"",
+ "\":\"",
+ "\"==\"",
+ "\"<=\"",
+ "\">=\"",
+ "\"!=\"",
+ "\"||\"",
+ "\"&&\"",
+ "\"++\"",
+ "\"--\"",
+ "\"+\"",
+ "\"-\"",
+ "\"*\"",
+ "\"/\"",
+ "\"&\"",
+ "\"|\"",
+ "\"^\"",
+ "\"%\"",
+ "\"<<\"",
+ "\"+=\"",
+ "\"-=\"",
+ "\"*=\"",
+ "\"/=\"",
+ "\"&=\"",
+ "\"|=\"",
+ "\"^=\"",
+ "\"%=\"",
+ "\"<<=\"",
+ "\">>=\"",
+ "\">>>=\"",
+ "\"...\"",
+ "\">>>\"",
+ "\">>\"",
+ "\">\"",
+ "\"\\u001a\"",
+ "<STUFF_TO_IGNORE>",
+ };
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParserTokenManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,2072 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserTokenManager.java */
+package jaxx.compiler.parser.java;
+
+public class JavaParserTokenManager implements JavaParserConstants {
+ public java.io.PrintStream debugStream = System.out;
+
+ public void setDebugStream(java.io.PrintStream ds) {
+ debugStream = ds;
+ }
+
+ private int jjStopStringLiteralDfa_0(int pos, long active0, long active1) {
+ switch (pos) {
+ case 0:
+ if ((active0 & 0x4L) != 0L || (active1 & 0x804000000000L) != 0L)
+ return 48;
+ if ((active1 & 0x80000000080000L) != 0L)
+ return 5;
+ if ((active0 & 0x1fffffffffffff00L) != 0L) {
+ jjmatchedKind = 72;
+ return 29;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x4L) != 0L)
+ return 46;
+ if ((active0 & 0x1fffffff7fcfff00L) != 0L) {
+ if (jjmatchedPos != 1) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 1;
+ }
+ return 29;
+ }
+ if ((active0 & 0x80300000L) != 0L)
+ return 29;
+ return -1;
+ case 2:
+ if ((active0 & 0x1dffff675fefff00L) != 0L) {
+ if (jjmatchedPos != 2) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 2;
+ }
+ return 29;
+ }
+ if ((active0 & 0x200009820000000L) != 0L)
+ return 29;
+ return -1;
+ case 3:
+ if ((active0 & 0x18effe571f2f4f00L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 3;
+ return 29;
+ }
+ if ((active0 & 0x510012040c0b000L) != 0L)
+ return 29;
+ return -1;
+ case 4:
+ if ((active0 & 0x88dbe57012c0700L) != 0L) {
+ if (jjmatchedPos != 4) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 4;
+ }
+ return 29;
+ }
+ if ((active0 & 0x106240001e034800L) != 0L)
+ return 29;
+ return -1;
+ case 5:
+ if ((active0 & 0x8890e15090c0500L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 5;
+ return 29;
+ }
+ if ((active0 & 0x44b04200200200L) != 0L)
+ return 29;
+ return -1;
+ case 6:
+ if ((active0 & 0x889081500040100L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 6;
+ return 29;
+ }
+ if ((active0 & 0x60009080400L) != 0L)
+ return 29;
+ return -1;
+ case 7:
+ if ((active0 & 0x801000000040100L) != 0L)
+ return 29;
+ if ((active0 & 0x88081500000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 7;
+ return 29;
+ }
+ return -1;
+ case 8:
+ if ((active0 & 0x8000500000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 8;
+ return 29;
+ }
+ if ((active0 & 0x80081000000000L) != 0L)
+ return 29;
+ return -1;
+ case 9:
+ if ((active0 & 0x8000000000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 9;
+ return 29;
+ }
+ if ((active0 & 0x500000000L) != 0L)
+ return 29;
+ return -1;
+ case 10:
+ if ((active0 & 0x8000000000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 10;
+ return 29;
+ }
+ return -1;
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_0(int pos, long active0, long active1) {
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);
+ }
+
+ private int jjStopAtPos(int pos, int kind) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+ }
+
+ private int jjStartNfaWithStates_0(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_0(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_0() {
+ switch (curChar) {
+ case 26:
+ return jjStopAtPos(0, 123);
+ case 33:
+ jjmatchedKind = 87;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x40000000L);
+ case 37:
+ jjmatchedKind = 106;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000000000L);
+ case 38:
+ jjmatchedKind = 103;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x1000100000000L);
+ case 40:
+ return jjStopAtPos(0, 75);
+ case 41:
+ return jjStopAtPos(0, 76);
+ case 42:
+ jjmatchedKind = 101;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000000L);
+ case 43:
+ jjmatchedKind = 99;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x100200000000L);
+ case 44:
+ return jjStopAtPos(0, 82);
+ case 45:
+ jjmatchedKind = 100;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x200400000000L);
+ case 46:
+ jjmatchedKind = 83;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000000000L);
+ case 47:
+ jjmatchedKind = 102;
+ return jjMoveStringLiteralDfa1_0(0x4L, 0x800000000000L);
+ case 58:
+ return jjStopAtPos(0, 90);
+ case 59:
+ return jjStopAtPos(0, 81);
+ case 60:
+ jjmatchedKind = 86;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x10080010000000L);
+ case 61:
+ jjmatchedKind = 85;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000L);
+ case 62:
+ jjmatchedKind = 122;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x360000020000000L);
+ case 63:
+ return jjStopAtPos(0, 89);
+ case 64:
+ return jjStopAtPos(0, 84);
+ case 91:
+ return jjStopAtPos(0, 79);
+ case 93:
+ return jjStopAtPos(0, 80);
+ case 94:
+ jjmatchedKind = 105;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa1_0(0x300L, 0x0L);
+ case 98:
+ return jjMoveStringLiteralDfa1_0(0x1c00L, 0x0L);
+ case 99:
+ return jjMoveStringLiteralDfa1_0(0x7e000L, 0x0L);
+ case 100:
+ return jjMoveStringLiteralDfa1_0(0x380000L, 0x0L);
+ case 101:
+ return jjMoveStringLiteralDfa1_0(0x1c00000L, 0x0L);
+ case 102:
+ return jjMoveStringLiteralDfa1_0(0x3e000000L, 0x0L);
+ case 103:
+ return jjMoveStringLiteralDfa1_0(0x40000000L, 0x0L);
+ case 105:
+ return jjMoveStringLiteralDfa1_0(0x1f80000000L, 0x0L);
+ case 108:
+ return jjMoveStringLiteralDfa1_0(0x2000000000L, 0x0L);
+ case 110:
+ return jjMoveStringLiteralDfa1_0(0x1c000000000L, 0x0L);
+ case 112:
+ return jjMoveStringLiteralDfa1_0(0x1e0000000000L, 0x0L);
+ case 114:
+ return jjMoveStringLiteralDfa1_0(0x200000000000L, 0x0L);
+ case 115:
+ return jjMoveStringLiteralDfa1_0(0xfc00000000000L, 0x0L);
+ case 116:
+ return jjMoveStringLiteralDfa1_0(0x3f0000000000000L, 0x0L);
+ case 118:
+ return jjMoveStringLiteralDfa1_0(0xc00000000000000L, 0x0L);
+ case 119:
+ return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L);
+ case 123:
+ return jjStopAtPos(0, 77);
+ case 124:
+ jjmatchedKind = 104;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2000080000000L);
+ case 125:
+ return jjStopAtPos(0, 78);
+ case 126:
+ return jjStopAtPos(0, 88);
+ default:
+ return jjMoveNfa_0(1, 0);
+ }
+ }
+
+ private int jjMoveStringLiteralDfa1_0(long active0, long active1) {
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0, active1);
+ return 1;
+ }
+ switch (curChar) {
+ case 38:
+ if ((active1 & 0x100000000L) != 0L)
+ return jjStopAtPos(1, 96);
+ break;
+ case 42:
+ if ((active0 & 0x4L) != 0L)
+ return jjStartNfaWithStates_0(1, 2, 46);
+ break;
+ case 43:
+ if ((active1 & 0x200000000L) != 0L)
+ return jjStopAtPos(1, 97);
+ break;
+ case 45:
+ if ((active1 & 0x400000000L) != 0L)
+ return jjStopAtPos(1, 98);
+ break;
+ case 46:
+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x80000000000000L);
+ case 60:
+ if ((active1 & 0x80000000000L) != 0L) {
+ jjmatchedKind = 107;
+ jjmatchedPos = 1;
+ }
+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x10000000000000L);
+ case 61:
+ if ((active1 & 0x8000000L) != 0L)
+ return jjStopAtPos(1, 91);
+ else if ((active1 & 0x10000000L) != 0L)
+ return jjStopAtPos(1, 92);
+ else if ((active1 & 0x20000000L) != 0L)
+ return jjStopAtPos(1, 93);
+ else if ((active1 & 0x40000000L) != 0L)
+ return jjStopAtPos(1, 94);
+ else if ((active1 & 0x100000000000L) != 0L)
+ return jjStopAtPos(1, 108);
+ else if ((active1 & 0x200000000000L) != 0L)
+ return jjStopAtPos(1, 109);
+ else if ((active1 & 0x400000000000L) != 0L)
+ return jjStopAtPos(1, 110);
+ else if ((active1 & 0x800000000000L) != 0L)
+ return jjStopAtPos(1, 111);
+ else if ((active1 & 0x1000000000000L) != 0L)
+ return jjStopAtPos(1, 112);
+ else if ((active1 & 0x2000000000000L) != 0L)
+ return jjStopAtPos(1, 113);
+ else if ((active1 & 0x4000000000000L) != 0L)
+ return jjStopAtPos(1, 114);
+ else if ((active1 & 0x8000000000000L) != 0L)
+ return jjStopAtPos(1, 115);
+ break;
+ case 62:
+ if ((active1 & 0x200000000000000L) != 0L) {
+ jjmatchedKind = 121;
+ jjmatchedPos = 1;
+ }
+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x160000000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa2_0(active0, 0x24002006000L, active1, 0L);
+ case 98:
+ return jjMoveStringLiteralDfa2_0(active0, 0x100L, active1, 0L);
+ case 101:
+ return jjMoveStringLiteralDfa2_0(active0, 0x208000080000L, active1, 0L);
+ case 102:
+ if ((active0 & 0x80000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 31, 29);
+ break;
+ case 104:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1070400000008000L, active1, 0L);
+ case 105:
+ return jjMoveStringLiteralDfa2_0(active0, 0xc000000L, active1, 0L);
+ case 108:
+ return jjMoveStringLiteralDfa2_0(active0, 0x10410000L, active1, 0L);
+ case 109:
+ return jjMoveStringLiteralDfa2_0(active0, 0x300000000L, active1, 0L);
+ case 110:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1c00800000L, active1, 0L);
+ case 111:
+ if ((active0 & 0x100000L) != 0L) {
+ jjmatchedKind = 20;
+ jjmatchedPos = 1;
+ }
+ return jjMoveStringLiteralDfa2_0(active0, 0xc00002060260400L, active1, 0L);
+ case 114:
+ return jjMoveStringLiteralDfa2_0(active0, 0x3800c0000000800L, active1, 0L);
+ case 115:
+ return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0L);
+ case 116:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1800000000000L, active1, 0L);
+ case 117:
+ return jjMoveStringLiteralDfa2_0(active0, 0x2110000000000L, active1, 0L);
+ case 119:
+ return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L);
+ case 120:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000L, active1, 0L);
+ case 121:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8000000001000L, active1, 0L);
+ case 124:
+ if ((active1 & 0x80000000L) != 0L)
+ return jjStopAtPos(1, 95);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(0, active0, active1);
+ }
+
+ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) {
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(0, old0, old1);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0, active1);
+ return 2;
+ }
+ switch (curChar) {
+ case 46:
+ if ((active1 & 0x80000000000000L) != 0L)
+ return jjStopAtPos(2, 119);
+ break;
+ case 61:
+ if ((active1 & 0x10000000000000L) != 0L)
+ return jjStopAtPos(2, 116);
+ else if ((active1 & 0x20000000000000L) != 0L)
+ return jjStopAtPos(2, 117);
+ break;
+ case 62:
+ if ((active1 & 0x100000000000000L) != 0L) {
+ jjmatchedKind = 120;
+ jjmatchedPos = 2;
+ }
+ return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x40000000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa3_0(active0, 0x80800000018000L, active1, 0L);
+ case 98:
+ return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L, active1, 0L);
+ case 99:
+ return jjMoveStringLiteralDfa3_0(active0, 0x20000000000L, active1, 0L);
+ case 101:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800L, active1, 0L);
+ case 102:
+ return jjMoveStringLiteralDfa3_0(active0, 0x80000L, active1, 0L);
+ case 105:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1414040000000000L, active1, 0L);
+ case 108:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800010002000000L, active1, 0L);
+ case 110:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800200c060000L, active1, 0L);
+ case 111:
+ return jjMoveStringLiteralDfa3_0(active0, 0x480010000400L, active1, 0L);
+ case 112:
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000300000000L, active1, 0L);
+ case 114:
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 29, 29);
+ return jjMoveStringLiteralDfa3_0(active0, 0x61000000000000L, active1, 0L);
+ case 115:
+ return jjMoveStringLiteralDfa3_0(active0, 0x400402300L, active1, 0L);
+ case 116:
+ if ((active0 & 0x800000000L) != 0L) {
+ jjmatchedKind = 35;
+ jjmatchedPos = 2;
+ }
+ return jjMoveStringLiteralDfa3_0(active0, 0x205041005000L, active1, 0L);
+ case 117:
+ return jjMoveStringLiteralDfa3_0(active0, 0x100000000a00000L, active1, 0L);
+ case 119:
+ if ((active0 & 0x8000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 39, 29);
+ break;
+ case 121:
+ if ((active0 & 0x200000000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 57, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(1, active0, active1);
+ }
+
+ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) {
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(1, old0, old1);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0, active1);
+ return 3;
+ }
+ switch (curChar) {
+ case 61:
+ if ((active1 & 0x40000000000000L) != 0L)
+ return jjStopAtPos(3, 118);
+ break;
+ case 97:
+ return jjMoveStringLiteralDfa4_0(active0, 0x80000001c080800L, active1, 0L);
+ case 98:
+ return jjMoveStringLiteralDfa4_0(active0, 0x200000L, active1, 0L);
+ case 99:
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000000004000L, active1, 0L);
+ case 100:
+ if ((active0 & 0x400000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 58, 29);
+ break;
+ case 101:
+ if ((active0 & 0x1000L) != 0L)
+ return jjStartNfaWithStates_0(3, 12, 29);
+ else if ((active0 & 0x2000L) != 0L)
+ return jjStartNfaWithStates_0(3, 13, 29);
+ else if ((active0 & 0x400000L) != 0L)
+ return jjStartNfaWithStates_0(3, 22, 29);
+ else if ((active0 & 0x100000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 56, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x2001001000200L, active1, 0L);
+ case 103:
+ if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 37, 29);
+ break;
+ case 105:
+ return jjMoveStringLiteralDfa4_0(active0, 0x1004000000000L, active1, 0L);
+ case 107:
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000L, active1, 0L);
+ case 108:
+ if ((active0 & 0x10000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 40, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x1000100100000400L, active1, 0L);
+ case 109:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(3, 23, 29);
+ break;
+ case 110:
+ return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0L);
+ case 111:
+ if ((active0 & 0x40000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 30, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x60000200000000L, active1, 0L);
+ case 114:
+ if ((active0 & 0x8000L) != 0L)
+ return jjStartNfaWithStates_0(3, 15, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L, active1, 0L);
+ case 115:
+ if ((active0 & 0x10000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 52, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x2030000L, active1, 0L);
+ case 116:
+ return jjMoveStringLiteralDfa4_0(active0, 0x4880400040100L, active1, 0L);
+ case 117:
+ return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L, active1, 0L);
+ case 118:
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L, active1, 0L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(2, active0, active1);
+ }
+
+ private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) {
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(2, old0, old1);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0, 0L);
+ return 4;
+ }
+ switch (curChar) {
+ case 97:
+ return jjMoveStringLiteralDfa5_0(active0, 0x60400000000L);
+ case 99:
+ return jjMoveStringLiteralDfa5_0(active0, 0x5000000000000L);
+ case 101:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 25, 29);
+ else if ((active0 & 0x1000000000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 60, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x80100000400L);
+ case 104:
+ if ((active0 & 0x4000L) != 0L)
+ return jjStartNfaWithStates_0(4, 14, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x8000000000000L);
+ case 105:
+ return jjMoveStringLiteralDfa5_0(active0, 0x900000040000L);
+ case 107:
+ if ((active0 & 0x800L) != 0L)
+ return jjStartNfaWithStates_0(4, 11, 29);
+ break;
+ case 108:
+ if ((active0 & 0x4000000L) != 0L) {
+ jjmatchedKind = 26;
+ jjmatchedPos = 4;
+ }
+ return jjMoveStringLiteralDfa5_0(active0, 0x8200000L);
+ case 110:
+ return jjMoveStringLiteralDfa5_0(active0, 0x1000000L);
+ case 114:
+ if ((active0 & 0x2000000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 49, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x201200000300L);
+ case 115:
+ if ((active0 & 0x10000L) != 0L)
+ return jjStartNfaWithStates_0(4, 16, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L);
+ case 116:
+ if ((active0 & 0x20000L) != 0L)
+ return jjStartNfaWithStates_0(4, 17, 29);
+ else if ((active0 & 0x10000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 28, 29);
+ else if ((active0 & 0x400000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 46, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x800000000000000L);
+ case 117:
+ return jjMoveStringLiteralDfa5_0(active0, 0x80000L);
+ case 118:
+ return jjMoveStringLiteralDfa5_0(active0, 0x4000000000L);
+ case 119:
+ if ((active0 & 0x20000000000000L) != 0L) {
+ jjmatchedKind = 53;
+ jjmatchedPos = 4;
+ }
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(3, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa5_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(3, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(4, active0, 0L);
+ return 5;
+ }
+ switch (curChar) {
+ case 97:
+ return jjMoveStringLiteralDfa6_0(active0, 0x500L);
+ case 99:
+ if ((active0 & 0x100000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 44, 29);
+ else if ((active0 & 0x800000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 47, 29);
+ return jjMoveStringLiteralDfa6_0(active0, 0x80000000000L);
+ case 100:
+ return jjMoveStringLiteralDfa6_0(active0, 0x1000000L);
+ case 101:
+ if ((active0 & 0x200000L) != 0L)
+ return jjStartNfaWithStates_0(5, 21, 29);
+ else if ((active0 & 0x4000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 38, 29);
+ break;
+ case 102:
+ return jjMoveStringLiteralDfa6_0(active0, 0x1000000000L);
+ case 103:
+ return jjMoveStringLiteralDfa6_0(active0, 0x20000000000L);
+ case 104:
+ if ((active0 & 0x4000000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 50, 29);
+ break;
+ case 105:
+ return jjMoveStringLiteralDfa6_0(active0, 0x880000000000000L);
+ case 108:
+ return jjMoveStringLiteralDfa6_0(active0, 0x8080000L);
+ case 109:
+ return jjMoveStringLiteralDfa6_0(active0, 0x100000000L);
+ case 110:
+ if ((active0 & 0x200000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 45, 29);
+ return jjMoveStringLiteralDfa6_0(active0, 0x400040000L);
+ case 114:
+ return jjMoveStringLiteralDfa6_0(active0, 0x8000000000000L);
+ case 115:
+ if ((active0 & 0x40000000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 54, 29);
+ break;
+ case 116:
+ if ((active0 & 0x200L) != 0L)
+ return jjStartNfaWithStates_0(5, 9, 29);
+ else if ((active0 & 0x200000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 33, 29);
+ return jjMoveStringLiteralDfa6_0(active0, 0x1040000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(4, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa6_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(4, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(5, active0, 0L);
+ return 6;
+ }
+ switch (curChar) {
+ case 97:
+ return jjMoveStringLiteralDfa7_0(active0, 0x1000000000L);
+ case 99:
+ return jjMoveStringLiteralDfa7_0(active0, 0x400000100L);
+ case 101:
+ if ((active0 & 0x20000000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 41, 29);
+ else if ((active0 & 0x40000000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 42, 29);
+ return jjMoveStringLiteralDfa7_0(active0, 0x80000100000000L);
+ case 102:
+ return jjMoveStringLiteralDfa7_0(active0, 0x1000000000000L);
+ case 108:
+ return jjMoveStringLiteralDfa7_0(active0, 0x800000000000000L);
+ case 110:
+ if ((active0 & 0x400L) != 0L)
+ return jjStartNfaWithStates_0(6, 10, 29);
+ break;
+ case 111:
+ return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L);
+ case 115:
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 24, 29);
+ break;
+ case 116:
+ if ((active0 & 0x80000L) != 0L)
+ return jjStartNfaWithStates_0(6, 19, 29);
+ return jjMoveStringLiteralDfa7_0(active0, 0x80000000000L);
+ case 117:
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000L);
+ case 121:
+ if ((active0 & 0x8000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 27, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(5, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa7_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(5, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(6, active0, 0L);
+ return 7;
+ }
+ switch (curChar) {
+ case 99:
+ return jjMoveStringLiteralDfa8_0(active0, 0x1000000000L);
+ case 101:
+ if ((active0 & 0x40000L) != 0L)
+ return jjStartNfaWithStates_0(7, 18, 29);
+ else if ((active0 & 0x800000000000000L) != 0L)
+ return jjStartNfaWithStates_0(7, 59, 29);
+ return jjMoveStringLiteralDfa8_0(active0, 0x80400000000L);
+ case 110:
+ return jjMoveStringLiteralDfa8_0(active0, 0x88000100000000L);
+ case 112:
+ if ((active0 & 0x1000000000000L) != 0L)
+ return jjStartNfaWithStates_0(7, 48, 29);
+ break;
+ case 116:
+ if ((active0 & 0x100L) != 0L)
+ return jjStartNfaWithStates_0(7, 8, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(6, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa8_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(6, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(7, active0, 0L);
+ return 8;
+ }
+ switch (curChar) {
+ case 100:
+ if ((active0 & 0x80000000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 43, 29);
+ break;
+ case 101:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 36, 29);
+ break;
+ case 105:
+ return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L);
+ case 111:
+ return jjMoveStringLiteralDfa9_0(active0, 0x400000000L);
+ case 116:
+ if ((active0 & 0x80000000000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 55, 29);
+ return jjMoveStringLiteralDfa9_0(active0, 0x100000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(7, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa9_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(7, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(8, active0, 0L);
+ return 9;
+ }
+ switch (curChar) {
+ case 102:
+ if ((active0 & 0x400000000L) != 0L)
+ return jjStartNfaWithStates_0(9, 34, 29);
+ break;
+ case 115:
+ if ((active0 & 0x100000000L) != 0L)
+ return jjStartNfaWithStates_0(9, 32, 29);
+ break;
+ case 122:
+ return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(8, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa10_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(8, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(9, active0, 0L);
+ return 10;
+ }
+ switch (curChar) {
+ case 101:
+ return jjMoveStringLiteralDfa11_0(active0, 0x8000000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(9, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa11_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(9, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(10, active0, 0L);
+ return 11;
+ }
+ switch (curChar) {
+ case 100:
+ if ((active0 & 0x8000000000000L) != 0L)
+ return jjStartNfaWithStates_0(11, 51, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(10, active0, 0L);
+ }
+
+ private void jjCheckNAdd(int state) {
+ if (jjrounds[state] != jjround) {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+ }
+
+ private void jjAddStates(int start, int end) {
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddTwoStates(int state1, int state2) {
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+ }
+
+ private void jjCheckNAddStates(int start, int end) {
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddStates(int start) {
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+ }
+
+ static final long[] jjbitVec0 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+ };
+ static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+ };
+ static final long[] jjbitVec3 = {
+ 0xfff0000000200002L, 0xffffffffffffdfffL, 0xfffff00f7fffffffL, 0x12000000007fffffL
+ };
+ static final long[] jjbitVec4 = {
+ 0x0L, 0x0L, 0x420043c00000000L, 0xff7fffffff7fffffL
+ };
+ static final long[] jjbitVec5 = {
+ 0xffffcffffffffL, 0xffffffffffff0000L, 0xf9ff3fffffffffffL, 0x401f00030003L
+ };
+ static final long[] jjbitVec6 = {
+ 0x0L, 0x400000000000000L, 0xfffffffbffffd740L, 0xffffffcff7fffL
+ };
+ static final long[] jjbitVec7 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff003L, 0x33fffffffff199fL
+ };
+ static final long[] jjbitVec8 = {
+ 0xfffe000000000000L, 0xfffffffe027fffffL, 0xffL, 0x707ffffff0000L
+ };
+ static final long[] jjbitVec9 = {
+ 0x7fffffe00000000L, 0xfffe0000000007ffL, 0xffffffffffffffffL, 0x1c000060002fffffL
+ };
+ static final long[] jjbitVec10 = {
+ 0x1ffffffd0000L, 0x0L, 0x3fffffffffL, 0x0L
+ };
+ static final long[] jjbitVec11 = {
+ 0x23ffffffffffffe0L, 0x3ff010000L, 0x3c5fdfffff99fe0L, 0xf0003b0000000L
+ };
+ static final long[] jjbitVec12 = {
+ 0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbafe0L, 0x100010000L
+ };
+ static final long[] jjbitVec13 = {
+ 0x23cdfdfffff99fe0L, 0x3b0000000L, 0x3bfc718d63dc7e0L, 0x0L
+ };
+ static final long[] jjbitVec14 = {
+ 0x3effdfffffddfe0L, 0x300000000L, 0x3effdfffffddfe0L, 0x340000000L
+ };
+ static final long[] jjbitVec15 = {
+ 0x3fffdfffffddfe0L, 0x300000000L, 0x2ffbfffffc7fffe0L, 0x7fL
+ };
+ static final long[] jjbitVec16 = {
+ 0x800dfffffffffffeL, 0x7fL, 0x200decaefef02596L, 0x3000005fL
+ };
+ static final long[] jjbitVec17 = {
+ 0x1L, 0x7fffffffeffL, 0xf00L, 0x0L
+ };
+ static final long[] jjbitVec18 = {
+ 0x6fbffffffffL, 0x3f0000L, 0xffffffff00000000L, 0x7fffffffff003fL
+ };
+ static final long[] jjbitVec19 = {
+ 0xffffffffffffffffL, 0xffffffff83ffffffL, 0xffffff07ffffffffL, 0x3ffffffffffffffL
+ };
+ static final long[] jjbitVec20 = {
+ 0xffffffffffffff7fL, 0xffffffff3d7f3d7fL, 0x7f3d7fffffff3d7fL, 0xffff7fffff7f7f3dL
+ };
+ static final long[] jjbitVec21 = {
+ 0xffffffff7f3d7fffL, 0x7ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL
+ };
+ static final long[] jjbitVec22 = {
+ 0xffffffffffffffffL, 0x7f9fffffffffffL, 0xffffffff07fffffeL, 0x7ffffffffffL
+ };
+ static final long[] jjbitVec23 = {
+ 0x0L, 0x0L, 0xfffffffffffffL, 0x8000000L
+ };
+ static final long[] jjbitVec24 = {
+ 0xffffffff00000000L, 0xffffffffffffffL, 0x1ffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec25 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL
+ };
+ static final long[] jjbitVec26 = {
+ 0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL
+ };
+ static final long[] jjbitVec27 = {
+ 0x8000000000000000L, 0x8000000000000001L, 0xffff00000000L, 0x0L
+ };
+ static final long[] jjbitVec28 = {
+ 0x3fbbd503e2ffc84L, 0xffffffff00000000L, 0xfL, 0x0L
+ };
+ static final long[] jjbitVec29 = {
+ 0x73e03fe000000e0L, 0xfffffffffffffffeL, 0xfffffffe601fffffL, 0x7fffffffffffffffL
+ };
+ static final long[] jjbitVec30 = {
+ 0xfffe1fffffffffe0L, 0xffffffffffffffffL, 0xffffff00007fffL, 0x0L
+ };
+ static final long[] jjbitVec31 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec32 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L
+ };
+ static final long[] jjbitVec33 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x1fffL, 0x0L
+ };
+ static final long[] jjbitVec34 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L
+ };
+ static final long[] jjbitVec35 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+ };
+ static final long[] jjbitVec36 = {
+ 0x5f7ffdffa0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L
+ };
+ static final long[] jjbitVec37 = {
+ 0x3fffffffffffffffL, 0xffffffffffff0000L, 0xfffffffffffcffffL, 0xfff0000000000ffL
+ };
+ static final long[] jjbitVec38 = {
+ 0x18000000000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x1fffffffffffffffL
+ };
+ static final long[] jjbitVec39 = {
+ 0x87fffffe00000010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0x631cfcfcfcL
+ };
+ static final long[] jjbitVec40 = {
+ 0x0L, 0x0L, 0x420043cffffffffL, 0xff7fffffff7fffffL
+ };
+ static final long[] jjbitVec41 = {
+ 0xffffffffffffffffL, 0x400000700007fffL, 0xfffffffbffffd740L, 0xffffffcff7fffL
+ };
+ static final long[] jjbitVec42 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff07bL, 0x33fffffffff199fL
+ };
+ static final long[] jjbitVec43 = {
+ 0xfffe000000000000L, 0xfffffffe027fffffL, 0xbbfffffbfffe00ffL, 0x707ffffff0016L
+ };
+ static final long[] jjbitVec44 = {
+ 0x7fffffe00000000L, 0xffff03ff003fffffL, 0xffffffffffffffffL, 0x1fff3dff9fefffffL
+ };
+ static final long[] jjbitVec45 = {
+ 0xffff1fffffff8000L, 0x7ffL, 0x1ffffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec46 = {
+ 0xf3ffffffffffffeeL, 0xffcfff1f3fffL, 0xd3c5fdfffff99feeL, 0xfffcfb080399fL
+ };
+ static final long[] jjbitVec47 = {
+ 0xd36dfdfffff987e4L, 0x1fffc05e003987L, 0xf3edfdfffffbafeeL, 0xffc100013bbfL
+ };
+ static final long[] jjbitVec48 = {
+ 0xf3cdfdfffff99feeL, 0xffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0xff8000803dc7L
+ };
+ static final long[] jjbitVec49 = {
+ 0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xc3effdfffffddfecL, 0xffc340603ddfL
+ };
+ static final long[] jjbitVec50 = {
+ 0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x2ffbfffffc7fffecL, 0xc0000ff5f847fL
+ };
+ static final long[] jjbitVec51 = {
+ 0x87fffffffffffffeL, 0x3ff7fffL, 0x3bffecaefef02596L, 0x33ff3f5fL
+ };
+ static final long[] jjbitVec52 = {
+ 0xc2a003ff03000001L, 0xfffe07fffffffeffL, 0x1ffffffffeff0fdfL, 0x40L
+ };
+ static final long[] jjbitVec53 = {
+ 0x3c7f6fbffffffffL, 0x3ff03ffL, 0xffffffff00000000L, 0x7fffffffff003fL
+ };
+ static final long[] jjbitVec54 = {
+ 0xffffffff7f3d7fffL, 0x3fe0007ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL
+ };
+ static final long[] jjbitVec55 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0x3ff080fffffL
+ };
+ static final long[] jjbitVec56 = {
+ 0xffffffff03ff7800L, 0xffffffffffffffL, 0x3ffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec57 = {
+ 0x80007c000000f000L, 0x8000fc0000000001L, 0xffff00000000L, 0x21fff0000L
+ };
+ static final long[] jjbitVec58 = {
+ 0x73efffe000000e0L, 0xfffffffffffffffeL, 0xfffffffe661fffffL, 0x7fffffffffffffffL
+ };
+ static final long[] jjbitVec59 = {
+ 0x5f7ffdffe0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L
+ };
+ static final long[] jjbitVec60 = {
+ 0x18000f00000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x9fffffffffffffffL
+ };
+ static final long[] jjbitVec61 = {
+ 0x87fffffe03ff0010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0xe0000631cfcfcfcL
+ };
+
+ private int jjMoveNfa_0(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 71;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 1:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(0, 6);
+ else if ((0x100003600L & l) != 0L) {
+ if (kind > 3)
+ kind = 3;
+ jjCheckNAdd(0);
+ } else if (curChar == 47)
+ jjAddStates(7, 8);
+ else if (curChar == 36) {
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ } else if (curChar == 34)
+ jjCheckNAddStates(9, 11);
+ else if (curChar == 39)
+ jjAddStates(12, 13);
+ else if (curChar == 46)
+ jjCheckNAdd(5);
+ if ((0x3fe000000000000L & l) != 0L) {
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(2, 3);
+ } else if (curChar == 48) {
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddStates(14, 18);
+ }
+ break;
+ case 48:
+ if (curChar == 47) {
+ if (kind > 4)
+ kind = 4;
+ jjCheckNAddStates(19, 21);
+ } else if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 46;
+ break;
+ case 0:
+ if ((0x100003600L & l) == 0L)
+ break;
+ if (kind > 3)
+ kind = 3;
+ jjCheckNAdd(0);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(2, 3);
+ break;
+ case 4:
+ if (curChar == 46)
+ jjCheckNAdd(5);
+ break;
+ case 5:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddStates(22, 24);
+ break;
+ case 7:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(8);
+ break;
+ case 8:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(8, 9);
+ break;
+ case 10:
+ if (curChar == 39)
+ jjAddStates(12, 13);
+ break;
+ case 11:
+ if ((0xffffff7fffffdbffL & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 12:
+ if (curChar == 39 && kind > 70)
+ kind = 70;
+ break;
+ case 14:
+ if ((0x8400000000L & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 15:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(16, 12);
+ break;
+ case 16:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 17:
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 18;
+ break;
+ case 18:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAdd(16);
+ break;
+ case 19:
+ if (curChar == 34)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 20:
+ if ((0xfffffffbffffdbffL & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 22:
+ if ((0x8400000000L & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 23:
+ if (curChar == 34 && kind > 71)
+ kind = 71;
+ break;
+ case 24:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(25, 28);
+ break;
+ case 25:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 26:
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 27;
+ break;
+ case 27:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAdd(25);
+ break;
+ case 28:
+ if (curChar != 36)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 29:
+ if ((0x3ff00100fffc1ffL & l) == 0L)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 30:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(0, 6);
+ break;
+ case 31:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(29, 31);
+ break;
+ case 33:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(34);
+ break;
+ case 34:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(34, 9);
+ break;
+ case 35:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(35, 36);
+ break;
+ case 37:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(38);
+ break;
+ case 38:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(38, 9);
+ break;
+ case 39:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(39, 40);
+ break;
+ case 40:
+ if (curChar != 46)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddStates(32, 34);
+ break;
+ case 41:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddStates(32, 34);
+ break;
+ case 43:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(44);
+ break;
+ case 44:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(44, 9);
+ break;
+ case 45:
+ if (curChar == 47)
+ jjAddStates(7, 8);
+ break;
+ case 46:
+ if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 47;
+ break;
+ case 47:
+ if ((0xffff7fffffffffffL & l) != 0L && kind > 1)
+ kind = 1;
+ break;
+ case 49:
+ if (curChar != 47)
+ break;
+ if (kind > 4)
+ kind = 4;
+ jjCheckNAddStates(19, 21);
+ break;
+ case 50:
+ if ((0xffffffffffffdbffL & l) == 0L)
+ break;
+ if (kind > 4)
+ kind = 4;
+ jjCheckNAddStates(19, 21);
+ break;
+ case 51:
+ if ((0x2400L & l) != 0L && kind > 4)
+ kind = 4;
+ break;
+ case 52:
+ if (curChar == 10 && kind > 4)
+ kind = 4;
+ break;
+ case 53:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 52;
+ break;
+ case 54:
+ if (curChar != 48)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddStates(14, 18);
+ break;
+ case 56:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(56, 3);
+ break;
+ case 57:
+ if ((0xff000000000000L & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(57, 3);
+ break;
+ case 59:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjAddStates(35, 36);
+ break;
+ case 60:
+ if (curChar == 46)
+ jjCheckNAdd(61);
+ break;
+ case 61:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(61, 62);
+ break;
+ case 63:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(64);
+ break;
+ case 64:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(64, 9);
+ break;
+ case 66:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(37, 39);
+ break;
+ case 67:
+ if (curChar == 46)
+ jjCheckNAdd(68);
+ break;
+ case 69:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(70);
+ break;
+ case 70:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(70, 9);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 1:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 3:
+ if ((0x100000001000L & l) != 0L && kind > 61)
+ kind = 61;
+ break;
+ case 6:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(40, 41);
+ break;
+ case 9:
+ if ((0x5000000050L & l) != 0L && kind > 65)
+ kind = 65;
+ break;
+ case 11:
+ if ((0xffffffffefffffffL & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 13:
+ if (curChar == 92)
+ jjAddStates(42, 44);
+ break;
+ case 14:
+ if ((0x14404410000000L & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 20:
+ if ((0xffffffffefffffffL & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 21:
+ if (curChar == 92)
+ jjAddStates(45, 47);
+ break;
+ case 22:
+ if ((0x14404410000000L & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 29:
+ if ((0x87fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 32:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(48, 49);
+ break;
+ case 36:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(50, 51);
+ break;
+ case 42:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(52, 53);
+ break;
+ case 47:
+ if (kind > 1)
+ kind = 1;
+ break;
+ case 50:
+ if (kind > 4)
+ kind = 4;
+ jjAddStates(19, 21);
+ break;
+ case 55:
+ if ((0x100000001000000L & l) != 0L)
+ jjCheckNAdd(56);
+ break;
+ case 56:
+ if ((0x7e0000007eL & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(56, 3);
+ break;
+ case 58:
+ if ((0x100000001000000L & l) != 0L)
+ jjCheckNAddTwoStates(59, 60);
+ break;
+ case 59:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAddTwoStates(59, 60);
+ break;
+ case 61:
+ if ((0x7e0000007eL & l) != 0L)
+ jjAddStates(54, 55);
+ break;
+ case 62:
+ if ((0x1000000010000L & l) != 0L)
+ jjAddStates(56, 57);
+ break;
+ case 65:
+ if ((0x100000001000000L & l) != 0L)
+ jjCheckNAdd(66);
+ break;
+ case 66:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAddStates(37, 39);
+ break;
+ case 68:
+ if ((0x1000000010000L & l) != 0L)
+ jjAddStates(58, 59);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int hiByte = (int) (curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 1:
+ if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 11:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjstateSet[jjnewStateCnt++] = 12;
+ break;
+ case 20:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjAddStates(9, 11);
+ break;
+ case 29:
+ if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 47:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 1)
+ kind = 1;
+ break;
+ case 50:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 4)
+ kind = 4;
+ jjAddStates(19, 21);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 71 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjMoveStringLiteralDfa0_2() {
+ switch (curChar) {
+ case 42:
+ return jjMoveStringLiteralDfa1_2(0x40L);
+ default:
+ return 1;
+ }
+ }
+
+ private int jjMoveStringLiteralDfa1_2(long active0) {
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return 1;
+ }
+ switch (curChar) {
+ case 47:
+ if ((active0 & 0x40L) != 0L)
+ return jjStopAtPos(1, 6);
+ break;
+ default:
+ return 2;
+ }
+ return 2;
+ }
+
+ private int jjMoveStringLiteralDfa0_1() {
+ switch (curChar) {
+ case 42:
+ return jjMoveStringLiteralDfa1_1(0x20L);
+ default:
+ return 1;
+ }
+ }
+
+ private int jjMoveStringLiteralDfa1_1(long active0) {
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return 1;
+ }
+ switch (curChar) {
+ case 47:
+ if ((active0 & 0x20L) != 0L)
+ return jjStopAtPos(1, 5);
+ break;
+ default:
+ return 2;
+ }
+ return 2;
+ }
+
+ static final int[] jjnextStates = {
+ 31, 32, 9, 35, 36, 39, 40, 48, 49, 20, 21, 23, 11, 13, 55, 57,
+ 3, 58, 65, 50, 51, 53, 5, 6, 9, 20, 21, 25, 23, 31, 32, 9,
+ 41, 42, 9, 59, 60, 66, 67, 68, 7, 8, 14, 15, 17, 22, 24, 26,
+ 33, 34, 37, 38, 43, 44, 61, 62, 63, 64, 69, 70,
+ };
+
+ private static boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) {
+ switch (hiByte) {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ default:
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+ }
+
+ private static boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) {
+ switch (hiByte) {
+ case 0:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 2:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 3:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ case 4:
+ return ((jjbitVec7[i2] & l2) != 0L);
+ case 5:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ case 6:
+ return ((jjbitVec9[i2] & l2) != 0L);
+ case 7:
+ return ((jjbitVec10[i2] & l2) != 0L);
+ case 9:
+ return ((jjbitVec11[i2] & l2) != 0L);
+ case 10:
+ return ((jjbitVec12[i2] & l2) != 0L);
+ case 11:
+ return ((jjbitVec13[i2] & l2) != 0L);
+ case 12:
+ return ((jjbitVec14[i2] & l2) != 0L);
+ case 13:
+ return ((jjbitVec15[i2] & l2) != 0L);
+ case 14:
+ return ((jjbitVec16[i2] & l2) != 0L);
+ case 15:
+ return ((jjbitVec17[i2] & l2) != 0L);
+ case 16:
+ return ((jjbitVec18[i2] & l2) != 0L);
+ case 17:
+ return ((jjbitVec19[i2] & l2) != 0L);
+ case 18:
+ return ((jjbitVec20[i2] & l2) != 0L);
+ case 19:
+ return ((jjbitVec21[i2] & l2) != 0L);
+ case 20:
+ return ((jjbitVec0[i2] & l2) != 0L);
+ case 22:
+ return ((jjbitVec22[i2] & l2) != 0L);
+ case 23:
+ return ((jjbitVec23[i2] & l2) != 0L);
+ case 24:
+ return ((jjbitVec24[i2] & l2) != 0L);
+ case 30:
+ return ((jjbitVec25[i2] & l2) != 0L);
+ case 31:
+ return ((jjbitVec26[i2] & l2) != 0L);
+ case 32:
+ return ((jjbitVec27[i2] & l2) != 0L);
+ case 33:
+ return ((jjbitVec28[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec29[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec30[i2] & l2) != 0L);
+ case 77:
+ return ((jjbitVec31[i2] & l2) != 0L);
+ case 159:
+ return ((jjbitVec32[i2] & l2) != 0L);
+ case 164:
+ return ((jjbitVec33[i2] & l2) != 0L);
+ case 215:
+ return ((jjbitVec34[i2] & l2) != 0L);
+ case 250:
+ return ((jjbitVec35[i2] & l2) != 0L);
+ case 251:
+ return ((jjbitVec36[i2] & l2) != 0L);
+ case 253:
+ return ((jjbitVec37[i2] & l2) != 0L);
+ case 254:
+ return ((jjbitVec38[i2] & l2) != 0L);
+ case 255:
+ return ((jjbitVec39[i2] & l2) != 0L);
+ default:
+ if ((jjbitVec3[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+ }
+
+ private static boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) {
+ switch (hiByte) {
+ case 0:
+ return ((jjbitVec40[i2] & l2) != 0L);
+ case 2:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 3:
+ return ((jjbitVec41[i2] & l2) != 0L);
+ case 4:
+ return ((jjbitVec42[i2] & l2) != 0L);
+ case 5:
+ return ((jjbitVec43[i2] & l2) != 0L);
+ case 6:
+ return ((jjbitVec44[i2] & l2) != 0L);
+ case 7:
+ return ((jjbitVec45[i2] & l2) != 0L);
+ case 9:
+ return ((jjbitVec46[i2] & l2) != 0L);
+ case 10:
+ return ((jjbitVec47[i2] & l2) != 0L);
+ case 11:
+ return ((jjbitVec48[i2] & l2) != 0L);
+ case 12:
+ return ((jjbitVec49[i2] & l2) != 0L);
+ case 13:
+ return ((jjbitVec50[i2] & l2) != 0L);
+ case 14:
+ return ((jjbitVec51[i2] & l2) != 0L);
+ case 15:
+ return ((jjbitVec52[i2] & l2) != 0L);
+ case 16:
+ return ((jjbitVec53[i2] & l2) != 0L);
+ case 17:
+ return ((jjbitVec19[i2] & l2) != 0L);
+ case 18:
+ return ((jjbitVec20[i2] & l2) != 0L);
+ case 19:
+ return ((jjbitVec54[i2] & l2) != 0L);
+ case 20:
+ return ((jjbitVec0[i2] & l2) != 0L);
+ case 22:
+ return ((jjbitVec22[i2] & l2) != 0L);
+ case 23:
+ return ((jjbitVec55[i2] & l2) != 0L);
+ case 24:
+ return ((jjbitVec56[i2] & l2) != 0L);
+ case 30:
+ return ((jjbitVec25[i2] & l2) != 0L);
+ case 31:
+ return ((jjbitVec26[i2] & l2) != 0L);
+ case 32:
+ return ((jjbitVec57[i2] & l2) != 0L);
+ case 33:
+ return ((jjbitVec28[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec58[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec30[i2] & l2) != 0L);
+ case 77:
+ return ((jjbitVec31[i2] & l2) != 0L);
+ case 159:
+ return ((jjbitVec32[i2] & l2) != 0L);
+ case 164:
+ return ((jjbitVec33[i2] & l2) != 0L);
+ case 215:
+ return ((jjbitVec34[i2] & l2) != 0L);
+ case 250:
+ return ((jjbitVec35[i2] & l2) != 0L);
+ case 251:
+ return ((jjbitVec59[i2] & l2) != 0L);
+ case 253:
+ return ((jjbitVec37[i2] & l2) != 0L);
+ case 254:
+ return ((jjbitVec60[i2] & l2) != 0L);
+ case 255:
+ return ((jjbitVec61[i2] & l2) != 0L);
+ default:
+ if ((jjbitVec3[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+ }
+
+ public static final String[] jjstrLiteralImages = {
+ "", null, null, null, null, null, null, null,
+ "\141\142\163\164\162\141\143\164", "\141\163\163\145\162\164", "\142\157\157\154\145\141\156",
+ "\142\162\145\141\153", "\142\171\164\145", "\143\141\163\145", "\143\141\164\143\150",
+ "\143\150\141\162", "\143\154\141\163\163", "\143\157\156\163\164",
+ "\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164", "\144\157", "\144\157\165\142\154\145",
+ "\145\154\163\145", "\145\156\165\155", "\145\170\164\145\156\144\163", "\146\141\154\163\145",
+ "\146\151\156\141\154", "\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162",
+ "\147\157\164\157", "\151\146", "\151\155\160\154\145\155\145\156\164\163",
+ "\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146", "\151\156\164",
+ "\151\156\164\145\162\146\141\143\145", "\154\157\156\147", "\156\141\164\151\166\145", "\156\145\167",
+ "\156\165\154\154", "\160\141\143\153\141\147\145", "\160\162\151\166\141\164\145",
+ "\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143", "\162\145\164\165\162\156",
+ "\163\150\157\162\164", "\163\164\141\164\151\143", "\163\164\162\151\143\164\146\160",
+ "\163\165\160\145\162", "\163\167\151\164\143\150",
+ "\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163", "\164\150\162\157\167", "\164\150\162\157\167\163",
+ "\164\162\141\156\163\151\145\156\164", "\164\162\165\145", "\164\162\171", "\166\157\151\144",
+ "\166\157\154\141\164\151\154\145", "\167\150\151\154\145", null, null, null, null, null, null, null, null, null,
+ null, null, null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\73",
+ "\54", "\56", "\100", "\75", "\74", "\41", "\176", "\77", "\72", "\75\75", "\74\75",
+ "\76\75", "\41\75", "\174\174", "\46\46", "\53\53", "\55\55", "\53", "\55", "\52",
+ "\57", "\46", "\174", "\136", "\45", "\74\74", "\53\75", "\55\75", "\52\75",
+ "\57\75", "\46\75", "\174\75", "\136\75", "\45\75", "\74\74\75", "\76\76\75",
+ "\76\76\76\75", "\56\56\56", "\76\76\76", "\76\76", "\76", "\32", null,};
+ public static final String[] lexStateNames = {
+ "DEFAULT",
+ "IN_FORMAL_COMMENT",
+ "IN_MULTI_LINE_COMMENT",
+ };
+ public static final int[] jjnewLexState = {
+ -1, 1, 2, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ };
+ static final long[] jjtoToken = {
+ 0x3fffffffffffff01L, 0x1ffffffffffff9c2L,
+ };
+ static final long[] jjtoSkip = {
+ 0x78L, 0x0L,
+ };
+ static final long[] jjtoSpecial = {
+ 0x78L, 0x0L,
+ };
+ static final long[] jjtoMore = {
+ 0x86L, 0x0L,
+ };
+ protected JavaCharStream input_stream;
+ private final int[] jjrounds = new int[71];
+ private final int[] jjstateSet = new int[142];
+ StringBuffer image;
+ int jjimageLen;
+ int lengthOfMatch;
+ protected char curChar;
+
+ public JavaParserTokenManager(JavaCharStream stream) {
+ if (JavaCharStream.staticFlag)
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+ input_stream = stream;
+ }
+
+ public JavaParserTokenManager(JavaCharStream stream, int lexState) {
+ this(stream);
+ SwitchTo(lexState);
+ }
+
+ public void ReInit(JavaCharStream stream) {
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+ }
+
+ private void ReInitRounds() {
+ int i;
+ jjround = 0x80000001;
+ for (i = 71; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+ }
+
+ public void ReInit(JavaCharStream stream, int lexState) {
+ ReInit(stream);
+ SwitchTo(lexState);
+ }
+
+ public void SwitchTo(int lexState) {
+ if (lexState >= 3 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+ }
+
+ protected Token jjFillToken() {
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+ }
+
+ int curLexState = 0;
+ int defaultLexState = 0;
+ int jjnewStateCnt;
+ int jjround;
+ int jjmatchedPos;
+ int jjmatchedKind;
+
+ public Token getNextToken() {
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop:
+ for (; ;) {
+ try {
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e) {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ image = null;
+ jjimageLen = 0;
+
+ for (; ;) {
+ switch (curLexState) {
+ case 0:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ if (jjmatchedPos == 0 && jjmatchedKind > 124) {
+ jjmatchedKind = 124;
+ }
+ break;
+ case 1:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_1();
+ if (jjmatchedPos == 0 && jjmatchedKind > 7) {
+ jjmatchedKind = 7;
+ }
+ break;
+ case 2:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_2();
+ if (jjmatchedPos == 0 && jjmatchedKind > 7) {
+ jjmatchedKind = 7;
+ }
+ break;
+ }
+ if (jjmatchedKind != 0x7fffffff) {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ TokenLexicalActions(matchedToken);
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ return matchedToken;
+ } else
+ if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ matchedToken = jjFillToken();
+ if (specialToken == null)
+ specialToken = matchedToken;
+ else {
+ matchedToken.specialToken = specialToken;
+ specialToken = (specialToken.next = matchedToken);
+ }
+ SkipLexicalActions(matchedToken);
+ } else
+ SkipLexicalActions(null);
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ continue EOFLoop;
+ }
+ MoreLexicalActions();
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ curPos = 0;
+ jjmatchedKind = 0x7fffffff;
+ try {
+ curChar = input_stream.readChar();
+ continue;
+ }
+ catch (java.io.IOException e1) {
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try {
+ input_stream.readChar();
+ input_stream.backup(1);
+ }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ } else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+ }
+ }
+
+ void SkipLexicalActions(Token matchedToken) {
+ switch (jjmatchedKind) {
+ default:
+ break;
+ }
+ }
+
+ void MoreLexicalActions() {
+ jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
+ switch (jjmatchedKind) {
+ case 1:
+ if (image == null)
+ image = new StringBuffer();
+ image.append(input_stream.GetSuffix(jjimageLen));
+ jjimageLen = 0;
+ input_stream.backup(1);
+ break;
+ default:
+ break;
+ }
+ }
+
+ void TokenLexicalActions(Token matchedToken) {
+ switch (jjmatchedKind) {
+ case 120:
+ if (image == null)
+ image = new StringBuffer();
+ image.append(jjstrLiteralImages[120]);
+ matchedToken.kind = GT;
+ ((Token.GTToken) matchedToken).realKind = RUNSIGNEDSHIFT;
+ input_stream.backup(2);
+ matchedToken.image = ">";
+ break;
+ case 121:
+ if (image == null)
+ image = new StringBuffer();
+ image.append(jjstrLiteralImages[121]);
+ matchedToken.kind = GT;
+ ((Token.GTToken) matchedToken).realKind = RSIGNEDSHIFT;
+ input_stream.backup(1);
+ matchedToken.image = ">";
+ break;
+ default:
+ break;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParserTreeConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,230 @@
+/* Generated By:JJTree: Do not edit this line. ./JavaParserTreeConstants.java */
+
+package jaxx.compiler.parser.java;
+
+public interface JavaParserTreeConstants {
+ public int JJTLINE = 0;
+ public int JJTCOMPILATIONUNIT = 1;
+ public int JJTPACKAGEDECLARATION = 2;
+ public int JJTIMPORTDECLARATION = 3;
+ public int JJTMODIFIERS = 4;
+ public int JJTTYPEDECLARATION = 5;
+ public int JJTCLASSORINTERFACEDECLARATION = 6;
+ public int JJTEXTENDSLIST = 7;
+ public int JJTIMPLEMENTSLIST = 8;
+ public int JJTENUMDECLARATION = 9;
+ public int JJTENUMBODY = 10;
+ public int JJTENUMCONSTANT = 11;
+ public int JJTTYPEPARAMETERS = 12;
+ public int JJTTYPEPARAMETER = 13;
+ public int JJTTYPEBOUND = 14;
+ public int JJTCLASSORINTERFACEBODY = 15;
+ public int JJTCLASSORINTERFACEBODYDECLARATION = 16;
+ public int JJTFIELDDECLARATION = 17;
+ public int JJTVARIABLEDECLARATOR = 18;
+ public int JJTVARIABLEDECLARATORID = 19;
+ public int JJTVARIABLEINITIALIZER = 20;
+ public int JJTARRAYINITIALIZER = 21;
+ public int JJTMETHODDECLARATION = 22;
+ public int JJTMETHODDECLARATOR = 23;
+ public int JJTFORMALPARAMETERS = 24;
+ public int JJTFORMALPARAMETER = 25;
+ public int JJTCONSTRUCTORDECLARATION = 26;
+ public int JJTEXPLICITCONSTRUCTORINVOCATION = 27;
+ public int JJTINITIALIZER = 28;
+ public int JJTTYPE = 29;
+ public int JJTREFERENCETYPE = 30;
+ public int JJTCLASSORINTERFACETYPE = 31;
+ public int JJTTYPEARGUMENTS = 32;
+ public int JJTTYPEARGUMENT = 33;
+ public int JJTWILDCARDBOUNDS = 34;
+ public int JJTPRIMITIVETYPE = 35;
+ public int JJTRESULTTYPE = 36;
+ public int JJTNAME = 37;
+ public int JJTNAMELIST = 38;
+ public int JJTEXPRESSION = 39;
+ public int JJTASSIGNMENTOPERATOR = 40;
+ public int JJTASSIGNMENTEXPRESSION = 41;
+ public int JJTCONDITIONALEXPRESSION = 42;
+ public int JJTCONDITIONALOREXPRESSION = 43;
+ public int JJTCONDITIONALANDEXPRESSION = 44;
+ public int JJTINCLUSIVEOREXPRESSION = 45;
+ public int JJTEXCLUSIVEOREXPRESSION = 46;
+ public int JJTANDEXPRESSION = 47;
+ public int JJTEQUALITYEXPRESSION = 48;
+ public int JJTINSTANCEOFEXPRESSION = 49;
+ public int JJTRELATIONALEXPRESSION = 50;
+ public int JJTSHIFTEXPRESSION = 51;
+ public int JJTADDITIVEEXPRESSION = 52;
+ public int JJTMULTIPLICATIVEEXPRESSION = 53;
+ public int JJTUNARYEXPRESSION = 54;
+ public int JJTPREINCREMENTEXPRESSION = 55;
+ public int JJTPREDECREMENTEXPRESSION = 56;
+ public int JJTUNARYEXPRESSIONNOTPLUSMINUS = 57;
+ public int JJTCASTLOOKAHEAD = 58;
+ public int JJTPOSTFIXEXPRESSION = 59;
+ public int JJTPOSTFIXOPERATOR = 60;
+ public int JJTCASTEXPRESSION = 61;
+ public int JJTPRIMARYEXPRESSION = 62;
+ public int JJTMEMBERSELECTOR = 63;
+ public int JJTPRIMARYPREFIX = 64;
+ public int JJTPRIMARYSUFFIX = 65;
+ public int JJTLITERAL = 66;
+ public int JJTBOOLEANLITERAL = 67;
+ public int JJTNULLLITERAL = 68;
+ public int JJTARGUMENTS = 69;
+ public int JJTARGUMENTLIST = 70;
+ public int JJTALLOCATIONEXPRESSION = 71;
+ public int JJTARRAYDIMSANDINITS = 72;
+ public int JJTSTATEMENT = 73;
+ public int JJTASSERTSTATEMENT = 74;
+ public int JJTLABELEDSTATEMENT = 75;
+ public int JJTBLOCK = 76;
+ public int JJTBLOCKSTATEMENT = 77;
+ public int JJTLOCALVARIABLEDECLARATION = 78;
+ public int JJTEMPTYSTATEMENT = 79;
+ public int JJTSTATEMENTEXPRESSION = 80;
+ public int JJTSWITCHSTATEMENT = 81;
+ public int JJTSWITCHLABEL = 82;
+ public int JJTIFSTATEMENT = 83;
+ public int JJTWHILESTATEMENT = 84;
+ public int JJTDOSTATEMENT = 85;
+ public int JJTFORSTATEMENT = 86;
+ public int JJTFORINIT = 87;
+ public int JJTSTATEMENTEXPRESSIONLIST = 88;
+ public int JJTFORUPDATE = 89;
+ public int JJTBREAKSTATEMENT = 90;
+ public int JJTCONTINUESTATEMENT = 91;
+ public int JJTRETURNSTATEMENT = 92;
+ public int JJTTHROWSTATEMENT = 93;
+ public int JJTSYNCHRONIZEDSTATEMENT = 94;
+ public int JJTTRYSTATEMENT = 95;
+ public int JJTRUNSIGNEDSHIFT = 96;
+ public int JJTRSIGNEDSHIFT = 97;
+ public int JJTANNOTATION = 98;
+ public int JJTNORMALANNOTATION = 99;
+ public int JJTMARKERANNOTATION = 100;
+ public int JJTSINGLEMEMBERANNOTATION = 101;
+ public int JJTMEMBERVALUEPAIRS = 102;
+ public int JJTMEMBERVALUEPAIR = 103;
+ public int JJTMEMBERVALUE = 104;
+ public int JJTMEMBERVALUEARRAYINITIALIZER = 105;
+ public int JJTANNOTATIONTYPEDECLARATION = 106;
+ public int JJTANNOTATIONTYPEBODY = 107;
+ public int JJTANNOTATIONTYPEMEMBERDECLARATION = 108;
+ public int JJTDEFAULTVALUE = 109;
+
+
+ public String[] jjtNodeName = {
+ "Line",
+ "CompilationUnit",
+ "PackageDeclaration",
+ "ImportDeclaration",
+ "Modifiers",
+ "TypeDeclaration",
+ "ClassOrInterfaceDeclaration",
+ "ExtendsList",
+ "ImplementsList",
+ "EnumDeclaration",
+ "EnumBody",
+ "EnumConstant",
+ "TypeParameters",
+ "TypeParameter",
+ "TypeBound",
+ "ClassOrInterfaceBody",
+ "ClassOrInterfaceBodyDeclaration",
+ "FieldDeclaration",
+ "VariableDeclarator",
+ "VariableDeclaratorId",
+ "VariableInitializer",
+ "ArrayInitializer",
+ "MethodDeclaration",
+ "MethodDeclarator",
+ "FormalParameters",
+ "FormalParameter",
+ "ConstructorDeclaration",
+ "ExplicitConstructorInvocation",
+ "Initializer",
+ "Type",
+ "ReferenceType",
+ "ClassOrInterfaceType",
+ "TypeArguments",
+ "TypeArgument",
+ "WildcardBounds",
+ "PrimitiveType",
+ "ResultType",
+ "Name",
+ "NameList",
+ "Expression",
+ "AssignmentOperator",
+ "AssignmentExpression",
+ "ConditionalExpression",
+ "ConditionalOrExpression",
+ "ConditionalAndExpression",
+ "InclusiveOrExpression",
+ "ExclusiveOrExpression",
+ "AndExpression",
+ "EqualityExpression",
+ "InstanceOfExpression",
+ "RelationalExpression",
+ "ShiftExpression",
+ "AdditiveExpression",
+ "MultiplicativeExpression",
+ "UnaryExpression",
+ "PreIncrementExpression",
+ "PreDecrementExpression",
+ "UnaryExpressionNotPlusMinus",
+ "CastLookahead",
+ "PostfixExpression",
+ "PostfixOperator",
+ "CastExpression",
+ "PrimaryExpression",
+ "MemberSelector",
+ "PrimaryPrefix",
+ "PrimarySuffix",
+ "Literal",
+ "BooleanLiteral",
+ "NullLiteral",
+ "Arguments",
+ "ArgumentList",
+ "AllocationExpression",
+ "ArrayDimsAndInits",
+ "Statement",
+ "AssertStatement",
+ "LabeledStatement",
+ "Block",
+ "BlockStatement",
+ "LocalVariableDeclaration",
+ "EmptyStatement",
+ "StatementExpression",
+ "SwitchStatement",
+ "SwitchLabel",
+ "IfStatement",
+ "WhileStatement",
+ "DoStatement",
+ "ForStatement",
+ "ForInit",
+ "StatementExpressionList",
+ "ForUpdate",
+ "BreakStatement",
+ "ContinueStatement",
+ "ReturnStatement",
+ "ThrowStatement",
+ "SynchronizedStatement",
+ "TryStatement",
+ "RUNSIGNEDSHIFT",
+ "RSIGNEDSHIFT",
+ "Annotation",
+ "NormalAnnotation",
+ "MarkerAnnotation",
+ "SingleMemberAnnotation",
+ "MemberValuePairs",
+ "MemberValuePair",
+ "MemberValue",
+ "MemberValueArrayInitializer",
+ "AnnotationTypeDeclaration",
+ "AnnotationTypeBody",
+ "AnnotationTypeMemberDeclaration",
+ "DefaultValue",
+ };
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Node.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,51 @@
+/* Generated By:JJTree: Do not edit this line. Node.java */
+
+package jaxx.compiler.parser.java;
+
+/* All AST nodes must implement this interface. It provides basic
+ machinery for constructing the parent and child relationships
+ between nodes. */
+
+public interface Node {
+
+ /**
+ * This method is called after the node has been made the current
+ * node. It indicates that child nodes can now be added to it.
+ */
+ public void jjtOpen();
+
+ /**
+ * This method is called after all the child nodes have been
+ * added.
+ */
+ public void jjtClose();
+
+ /**
+ * This pair of methods are used to inform the node of its
+ * parent.
+ *
+ * @param n node
+ */
+ public void jjtSetParent(Node n);
+
+ public Node jjtGetParent();
+
+ /**
+ * This method tells the node to add its argument to the node's
+ * list of children.
+ *
+ * @param n node
+ * @param i index ?
+ */
+ public void jjtAddChild(Node n, int i);
+
+ /**
+ * @param i index of child
+ * @return a child node. The children are numbered
+ * from zero, left to right.
+ */
+ public Node jjtGetChild(int i);
+
+ /** @return the number of children the node has. */
+ public int jjtGetNumChildren();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/ParseException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,214 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+package jaxx.compiler.parser.java;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ * <p/>
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends jaxx.compiler.CompilerException {
+ int line;
+ int column;
+ private static final long serialVersionUID = 6179854408401024700L;
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ *
+ * @param currentTokenVal ?
+ * @param expectedTokenSequencesVal ?
+ * @param tokenImageVal ?
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ ) {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ public ParseException(String message, int line, int column) {
+ super(message);
+ specialConstructor = false;
+ this.line = line;
+ this.column = column;
+ }
+
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int[] expectedTokenSequence : expectedTokenSequences) {
+ if (maxSize < expectedTokenSequence.length) {
+ maxSize = expectedTokenSequence.length;
+ }
+ for (int anExpectedTokenSequence : expectedTokenSequence) {
+ expected.append(tokenImage[anExpectedTokenSequence]).append(" ");
+ }
+ if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+
+ public int getLine() {
+ return line;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ /** The end of line string for this machine. */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ *
+ * @param str text to treate
+ * @return the escaped version of text
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i)) {
+ case 0:
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ }
+ }
+ return retval.toString();
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/SimpleNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,135 @@
+/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
+
+package jaxx.compiler.parser.java;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+public class SimpleNode implements Node {
+ protected Node parent;
+ protected Node[] children;
+ protected int id;
+ protected JavaParser parser;
+ public Token firstToken;
+ public Token lastToken;
+ private ClassDescriptor javaType;
+
+
+ public SimpleNode(int i) {
+ id = i;
+ }
+
+ public SimpleNode(JavaParser p, int i) {
+ this(i);
+ parser = p;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void jjtOpen() {
+ }
+
+ public void jjtClose() {
+ }
+
+ public void jjtSetParent(Node n) {
+ parent = n;
+ }
+
+ public Node jjtGetParent() {
+ return parent;
+ }
+
+ public SimpleNode getParent() {
+ return (SimpleNode) parent;
+ }
+
+
+ public ClassDescriptor getJavaType() {
+ return javaType;
+ }
+
+
+ public void setJavaType(ClassDescriptor javaType) {
+ this.javaType = javaType;
+ }
+
+ public void jjtAddChild(Node n, int i) {
+ if (children == null) {
+ children = new Node[i + 1];
+ } else if (i >= children.length) {
+ Node c[] = new Node[i + 1];
+ System.arraycopy(children, 0, c, 0, children.length);
+ children = c;
+ }
+ children[i] = n;
+ }
+
+ public Node jjtGetChild(int i) {
+ return children[i];
+ }
+
+ public SimpleNode getChild(int i) {
+ return (SimpleNode) children[i];
+ }
+
+ public int jjtGetNumChildren() {
+ return (children == null) ? 0 : children.length;
+ }
+
+ /* You can override these two methods in subclasses of SimpleNode to
+customize the way the node appears when the tree is dumped. If
+your output uses more than one line you should override
+toString(String), otherwise overriding toString() is probably all
+you need to do. */
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getText() + "]";
+ }
+
+ public String toString(String prefix) {
+ return prefix + toString();
+ }
+
+ /* Override this method if you want to customize how the node dumps
+ out its children. */
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+ if (children != null) {
+ for (Node aChildren : children) {
+ SimpleNode n = (SimpleNode) aChildren;
+ if (n != null) {
+ n.dump(prefix + " ");
+ }
+ }
+ }
+ }
+
+ private void appendSpecialTokens(StringBuffer s, Token st) {
+ if (st != null) {
+ appendSpecialTokens(s, st.specialToken);
+ s.append(st.image);
+ }
+ }
+
+
+ /** @return the text of the tokens comprising this node. */
+ public String getText() {
+ StringBuffer text = new StringBuffer();
+ Token t = firstToken;
+ while (t != null) {
+ appendSpecialTokens(text, t.specialToken);
+ text.append(t.image);
+ if (t == lastToken)
+ break;
+ t = t.next;
+ }
+
+ return text.toString();
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Token.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,79 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+package jaxx.compiler.parser.java;
+
+/** Describes the input token stream. */
+
+public class Token {
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /** The string image of the token. */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /** Returns the image. */
+ public String toString() {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ * <p/>
+ * case MyParserConstants.ID : return new IDToken();
+ * <p/>
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind) {
+ switch (ofKind) {
+ default:
+ return new Token();
+ case JavaParserConstants.RUNSIGNEDSHIFT:
+ case JavaParserConstants.RSIGNEDSHIFT:
+ case JavaParserConstants.GT:
+ return new GTToken();
+ }
+ }
+
+ public static class GTToken extends Token {
+ int realKind = JavaParserConstants.GT;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/TokenMgrError.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,126 @@
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+package jaxx.compiler.parser.java;
+
+public class TokenMgrError extends Error {
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /** Lexical error occured. */
+ static final int LEXICAL_ERROR = 0;
+
+ /** An attempt wass made to create a second instance of a static token manager. */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /** Tried to change to an invalid lexical state. */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /** Detected (and bailed out of) an infinite loop in the token manager. */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+ private static final long serialVersionUID = -9131500865453532454L;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ *
+ * @param str text to treate
+ * @return the treated text
+ */
+ protected static String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i)) {
+ case 0:
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * @param EOFSeen : indicates if EOF caused the lexicl error
+ * @param lexState : lexical state in which this error occured
+ * @param errorLine : line number when the error occured
+ * @param errorColumn : column number when the error occured
+ * @param errorAfter : prefix that was seen before this error occured
+ * @param curChar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ * @return a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return ("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ * <p/>
+ * "Internal Error : Please file a bug report .... "
+ * <p/>
+ * from this method for such cases in the release version of your parser.
+ */
+ @Override
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/ClassDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,144 @@
+package jaxx.compiler.reflect;
+
+import jaxx.runtime.JAXXObjectDescriptor;
+
+import java.util.Arrays;
+
+/**
+ * Mirrors the class <code>java.lang.Class</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
+ * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
+ * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
+ * circular dependencies).
+ */
+public abstract class ClassDescriptor {
+
+ private String name;
+ private String packageName;
+ private String superclass;
+ private String[] interfaces;
+ private boolean isInterface;
+ private boolean isArray;
+ private String componentType;
+ private JAXXObjectDescriptor jaxxObjectDescriptor;
+ private ClassLoader classLoader;
+ private MethodDescriptor[] methodDescriptors;
+ private FieldDescriptor[] fieldDescriptors;
+
+ public abstract MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException;
+
+ public abstract FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException;
+
+ ClassDescriptor(String name, String packageName, String superclass, String[] interfaces, boolean isInterface,
+ boolean isArray, String componentType, JAXXObjectDescriptor jaxxObjectDescriptor,
+ ClassLoader classLoader, MethodDescriptor[] methodDescriptors, FieldDescriptor[] fieldDescriptors) {
+ this.name = name;
+ this.packageName = packageName;
+ this.superclass = superclass;
+ this.interfaces = interfaces;
+ this.isInterface = isInterface;
+ this.isArray = isArray;
+ this.componentType = componentType;
+ this.jaxxObjectDescriptor = jaxxObjectDescriptor;
+ this.classLoader = classLoader;
+ this.methodDescriptors = methodDescriptors;
+ this.fieldDescriptors = fieldDescriptors;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public ClassDescriptor getSuperclass() {
+ try {
+ return superclass != null ? ClassDescriptorLoader.getClassDescriptor(superclass, getClassLoader()) : null;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public ClassDescriptor[] getInterfaces() {
+ try {
+ ClassDescriptor[] result = new ClassDescriptor[interfaces.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = ClassDescriptorLoader.getClassDescriptor(interfaces[i], getClassLoader());
+ }
+ return result;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean isInterface() {
+ return isInterface;
+ }
+
+ public boolean isArray() {
+ return isArray;
+ }
+
+ public ClassDescriptor getComponentType() {
+ try {
+ return componentType != null ? ClassDescriptorLoader.getClassDescriptor(componentType, getClassLoader()) : null;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public MethodDescriptor[] getMethodDescriptors() {
+ return methodDescriptors;
+ }
+
+ public MethodDescriptor getMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
+ for (MethodDescriptor methodDescriptor : methodDescriptors) {
+ if (methodDescriptor.getName().equals(name) && methodDescriptor.getParameterTypes().length == parameterTypes.length && Arrays.equals(methodDescriptor.getParameterTypes(), parameterTypes)) {
+ return methodDescriptor;
+ }
+ }
+ throw new NoSuchMethodException("Could not find method " + name + "(" + Arrays.asList(parameterTypes) + ") in " + getName());
+ }
+
+ public FieldDescriptor[] getFieldDescriptors() {
+ return fieldDescriptors;
+ }
+
+ public FieldDescriptor getFieldDescriptor(String name) throws NoSuchFieldException {
+ for (FieldDescriptor fieldDescriptor : fieldDescriptors) {
+ if (fieldDescriptor.getName().equals(name)) {
+ return fieldDescriptor;
+ }
+ }
+ throw new NoSuchFieldException("Could not find field " + name + " in " + getName());
+ }
+
+ public JAXXObjectDescriptor getJAXXObjectDescriptor() {
+ return jaxxObjectDescriptor;
+ }
+
+ public boolean isAssignableFrom(ClassDescriptor descriptor) {
+ while (descriptor != null) {
+ if (descriptor == this) {
+ return true;
+ }
+ for (ClassDescriptor anInterface : descriptor.getInterfaces()) {
+ if (anInterface == this) {
+ return true;
+ }
+ }
+ descriptor = descriptor.getSuperclass();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "ClassDescriptor[" + getName() + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/ClassDescriptorLoader.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,426 @@
+package jaxx.compiler.reflect;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.SymbolTable;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXObjectDescriptor;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Mirrors the class <code>java.lang.ClassLoader</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
+ * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
+ * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
+ * circular dependencies).
+ */
+public class ClassDescriptorLoader {
+
+ private static Map<String, ClassDescriptor> descriptors = new HashMap<String, ClassDescriptor>();
+
+ private ClassDescriptorLoader() {
+ }
+
+ public static synchronized ClassDescriptor getClassDescriptor(String className) throws ClassNotFoundException {
+ return getClassDescriptor(className, Thread.currentThread().getContextClassLoader());
+ //return getClassDescriptor(className, ClassDescriptorLoader.class.getClassLoader());
+ }
+
+ public static synchronized ClassDescriptor getClassDescriptor(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ ClassDescriptor result = descriptors.get(className);
+ if (result != null) {
+ return result;
+ }
+
+// if (result == null) {
+ if (JAXXCompilerLaunchor.isRegistred() && JAXXCompilerLaunchor.get().getSymbolTable(className) != null) {
+ result = createClassDescriptorFromSymbolTable(className, classLoader);
+ } else {
+ if (classLoader == null) {
+ classLoader = ClassDescriptorLoader.class.getClassLoader();
+ }
+
+ String relativePath = className.replaceAll("\\.", "/");
+ String relativePathPattern = ".*";// + className + ".*"; // used to ensure that the located resource has the right character cases
+
+ // find the most recently updated source for the class -- Java source, JAXX source, or compiled class file
+ long javaLastModified = -1;
+ URL javaFile = classLoader.getResource(relativePath + ".java");
+ if (javaFile != null && javaFile.toString().startsWith("file:") && javaFile.toString().matches(relativePathPattern)) {
+ javaLastModified = JAXXCompiler.URLtoFile(javaFile).lastModified();
+ }
+
+ long classLastModified = -1;
+ URL classFile = classLoader.getResource(relativePath + ".class");
+ if (classFile != null && classFile.toString().startsWith("file:") && classFile.toString().matches(relativePathPattern)) {
+ classLastModified = JAXXCompiler.URLtoFile(classFile).lastModified();
+ }
+
+ long jaxxLastModified = -1;
+ URL jaxxFile = classLoader.getResource(relativePath + ".jaxx");
+ if (jaxxFile != null && jaxxFile.toString().startsWith("file:") && jaxxFile.toString().matches(relativePathPattern)) {
+ File jaxxFilePath = JAXXCompiler.URLtoFile(jaxxFile);
+ jaxxLastModified = jaxxFilePath.lastModified();
+ String simplePath = jaxxFilePath.getPath();
+ simplePath = simplePath.substring(0, simplePath.length() - ".jaxx".length());
+ File cssFilePath = new File(simplePath + ".css");
+ if (cssFilePath.exists()) {
+ jaxxLastModified = Math.max(jaxxLastModified, cssFilePath.lastModified());
+ }
+ File scriptFilePath = new File(simplePath + ".script");
+ if (scriptFilePath.exists()) {
+ jaxxLastModified = Math.max(jaxxLastModified, scriptFilePath.lastModified());
+ }
+ }
+
+ if (jaxxLastModified != -1 && JAXXCompilerLaunchor.isRegistred() && JAXXCompilerLaunchor.get().getSymbolTable(className) == null) {
+ jaxxLastModified = -1; // file has been modified, but wasn't included in this
+ }
+ // compilation set so we don't have a symbol table
+
+ if (javaLastModified != -1 || classLastModified != -1 || jaxxLastModified != -1) {
+ if (jaxxLastModified > classLastModified && jaxxLastModified > javaLastModified) {
+ result = createClassDescriptorFromSymbolTable(className, classLoader);
+ } else if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified) {
+ result = createClassDescriptorFromJavaSource(javaFile, classLoader);
+ }
+ }
+ // else work off of the class file. This also handles the case where the class is available, but wasn't in a location where
+ // we could check its last modified date (in a JAR, over the network, etc.)
+ if (result == null) {
+ Class<?> javaClass = getClass(className, classLoader);
+ result = createClassDescriptorFromClass(javaClass);
+ }
+ }
+ descriptors.put(className, result);
+// }
+ return result;
+ }
+
+ public static ClassDescriptor getClassDescriptor(Class<?> javaClass) {
+ try {
+ return getClassDescriptor(javaClass.getName(), javaClass.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Class<?> getPrimitiveBoxedClass(String className) throws ClassNotFoundException {
+ if (className.equals("boolean")) {
+ return Boolean.class;
+ }
+ if (className.equals("byte")) {
+ return Byte.class;
+ }
+ if (className.equals("short")) {
+ return Short.class;
+ }
+ if (className.equals("int")) {
+ return Integer.class;
+ }
+ if (className.equals("long")) {
+ return Long.class;
+ }
+ if (className.equals("float")) {
+ return Float.class;
+ }
+ if (className.equals("double")) {
+ return Double.class;
+ }
+ if (className.equals("char")) {
+ return Character.class;
+ }
+ if (className.equals("void")) {
+ return Void.class;
+ }
+ return null;
+ }
+
+ public static Class<?> getPrimitiveClass(String className) throws ClassNotFoundException {
+ if (className.equals("boolean")) {
+ return boolean.class;
+ }
+ if (className.equals("byte")) {
+ return byte.class;
+ }
+ if (className.equals("short")) {
+ return short.class;
+ }
+ if (className.equals("int")) {
+ return int.class;
+ }
+ if (className.equals("long")) {
+ return long.class;
+ }
+ if (className.equals("float")) {
+ return float.class;
+ }
+ if (className.equals("double")) {
+ return double.class;
+ }
+ if (className.equals("char")) {
+ return char.class;
+ }
+ if (className.equals("void")) {
+ return void.class;
+ }
+ // detect arrays
+ int arrayCount = 0;
+ while (className.endsWith("[]")) {
+ arrayCount++;
+ className = className.substring(0, className.length() - 2);
+ }
+ Class<?> klass = null;
+ if (arrayCount > 0) {
+ klass = getPrimitiveClass(className);
+ if (klass == null) {
+ // none primitive array
+ return null;
+ }
+ // must take the boxed class, other it does not works
+ // to make a Class.forName("[Lchar;"); but works
+ // with Class.forName("[LCharacter;"); ...
+ klass = getPrimitiveBoxedClass(className);
+ className = klass.getName();
+
+ className = "L" + className + ";";
+ while (arrayCount > 0) {
+ className = "[" + className;
+ arrayCount--;
+ }
+ //System.out.println("primitive array class "+className);
+ return Class.forName(className);
+ }
+ return null;
+ }
+
+ public static Class<?> getClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ Class<?> klass = getPrimitiveClass(className);
+ if (klass != null) {
+ return klass;
+ }
+ // try an array of none primitive classes
+ int arrayCount = 0;
+ while (className.endsWith("[]")) {
+ arrayCount++;
+ className = className.substring(0, className.length() - 2);
+ }
+ if (arrayCount > 0) {
+ className = "L" + className + ";";
+ while (arrayCount > 0) {
+ className = "[" + className;
+ arrayCount--;
+ }
+ }
+ try {
+ return classLoader != null ? Class.forName(className, true, classLoader) : Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ // perharps we are in a inner class ?
+ int dotIndex = className.lastIndexOf(".");
+ if (dotIndex > -1) {
+ String parentFQN = className.substring(0, dotIndex);
+ String simpleName = className.substring(dotIndex + 1);
+ try {
+ Class<?> parentClass = classLoader != null ? Class.forName(parentFQN, true, classLoader) : Class.forName(parentFQN);
+ for (Class<?> innerClass : parentClass.getClasses()) {
+ if (simpleName.equals(innerClass.getSimpleName())) {
+ return innerClass;
+ }
+ }
+ } catch (ClassNotFoundException e1) {
+ // no super class,so let the first exception throw...
+ }
+ }
+ throw e;
+ } catch (NoClassDefFoundError e) {
+
+ throw new ClassNotFoundException(e.toString());
+ }
+ }
+
+ private static MethodDescriptor createMethodDescriptor(Method javaMethod, ClassLoader classLoader) {
+ String methodName = javaMethod.getName();
+ int modifiers = javaMethod.getModifiers();
+ String returnType = javaMethod.getReturnType().getName();
+ Class<?>[] javaParameters = javaMethod.getParameterTypes();
+ String[] parameters = new String[javaParameters.length];
+ for (int i = 0; i < parameters.length; i++) {
+ parameters[i] = javaParameters[i].getName();
+ }
+ return new MethodDescriptor(methodName, modifiers, returnType, parameters, classLoader);
+ }
+
+ private static FieldDescriptor createFieldDescriptor(Field javaField, ClassLoader classLoader) {
+ String fieldName = javaField.getName();
+ int modifiers = javaField.getModifiers();
+ String type = javaField.getType().getName();
+ return new FieldDescriptor(fieldName, modifiers, type, classLoader);
+ }
+
+ private static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) {
+ if (!JAXXObject.class.isAssignableFrom(jaxxClass) || jaxxClass == JAXXObject.class) {
+ return null;
+ }
+ try {
+ Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor", new Class<?>[0]);
+ return (JAXXObjectDescriptor) getJAXXObjectDescriptor.invoke(null);
+ } catch (NoSuchMethodException e) {
+ throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + " to have a static method named $getJAXXObjectDescriptor");
+ } catch (IllegalAccessException e) {
+ throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + "'s $getJAXXObjectDescriptor method to be public");
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static ClassDescriptor createClassDescriptorFromJavaSource(URL javaSource, ClassLoader classLoader) throws ClassNotFoundException {
+ try {
+ InputStream in = javaSource.openStream();
+ Reader reader = new InputStreamReader(in, "utf-8");
+ ClassDescriptor result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, classLoader);
+ reader.close();
+ return result;
+ } catch (IOException e) {
+ throw new ClassNotFoundException(e.toString());
+ }
+ }
+
+ private static ClassDescriptor createClassDescriptorFromSymbolTable(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ final JAXXCompiler compiler = JAXXCompilerLaunchor.get().getJAXXCompiler(className);
+ final SymbolTable symbolTable = JAXXCompilerLaunchor.get().getSymbolTable(className);
+ if (symbolTable == null) {
+ throw new CompilerException("Internal error: no symbol table was generated for class '" + className + "'");
+ }
+ ClassDescriptor superclass = getClassDescriptor(symbolTable.getSuperclassName(), classLoader);
+ List<MethodDescriptor> publicMethods = symbolTable.getScriptMethods();
+ List<FieldDescriptor> publicFields = symbolTable.getScriptFields();
+ //List<MethodDescriptor> declaredMethods = new ArrayList<MethodDescriptor>(publicMethods);
+ //List<FieldDescriptor> declaredFields = new ArrayList<FieldDescriptor>(publicFields);
+ Iterator<MethodDescriptor> methods = publicMethods.iterator();
+ while (methods.hasNext()) {
+ MethodDescriptor method = methods.next();
+ if (!Modifier.isPublic(method.getModifiers())) {
+ methods.remove();
+ }
+ }
+ Iterator<FieldDescriptor> fields = publicFields.iterator();
+ while (fields.hasNext()) {
+ FieldDescriptor field = fields.next();
+ if (!Modifier.isPublic(field.getModifiers())) {
+ fields.remove();
+ }
+ }
+ publicMethods.addAll(Arrays.asList(superclass.getMethodDescriptors()));
+ publicFields.addAll(Arrays.asList(superclass.getFieldDescriptors()));
+ int dotPos = className.lastIndexOf(".");
+ String packageName = dotPos != -1 ? className.substring(0, dotPos) : null;
+ Set<String> interfaces = new HashSet<String>();
+ ClassDescriptor[] superclassInterfaces = superclass.getInterfaces();
+ for (ClassDescriptor superclassInterface : superclassInterfaces) {
+ interfaces.add(superclassInterface.getName());
+ }
+ interfaces.add(JAXXObject.class.getName());
+ return new ClassDescriptor(className, packageName, symbolTable.getSuperclassName(),
+ interfaces.toArray(new String[interfaces.size()]), false, false, null, null, classLoader,
+ publicMethods.toArray(new MethodDescriptor[publicMethods.size()]),
+ publicFields.toArray(new FieldDescriptor[publicFields.size()])) {
+
+ @Override
+ public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
+ String type = symbolTable.getClassTagIds().get(name);
+ if (type != null) {
+ return new FieldDescriptor(name, Modifier.PROTECTED, type, compiler.getClassLoader());
+ }
+ throw new NoSuchFieldException(name);
+ }
+
+ @Override
+ public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
+ throw new NoSuchMethodException(name);
+ }
+
+ @Override
+ public JAXXObjectDescriptor getJAXXObjectDescriptor() {
+ return compiler.getJAXXObjectDescriptor();
+ }
+ };
+ }
+
+ private static ClassDescriptor createClassDescriptorFromClass(final Class<?> javaClass) {
+ String name = javaClass.getName();
+ Package p = javaClass.getPackage();
+ String packageName = p != null ? p.getName() : null;
+ Class<?> superclass = javaClass.getSuperclass();
+ String superclassName = superclass != null ? superclass.getName() : null;
+ Class<?>[] interfaces = javaClass.getInterfaces();
+ String[] interfaceNames = new String[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++) {
+ interfaceNames[i] = interfaces[i].getName();
+ }
+ boolean isInterface = javaClass.isInterface();
+ boolean isArray = javaClass.isArray();
+ String componentTypeName = isArray ? javaClass.getComponentType().getName() : null;
+ JAXXObjectDescriptor jaxxObjectDescriptor = getJAXXObjectDescriptor(javaClass);
+ ClassLoader classLoader = javaClass.getClassLoader();
+ Method[] javaMethods = javaClass.getMethods();
+ MethodDescriptor[] methods = new MethodDescriptor[javaMethods.length];
+ for (int i = 0; i < methods.length; i++) {
+ methods[i] = createMethodDescriptor(javaMethods[i], javaClass.getClassLoader());
+ }
+ Field[] javaFields = javaClass.getFields();
+ FieldDescriptor[] fields = new FieldDescriptor[javaFields.length];
+ for (int i = 0; i < fields.length; i++) {
+ fields[i] = createFieldDescriptor(javaFields[i], javaClass.getClassLoader());
+ }
+ return new ClassDescriptor(name, packageName, superclassName, interfaceNames, isInterface, isArray, componentTypeName, jaxxObjectDescriptor, classLoader, methods, fields) {
+
+ @Override
+ public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
+ return createFieldDescriptor(javaClass.getDeclaredField(name), javaClass.getClassLoader());
+ }
+
+ @Override
+ public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
+ try {
+ Class[] parameterTypeClasses = new Class[parameterTypes.length];
+ for (int i = 0; i < parameterTypes.length; i++) {
+ parameterTypeClasses[i] = Class.forName(parameterTypes[i].getName());
+ }
+ return createMethodDescriptor(javaClass.getDeclaredMethod(name, parameterTypeClasses), javaClass.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ }
+
+ public static void checkSupportClass(Class<?> handlerClass, ClassDescriptor beanClass, Class<?>... tagClasses) {
+ for (Class<?> tagClass : tagClasses) {
+ if (getClassDescriptor(tagClass).isAssignableFrom(beanClass)) {
+ return;
+ }
+ }
+ throw new IllegalArgumentException(handlerClass.getName() + " does not support the class " + beanClass.getName());
+ }
+
+ public static void reset() {
+ descriptors.clear();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/FieldDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,25 @@
+package jaxx.compiler.reflect;
+
+/**
+ * Mirrors the class <code>java.lang.ref.Field</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
+ * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
+ * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
+ * circular dependencies).
+ */
+public class FieldDescriptor extends MemberDescriptor {
+
+ private String type;
+
+ public FieldDescriptor(String name, int modifiers, String type, ClassLoader classLoader) {
+ super(name, modifiers, classLoader);
+ this.type = type;
+ }
+
+ public ClassDescriptor getType() {
+ try {
+ return ClassDescriptorLoader.getClassDescriptor(type, getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/JavaFileParser.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,217 @@
+package jaxx.compiler.reflect;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.ParseException;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.tags.TagManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Reader;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+// TODO: need to unify this implementation with the parsing in ScriptManager
+public class JavaFileParser {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(JavaFileParser.class);
+ private JAXXCompiler compiler;
+ private String className;
+ private String packageName = null;
+ private String superclass = "java.lang.Object";
+ private List<MethodDescriptor> methods = new ArrayList<MethodDescriptor>();
+ private List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
+
+ private JavaFileParser(ClassLoader classLoader) {
+ compiler = JAXXCompilerLaunchor.createDummyCompiler(classLoader);
+ }
+
+ public static ClassDescriptor parseJavaFile(String displayName, Reader src, ClassLoader classLoader) throws ClassNotFoundException {
+ // has some limitations -- it reports all members as public, leaves getDeclaredMethod and getDeclaredField
+ // undefined, and doesn't report interfaces. It's safe to leave those the way they are for now, because
+ // JAXX doesn't look at any of those for non-JAXX classes.
+ JavaFileParser parser = new JavaFileParser(classLoader);
+ if (log.isDebugEnabled()) {
+ log.debug("starting parsing : " + displayName);
+ }
+ try {
+ parser.doParse(displayName, src);
+ } catch (Exception e) {
+ log.error(e.getMessage());
+ throw new RuntimeException(e);
+ }
+
+ List<MethodDescriptor> publicMethods = parser.methods;
+ List<FieldDescriptor> publicFields = parser.fields;
+ //List/*<MethodDescriptor>*/ declaredMethods = new ArrayList/*<MethodDescriptor>*/(publicMethods);
+ //List/*<FieldDescriptor>*/ declaredFields = new ArrayList/*<FieldDescriptor>*/(publicFields);
+ Iterator<MethodDescriptor> methods = publicMethods.iterator();
+ while (methods.hasNext()) {
+ MethodDescriptor method = methods.next();
+ if (!Modifier.isPublic(method.getModifiers())) {
+ methods.remove();
+ }
+ }
+ Iterator<FieldDescriptor> fields = publicFields.iterator();
+ while (fields.hasNext()) {
+ FieldDescriptor field = fields.next();
+ if (!Modifier.isPublic(field.getModifiers())) {
+ fields.remove();
+ }
+ }
+ ClassDescriptor superclassDescriptor = ClassDescriptorLoader.getClassDescriptor(parser.superclass, classLoader);
+ publicMethods.addAll(Arrays.asList(superclassDescriptor.getMethodDescriptors()));
+ publicFields.addAll(Arrays.asList(superclassDescriptor.getFieldDescriptors()));
+ //Set<String> interfaces = new HashSet<String>();
+ //ClassDescriptor[] superclassInterfaces = superclassDescriptor.getInterfaces();
+ //for (ClassDescriptor superclassInterface : superclassInterfaces) {
+ //interfaces.add(superclassInterface.getName());
+ //}
+ return new ClassDescriptor(parser.className, parser.packageName, parser.superclass, new String[0], false, false, null, null, classLoader,
+ publicMethods.toArray(new MethodDescriptor[publicMethods.size()]),
+ publicFields.toArray(new FieldDescriptor[publicFields.size()])) {
+
+ @Override
+ public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
+ throw new NoSuchFieldException(name);
+ }
+
+ @Override
+ public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
+ throw new NoSuchMethodException(name);
+ }
+ };
+ }
+
+ private void doParse(String displayName, Reader src) {
+ try {
+ JavaParser p = new JavaParser(src);
+ p.CompilationUnit();
+ SimpleNode node = p.popNode();
+ if (node != null) {
+ scanCompilationUnit(node);
+ return;
+ }
+ throw new CompilerException("Internal error: null node parsing Java file from " + src);
+ } catch (ParseException e) {
+ throw new CompilerException("Error parsing Java source code " + displayName + ": " + e.getMessage());
+ }
+ }
+
+ private void scanCompilationUnit(SimpleNode node) {
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode child = node.getChild(i);
+ int nodeType = child.getId();
+ if (nodeType == JavaParserTreeConstants.JJTPACKAGEDECLARATION) {
+ packageName = child.getChild(1).getText().trim();
+ compiler.addImport(packageName + ".*");
+ } else if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) {
+ String text = child.getText().trim();
+ if (text.startsWith("import")) {
+ text = text.substring("import".length()).trim();
+ }
+ if (text.endsWith(";")) {
+ text = text.substring(0, text.length() - 1);
+ }
+ compiler.addImport(text);
+ } else if (nodeType == JavaParserTreeConstants.JJTTYPEDECLARATION) {
+ scanCompilationUnit(child);
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) {
+ scanClass(child);
+ }
+ }
+ }
+
+ // scans the main ClassOrInterfaceDeclaration
+ private void scanClass(SimpleNode node) {
+ boolean isInterface = node.firstToken.image.equals("interface");
+ className = node.firstToken.next.image;
+ if (packageName != null) {
+ className = packageName + "." + className;
+ }
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode child = node.getChild(i);
+ int nodeType = child.getId();
+ if (nodeType == JavaParserTreeConstants.JJTEXTENDSLIST) {
+ if (!isInterface) {
+ assert child.jjtGetNumChildren() == 1 : "expected ExtendsList to have exactly one child for a non-interface class";
+ String rawName = child.getChild(0).getText().trim();
+ superclass = TagManager.resolveClassName(rawName, compiler);
+ if (superclass == null) {
+ throw new CompilerException("Could not find class: " + rawName);
+ }
+ }
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEBODY) {
+ scanClassNode(child);
+ }
+ }
+ }
+
+ // scans class body nodes
+ private void scanClassNode(SimpleNode node) {
+ int nodeType = node.getId();
+ if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) {
+ String returnType = null;
+ String name = null;
+ List<String> parameterTypes = new ArrayList<String>();
+ //List<String> parameterNames = new ArrayList<String>();
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode child = node.getChild(i);
+ int type = child.getId();
+ if (type == JavaParserTreeConstants.JJTRESULTTYPE) {
+ returnType = TagManager.resolveClassName(child.getText().trim(), compiler);
+ } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) {
+ name = child.firstToken.image.trim();
+ SimpleNode formalParameters = child.getChild(0);
+ assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS;
+ for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) {
+ SimpleNode parameter = formalParameters.getChild(j);
+ String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]");
+ String parameterType = TagManager.resolveClassName(rawParameterType, compiler);
+ if (parameterType == null && JAXXCompiler.STRICT_CHECKS) {
+ throw new CompilerException("could not find class '" + rawParameterType + "'");
+ }
+ parameterTypes.add(parameterType);
+ //parameterNames.add(parameter.getChild(2).getText().trim());
+ }
+ }
+ }
+ methods.add(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); // TODO: determine the actual modifiers
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) {
+ // TODO: handle inner classes
+ } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) {
+ // TODO: handle constructors
+ } else if (nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) {
+ String text = node.getText();
+ String declaration = text;
+ int equals = text.indexOf("=");
+ if (equals != -1) {
+ declaration = declaration.substring(0, equals);
+ }
+ declaration = declaration.trim();
+ String[] declarationTokens = declaration.split("\\s");
+ //boolean isFinal = Arrays.asList(declarationTokens).contains("final");
+ //boolean isStatic = Arrays.asList(declarationTokens).contains("static");
+ String name = declarationTokens[declarationTokens.length - 1];
+ if (name.endsWith(";")) {
+ name = name.substring(0, name.length() - 1).trim();
+ }
+ String cName = declarationTokens[declarationTokens.length - 2];
+ String type = TagManager.resolveClassName(cName, compiler);
+ fields.add(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers
+ } else {
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode child = node.getChild(i);
+ scanClassNode(child);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/MemberDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,37 @@
+package jaxx.compiler.reflect;
+
+/**
+ * Mirrors the class <code>java.lang.ref.Member</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
+ * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
+ * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
+ * circular dependencies).
+ */
+public abstract class MemberDescriptor {
+
+ private String name;
+ private int modifiers;
+ private ClassLoader classLoader;
+
+ MemberDescriptor(String name, int modifiers, ClassLoader classLoader) {
+ this.name = name;
+ this.modifiers = modifiers;
+ this.classLoader = classLoader;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getModifiers() {
+ return modifiers;
+ }
+
+ protected ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getName() + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/MethodDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+package jaxx.compiler.reflect;
+
+import jaxx.compiler.JAXXCompiler;
+
+/**
+ * Mirrors the class <code>java.lang.ref.Method</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
+ * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
+ * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
+ * circular dependencies).
+ */
+public class MethodDescriptor extends MemberDescriptor {
+
+ private String returnType;
+ private String[] parameterTypes;
+
+ public MethodDescriptor(String name, int modifiers, String returnType, String[] parameterTypes, ClassLoader classLoader) {
+ super(name, modifiers, classLoader);
+ this.returnType = returnType;
+ this.parameterTypes = parameterTypes;
+ if (JAXXCompiler.STRICT_CHECKS && java.util.Arrays.asList(parameterTypes).contains(null)) {
+ throw new NullPointerException(name);
+ }
+ }
+
+ public ClassDescriptor getReturnType() {
+ try {
+ //TC 20090228 : fix bug when no return type defined (constructor method)
+ if (returnType == null) {
+ return null;
+ }
+ return ClassDescriptorLoader.getClassDescriptor(returnType);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("could not find return type " + returnType, e);
+ }
+ }
+
+ public ClassDescriptor[] getParameterTypes() {
+ ClassDescriptor[] result = new ClassDescriptor[parameterTypes.length];
+ try {
+ for (int i = 0; i < result.length; i++) {
+ if (parameterTypes[i] != null) {
+ result[i] = ClassDescriptorLoader.getClassDescriptor(parameterTypes[i], getClassLoader());
+ }
+ }
+ return result;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("could not find the parameter types " + java.util.Arrays.toString(parameterTypes), e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.spi;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import javax.swing.JCheckBox;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JEditorPane;
+import javax.swing.JFormattedTextField;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JList;
+import javax.swing.JMenu;
+import javax.swing.JPasswordField;
+import javax.swing.JPopupMenu;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButton;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JSpinner;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.JTextPane;
+import javax.swing.JToggleButton;
+import javax.swing.JToolBar;
+import javax.swing.JTree;
+import javax.swing.JWindow;
+import javax.swing.KeyStroke;
+import javax.swing.text.JTextComponent;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.beans.BeanInfoUtil;
+
+import jaxx.compiler.decorators.BoxedCompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.decorators.DefaultCompiledObjectDecorator;
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.ScriptHandler;
+import jaxx.compiler.tags.StyleHandler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.tags.swing.ApplicationHandler;
+import jaxx.compiler.tags.swing.CellHandler;
+import jaxx.compiler.tags.swing.ItemHandler;
+import jaxx.compiler.tags.swing.JAXXComboBoxHandler;
+import jaxx.compiler.tags.swing.JAXXListHandler;
+import jaxx.compiler.tags.swing.JAXXTabHandler;
+import jaxx.compiler.tags.swing.JAXXTreeHandler;
+import jaxx.compiler.tags.swing.JCheckBoxHandler;
+import jaxx.compiler.tags.swing.JComboBoxHandler;
+import jaxx.compiler.tags.swing.JInternalFrameHandler;
+import jaxx.compiler.tags.swing.JListHandler;
+import jaxx.compiler.tags.swing.JMenuHandler;
+import jaxx.compiler.tags.swing.JPasswordFieldHandler;
+import jaxx.compiler.tags.swing.JPopupMenuHandler;
+import jaxx.compiler.tags.swing.JProgressBarHandler;
+import jaxx.compiler.tags.swing.JRadioButtonHandler;
+import jaxx.compiler.tags.swing.JScrollPaneHandler;
+import jaxx.compiler.tags.swing.JSliderHandler;
+import jaxx.compiler.tags.swing.JSpinnerHandler;
+import jaxx.compiler.tags.swing.JSplitPaneHandler;
+import jaxx.compiler.tags.swing.JTabbedPaneHandler;
+import jaxx.compiler.tags.swing.JTextComponentHandler;
+import jaxx.compiler.tags.swing.JToolBarHandler;
+import jaxx.compiler.tags.swing.JTreeHandler;
+import jaxx.compiler.tags.swing.JWindowHandler;
+import jaxx.compiler.tags.swing.RowHandler;
+import jaxx.compiler.tags.swing.TabHandler;
+import jaxx.compiler.tags.swing.TableHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler;
+import jaxx.compiler.tags.validator.ExcludeFieldValidatorHandler;
+import jaxx.compiler.tags.validator.FieldValidatorHandler;
+
+import jaxx.compiler.types.ColorConverter;
+import jaxx.compiler.types.GridBagConstraintsConverter;
+import jaxx.compiler.types.InsetsConverter;
+import jaxx.compiler.types.KeyStrokeConverter;
+import jaxx.compiler.types.PrimitiveConverter;
+
+import jaxx.compiler.types.TypeConverter;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Application;
+import jaxx.runtime.swing.JAXXButtonGroup;
+import jaxx.runtime.swing.JAXXComboBox;
+import jaxx.runtime.swing.JAXXList;
+import jaxx.runtime.swing.JAXXTab;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.runtime.swing.Table;
+import jaxx.runtime.swing.editor.EnumEditor;
+import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.runtime.validator.swing.SwingValidator;
+
+/**
+ * Initializes support provided from JAXX (java, swing and validation).
+ *
+ */
+public class DefaultInitializer implements Initializer {
+
+ @Override
+ public void initialize() {
+
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing");
+
+ registerDefaultNamespace("javax.swing.*",
+ JEditorPane.class,
+ JFormattedTextField.class,
+ JPasswordField.class,
+ JTextArea.class,
+ JTextField.class,
+ JTextPane.class);
+
+
+ //
+ // Register decorators
+ //
+
+ registerDecorator("default", DefaultCompiledObjectDecorator.class);
+ registerDecorator("boxed", BoxedCompiledObjectDecorator.class);
+ registerDecorator("help", HelpRootCompiledObjectDecorator.class);
+
+ //
+ // Register tags
+ //
+
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler());
+
+ //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing
+ registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
+
+
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, BeanValidatorHandler.TAG, new BeanValidatorHandler(ClassDescriptorLoader.getClassDescriptor(SwingValidator.class)));
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.TAG, new FieldValidatorHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, ExcludeFieldValidatorHandler.TAG, new FieldValidatorHandler());
+
+
+ //
+ // Register beans
+ //
+
+ registerBean(Object.class, DefaultObjectHandler.class);
+ registerBean(Component.class, DefaultComponentHandler.class);
+
+ // check boxes
+ registerBean(JCheckBox.class, JCheckBoxHandler.class);
+ registerBean(JCheckBoxMenuItem.class, JCheckBoxHandler.class);
+
+ // combo boxes
+ registerBean(JComboBox.class, JComboBoxHandler.class);
+ registerBean(EnumEditor.class, JComboBoxHandler.class);
+ registerBean(LocaleEditor.class, JComboBoxHandler.class);
+ registerBean(JAXXComboBox.class, JAXXComboBoxHandler.class);
+
+ // radio boxes
+ registerBean(JRadioButton.class, JRadioButtonHandler.class);
+ registerBean(JRadioButtonMenuItem.class, JRadioButtonHandler.class);
+ registerBean(JToggleButton.class, JRadioButtonHandler.class);
+
+ // Lists
+ registerBean(JList.class, JListHandler.class);
+ registerBean(JAXXList.class, JAXXListHandler.class);
+
+ // Trees
+ registerBean(JTree.class, JTreeHandler.class);
+ registerBean(JAXXTree.class, JAXXTreeHandler.class);
+
+ // Windows
+ registerBean(JDialog.class, JWindowHandler.class);
+ registerBean(JFrame.class, JWindowHandler.class);
+ registerBean(JWindow.class, JWindowHandler.class);
+
+ registerBean(Application.class, ApplicationHandler.class);
+
+ registerBean(JInternalFrame.class, JInternalFrameHandler.class);
+ registerBean(JMenu.class, JMenuHandler.class);
+ registerBean(JPasswordField.class, JPasswordFieldHandler.class);
+ registerBean(JPopupMenu.class, JPopupMenuHandler.class);
+ registerBean(JProgressBar.class, JProgressBarHandler.class);
+ registerBean(JScrollPane.class, JScrollPaneHandler.class);
+ registerBean(JSlider.class, JSliderHandler.class);
+ registerBean(JSpinner.class, JSpinnerHandler.class);
+ registerBean(JSplitPane.class, JSplitPaneHandler.class);
+ registerBean(JTabbedPane.class, JTabbedPaneHandler.class);
+ registerBean(JTextComponent.class, JTextComponentHandler.class);
+ registerBean(JToolBar.class, JToolBarHandler.class);
+
+ registerBean(Table.class, TableHandler.class);
+ registerBean(JAXXTab.class, JAXXTabHandler.class);
+
+
+ registerBean(SwingValidator.class, BeanValidatorHandler.class);
+
+
+
+ //
+ // Register converters
+ //
+
+ PrimitiveConverter primitiveConverter = new PrimitiveConverter();
+ registerTypeConverter(boolean.class, primitiveConverter);
+ registerTypeConverter(Boolean.class, primitiveConverter);
+ registerTypeConverter(byte.class, primitiveConverter);
+ registerTypeConverter(Byte.class, primitiveConverter);
+ registerTypeConverter(short.class, primitiveConverter);
+ registerTypeConverter(Short.class, primitiveConverter);
+ registerTypeConverter(int.class, primitiveConverter);
+ registerTypeConverter(Integer.class, primitiveConverter);
+ registerTypeConverter(long.class, primitiveConverter);
+ registerTypeConverter(Long.class, primitiveConverter);
+ registerTypeConverter(float.class, primitiveConverter);
+ registerTypeConverter(Float.class, primitiveConverter);
+ registerTypeConverter(double.class, primitiveConverter);
+ registerTypeConverter(Double.class, primitiveConverter);
+ registerTypeConverter(char.class, primitiveConverter);
+ registerTypeConverter(Character.class, primitiveConverter);
+ registerTypeConverter(String.class, primitiveConverter);
+
+ registerTypeConverter(Color.class, new ColorConverter());
+ registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter());
+ registerTypeConverter(Insets.class, new InsetsConverter());
+ registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
+
+ }
+
+ protected void registerBean(Class<?> beanClass, Class<? extends TagHandler> handlerClass) {
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(beanClass), handlerClass);
+ }
+
+ protected void registerTag(String namespace, String tagName, TagHandler handler) {
+ TagManager.registerTag(namespace, tagName, handler);
+ }
+
+ protected void registerDecorator(String name, Class<? extends CompiledObjectDecorator> decoratorClass) {
+
+ CompiledObjectDecoratorManager.registerDecorator(name, decoratorClass);
+ }
+
+ protected void registerTypeConverter(Class<?> converterType, TypeConverter converter) {
+
+ TypeManager.registerTypeConverter(converterType, converter);
+ }
+
+ protected void registerDefaultNamespace(String namespace, Class<?>... beanClass) {
+
+ for (Class<?> c : beanClass) {
+ TagManager.registerDefaultNamespace(c.getSimpleName(), namespace);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/spi/Initializer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,17 @@
+package jaxx.compiler.spi;
+
+/**
+ * Performs SPI initialization, typically to register new tags, beans and converter.
+ * <p/>
+ * <b>Note:</b> To load such Initializer, we use the {@link java.util.ServiceLoader} mecanism.
+ *
+ * @see DefaultInitializer
+ */
+public interface Initializer {
+
+ /**
+ * Performs SPI initialization, typically to register new
+ * tags, beans and converter.
+ */
+ void initialize();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerListener;
+import java.awt.event.FocusListener;
+import java.beans.IntrospectionException;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+
+public class DefaultComponentHandler extends DefaultObjectHandler {
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
+ private String containerDelegate;
+
+ public DefaultComponentHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class);
+ }
+
+ @Override
+ protected void init() throws IntrospectionException {
+ if (jaxxBeanInfo == null) {
+ super.init();
+
+ containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
+ if (containerDelegate == null && ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass().getSuperclass())) {
+ containerDelegate = ((DefaultComponentHandler) TagManager.getTagHandler(getBeanClass().getSuperclass())).getContainerDelegate();
+ }
+ }
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("hasFocus", FocusListener.class);
+ addProxyEventInfo("isVisible", ComponentListener.class);
+ addProxyEventInfo("getBounds", ComponentListener.class);
+ addProxyEventInfo("getLocation", ComponentListener.class);
+ addProxyEventInfo("getLocationOnScreen", ComponentListener.class);
+ addProxyEventInfo("getSize", ComponentListener.class);
+ addProxyEventInfo("getX", ComponentListener.class);
+ addProxyEventInfo("getY", ComponentListener.class);
+ addProxyEventInfo("getWidth", ComponentListener.class);
+ addProxyEventInfo("getHeight", ComponentListener.class);
+ if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass())) {
+ addProxyEventInfo("getComponentCount", ContainerListener.class);
+ }
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "name", object.getId(), false, compiler);
+ openComponent(object, tag, compiler);
+ }
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileSecondPass(tag, compiler);
+ closeComponent(compiler.getOpenComponent(), tag, compiler);
+ }
+
+ protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ String constraints = tag.getAttribute("constraints");
+ if (constraints != null && constraints.length() > 0) {
+ compiler.openComponent(object, constraints);
+ } else {
+ compiler.openComponent(object);
+ }
+ }
+
+ protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ compiler.closeComponent(object);
+ }
+
+ @Override
+ public boolean isPropertyInherited(String property) throws UnsupportedAttributeException {
+ return property.equals("font") || property.startsWith("font-") || property.equals("foreground") || property.equals("enabled");
+ }
+
+ @Override
+ public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException {
+ if (propertyName.equals("x") || propertyName.equals("y") || propertyName.equals("width") || propertyName.equals("height") ||
+ "font-size".equals(propertyName)) {
+ return ClassDescriptorLoader.getClassDescriptor(Integer.class);
+ }
+ if (propertyName.equals("font-face") || propertyName.equals("font-style") || propertyName.equals("font-weight")) {
+ return ClassDescriptorLoader.getClassDescriptor(String.class);
+ }
+ return super.getPropertyType(object, propertyName, compiler);
+ }
+
+ @Override
+ public String getGetPropertyCode(String id, String name, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals("font-face")) {
+ return id + ".getFont().getFontName()";
+ }
+ if (name.equals("font-size")) {
+ return id + ".getFont().getSize()";
+ }
+ if (name.equals("font-weight")) {
+ return "(" + id + ".getFont().getStyle() & Font.BOLD) != 0 ? \"bold\" : \"normal\"";
+ }
+ if (name.equals("font-style")) {
+ return "(" + id + ".getFont().getStyle() & Font.ITALIC) != 0 ? \"italic\" : \"normal\"";
+ }
+ return super.getGetPropertyCode(id, name, compiler);
+ }
+
+ @Override
+ public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals("x")) {
+ return id + ".setLocation(" + valueCode + ", " + id + ".getY());";
+ }
+ if (name.equals("y")) {
+ return id + ".setLocation(" + id + ".getX(), " + valueCode + ");";
+ }
+ if (name.equals("width")) { // need to optimize case when both width and height are being assigned
+ return "jaxx.runtime.Util.setComponentWidth(" + id + "," + valueCode + ");\n";
+ }
+ if (name.equals("height")) {
+ return "jaxx.runtime.Util.setComponentHeight(" + id + "," + valueCode + ");\n";
+ }
+ if (name.equals("font-face")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(new Font(" + valueCode + ", " + id + ".getFont().getStyle(), " + id + ".getFont().getSize()));";
+ }
+ if (name.equals("font-size")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont((float) " + valueCode + "));";
+ }
+ if (name.equals("font-weight")) {
+ if (valueCode.equals("\"bold\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));";
+ }
+ if (valueCode.equals("\"normal\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD));";
+ }
+ if (!valueCode.startsWith("\"")) {
+ return "if (" + id + ".getFont() != null) { if ((" + valueCode + ").equals(\"bold\")) " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD)); else " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD)); }";
+ }
+ compiler.reportError("font-weight must be either \"normal\" or \"bold\", found " + valueCode);
+ return "";
+ }
+ if (name.equals("font-style")) {
+ if (valueCode.equals("\"italic\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));";
+ }
+ if (valueCode.equals("\"normal\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC));";
+ }
+ if (!valueCode.startsWith("\"")) {
+ return "if (" + id + ".getFont() != null) { if ((" + valueCode + ").equals(\"italic\")) " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC)); else " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC)); }";
+ }
+ compiler.reportError("font-style must be either \"normal\" or \"italic\", found " + valueCode);
+ return "";
+ }
+ if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame)
+ String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
+ if (cDelegate != null) {
+ return id + '.' + cDelegate + "().setLayout(" + valueCode + ");";
+ }
+ }
+ // ajout du support i18n
+ if (I18nHelper.isI18nableAttribute(name, compiler)) {
+ valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler);
+ }
+
+ return super.getSetPropertyCode(id, name, valueCode, compiler);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+
+ if (propertyName.startsWith("_")) {
+ // client property
+ if (stringValue.startsWith("{")) {
+ stringValue = stringValue.substring(1, stringValue.length() - 1);
+ }
+ object.addClientProperty(propertyName.substring(1), stringValue);
+ //TC-20090327 rather not generating code here
+ //object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");");
+ return;
+ }
+ if ("icon".equals(propertyName)) {
+ if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) {
+ // this is a customized icon, add the icon creation code
+ if (compiler.getConfiguration().isUseUIManagerForIcon()) {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}";
+ } else {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createImageIcon(\"" + stringValue + "\")}";
+ }
+ }
+ } else if ("actionIcon".equals(propertyName)) {
+ // customized actionIcon property
+ if (stringValue.startsWith("{") && stringValue.endsWith("}")) {
+ // there is a script to define the action icon, this is forbidden
+ compiler.reportError("the actionIcon does not support script, remove braces..., fix the file " + compiler.getOutputClassName());
+ return;
+ }
+ propertyName = "icon";
+ if (compiler.getConfiguration().isUseUIManagerForIcon()) {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}";
+ } else {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createActionIcon(\"" + stringValue + "\")}";
+ }
+ }
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+
+ @Override
+ protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) {
+ super.scanAttributesForDependencies(tag, compiler);
+ // check for clientProperty attributes
+ //FIXME make this works,... it seems jaxx compiler does not come here ?
+ //FIXME see the the firstPassHandler in JAXXCompiler ?
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0, max = children.getLength(); i < max; i++) {
+ Attr attr = (Attr) children.item(i);
+ String name = attr.getName();
+ if (!name.startsWith("_")) {
+ continue;
+ }
+ String value = attr.getValue();
+ if (value.startsWith("{")) {
+ compiler.reportWarning(tag, "an clientProperty attribute " + name.substring(1) + " does not required curly value but was : " + value, 0);
+ }
+ }
+
+ }
+
+ /**
+ * Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
+ * example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
+ * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively.
+ * <p/>
+ * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an
+ * int-valued property has a value which is not a valid number. By default, this method looks at the
+ * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>.
+ *
+ * @param key the name of the int-typed property
+ * @param value the non-numeric value that was specified for the property
+ * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid
+ * @throws NumberFormatException if the property is not an enumeration
+ */
+ @Override
+ protected int constantValue(String key, String value) {
+ if ((key.equals("mnemonic") || key.equals("displayedMnemonic"))) {
+ if (value.length() == 1) {
+ return value.charAt(0);
+ }
+ try {
+ Field vk = java.awt.event.KeyEvent.class.getField(value);
+ return (Integer) vk.get(null);
+ } catch (NoSuchFieldException e) {
+ throw new IllegalArgumentException("mnemonics must be either a single character or the name of a field in KeyEvent (found: '" + value + "')");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return super.constantValue(key, value);
+ }
+
+ /**
+ * Returns <code>true</code> if this component can contain other components. For children to be
+ * allowed, the component must be a subclass of <code>Container</code> and its <code>JAXXBeanInfo</code>
+ * must not have the value <code>false</code> for its <code>isContainer</code> value.
+ *
+ * @return <code>true</code> if children are allowed
+ */
+ public boolean isContainer() {
+ boolean container = ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass());
+ if (container) {
+ try {
+ init();
+ if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) {
+ container = false;
+ }
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return container;
+ }
+
+ public String getContainerDelegate() {
+ try {
+ init();
+ return containerDelegate;
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,1135 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaArgument;
+import jaxx.compiler.JavaMethod;
+import jaxx.compiler.StylesheetHelper;
+import jaxx.compiler.beans.JAXXBeanInfo;
+import jaxx.compiler.beans.JAXXEventSetDescriptor;
+import jaxx.compiler.beans.JAXXIntrospector;
+import jaxx.compiler.beans.JAXXPropertyDescriptor;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.ComponentDescriptor;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXObjectDescriptor;
+import jaxx.runtime.css.Stylesheet;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * Default handler for class tags. Class tags are tags which represent instances of Java classes,
+ * such as <code><JButton label='Close'/></code>. <code>DefaultObjectHandler</code>
+ * provides support for attributes and events which adhere to JavaBeans naming conventions as
+ * well as basic JAXX features like the <code>id</code> attribute and data binding by means of
+ * curly braces.
+ * <p/>
+ * Throughout this class, the word "member" refers to the name of a field or method (e.g.
+ * <code>"getDocument"</code>) and the word "property" refers to the JavaBeans-style simple
+ * name of a property (e.g. <code>"document"</code>).
+ */
+public class DefaultObjectHandler implements TagHandler {
+
+ /** The class that this handler provides support for. */
+ private ClassDescriptor beanClass;
+ /** The JAXXBeanInfo for the beanClass. */
+ protected JAXXBeanInfo jaxxBeanInfo;
+ /** Maps property names to their respective JAXXPropertyDescriptors. */
+ private Map<String, JAXXPropertyDescriptor> properties;
+ /** Maps event names to their respective JAXXEventSetDescriptors. */
+ private Map<String, JAXXEventSetDescriptor> events;
+ /** Maps property names to their respective ProxyEventInfos. */
+ private Map<String, ProxyEventInfo> eventInfos;
+ /** Maps XML tags to the CompiledObjects created from them. */
+ protected static Map<Element, CompiledObject> objectMap = new WeakHashMap<Element, CompiledObject>();
+
+ /**
+ * Encapsulates information about a "proxy event handler", which is an event handler that
+ * fires PropertyChangeEvents when it is triggered. ProxyEventInfos simplify the data binding
+ * system by allowing all dependencies to fire the same kind of event even if they would
+ * normally throw something else, like <code>DocumentEvent</code>.
+ */
+ private class ProxyEventInfo {
+
+ /** The name of the method or field being proxied, e.g. "getText". */
+ String memberName;
+ /** The "actual" event listener for the property in question, e.g. DocumentListener. */
+ ClassDescriptor listenerClass;
+ /**
+ * In cases where a different object (such as a model) is more directly responsible for
+ * managing the property, this is the name of the property where that object can be
+ * found, e.g. "document" (which is turned into a call to "getDocument()"). This property
+ * is also treated as a dependency of the data binding expression, and any updates to it
+ * (assuming it is bound) will cause the listener to be removed from the old value and
+ * attached to the new value, and the data binding to be processed.
+ */
+ String modelName;
+ /** The name of the method used to add the "native" event listener, e.g. "addDocumentListener". */
+ String addMethod;
+ /** The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". */
+ String removeMethod;
+ }
+
+ /**
+ * Creates a new <code>DefaultObjectHandler</code> which provides support for the specified class. The
+ * class is not actually introspected until the {@link #compileFirstPass} method is invoked.
+ *
+ * @param beanClass the class which this handler supports
+ */
+ public DefaultObjectHandler(ClassDescriptor beanClass) {
+ this.beanClass = beanClass;
+ }
+
+ /**
+ * Performs introspection on the beanClass and stores the results.
+ *
+ * @throws java.beans.IntrospectionException
+ * TODO
+ */
+ protected void init() throws IntrospectionException {
+ if (jaxxBeanInfo == null) {
+ // perform introspection & cache the results
+ jaxxBeanInfo = getJAXXBeanInfo(beanClass);
+
+ JAXXPropertyDescriptor[] propertiesArray = jaxxBeanInfo.getJAXXPropertyDescriptors();
+ properties = new HashMap<String, JAXXPropertyDescriptor>();
+ for (int i = propertiesArray.length - 1; i >= 0; i--) {
+ properties.put(propertiesArray[i].getName(), propertiesArray[i]);
+ }
+
+ JAXXEventSetDescriptor[] eventsArray = jaxxBeanInfo.getJAXXEventSetDescriptors();
+ events = new HashMap<String, JAXXEventSetDescriptor>();
+ for (int i = eventsArray.length - 1; i >= 0; i--) {
+ MethodDescriptor[] methods = eventsArray[i].getListenerMethods();
+ for (MethodDescriptor method : methods) {
+ events.put(method.getName(), eventsArray[i]);
+ }
+ }
+
+ configureProxyEventInfo();
+ }
+ }
+
+ /**
+ * Returns
+ *
+ * @return the class which this <code>DefaultObjectHandler</code> supports.
+ */
+ public ClassDescriptor getBeanClass() {
+ return beanClass;
+ }
+
+ /**
+ * @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code>
+ * supports.
+ */
+ public JAXXBeanInfo getJAXXBeanInfo() {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ return jaxxBeanInfo;
+ }
+
+ /**
+ * Returns the <code>JAXXBeanInfo</code> for the specified class.
+ *
+ * @param beanClass the bean class for which to retrieve <code>JAXXBeanInfo</code>
+ * @return the class' <code>JAXXBeanInfo</code>
+ * @throws java.beans.IntrospectionException
+ * ?
+ */
+ public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor beanClass) throws IntrospectionException {
+ return JAXXIntrospector.getJAXXBeanInfo(beanClass);
+ }
+
+ /**
+ * Returns the type of the named property. This is the return type of the property's <code>get</code> method;
+ * for instance <code>JLabel</code>'s <code>text</code> property is a <code>String</code>.
+ *
+ * @param object the object being compiled
+ * @param propertyName the simple JavaBeans-style name of the property
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the property's type
+ * @throws CompilerException if the type cannot be determined
+ */
+ public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ JAXXPropertyDescriptor property = properties.get(propertyName);
+ if (property != null) {
+ return property.getPropertyType();
+ }
+ throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object);
+ }
+
+ /**
+ * @param name ?
+ * @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code>
+ * when modified). Members are either fields (represented by the simple name of the field) or <code>get/is</code>
+ * methods (represented by the simple name of the method, <b>not</b> the simplified JavaBeans-style name).
+ * Methods which are not actually bound in their native class, but for which proxy events have been
+ * configured (such as <code>JTextField.getText</code>, return <code>true</code>.
+ * @throws UnsupportedAttributeException
+ * ?
+ */
+ public boolean isMemberBound(String name) throws UnsupportedAttributeException {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ if (eventInfos != null && eventInfos.containsKey(name)) {
+ return true;
+ }
+
+ if (name.equals("getClass")) {
+ return false;
+ }
+
+ String propertyName = null;
+ if (name.startsWith("get")) {
+ propertyName = Introspector.decapitalize(name.substring("get".length()));
+ } else if (name.startsWith("is")) {
+ propertyName = Introspector.decapitalize(name.substring("is".length()));
+ }
+ JAXXPropertyDescriptor property = propertyName != null ? properties.get(propertyName) : null;
+ if (property != null) {
+ return property.isBound();
+ }
+ try {
+ FieldDescriptor field = getBeanClass().getFieldDescriptor(name);
+ return Modifier.isFinal(field.getModifiers()); // final fields might as well be considered bound -- they can't be modified anyway
+ } catch (NoSuchFieldException e) {
+ throw new UnsupportedAttributeException("cannot find property '" + name + "' of " + getBeanClass());
+ }
+ }
+
+ private static ClassDescriptor getEventClass(ClassDescriptor listenerClass) {
+ return listenerClass.getMethodDescriptors()[0].getParameterTypes()[0];
+ }
+
+ /**
+ * @param memberName name of the member
+ * @return an array of members on which the given property depends. For
+ * example, the JTextField.getText() member depends upon the getModel()
+ * member. Returns <code>null</code> if there are no dependencies.
+ */
+ public String[] getMemberDependencies(String memberName) {
+ ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null;
+ return eventInfo == null ? null : new String[]{eventInfo.modelName};
+ }
+
+ /**
+ * Returns a snippet of Java code which will cause a <code>PropertyChangeListener</code> to be notified
+ * when the member's value changes. The <code>PropertyChangeListener</code> is provided in the form
+ * of a Java code snippet that evaluates to a listener object.
+ * <p/>
+ * For ordinary bound JavaBeans properties, the Java code returned is a simple call to
+ * <code>addPropertyChangeListener</code>. Fields and methods which do not actually fire
+ * <code>PropertyChangeEvents</code> when they change necessitate more complex code.
+ *
+ * @param objectCode Java code which evaluates to the object to which to add the listener
+ * *@param dataBinding the name of the data binding this listener is a part of
+ * @param dataBinding databinding
+ * @param memberName the name of the field or method to listen to
+ * @param propertyChangeListenerCode Java code which evaluates to a <code>PropertyChangeListener</code>
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return Java code snippet which causes the listener to be added to the object
+ */
+ public String getAddMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) {
+ if ("getClass".equals(memberName)) {
+ return null;
+ }
+
+ ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null;
+ if (eventInfo != null) { // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents
+ StringBuffer result = new StringBuffer();
+ String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode);
+ boolean methodExists = compiler.hasMethod(methodName);
+ ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass);
+ if (!methodExists) {
+ compiler.addMethodToJavaFile(new JavaMethod(Modifier.PUBLIC, "void", methodName,
+ new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null,
+ propertyChangeListenerCode + ".propertyChange(null);"));
+ }
+ String code = objectCode + (eventInfo.modelName != null ? ".get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName) + "()" : "");
+ result.append("$bindingSources.put(\"").append(code).append("\", ").append(code).append(");").append(JAXXCompiler.getLineSeparator());
+ result.append(code).append('.').append(eventInfo.addMethod).append("((").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(") jaxx.runtime.Util.getEventListener(").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));\n");
+ if (eventInfo.modelName != null) {
+ result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName),
+ "jaxx.runtime.Util.getDataBindingUpdateListener(this , \"" + dataBinding + "\")",
+ compiler));
+ }
+ return result.toString();
+ } else {
+ String propertyName = null;
+ if (memberName.startsWith("get")) {
+ propertyName = Introspector.decapitalize(memberName.substring("get".length()));
+ } else if (memberName.startsWith("is")) {
+ propertyName = Introspector.decapitalize(memberName.substring("is".length()));
+ } else {
+ try {
+ getBeanClass().getFieldDescriptor(memberName);
+ propertyName = memberName;
+ } catch (NoSuchFieldException e) {
+ // ignore ?
+ }
+ }
+ if (propertyName != null) {
+ try {
+ // check for property-specific addPropertyChangeListener method
+ getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class),
+ ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class));
+ return objectCode + ".addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n";
+ } catch (NoSuchMethodException e) {
+ // no property-specific method, use general one
+ return objectCode + ".addPropertyChangeListener(" + propertyChangeListenerCode + ");\n";
+ }
+ }
+ return null;
+ }
+ }
+
+ public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) {
+ if ("getClass".equals(memberName)) {
+ return null;
+ }
+
+ ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null;
+ if (eventInfo != null) { // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents
+ StringBuffer result = new StringBuffer();
+ String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode);
+ boolean methodExists = compiler.hasMethod(methodName);
+ if (!methodExists) {
+ ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass);
+ compiler.addMethodToJavaFile(new JavaMethod(Modifier.PUBLIC, "void", methodName,
+ new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null,
+ propertyChangeListenerCode + ".propertyChange(null);"));
+ }
+ try {
+ String modelMemberName = eventInfo.modelName != null ? "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName) : null;
+ String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass());
+ String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : "");
+ result.append("((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\")).").append(eventInfo.removeMethod).append("((").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(") jaxx.runtime.Util.getEventListener(").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));\n");
+ if (eventInfo.modelName != null) {
+ result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName),
+ "jaxx.runtime.Util.getDataBindingUpdateListener(this, \"" + dataBinding + "\")",
+ compiler));
+ }
+ return result.toString();
+ } catch (NoSuchMethodException e) {
+ throw new CompilerException("Internal error: " + e);
+ }
+ } else {
+ String propertyName = null;
+ if (memberName.startsWith("get")) {
+ propertyName = Introspector.decapitalize(memberName.substring("get".length()));
+ } else if (memberName.startsWith("is")) {
+ propertyName = Introspector.decapitalize(memberName.substring("is".length()));
+ } else {
+ try {
+ getBeanClass().getFieldDescriptor(memberName);
+ propertyName = memberName;
+ } catch (NoSuchFieldException e) {
+ // ignore ?
+ }
+ }
+ if (propertyName != null) {
+ try {
+ // check for property-specific removePropertyChangeListener method
+ getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class),
+ ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class));
+ return objectCode + ".removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n";
+ } catch (NoSuchMethodException e) {
+ // no property-specific method, use general one
+ return objectCode + ".removePropertyChangeListener(" + propertyChangeListenerCode + ");\n";
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Configures the event handling for members which do not fire <code>PropertyChangeEvent</code> when
+ * modified. The default implementation does nothing. Subclasses should override this method to call
+ * <code>addProxyEventInfo</code> for each member which requires special handling.
+ */
+ protected void configureProxyEventInfo() {
+ }
+
+ /**
+ * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
+ * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
+ * not bound property <code>get</code> methods. The proxy event handler will attach the specified kind
+ * of listener to the class and fire a <code>PropertyChangeEvent</code> whenever the listener receives
+ * any kind of event.
+ * <p/>
+ * Even though this method can theoretically be applied to fields (in addition to methods), it would be an
+ * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would
+ * be difficult to have a listener that was always notified when a field value changed.
+ *
+ * @param memberName the name of the field or method being proxied
+ * @param listenerClass the type of listener which receives events when the field or method is updated
+ */
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass) {
+ addProxyEventInfo(memberName, listenerClass, null);
+ }
+
+ /**
+ * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
+ * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
+ * not bound property <code>get</code> methods. This variant attaches a listener to a property of the
+ * object (such as <code>model</code>) and not the object itself, which is useful when there is a model
+ * that is the "real" container of the information. The proxy event handler will attach the specified kind
+ * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire
+ * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event.
+ * <p/>
+ * If the property is itself bound (typically the case with models), any updates to the property's value will
+ * cause the listener to be removed from the old property value and reattached to the new property value,
+ * as well as cause a <code>PropertyChangeEvent</code> to be fired.
+ * <p/>
+ * Even though this method can theoretically be applied to fields (in addition to methods), it would be an
+ * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would
+ * be difficult to have a listener that was always notified when a field value changed.
+ *
+ * @param memberName the name of the field or method being proxied
+ * @param listenerClass the type of listener which receives events when the field or method is updated
+ * @param modelName the JavaBeans-style name of the model property
+ */
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass, String modelName) {
+ String listenerName = listenerClass.getName();
+ listenerName = listenerName.substring(listenerName.lastIndexOf(".") + 1);
+ addProxyEventInfo(memberName, listenerClass, modelName, "add" + listenerName, "remove" + listenerName);
+ }
+
+ // TODO: remove this temporary method, complete switchover to ClassDescriptors
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass,
+ String modelName, String addMethod, String removeMethod) {
+ try {
+ addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
+ * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
+ * not bound property <code>get</code> methods. This variant attaches a listener to a property of the
+ * object (such as <code>model</code>) and not the object itself, which is useful when there is a model
+ * that is the "real" container of the information. The proxy event handler will attach the specified kind
+ * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire
+ * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event.
+ * <p/>
+ * If the property is itself bound (typically the case with models), any updates to the property's value will
+ * cause the listener to be removed from the old property value and reattached to the new property value,
+ * as well as cause a <code>PropertyChangeEvent</code> to be fired.
+ * <p/>
+ * This variant of <code>addProxyEventInfo</code> allows the names of the methods that add and remove
+ * the event listener to be specified, in cases where the names are not simply <code>add<listenerClassName></code>
+ * and <code>remove<listenerClassName></code>.
+ * <p/>
+ * Even though this method can theoretically be applied to fields (in addition to methods), it would be an
+ * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would
+ * be difficult to have a listener that was always notified when a field value changed.
+ *
+ * @param memberName the name of the field or method being proxied
+ * @param listenerClass the type of listener which receives events when the field or method is updated
+ * @param modelName the JavaBeans-style name of the model property
+ * @param addMethod add method name
+ * @param removeMethod remove method name
+ */
+ public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass,
+ String modelName, String addMethod, String removeMethod) {
+ ProxyEventInfo info = new ProxyEventInfo();
+ info.memberName = memberName;
+ info.listenerClass = listenerClass;
+ info.modelName = modelName;
+ info.addMethod = addMethod;
+ info.removeMethod = removeMethod;
+ if (eventInfos == null) {
+ eventInfos = new HashMap<String, ProxyEventInfo>();
+ }
+ eventInfos.put(memberName, info);
+ }
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ scanAttributesForDependencies(tag, compiler);
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new CompilerException(e);
+ }
+ CompiledObject object = objectMap.get(tag);
+ if (object == null) {
+ throw new IllegalStateException("unable to find CompiledObject associated with tag <" + tag.getTagName() + ">; should have been registered before second pass");
+ }
+ compiler.checkOverride(object);
+ String constructorParams = tag.getAttribute("constructorParams");
+ if (constructorParams != null && constructorParams.length() > 0) {
+ object.setConstructorParams(compiler.getScriptManager().trimScript(constructorParams));
+ }
+
+ setDefaults(object, tag, compiler);
+ setAttributes(object, tag, compiler);
+ if (object.getGenericTypesLength() > 0 && !(object == compiler.getRootObject() || object.isJavaBean())) {
+ // can ony be apply to root object or javaBean object
+ compiler.reportWarning("'genericType' attribute can only be found on root, or a javaBean object tag but was found on tag " + tag);
+ object.setGenericTypes(null);
+ return;
+ }
+ compileChildrenSecondPass(tag, compiler);
+ }
+
+ public void registerCompiledObject(Element tag, JAXXCompiler compiler) {
+ String id = tag.getAttribute("id");
+ if (id == null || id.length() == 0) {
+ id = compiler.getAutoId(getBeanClass());
+ }
+ CompiledObject object = createCompiledObject(id, compiler);
+ objectMap.put(tag, object);
+ String styleClass = tag.getAttribute("styleClass").trim();
+ if (styleClass.length() > 0) {
+ object.setStyleClass(styleClass);
+ }
+ compiler.registerCompiledObject(object);
+ }
+
+ /**
+ * Creates the <code>CompiledObject</code> which will represent the object created by this <code>TagHandler</code>.
+ *
+ * @param id the <code>CompiledObject's</code> ID.
+ * @param compiler compiler to use
+ * @return the <code>CompiledObject</code> to use
+ */
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) {
+ return new CompiledObject(id, getBeanClass(), compiler);
+ }
+
+ /**
+ * Initializes the default settings of the object, prior to setting its attribute values. The default
+ * implementation does nothing.
+ *
+ * @param object the object to initialize
+ * @param tag the tag being compiled
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ }
+
+ /**
+ * @param property property name to test
+ * @return <code>true</code> if the specified property should be inherited by child components when specified
+ * via CSS.
+ * @throws UnsupportedAttributeException
+ * ?
+ */
+ public boolean isPropertyInherited(String property) throws UnsupportedAttributeException {
+ return false;
+ }
+
+ /**
+ * @param name name of event
+ * @return <code>true</code> if the specified name has the form of an event handler attribute
+ * (e.g. "onActionPerformed").
+ */
+ public boolean isEventHandlerName(String name) {
+ return name.length() > 2 && name.startsWith("on") && Character.isUpperCase(name.charAt(2));
+ }
+
+ /**
+ * Scans all attributes for any dependency classes and adds them to the current compilation
+ * set. Called by <code>compileFirstPass()</code> (it is an error to add dependencies after
+ * pass 1 is complete).
+ *
+ * @param tag tag to scan
+ * @param compiler compiler to use
+ */
+ protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) {
+ List<Attr> attributes = new ArrayList<Attr>();
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ attributes.add((Attr) children.item(i));
+ }
+ Collections.sort(attributes, getAttributeComparator());
+
+ for (Attr attribute : attributes) {
+ String name = attribute.getName();
+ String value = attribute.getValue();
+ if (name.equals("javaBean")) {
+ //compiler.preprocessScript(value);
+ continue;
+ }
+ if (name.equals("constraints") || isEventHandlerName(name)) {
+ compiler.preprocessScript(value); // adds dependencies as a side effect
+ } else if (name.equals("constructorParams")) {
+ for (String param : value.split("\\s*,\\s*")) {
+ compiler.preprocessScript(param);
+ }
+ } else if (value.startsWith("{") && value.endsWith("}")) {
+ compiler.preprocessScript(value.substring(1, value.length() - 1));
+ }
+ }
+ }
+
+ /**
+ * Processes the attributes of an XML tag. Four kinds of attributes are supported: simple property values (of any
+ * datatype supported by {@link #convertFromString}), data binding expressions (attributes containing curly-brace
+ * pairs), event listeners (attributes starting with 'on', such as 'onActionPerformed'), and JAXX-defined properties
+ * such as 'id'.
+ *
+ * @param object the object to be modified
+ * @param tag the tag from which to pull attributes
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ List<Attr> attributes = new ArrayList<Attr>();
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ attributes.add((Attr) children.item(i));
+ }
+ Collections.sort(attributes, getAttributeComparator());
+
+ for (Attr attribute : attributes) {
+ String name = attribute.getName();
+ String value = attribute.getValue().trim();
+ if (name.equals("id") || name.equals("constraints") || name.equals("constructorParams") || name.equals("styleClass") ||
+ name.startsWith("xmlns") || JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ // ignore, already handled
+ continue;
+ }
+ if (name.equals("javaBean")) {
+ object.setJavaBean(true);
+ if (!value.isEmpty()) {
+ object.setJavaBeanInitCode(value);
+ }
+ continue;
+ }
+ if (name.equals("implements")) {
+ if (object != compiler.getRootObject()) {
+ // can ony be apply to root object
+ compiler.reportError("'implements' attribute can only be found on root tag but was found on tag " + tag);
+ return;
+ }
+ String[] interfaces = value.split(",");
+ compiler.setExtraInterfaces(interfaces);
+ continue;
+ }
+
+ if (name.equals("abstract")) {
+ if (object != compiler.getRootObject()) {
+ // can ony be apply to root object
+ compiler.reportError("'abstract' attribute can only be found on root tag but was found on tag " + tag);
+ return;
+ }
+ compiler.setAbstractClass(true);
+ continue;
+ }
+
+ if (name.equals("genericType")) {
+ //TC-20090313 check after all atributes been processed
+ if (object == compiler.getRootObject()) {
+ compiler.setGenericType(value);
+ } else {
+ object.setGenericTypes(value.split(","));
+ }
+ continue;
+ }
+
+ if (name.equals("superGenericType")) {
+ if (object != compiler.getRootObject()) {
+ // can ony be apply to root object
+ compiler.reportError("'superGenericType' attribute can only be found on root tag but was found on tag " + tag);
+ return;
+ }
+ compiler.setSuperGenericType(value);
+ continue;
+ }
+
+ if (name.equals("decorator")) {
+ if (!value.isEmpty()) {
+ CompiledObjectDecorator decorator = CompiledObjectDecoratorManager.getDecorator(value);
+ object.setDecorator(decorator);
+ }
+ continue;
+ }
+
+ if (isEventHandlerName(name)) {
+ // event handler
+ if (!value.endsWith(";")) {
+ value += ";";
+ }
+ addEventHandler(object, Introspector.decapitalize(name.substring(2)), value, compiler);
+ continue;
+ }
+ // simple property
+ setAttribute(object, name, value, true, compiler);
+ }
+ }
+
+ /**
+ * Returns a <code>Comparator</code> which defines the ordering in which the tag's attributes should be processed. The
+ * default implementation sorts the attributes according to the order defined by the {@link #getAttributeOrdering} method.
+ *
+ * @return a <code>Comparator</code> defining the order of attribute processing
+ */
+ protected Comparator<Attr> getAttributeComparator() {
+ return new Comparator<Attr>() {
+
+ @Override
+ public int compare(Attr a, Attr b) {
+ int aOrder = getAttributeOrdering(a);
+ int bOrder = getAttributeOrdering(b);
+
+ return aOrder - bOrder;
+ }
+ };
+ }
+
+ /**
+ * Returns the priority with which a particular attribute should be processed. Lower numbers should be processed before
+ * higher numbers. This value is used by the {@link #getAttributeComparator} method to define the sort ordering.
+ *
+ * @param attr the attribute to treate
+ * @return the attribute's priority
+ */
+ protected int getAttributeOrdering(Attr attr) {
+ if (attr.getName().equals("displayedMnemonicIndex") || attr.getName().equals("displayedMnemonic") || attr.getName().equals("mnemonic")) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) {
+ ClassDescriptor type = getPropertyType(object, propertyName, compiler);
+ String binding = compiler.processDataBindings(stringValue, type);
+ if (binding != null) {
+ return "";
+ }
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Object value = convertFromString(propertyName, stringValue, typeClass);
+ return getSetPropertyCode(object.getJavaCode(), propertyName, TypeManager.getJavaCode(value), compiler);
+ } catch (NumberFormatException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (IllegalArgumentException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("could not find class " + type.getName());
+ }
+ return "";
+ }
+
+ /**
+ * Set a single property on an object. The value may be either a simple value or contain data binding expressions.
+ * Simple values are first converted to the property's type using {@link #convertFromString}.
+ *
+ * @param object the object on which to set the property
+ * @param propertyName the name of the property to set
+ * @param stringValue the raw string value of the property from the XML
+ * @param inline <code>true</code> if the value was directly specified as an inline class tag attribute, <code>false</code> otherwise (a default value, specified in CSS, etc.)
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+ try {
+ if (ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(object.getObjectClass())) {
+ // check for data binding & remove if found
+ JAXXObjectDescriptor jaxxObjectDescriptor = object.getObjectClass().getJAXXObjectDescriptor();
+ ComponentDescriptor root = jaxxObjectDescriptor.getComponentDescriptors()[0];
+ object.appendInitializationCode(object.getJavaCode() + ".removeDataBinding(" + TypeManager.getJavaCode(root.getId() + "." + propertyName) + ");" + JAXXCompiler.getLineSeparator());
+ }
+ object.addProperty(propertyName, stringValue);
+ ClassDescriptor type = getPropertyType(object, propertyName, compiler);
+ String binding = compiler.processDataBindings(stringValue, type);
+ if (binding != null) {
+ if (inline) {
+ compiler.addInlineStyle(object, propertyName, true);
+ }
+ ClassDescriptor propertyType = getPropertyType(object, propertyName, compiler);
+ if (propertyType != null &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Boolean.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Byte.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Short.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Integer.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Float.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Double.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Character.class)) {
+ //binding = "((" + propertyType.getName() + ") " + binding + ")";
+ }
+ if (propertyName.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame)
+ // have to set layout early, before children are added
+ object.appendInitializationCode(getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler));
+ }
+ object.registerDataBinding(binding, propertyName, getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler), compiler);
+ } else { // no bindings, convert from string
+ if (inline) {
+ compiler.addInlineStyle(object, propertyName, false);
+ }
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Object value = convertFromString(propertyName, stringValue, typeClass);
+ setProperty(object, propertyName, value, compiler);
+ } catch (NumberFormatException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (IllegalArgumentException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("could not find class " + type.getName());
+ }
+ }
+ } catch (UnsupportedAttributeException e) {
+ compiler.reportError("class " + object.getObjectClass().getName() + " does not support attribute '" + propertyName + "'");
+ }
+ }
+
+ public void applyStylesheets(CompiledObject object, JAXXCompiler compiler) {
+ applyStylesheets(object, compiler, null);
+ }
+
+ private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) {
+ applyStylesheets(object, compiler, overrides, true);
+ }
+
+ private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) {
+ try {
+ Stylesheet stylesheet = compiler.getStylesheet();
+ ClassDescriptor objectClass = object.getObjectClass();
+ if (recurse && ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(objectClass)) {
+ JAXXObjectDescriptor jaxxObjectDescriptor = objectClass.getJAXXObjectDescriptor();
+ ComponentDescriptor[] descriptors = jaxxObjectDescriptor.getComponentDescriptors();
+ for (ComponentDescriptor descriptor : descriptors) {
+ ClassDescriptor classDescriptor = ClassDescriptorLoader.getClassDescriptor(descriptor.getJavaClassName());
+ boolean isRoot = classDescriptor != objectClass;
+ String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId();
+ CompiledObject child = new CompiledObject(id,
+ "((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " +
+ object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))",
+ classDescriptor,
+ compiler,
+ true);
+ ComponentDescriptor parentDescriptor = descriptor.getParent();
+ CompiledObject currentObject = child;
+ while (parentDescriptor != null) {
+ CompiledObject parent = new CompiledObject("internal", ClassDescriptorLoader.getClassDescriptor(parentDescriptor.getJavaClassName()), compiler);
+ currentObject.setParent(parent);
+ currentObject = parent;
+ parentDescriptor = parentDescriptor.getParent();
+ }
+ currentObject.setParent(object);
+ String styleClass = object.getStyleClass();
+ if (styleClass == null) {
+ styleClass = descriptor.getStyleClass();
+ }
+ child.setStyleClass(styleClass);
+ Stylesheet mergedStylesheet = overrides;
+ Stylesheet childOverrides = jaxxObjectDescriptor.getStylesheet();
+ if (childOverrides != null) {
+ if (mergedStylesheet == null) {
+ mergedStylesheet = childOverrides;
+ } else {
+ mergedStylesheet.add(childOverrides.getRules());
+ }
+ }
+ TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot);
+ object.appendInitializationCode(child.getInitializationCode(compiler));
+ }
+ } else if (stylesheet != null) {
+ StylesheetHelper.applyTo(object, compiler, stylesheet, overrides);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new CompilerException(e);
+ } catch (IllegalArgumentException e) {
+ compiler.reportError(e.getMessage());
+ }
+ }
+
+ /**
+ * Adds the necessary Java code to a <code>CompiledObject</code> to add an event listener at runtime.
+ *
+ * @param object the <code>CompiledObject</code> to which the event listener should be added
+ * @param name the name of the event listener, such as <code>"actionPerformed"</code>
+ * @param value the Java code snippet to execute when the event is fired
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ public void addEventHandler(CompiledObject object, String name, String value, JAXXCompiler compiler) {
+ JAXXEventSetDescriptor JAXXEventSetDescriptor = events.get(name);
+ if (JAXXEventSetDescriptor != null) {
+ MethodDescriptor[] listenerMethods = JAXXEventSetDescriptor.getListenerMethods();
+ MethodDescriptor listenerMethod = null;
+ for (MethodDescriptor listenerMethod1 : listenerMethods) {
+ if (listenerMethod1.getName().equals(name)) {
+ listenerMethod = listenerMethod1;
+ break;
+ }
+ }
+ if (listenerMethod == null) {
+ throw new RuntimeException("expected to find method '" + name + "' in JAXXEventSetDescriptor.getListenerMethods()");
+ }
+ try {
+ value = compiler.preprocessScript(value);
+ object.addEventHandler(name, JAXXEventSetDescriptor.getAddListenerMethod(), listenerMethod, value, compiler);
+ } catch (CompilerException e) {
+ compiler.reportError("While parsing event handler for '" + name + "': " + e.getMessage());
+ }
+ } else {
+ compiler.reportError("could not find event '" + name + "' for object " + object);
+ }
+ }
+
+ /**
+ * Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is
+ * just a call to the property's <code>get</code> method, but it can be arbitrarily complex.
+ *
+ * @param javaCode Java code for the object whose property is being retrieved
+ * @param name the name of the property to retrieve
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the snippet
+ * @throws CompilerException if a compilation error occurs
+ */
+ public String getGetPropertyCode(String javaCode, String name, JAXXCompiler compiler) {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ JAXXPropertyDescriptor property = properties.get(name);
+ if (property != null) {
+ if (property.getReadMethodDescriptor() != null) {
+ return javaCode + '.' + property.getReadMethodDescriptor().getName() + "()";
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " has no read method");
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
+ }
+
+ /**
+ * Returns a snippet of Java code which will set an object property at runtime. Typically the code is
+ * just a call to the property's <code>set</code> method, but it can be arbitrarily complex.
+ *
+ * @param javaCode Java code for the object whose property is being set
+ * @param name the name of the property to set
+ * @param valueCode Java expression representing the value to set the property to
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the snippet
+ * @throws CompilerException if a compilation error occurs
+ */
+ public String getSetPropertyCode(String javaCode, String name, String valueCode, JAXXCompiler compiler) {
+ JAXXPropertyDescriptor property = properties.get(name);
+ if (property != null) {
+ if (property.getWriteMethodDescriptor() != null) {
+ return javaCode + '.' + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");";
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " is read-only");
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
+ }
+
+ /**
+ * Appends Java code to a <code>CompiledObject</code> in order to implement a property assignment.
+ * <code>setProperty</code> is invoked in response to most XML attributes (those which are not more
+ * complicated cases, like data bindings or event handlers).
+ * <p/>
+ * By the time it reaches this method, the <code>value</code> has already been converted from its XML
+ * string representation to the appropriate destination type for the property (i.e. if
+ * <code>JLabel.foreground</code> is being set, <code>value</code> will be a <code>Color</code>).
+ *
+ * @param object the object being modified
+ * @param name the name of the property to set
+ * @param value the value to set the property to
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ */
+ public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) {
+ object.appendInitializationCode(getSetPropertyCode(object.getJavaCodeForProperty(name), name, TypeManager.getJavaCode(value), compiler));
+ }
+
+ /**
+ * Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
+ * example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
+ * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively.
+ * <p/>
+ * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an
+ * int-valued property has a value which is not a valid number. By default, this method looks at the
+ * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>.
+ *
+ * @param key the name of the int-typed property
+ * @param value the non-numeric value that was specified for the property
+ * @return the constant integer value
+ * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid
+ * @throws NumberFormatException if the property is not an enumeration
+ */
+ protected int constantValue(String key, String value) {
+ JAXXBeanInfo JAXXBeanInfo = getJAXXBeanInfo();
+ JAXXPropertyDescriptor[] props = JAXXBeanInfo.getJAXXPropertyDescriptors();
+ String lowercaseValue = value.toLowerCase();
+ for (JAXXPropertyDescriptor property : props) {
+ if (property.getName().equals(key)) {
+ Object[] values = (Object[]) property.getValue("enumerationValues");
+ if (values != null) {
+ for (int j = 0; j < values.length - 2; j += 3) {
+ if (((String) values[j]).toLowerCase().equals(lowercaseValue)) {
+ return (Integer) values[j + 1];
+ }
+ }
+
+ StringBuffer message = new StringBuffer("value of '" + key + "' must be one of: [");
+ for (int j = 0; j < values.length - 2; j += 3) {
+ if (j != 0) {
+ message.append(", ");
+ }
+ message.append(((String) values[j]).toLowerCase());
+ }
+ message.append("] (found '").append(value).append("')");
+ throw new IllegalArgumentException(message.toString());
+ }
+ }
+ }
+ throw new NumberFormatException(value);
+ }
+
+ /**
+ * As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names
+ * for <code>int</code>-valued types.
+ *
+ * @param key the name of the property whose value is being converted
+ * @param value the raw string value of the property as it appears in the XML
+ * @param type the datatype to convert the string into
+ * @return the converted object
+ * @see #constantValue
+ */
+ protected Object convertFromString(String key, String value, Class<?> type) {
+ if (type == null || type == Object.class) {
+ return value;
+ }
+
+ try {
+ return TypeManager.convertFromString(value, type);
+ } catch (NumberFormatException e) {
+ if (type == int.class || type == Integer.class) {
+ return constantValue(key, value);
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
+ * for each child tag.
+ *
+ * @param tag the tag whose children to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ }
+ }
+ }
+
+ /**
+ * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
+ * for each child tag.
+ *
+ * @param tag the tag whose children to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ /**
+ * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
+ * JAXXCompiler.compileFirstPass}.
+ *
+ * @param tag the child tag to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ /**
+ * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
+ * JAXXCompiler.compileSecondPass}.
+ *
+ * @param tag the child tag to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getBeanClass().getName() + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/ScriptHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringWriter;
+
+/**
+ * Handles the <code><script></code> tag.
+ *
+ * @author Ethan Nicholas
+ */
+public class ScriptHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ File scriptFile = null;
+ NamedNodeMap attributes = tag.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ String name = attribute.getName();
+ String attrValue = attribute.getValue();
+ if (name.equals("source")) {
+ scriptFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar));
+ StringWriter scriptBuffer = new StringWriter();
+ try {
+ FileReader in = new FileReader(scriptFile);
+ char[] readBuffer = new char[2048];
+ int c;
+ while ((c = in.read(readBuffer)) > 0) {
+ scriptBuffer.write(readBuffer, 0, c);
+ }
+ } catch (FileNotFoundException e) {
+ compiler.reportError("script file not found: " + scriptFile);
+ }
+ compiler.registerScript(scriptBuffer.toString(), scriptFile);
+ } else if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ StringBuffer script = new StringBuffer();
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ switch (child.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ compiler.reportError("<script> tag may not contain child elements: " + tag);
+ case Node.TEXT_NODE: // fall through
+ case Node.CDATA_SECTION_NODE:
+ script.append(((Text) child).getData());
+ }
+ }
+
+ String scriptString = script.toString().trim();
+ if (scriptString.length() > 0) {
+ if (scriptFile != null) {
+ compiler.reportError("<script> tag has both a source attribute and an inline script");
+ }
+ compiler.registerScript(script.toString());
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/StyleHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.parser.css.CSSParser;
+import jaxx.compiler.parser.css.CSSParserConstants;
+import jaxx.compiler.parser.css.CSSParserTreeConstants;
+import jaxx.runtime.css.Rule;
+import jaxx.runtime.css.Selector;
+import jaxx.compiler.parser.css.SimpleNode;
+import jaxx.runtime.css.Stylesheet;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Handles the <code><style></code> tag.
+ *
+ * @author Ethan Nicholas
+ */
+public class StyleHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ boolean source = false;
+ NamedNodeMap attributes = tag.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ String name = attribute.getName();
+ String attrValue = attribute.getValue();
+ if (name.equals("source")) {
+ source = true;
+ File styleFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar));
+ StringWriter styleBuffer = new StringWriter();
+ try {
+ FileReader in = new FileReader(styleFile);
+ char[] readBuffer = new char[2048];
+ int c;
+ while ((c = in.read(readBuffer)) > 0) {
+ styleBuffer.write(readBuffer, 0, c);
+ }
+ } catch (FileNotFoundException e) {
+ compiler.reportError("stylesheet file not found: " + styleFile);
+ }
+ compiler.getSourceFiles().push(styleFile);
+ compiler.registerStylesheet(processStylesheet(styleBuffer.toString()));
+ compiler.getSourceFiles().pop();
+ } else if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ StringBuffer style = new StringBuffer();
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ switch (child.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ compiler.reportError("<style> tag may not contain child elements: " + tag);
+ case Node.TEXT_NODE: // fall through
+ case Node.CDATA_SECTION_NODE:
+ style.append(((Text) child).getData());
+ }
+ }
+
+ String styleString = style.toString().trim();
+ if (styleString.length() > 0) {
+ if (source) {
+ compiler.reportError("<style> tag has both a source attribute and an inline stylesheet");
+ }
+ compiler.registerStylesheet(processStylesheet(style.toString()));
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ }
+
+ protected Selector processSelector(SimpleNode selector) {
+ if (selector.getId() != CSSParserTreeConstants.JJTSELECTOR) {
+ throw new IllegalArgumentException("argument node is not a Selector");
+ }
+ String javaClassName = null;
+ String styleClass = null;
+ String pseudoClass = null;
+ String id = null;
+
+ for (int i = 0; i < selector.jjtGetNumChildren(); i++) {
+ SimpleNode child = selector.getChild(i);
+ switch (child.getId()) {
+ case CSSParserTreeConstants.JJTJAVACLASS:
+ if (!child.getText().trim().equals("*")) {
+ javaClassName = child.getText();
+ }
+ break;
+ case CSSParserTreeConstants.JJTCLASS:
+ styleClass = child.getText().substring(1);
+ break;
+ case CSSParserTreeConstants.JJTPSEUDOCLASS:
+ pseudoClass = child.getText().substring(1);
+ break;
+ case CSSParserTreeConstants.JJTID:
+ id = child.getText().substring(1);
+ break;
+
+ default:
+ throw new IllegalStateException("unexpected child of Selector node, type=" + child.getId());
+ }
+ }
+
+ return new Selector(javaClassName, styleClass, pseudoClass, id);
+ }
+
+ protected Rule processRule(SimpleNode ruleNode) {
+ if (ruleNode.getId() != CSSParserTreeConstants.JJTRULE) {
+ throw new IllegalArgumentException("argument node is not a Rule");
+ }
+ SimpleNode selectorsNode = ruleNode.getChild(0);
+ assert selectorsNode.getId() == CSSParserTreeConstants.JJTSELECTORS : "expected node to be of type Selectors";
+
+ List<Selector> selectors = new ArrayList<Selector>();
+ for (int i = 0; i < selectorsNode.jjtGetNumChildren(); i++) {
+ SimpleNode selectorNode = selectorsNode.getChild(i);
+ selectors.add(processSelector(selectorNode));
+ }
+
+ Map<String, String> properties = new HashMap<String, String>();
+ for (int i = 1; i < ruleNode.jjtGetNumChildren(); i++) {
+ SimpleNode declarationNode = ruleNode.getChild(i);
+ if (declarationNode.getId() == CSSParserTreeConstants.JJTDECLARATION) {
+ String key = declarationNode.getChild(0).getText();
+ SimpleNode valueNode = declarationNode.getChild(1);
+ String value = valueNode.getText();
+ if (valueNode.firstToken.kind == CSSParserConstants.STRING) {
+ value = value.substring(1, value.length() - 1);
+ }
+ properties.put(key, value);
+ }
+ }
+ Rule rule;
+ rule = new Rule(selectors.toArray(new Selector[selectors.size()]), properties);
+ return rule;
+ }
+
+ protected Stylesheet processStylesheet(String stylesheetText) throws CompilerException {
+ CSSParser p = new CSSParser(new StringReader(stylesheetText));
+ SimpleNode node;
+ try {
+ node = p.Stylesheet();
+ } catch (Error e) {
+ throw new CompilerException(e);
+ }
+ List<Rule> rules = new ArrayList<Rule>();
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode ruleNode = node.getChild(i);
+ Rule rule = processRule(ruleNode);
+ rules.add(rule);
+ }
+ Stylesheet stylesheet;
+ stylesheet = new Stylesheet(rules.toArray(new Rule[rules.size()]));
+ return stylesheet;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+/**
+ * Implementations of <code>TagHandler</code> produce Java source code from XML tags.
+ * <code>TagHandlers</code> are mapped to particular XML tags (such as <JFrame>) in {@link JAXXCompiler}.
+ * There is only one <code>TagHandler</code> for any given XML tag, and therefore implementations must be
+ * stateless.
+ *
+ * @author Ethan Nicholas
+ */
+public interface TagHandler {
+
+ /**
+ * Performs the first pass of compilation on an XML tag from a JAXX source file.
+ * <code>TagHandler</code> implementations affect the generated <code>.java</code>
+ * file by calling methods in the <code>JAXXCompiler</code>.
+ *
+ * @param tag the XML tag to compile
+ * @param compiler the active JAXXCompiler
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException;
+
+ /**
+ * Performs the second pass of compilation on an XML tag from a JAXX source file.
+ * <code>TagHandler</code> implementations affect the generated <code>.java</code>
+ * file by calling methods in the <code>JAXXCompiler</code>.
+ *
+ * @param tag the XML tag to compile
+ * @param compiler the active JAXXCompiler
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException;
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,461 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.*;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/** Manages TagHandlers, including automatically compiling .jaxx files corresponding to class tags. */
+public class TagManager {
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(TagManager.class);
+ /**
+ * Namespace for JAXX's non-class tags, such as <script;>. The namespace normally does not
+ * need to be specified but can be used to resolve ambiguities.
+ */
+ public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/";
+ /** Maps simple tag names to their default namespaces (package names). */
+ private static Map<String, String> defaultNamespaces = new HashMap<String, String>();
+ /** Maps qualified tag names to the TagHandlers responsible for processing them. */
+ private static Map<QName, TagHandler> registeredTags = new HashMap<QName, TagHandler>();
+ /** Keeps track of whether or not named classes exist. */
+ private static Map<String, Boolean> classExistenceCache = new HashMap<String, Boolean>();
+ /**
+ * Maps bean classes to their TagHandler classes. The mapping is to TagHandler classes, rather than to
+ * TagHandler instances, because subclasses of the bean class should be handled by the same TagHandler
+ * (assuming no more specific mappings exist), which requires creating a new instance of the TagHandler.
+ */
+ private static ClassMap<Class<? extends TagHandler>> registeredBeans = new ClassMap<Class<? extends TagHandler>>();
+
+ // still targeting 1.4, so I can't use javax.xml.namespace.QName
+ private static class QName {
+
+ private String namespaceURI;
+ private String localPart;
+
+ public QName(String namespaceURI, String localPart) {
+ if (localPart == null) {
+ throw new NullPointerException();
+ }
+ this.namespaceURI = namespaceURI;
+ this.localPart = localPart;
+ }
+
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+ public String getLocalPart() {
+ return localPart;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || !(o instanceof QName)) {
+ return false;
+ }
+ QName qname = (QName) o;
+ return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart());
+ }
+
+ @Override
+ public int hashCode() {
+ return (namespaceURI != null ? namespaceURI.hashCode() : 0) ^ getLocalPart().hashCode();
+ }
+ }
+
+ private TagManager() { /* not instantiable */ }
+
+ public static void reset(boolean verbose) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+ registeredBeans.clear();
+ registeredTags.clear();
+ defaultNamespaces.clear();
+ CompiledObjectDecoratorManager.reset();
+ JAXXCompilerLaunchor.loadLibraries(verbose);
+ }
+
+ /**
+ * Maps a class tag to a specific <code>TagHandler</code>. When a tag representing the bean class is
+ * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified
+ * <code>TagHandler</code> will be invoked to compile it.
+ *
+ * @param <T>
+ * @param beanClass the class to associate with a <code>TagHandler</code>
+ * @param handler the <code>TagHandler</code> class, which must descend from <code>DefaultObjectHandler</code>
+ * @throws IllegalArgumentException if the handler class does not descend from <code>DefaultObjectHandler</code>
+ */
+ public static <T extends TagHandler> void registerBean(ClassDescriptor beanClass, Class<T> handler) {
+ if (!DefaultObjectHandler.class.isAssignableFrom(handler)) {
+ throw new IllegalArgumentException("handler class must be a subclass of DefaultObjectHandler");
+ }
+ registeredBeans.put(beanClass, handler);
+ if (log.isDebugEnabled()) {
+ log.debug(beanClass + " : " + handler);
+ }
+ String name = beanClass.getName();
+ int dotPos = name.lastIndexOf(".");
+ String namespace = name.substring(0, dotPos + 1) + "*";
+ name = name.substring(dotPos + 1);
+ registerDefaultNamespace(name, namespace);
+ }
+
+ /**
+ * Sets the default namespace for a tag. When the tag is encountered with no namespace specified,
+ * the specified namespace will be assumed. Mapping the same tag to two or more default namespaces
+ * removes the mapping and marks the entry as being ambiguous (by putting a <code>null</code>
+ * value into the map); this causes an error to be thrown if the tag is used without a namespace being
+ * specified.
+ * <p/>
+ * Java package names on tags are automatically converted into namespaces (e.g. <javax.swing.JButton/>
+ * and <JButton xmlns="javax.swing.*"/> are equivalent), so tags with package names are considered
+ * to have namespaces specified.
+ *
+ * @param tag tag name
+ * @param namespace namespace
+ */
+ public static void registerDefaultNamespace(String tag, String namespace) {
+ if (defaultNamespaces.containsKey(tag) && !defaultNamespaces.get(tag).equals(namespace)) {
+ defaultNamespaces.put(tag, null); // tag name is now ambiguous
+ } else {
+ defaultNamespaces.put(tag, namespace);
+ }
+ }
+
+ /**
+ * Registers a <code>TagHandler</code> for a tag. When a tag with the given name and namespace
+ * is encountered, the <code>TagHandler's compileFirstPass</code> and <code>compileSecondPass</code>
+ * methods will be invoked to handle it.
+ * <p/>
+ * It is not an error to register an already-registered tag and namespace combination. The new mapping
+ * will replace the old mapping.
+ *
+ * @param <T>
+ * @param namespace the tag's namespace
+ * @param tag the simple name of the tag
+ * @param handler the <code>TagHandler</code> which should process the tag
+ */
+ public static <T extends TagHandler> void registerTag(String namespace, String tag, T handler) {
+ if (namespace == null) {
+ namespace = "*";
+ }
+ //System.out.println("registerTag "+namespace+" : "+tag+" : "+handler);
+ if (log.isDebugEnabled()) {
+ log.debug(tag + " : " + handler);
+ }
+ registeredTags.put(new QName(namespace, tag), handler);
+ registerDefaultNamespace(tag, namespace);
+ }
+
+ /**
+ * Returns the <code>TagHandler</code> that should be used to process the specified tag.
+ * If the tag represents the class name of an uncompiled <code>.jaxx</code> file, the
+ * <code>.jaxx</code> is first compiled.
+ *
+ * @param namespace the tag's namespace (may be <code>null</code>)
+ * @param tag the tag's simple name
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the <code>TagHandler</code> for the tag
+ * @throws CompilerException ?
+ */
+ public static TagHandler getTagHandler(String namespace, String tag, JAXXCompiler compiler) throws CompilerException {
+ return getTagHandler(namespace, tag, false, compiler);
+ }
+
+ private static String getNamespace(ClassDescriptor beanClass) {
+ String packageName = beanClass.getPackageName();
+ return packageName != null ? packageName + ".*" : "*";
+
+ }
+
+ private static String getSimpleName(ClassDescriptor beanClass) {
+ String packageName = beanClass.getPackageName();
+ if (packageName != null) {
+ assert beanClass.getName().startsWith(packageName);
+ return beanClass.getName().substring(packageName.length() + 1);
+ }
+ return beanClass.getName();
+ }
+
+ /**
+ * @param beanClass the tag class
+ * @return the <code>TagHandler</code> that should be used to process the specified class.
+ * Only <code>TagHandlers</code> previously registered with <code>registerBean</code>
+ * are considered.
+ * @throws CompilerException ?
+ */
+ public static DefaultObjectHandler getTagHandler(ClassDescriptor beanClass) throws CompilerException {
+ try {
+ if (beanClass == null) {
+ throw new NullPointerException();
+ }
+ String namespace = getNamespace(beanClass);
+ String tag = getSimpleName(beanClass);
+ DefaultObjectHandler handler = (DefaultObjectHandler) registeredTags.get(new QName(namespace, tag));
+ if (handler == null) {
+ Class<? extends TagHandler> handlerClass = registeredBeans.get(beanClass);
+ if (handlerClass == null) {
+ throw new CompilerException("unable to find handler for " + beanClass);
+ }
+ Constructor<? extends TagHandler> constructor = handlerClass.getConstructor(ClassDescriptor.class);
+ handler = (DefaultObjectHandler) constructor.newInstance(beanClass);
+ registerTag(namespace, tag, handler);
+ }
+ return handler;
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static boolean classExists(String className, JAXXCompiler compiler) {
+ if (classExistenceCache.containsKey(className)) {
+ return classExistenceCache.get(className);
+ }
+
+ boolean found = false;
+ try {
+ Class.forName(className, true, compiler.getClassLoader());
+ found = true;
+ } catch (ClassNotFoundException e) {
+ // ignore ?
+ } catch (NoClassDefFoundError e) { // we get this instead of ClassNotFoundException on case-insensitive file systems when
+ // looking up a class with the wrong case
+ }
+
+ if (!found) { // couldn't find .class, check for .java
+ URL javaURL = compiler.getClassLoader().getResource(className.replace('.', '/') + ".java");
+ found = javaURL != null;
+ }
+
+ if (!found) { // couldn't find .java, check for .jaxx
+ URL jaxxURL = compiler.getClassLoader().getResource(className.replace('.', '/') + ".jaxx");
+ found = jaxxURL != null;
+ }
+
+ classExistenceCache.put(className, found);
+
+ return found;
+ }
+
+ private static String determinePackage(String simpleClassName, String defaultPackage, JAXXCompiler compiler) {
+ String namespace = null;
+ Set<String> classes = compiler.getImportedClasses();
+ for (String className : classes) { // search class imports (e.g. import java.util.Date;)
+ if (className.equals(simpleClassName) || className.endsWith("." + simpleClassName)) {
+ namespace = className.substring(0, className.lastIndexOf(".") + 1) + "*";
+ }
+ }
+ if (namespace == null) { // search package imports (e.g. import java.util.*;)
+ Set<String> searchList = compiler.getImportedPackages();
+ if (defaultPackage != null) {
+ if (!defaultPackage.endsWith("*")) {
+ throw new IllegalArgumentException("defaultPackage must end in '*', found '" + defaultPackage + "'");
+ }
+ if (classExists(defaultPackage.substring(0, defaultPackage.length() - 1) + simpleClassName, compiler)) {
+ return defaultPackage;
+ }
+ }
+ for (String currentPackage : searchList) {
+ String className = currentPackage + simpleClassName;
+ if (classExists(className, compiler)) {
+ if (namespace != null) { // we've already found the same name in another package
+ compiler.reportError("symbol '" + simpleClassName + "' is ambiguous, found matching classes " + namespace.substring(0, namespace.length() - 1) + simpleClassName + " and " + currentPackage + simpleClassName + ". Use fully-qualified name to disambiguate.");
+ return null;
+ }
+ namespace = currentPackage + "*";
+ }
+ }
+ }
+
+ return namespace;
+ }
+
+ /**
+ * Returns the <code>TagHandler</code> that should be used to process the specified tag.
+ * <p/>
+ * The <code>namespacePrefix</code> parameter is used only for error checking, as it is an
+ * error to specify conflicting package names using both a fully-qualified tag name and a
+ * namespace prefix, but it is not an error to specify conflicting package names using a
+ * fully-qualified tag name and a <i>default</i> namespace (i.e. <awt:javax.swing.JButton xmlns:awt='java.awt.*'/>
+ * is an error, whereas <javax.swing.JButton xmlns='java.awt.*'/> is not).
+ *
+ * @param namespace the tag's namespace (may be <code>null</code>)
+ * @param tag the tag's simple name (which can include fully-qualified Java class names)
+ * @param namespacePrefix <code>true</code> if the namespace was specified by means of a namespace prefix (as opposed to a default namespace)
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the <code>TagHandler</code> for the tag
+ * @throws CompilerException ?
+ */
+ public static TagHandler getTagHandler(String namespace, String tag, boolean namespacePrefix, JAXXCompiler compiler) throws CompilerException {
+ if (tag == null) {
+ throw new NullPointerException();
+ }
+ if (namespace == null && defaultNamespaces.containsKey(tag)) {
+ namespace = defaultNamespaces.get(tag);
+ if (namespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity
+ compiler.reportError("tag '" + tag + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate");
+ return null;
+ }
+ }
+
+ TagHandler handler = registeredTags.get(new QName(namespace, tag));
+ if (handler == null) {
+ if (namespace == null || namespace.endsWith("*")) {
+ String className;
+ if (namespace != null) {
+ className = resolveClassName(namespace.substring(0, namespace.length() - 1) + tag, compiler);
+ if (className == null) {
+ className = resolveClassName(tag, compiler);
+ if (namespacePrefix && !className.startsWith(namespace.substring(0, namespace.length() - 1))) {
+ className = null; // namespace was specified, but we found it in a different package - ignore
+ }
+ }
+ } else {
+ className = resolveClassName(tag, compiler);
+ }
+ if (className != null) {
+ int dotPos = className.lastIndexOf(".");
+ namespace = className.substring(0, dotPos + 1) + "*";
+ tag = className.substring(dotPos + 1);
+ handler = registeredTags.get(new QName(namespace, tag));
+ if (handler == null) {
+ try {
+ handler = getTagHandler(ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader()));
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ return handler;
+ }
+
+ /**
+ * Resolves a simple class name (like <code>Object</code> or <code>String</code>) to its fully-qualified name. Inner
+ * classes should be represented as they would appear in Java source code (e.g. JPopupMenu.Separator). Fully-qualified names,
+ * such as <code>java.lang.Object</code> are legal and will be returned unmodified (and in fact it is generally impossible to
+ * even know whether a given reference is fully qualified until it has been resolved). Returns <code>null</code> if no matching
+ * class could be found.
+ *
+ * @param name name to resolve
+ * @param compiler compile to use
+ * @return the resolved fqn class name
+ */
+ public static String resolveClassName(String name, JAXXCompiler compiler) {
+ if (name.endsWith("[]")) {
+ return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]";
+ }
+ if (name.indexOf("<") != -1) {
+ name = name.substring(0, name.indexOf("<")); // strip off generic types
+ }
+
+ name = name.intern();
+ if (name.equals("boolean") || name.equals("byte") || name.equals("short") || name.equals("int") ||
+ name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char")) {
+ return name;
+ }
+
+ String result = null;
+ String originalName = name;
+ String defaultNamespace = null;
+ if (defaultNamespaces.containsKey(name)) {
+ defaultNamespace = defaultNamespaces.get(name);
+ if (defaultNamespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity
+ compiler.reportError("class '" + name + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate");
+ return null;
+ }
+ }
+ if (defaultNamespace != null && defaultNamespace.endsWith("*")) {
+ result = defaultNamespace.substring(0, defaultNamespace.length() - 1) + name;
+ }
+
+ if (result == null) {
+ // Inner class names (like JPopupMenu.Separator) present a special challenge. The name before the dot might be
+ // a package name, or it might be a class name. If it's a class name, it might be fully qualified, or it might
+ // not. And it's also not actually the correct name of the class, as far as the JVM is concerned -- the correct
+ // name uses a dollar sign instead of a dot (javax.swing.JPopupMenu$Separator). And there could be more than
+ // one inner class -- it's possible to have com.mycompany.Outer$Inner$Innerer$Innerest.
+ //
+ // The basic strategy is to start by treating the part before the last dot as a package name, as that is by far
+ // the most likely case. If we don't find the class there, change the last dot to a dollar sign and try again.
+ // Suppose we have the tag <com.mycompany.Outer.Inner.Innerer.Innerest/>, matching the class above. Resolution
+ // proceeds like this:
+ // com.mycompany.Outer.Inner.Innerer.* : Innerest
+ // com.mycompany.Outer.Inner.* : Innerer$Innerest
+ // com.mycompany.Outer.* : Inner$Innerer$Innerest
+ // com.mycompany.* : Outer$Inner$Innerer$Innerest
+ // And at this point we have a match with the class Outer$Inner$Innerer$Innerest in package com.mycompany.
+ int dotPos = originalName.lastIndexOf('.');
+ for (;;) {
+ String namespace = dotPos != -1 ? originalName.substring(0, dotPos) + ".*" : "*";
+ name = originalName.substring(dotPos + 1).replace('.', '$');
+ String packageName = determinePackage(name, namespace, compiler);
+ if (packageName != null) {
+ assert packageName.endsWith("*");
+ if (packageName.equals(namespace) || namespace.equals("*")) {
+ // check for an alias (like javax.swing.JComboBox actually being jaxx.runtime.swing.JAXXComboBox)
+ TagHandler handler = registeredTags.get(new QName(namespace, name));
+ if (handler != null) { // determine alias by looking at handler
+ ClassDescriptor alias = ((DefaultObjectHandler) handler).getBeanClass();
+ // make sure the same handler is used for both the aliased and non-aliased names, in order to avoid "no CompiledObject has been registered" error
+ // the line below doesn't bother to handle the case where the aliased class name doesn't have a package, since it's a pretty safe assumption that
+ // that will never happen
+ assert alias.getPackageName() != null && alias.getPackageName().length() > 0 : "aliasing with no package name has not been implemented";
+ registeredTags.put(new QName(alias.getPackageName() + ".*", alias.getName().substring(alias.getPackageName().length() + 1)), handler);
+ result = alias.getName();
+ break;
+ } else { // no alias
+ result = packageName.substring(0, packageName.length() - 1) + name;
+ break;
+ }
+ }
+ // else we found a class by the same name, but in the wrong package
+ }
+
+ if (dotPos <= 0) {
+ break;
+ }
+ dotPos = originalName.lastIndexOf('.', dotPos - 1);
+ }
+ }
+
+ if (result != null && !result.equals(originalName)) {
+ result = resolveClassName(result, compiler); // check for aliases against the new name as well
+ }
+
+ return result;
+ }
+
+ public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) {
+ try {
+ className = resolveClassName(className, compiler);
+ if (className == null) {
+ return null;
+ }
+ return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ApplicationHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Application;
+import jaxx.compiler.types.TypeManager;
+import org.w3c.dom.Element;
+
+import javax.swing.WindowConstants;
+
+public class ApplicationHandler extends JWindowHandler {
+
+ public ApplicationHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Application.class);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException {
+ if (propertyName.equals("lookAndFeel") && stringValue != null && !stringValue.trim().startsWith("{")) {
+ compiler.appendBodyCode("{ " + object.getJavaCode() + ".setLookAndFeel(" + TypeManager.getJavaCode(stringValue) + "); }" + JAXXCompiler.getLineSeparator());
+ } else {
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.EXIT_ON_CLOSE), false, compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/CellHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.types.TypeManager;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.io.IOException;
+
+public class CellHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ Node parent = tag.getParentNode();
+ if (parent.getNodeType() != Node.ELEMENT_NODE || !parent.getLocalName().equals("row")) {
+ compiler.reportError("cell tag may only appear within row tag");
+ return;
+ }
+
+ TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent();
+ table.newCell();
+ GridBagConstraints c = table.getCellConstraints();
+ setAttributes(c, tag);
+ compileChildrenSecondPass(tag, compiler);
+ }
+
+ public static void setAttribute(GridBagConstraints c, String name, String value) throws CompilerException {
+ value = value.trim();
+ if (name.equals("insets")) {
+ c.insets = (Insets) TypeManager.convertFromString(value, Insets.class);
+ } else if (name.equals("weightx")) {
+ c.weightx = Double.parseDouble(value);
+ } else if (name.equals("weighty")) {
+ c.weighty = Double.parseDouble(value);
+ } else if (name.equals("columns")) {
+ c.gridwidth = Integer.parseInt(value);
+ } else if (name.equals("rows")) {
+ c.gridheight = Integer.parseInt(value);
+ } else if (name.equals("fill")) {
+ if (value.equals("none")) {
+ c.fill = GridBagConstraints.NONE;
+ } else if (value.equals("horizontal")) {
+ c.fill = GridBagConstraints.HORIZONTAL;
+ } else if (value.equals("vertical")) {
+ c.fill = GridBagConstraints.VERTICAL;
+ } else if (value.equals("both")) {
+ c.fill = GridBagConstraints.BOTH;
+ } else {
+ throw new IllegalArgumentException("invalid value for fill attribute: '" + value + "'");
+ }
+ } else if (name.equals("anchor")) {
+ //todo use a converter
+ if (value.equals("north")) {
+ c.anchor = GridBagConstraints.NORTH;
+ } else if (value.equals("northeast")) {
+ c.anchor = GridBagConstraints.NORTHEAST;
+ } else if (value.equals("east")) {
+ c.anchor = GridBagConstraints.EAST;
+ } else if (value.equals("southeast")) {
+ c.anchor = GridBagConstraints.SOUTHEAST;
+ } else if (value.equals("south")) {
+ c.anchor = GridBagConstraints.SOUTH;
+ } else if (value.equals("southwest")) {
+ c.anchor = GridBagConstraints.SOUTHWEST;
+ } else if (value.equals("west")) {
+ c.anchor = GridBagConstraints.WEST;
+ } else if (value.equals("northwest")) {
+ c.anchor = GridBagConstraints.NORTHWEST;
+ } else if (value.equals("center")) {
+ c.anchor = GridBagConstraints.CENTER;
+ } else {
+ throw new IllegalArgumentException("invalid value for anchor attribute: '" + value + "'");
+ }
+ } else {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ public static void setAttributes(GridBagConstraints c, Element tag) throws CompilerException {
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Attr attribute = (Attr) children.item(i);
+ String name = attribute.getName();
+ String value = attribute.getValue();
+ if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ setAttribute(c, name, value);
+ }
+ }
+ }
+
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/CompiledItemContainer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.runtime.swing.Item;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+/** Compiled representation of a class that contains Items arranged in a list or tree structure (JComboBox, JList, JTree). */
+class CompiledItemContainer extends CompiledObject {
+
+ private List<Item> items = new ArrayList<Item>();
+ private Stack<Item> openNodes = new Stack<Item>();
+
+ public CompiledItemContainer(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ }
+
+ public void openItem(Item item) {
+ if (openNodes.isEmpty()) {
+ items.add(item);
+ } else {
+ Item openNode = openNodes.peek();
+ openNode.addChild(item);
+ }
+ openNodes.add(item);
+ }
+
+ public void closeItem(Item item) {
+ if (openNodes.pop() != item) {
+ throw new IllegalArgumentException(item + " was not at the top of the item stack");
+ }
+ }
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ public void setItems(List<Item> items) {
+ this.items = items;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Item;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.io.IOException;
+import java.util.List;
+
+public class ItemHandler implements TagHandler {
+
+ private String DATA_BINDING = "<data binding has not been processed yet>";
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ String id = tag.getAttribute("id");
+ if (id == null || id.length() == 0) {
+ id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class));
+ }
+ String label = null;
+ String value = null;
+ boolean selected = false;
+ NamedNodeMap children = tag.getAttributes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Attr attribute = (Attr) children.item(i);
+ String name = attribute.getName();
+ String attrValue = attribute.getValue();
+ if (name.equals("id")) {
+ // already handled
+ continue;
+ }
+ if (name.equals(Item.LABEL_PROPERTY)) {
+ String labelBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(String.class));
+ if (labelBinding != null) {
+ compiler.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");");
+ } else {
+ label = attrValue;
+ }
+ continue;
+ }
+ if (name.equals(Item.VALUE_PROPERTY)) {
+ String valueBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Object.class));
+ if (valueBinding != null) {
+ value = DATA_BINDING;
+ compiler.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");");
+ } else {
+ value = attrValue;
+ }
+ continue;
+ }
+ if (name.equals(Item.SELECTED_PROPERTY)) {
+ String selectedBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Boolean.class));
+ if (selectedBinding != null) {
+ compiler.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");");
+ } else {
+ selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class);
+ }
+ continue;
+ }
+
+ if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ Item item = new Item(id, label, value, selected);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ if (value == null) {
+ compiler.reportError("<item> tag is missing required 'value' attribute");
+ } else {
+ if (!value.equals(DATA_BINDING)) {
+ List<Item> items = list.getItems();
+ for (Item item1 : items) {
+ if (item1.getValue().equals(value)) {
+ compiler.reportError("This container already has an <item> tag with the value '" + value + "'");
+ break;
+ }
+ }
+ }
+ list.openItem(item);
+ compileChildrenSecondPass(tag, compiler);
+ list.closeItem(item);
+ }
+ }
+
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.JAXXComboBox;
+import jaxx.runtime.swing.Item;
+import org.w3c.dom.Element;
+
+import java.awt.event.ItemListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXComboBoxHandler extends DefaultComponentHandler {
+
+ public JAXXComboBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class);
+ addProxyEventInfo("getSelectedItem", ItemListener.class);
+ }
+
+ @Override
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.JAXXList;
+import jaxx.runtime.swing.Item;
+import org.w3c.dom.Element;
+
+import javax.swing.event.ListSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXListHandler extends DefaultComponentHandler {
+
+ public JAXXListHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ //TODO Add the correct generic type
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTabHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,11 @@
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+/** @author chemit */
+public class JAXXTabHandler extends TableHandler {
+
+ public JAXXTabHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import org.w3c.dom.Element;
+
+import javax.swing.event.TreeSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXTreeHandler extends DefaultComponentHandler {
+
+ public JAXXTreeHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException {
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ tree.appendAdditionCode(addMethod + "(" + id + ");");
+ createItems(tree, item.getChildren(), id + ".addChild", compiler);
+ }
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = tree.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = tree.getId() + "$items";
+ tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ createItems(tree, items, listName + ".add", compiler);
+ tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JCheckBoxHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.AbstractButton;
+import javax.swing.event.ChangeListener;
+
+public class JCheckBoxHandler extends DefaultComponentHandler {
+
+ public JCheckBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("isSelected", ChangeListener.class, "model");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import java.awt.event.ItemListener;
+import javax.swing.JComboBox;
+
+public class JComboBoxHandler extends DefaultComponentHandler {
+
+ public JComboBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class);
+ addProxyEventInfo("getSelectedItem", ItemListener.class);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JComboBox does not accept childs");
+ throw new CompilerException("JComboBox does not accept childs");
+ }
+ }
+}
+
+
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JInternalFrameHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JMenuBar;
+import javax.swing.WindowConstants;
+
+public class JInternalFrameHandler extends DefaultComponentHandler {
+
+ public JInternalFrameHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JInternalFrame.class);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) {
+ appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");");
+ } else {
+ super.addChild(child, constraints, compiler);
+ }
+ }
+ };
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "visible", "true", false, compiler);
+ setAttribute(object, "closable", "true", false, compiler);
+ setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.DISPOSE_ON_CLOSE), false, compiler);
+ }
+
+ @Override
+ public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setAttributes(object, tag, compiler);
+ compiler.appendInitializerCode(object.getId() + ".pack();\n");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,42 @@
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.JList;
+
+public class JListHandler extends DefaultComponentHandler {
+
+ public JListHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JList.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JList does not accept childs");
+ throw new CompilerException("JList does not accept childs");
+ }
+ }
+}
+
+
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JMenuHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JMenu;
+import javax.swing.event.MenuListener;
+
+public class JMenuHandler extends DefaultComponentHandler {
+
+ public JMenuHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JMenu.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("isSelected", MenuListener.class);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JPasswordFieldHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+
+import javax.swing.JPasswordField;
+import javax.swing.event.DocumentListener;
+
+public class JPasswordFieldHandler extends JTextComponentHandler {
+
+ public JPasswordFieldHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPasswordField.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getPassword", DocumentListener.class, "document");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JPopupMenuHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JPopupMenu;
+
+public class JPopupMenuHandler extends DefaultComponentHandler {
+
+ public JPopupMenuHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPopupMenu.class);
+ }
+
+ @Override
+ public boolean isContainer() {
+ return true;
+ }
+
+ @Override
+ protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ compiler.openInvisibleComponent(object);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JProgressBarHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JProgressBar;
+import javax.swing.event.ChangeListener;
+
+public class JProgressBarHandler extends DefaultComponentHandler {
+
+ public JProgressBarHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JProgressBar.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "change");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JRadioButtonHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.JAXXButtonGroup;
+
+import javax.swing.AbstractButton;
+import javax.swing.event.ChangeListener;
+
+public class JRadioButtonHandler extends DefaultComponentHandler {
+
+ private static final String VALUE_PROPERTY = JAXXButtonGroup.VALUE_CLIENT_PROPERTY.substring(1);
+ private static final String BUTTON_GROUP_PROPERTY = JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY.substring(1);
+
+ public JRadioButtonHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("isSelected", ChangeListener.class, "model");
+ }
+
+ @Override
+ public ClassDescriptor getPropertyType(CompiledObject object, String name, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals(BUTTON_GROUP_PROPERTY)) {
+ return null; // accepts either a String or a ButtonGroup
+ } else if (name.equals(VALUE_PROPERTY)) {
+ return ClassDescriptorLoader.getClassDescriptor(Object.class);
+ } else {
+ return super.getPropertyType(object, name, compiler);
+ }
+ }
+
+ @Override
+ public boolean isMemberBound(String name) throws UnsupportedAttributeException {
+ return !(name.equals(BUTTON_GROUP_PROPERTY) || name.equals(VALUE_PROPERTY)) && super.isMemberBound(name);
+ }
+
+ // handle buttonGroup assignment in addition block rather than initialization block
+ @Override
+ public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) {
+ if (name.equals(BUTTON_GROUP_PROPERTY)) {
+ object.appendAdditionCode(getSetPropertyCode(object.getJavaCode(), name, TypeManager.getJavaCode(value), compiler));
+ } else {
+ super.setProperty(object, name, value, compiler);
+ }
+ }
+
+ @Override
+ public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals(BUTTON_GROUP_PROPERTY)) {
+ if (valueCode.startsWith("\"") && valueCode.endsWith("\"")) {
+ valueCode = valueCode.substring(1, valueCode.length() - 1);
+ CompiledObject buttonGroup = compiler.getCompiledObject(valueCode);
+ if (buttonGroup == null) {
+ buttonGroup = new CompiledObject(valueCode, ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class), compiler);
+ compiler.registerCompiledObject(buttonGroup);
+ }
+ }
+ return "{ javax.swing.ButtonGroup $buttonGroup = " + valueCode + "; " + id + ".putClientProperty(\"$buttonGroup\", $buttonGroup); $buttonGroup.add(" + id + "); }\n";
+ } else if (name.equals(VALUE_PROPERTY)) {
+ return "{ " + id + ".putClientProperty(\"" + JAXXButtonGroup.VALUE_CLIENT_PROPERTY + "\", " + valueCode + "); Object $buttonGroup = " + id + ".getClientProperty(\"" + JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY + "\");" +
+ " if ($buttonGroup instanceof jaxx.runtime.swing.JAXXButtonGroup) { ((jaxx.runtime.swing.JAXXButtonGroup) $buttonGroup).updateSelectedValue(); } }\n";
+ } else {
+ return super.getSetPropertyCode(id, name, valueCode, compiler);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JScrollPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JScrollPane;
+
+public class JScrollPaneHandler extends DefaultComponentHandler {
+
+ public JScrollPaneHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JScrollPane.class);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ boolean hasChild;
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("JScrollPane does not accept constraints");
+ }
+ if (hasChild) {
+ compiler.reportError("JScrollPane may only have one child");
+ }
+ super.addChild(child, constraints, compiler);
+ hasChild = true;
+ }
+ };
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+import javax.swing.JSlider;
+import javax.swing.event.ChangeListener;
+
+public class JSliderHandler extends DefaultComponentHandler {
+
+ public JSliderHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass)) {
+ throw new IllegalArgumentException(getClass().getName() + " does not support the class " + beanClass.getName());
+ }
+ }
+
+ @Override
+ protected int getAttributeOrdering(Attr attr) {
+ if (attr.getName().equals("value")) {
+ return 1;
+ } else {
+ return super.getAttributeOrdering(attr);
+ }
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "value", "0", false, compiler);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "model");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSpinnerHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JSpinner;
+import javax.swing.event.ChangeListener;
+
+public class JSpinnerHandler extends DefaultComponentHandler {
+
+ public static String MINIMUM_PROPERTY = "minimum";
+ public static String MAXIMUM_PROPERTY = "maximum";
+ public static String VALUE_PROPERTY = "value";
+
+ public JSpinnerHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSpinner.class);
+ }
+
+ public static class CompiledSpinner extends CompiledObject {
+
+ Integer minimum = null;
+ Integer maximum = null;
+ Integer value = null;
+
+ public CompiledSpinner(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ }
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledSpinner(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "model");
+ }
+
+ @Override
+ public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException {
+ if (propertyName.equals(MINIMUM_PROPERTY) || propertyName.equals(MAXIMUM_PROPERTY) ||
+ propertyName.equals(VALUE_PROPERTY)) {
+ return ClassDescriptorLoader.getClassDescriptor(Integer.class);
+ }
+ return super.getPropertyType(object, propertyName, compiler);
+ }
+
+ @Override
+ public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals(MINIMUM_PROPERTY)) {
+ ((CompiledSpinner) object).minimum = (Integer) value;
+ } else if (name.equals(MAXIMUM_PROPERTY)) {
+ ((CompiledSpinner) object).maximum = (Integer) value;
+ } else if (name.equals(VALUE_PROPERTY)) {
+ ((CompiledSpinner) object).value = (Integer) value;
+ } else {
+ super.setProperty(object, name, value, compiler);
+ }
+ }
+
+ @Override
+ protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ CompiledSpinner spinner = (CompiledSpinner) object;
+ if (spinner.minimum != null || spinner.maximum != null || spinner.value != null) {
+ if (spinner.getConstructorParams() != null) {
+ compiler.reportError("constructorParams and minimum/maximum may not both be specified for the same JSpinner");
+ }
+ if (spinner.minimum == null) {
+ spinner.minimum = Math.min(0, spinner.maximum != null ? spinner.maximum.intValue() : 0);
+ }
+ if (spinner.maximum == null) {
+ spinner.maximum = Math.max(100, spinner.minimum.intValue());
+ }
+ if (spinner.value == null) {
+ spinner.value = spinner.minimum;
+ }
+ spinner.setConstructorParams("new SpinnerNumberModel(" + spinner.value + ", " + spinner.minimum + ", " + spinner.maximum + ", 1)");
+ }
+
+ super.closeComponent(object, tag, compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSplitPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JSplitPane;
+import java.awt.Component;
+
+public class JSplitPaneHandler extends DefaultComponentHandler {
+
+ public JSplitPaneHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSplitPane.class);
+ }
+
+ protected Component createRawComponent(Element tag) {
+ return new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ }
+
+ /**
+ * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. The
+ * values required by the JAXXBeanInfo are the unwieldy <code>vertical_split</code> and <code>horizontal_split</code>
+ * (which are also recognized).
+ */
+ @Override
+ protected int constantValue(String key, String value) {
+ if (key.equals("orientation")) {
+ value = value.trim().toLowerCase();
+ if (value.equals("horizontal") || value.equals("horizontal_split")) {
+ return JSplitPane.HORIZONTAL_SPLIT;
+ }
+ if (value.equals("vertical") || value.equals("vertical_split")) {
+ return JSplitPane.VERTICAL_SPLIT;
+ }
+ throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'");
+ }
+ return super.constantValue(key, value);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ private int count;
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("JSplitPane does not accept constraints");
+ }
+ if (count == 0) {
+ super.addChild(child, "JSplitPane.LEFT", compiler);
+ } else if (count == 1) {
+ super.addChild(child, "JSplitPane.RIGHT", compiler);
+ } else {
+ compiler.reportError("JSplitPane is limited to two children");
+ }
+ count++;
+ }
+ };
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTabbedPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.TabInfo;
+
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+import javax.swing.event.ChangeListener;
+import java.awt.Color;
+import java.awt.event.ContainerListener;
+
+public class JTabbedPaneHandler extends DefaultComponentHandler {
+
+ public JTabbedPaneHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTabbedPane.class);
+ }
+
+ public static class CompiledTabbedPane extends CompiledObject {
+
+ private static final TabInfo USED = new TabInfo("ALREADY USED");
+ int tabCount;
+ TabInfo tabInfo;
+
+ public CompiledTabbedPane(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ }
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("JTabbedPane tabs may not have constraints");
+ }
+
+ super.addChild(child, constraints, compiler);
+
+ if (tabInfo == null) {
+ compiler.reportError("JTabbedPaneHandler may only have 'tab' tags as children (found " + child.getObjectClass() + ")");
+ return;
+ } else if (tabInfo == USED) {
+ compiler.reportError("<tab> tags may only have one child component");
+ return;
+ }
+
+ int tabIndex = ++tabCount - 1;
+ appendAdditionCode(tabInfo.getId() + ".addPropertyChangeListener(new jaxx.runtime.swing.TabInfoPropertyChangeListener(" + getId() + ", " + tabIndex + "));");
+
+ String title = tabInfo.getTitle();
+ if (title != null) {
+ if (I18nHelper.isI18nAttribute("title")) {
+ if (!title.startsWith("_(\"")) {
+ // we did not have the invocation code, add it
+ title = I18nHelper.addI18nInvocation(getId(), "title", TypeManager.getJavaCode(title), compiler);
+ }
+ } else {
+ title = TypeManager.getJavaCode(title);
+ }
+ appendAdditionCode(getId() + ".setTitleAt(" + tabIndex + ", " + title + ");");
+ }
+
+ String toolTipText = tabInfo.getToolTipText();
+ if (toolTipText != null) {
+ if (I18nHelper.isI18nAttribute("toolTipText")) {
+ if (!toolTipText.startsWith("_(\"")) {
+ // we did not have the invocation code, add it
+ toolTipText = I18nHelper.addI18nInvocation(getId(), "toolTipText", TypeManager.getJavaCode(toolTipText), compiler);
+ }
+ } else {
+ toolTipText = TypeManager.getJavaCode(toolTipText);
+ }
+ appendAdditionCode(getId() + ".setToolTipTextAt(" + tabIndex + ", " + toolTipText + ");");
+ }
+
+ boolean enabled = tabInfo.isEnabled();
+ if (!enabled) {
+ appendAdditionCode(getId() + ".setEnabledAt(" + tabIndex + ", false);");
+ }
+
+ Color foreground = tabInfo.getForeground();
+ if (foreground != null) {
+ appendAdditionCode(getId() + ".setForegroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(foreground) + ");");
+ }
+
+ Color background = tabInfo.getBackground();
+ if (background != null) {
+ appendAdditionCode(getId() + ".setBackgroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(background) + ");");
+ }
+
+ int mnemonic = tabInfo.getMnemonic();
+ if (mnemonic != -1) {
+ appendAdditionCode(getId() + ".setMnemonicAt(" + tabIndex + ", " + mnemonic + ");");
+ }
+
+ int displayedMnemonicIndex = tabInfo.getDisplayedMnemonicIndex();
+ if (displayedMnemonicIndex != -1) {
+ appendAdditionCode(getId() + ".setDisplayedMnemonicIndexAt(" + tabIndex + ", " + displayedMnemonicIndex + ");");
+ }
+
+ Icon icon = tabInfo.getIcon();
+ if (icon != null) {
+ appendAdditionCode(getId() + ".setIconAt(" + tabIndex + ", " + icon + ");");
+ }
+
+ Icon disabledIcon = tabInfo.getDisabledIcon();
+ if (disabledIcon != null) {
+ appendAdditionCode(getId() + ".setDisabledIconAt(" + tabIndex + ", " + disabledIcon + ");");
+ }
+
+ tabInfo = USED;
+ }
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledTabbedPane(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ChangeListener.class);
+ addProxyEventInfo("getSelectedComponent", ChangeListener.class);
+ addProxyEventInfo("getTabCount", ContainerListener.class);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTextComponentHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.runtime.SwingUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+import javax.swing.JTextArea;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.JTextComponent;
+
+public class JTextComponentHandler extends DefaultComponentHandler {
+
+ private static final int DEFAULT_COLUMNS = 15;
+
+ public JTextComponentHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTextComponent.class);
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ try {
+ object.getObjectClass().getMethodDescriptor("setColumns", ClassDescriptorLoader.getClassDescriptor(int.class));
+ setAttribute(object, "columns", String.valueOf(DEFAULT_COLUMNS), false, compiler);
+ } catch (NoSuchMethodException e) {
+ // ignore ?
+ }
+
+ if (ClassDescriptorLoader.getClassDescriptor(JTextArea.class).isAssignableFrom(object.getObjectClass())) {
+ setAttribute(object, "lineWrap", "true", false, compiler);
+ setAttribute(object, "wrapStyleWord", "true", false, compiler);
+ }
+ }
+
+ @Override
+ public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals("text")) {
+ return SwingUtil.class.getName() + ".setText(" + id + ", " + valueCode + ");\n";
+ //return "jaxx.runtime.swing.Utils.setText(" + id + ", " + valueCode + ");\n";
+ }
+ return super.getSetPropertyCode(id, name, valueCode, compiler);
+ }
+
+ @Override
+ protected int getAttributeOrdering(Attr attr) {
+ // delay text in case other attributes affect how it's processed, as is the case
+ // with JEditorPane's contentType
+ if (attr.getName().equals("text")) {
+ return 1;
+ }
+ return super.getAttributeOrdering(attr);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getText", DocumentListener.class, "document");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JToolBarHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JToolBar;
+
+public class JToolBarHandler extends DefaultComponentHandler {
+
+ public JToolBarHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JToolBar.class);
+ }
+
+ /**
+ * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. These values should
+ * have been supported without any special effort on my part, but JToolBar's BeanInfo doesn't contain the enum attribute
+ * for the orientation property.
+ */
+ @Override
+ protected int constantValue(String key, String value) {
+ if (key.equals("orientation")) {
+ value = value.trim().toLowerCase();
+ if (value.equals("horizontal")) {
+ return JToolBar.HORIZONTAL;
+ }
+ if (value.equals("vertical")) {
+ return JToolBar.VERTICAL;
+ }
+ throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'");
+ }
+ return super.constantValue(key, value);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,43 @@
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.event.TreeSelectionListener;
+import java.io.IOException;
+import javax.swing.JTree;
+import org.w3c.dom.NodeList;
+
+public class JTreeHandler extends DefaultComponentHandler {
+
+ public JTreeHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTree.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JTree does not accept childs");
+ throw new CompilerException("JTree does not accept childs");
+ }
+ }
+}
+
+
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JMenuBar;
+import javax.swing.JWindow;
+import java.io.IOException;
+import java.util.Map;
+
+public class JWindowHandler extends DefaultComponentHandler {
+
+ public JWindowHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JWindow.class, JFrame.class, JDialog.class);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) {
+ appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");");
+ } else {
+ super.addChild(child, constraints, compiler);
+ }
+ }
+ };
+ }
+
+ @Override
+ protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ if (compiler.getOpenComponent() != null) {
+ compiler.openInvisibleComponent(object);
+ } else {
+ super.openComponent(object, tag, compiler);
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileSecondPass(tag, compiler);
+ CompiledObject object = objectMap.get(tag);
+ Map<?, ?> properties = object.getProperties();
+ if (!properties.containsKey("width") && !properties.containsKey("height")) {
+ compiler.appendLateInitializer(object.getId() + ".pack();\n");
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.runtime.swing.Table;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.awt.GridBagConstraints;
+import java.io.IOException;
+
+public class RowHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (!ClassDescriptorLoader.getClassDescriptor(Table.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError("row tag may only appear within Table tag");
+ return;
+ }
+
+ TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent();
+ table.newRow();
+ GridBagConstraints c = table.getRowConstraints();
+ CellHandler.setAttributes(c, tag);
+ compileChildrenSecondPass(tag, compiler);
+ }
+
+ public void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ if (!child.getLocalName().equals("cell")) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children");
+ }
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ if (!child.getLocalName().equals("cell")) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children");
+ }
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.TabInfo;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+import java.awt.Color;
+import java.io.IOException;
+
+public class TabHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (!ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError("tab tag may only appear within JTabbedPane tag");
+ return;
+ }
+
+ JTabbedPaneHandler.CompiledTabbedPane tabs = (JTabbedPaneHandler.CompiledTabbedPane) compiler.getOpenComponent();
+
+ String id = tag.getAttribute("id");
+ if (id == null || id.length() == 0) {
+ id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(TabInfo.class));
+ }
+ TabInfo tabInfo = new TabInfo(id);
+ CompiledObject compiledTabInfo = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(TabInfo.class), compiler);
+ compiler.registerCompiledObject(compiledTabInfo);
+ //id = tabInfo.getId();
+ tabs.tabInfo = tabInfo;
+ setAttributes(compiledTabInfo, tabs, tag, compiler);
+ compileChildrenSecondPass(tag, compiler);
+ tabs.tabInfo = null;
+ }
+
+ public static void setAttribute(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, String name, String value, JAXXCompiler compiler) throws CompilerException {
+ value = value.trim();
+ TabInfo tabInfo = tabs.tabInfo;
+ String id = tabInfo.getId();
+ String binding = compiler.processDataBindings(value, ClassDescriptorLoader.getClassDescriptor(Object.class));
+ if (binding != null) {
+ compiler.registerDataBinding(binding, id + "." + name, id + ".set" + org.apache.commons.lang.StringUtils.capitalize(name) + "(" + binding + ");");
+ return;
+ }
+
+ String valueCode = TypeManager.getJavaCode(value);
+
+ // add i18n support
+ if (I18nHelper.isI18nableAttribute(name, compiler)) {
+ value = valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler);
+ }
+
+ if (name.equals("title")) {
+ tabInfo.setTitle(value);
+ compiledTabInfo.appendInitializationCode(id + ".setTitle(" + valueCode + ");");
+ //compiledTabInfo.appendInitializationCode(id + ".setTitle(" + TypeManager.getJavaCode(value) + ");");
+ } else if (name.equals("toolTipText")) {
+ tabInfo.setToolTipText(value);
+ compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + valueCode + ");");
+ //compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + TypeManager.getJavaCode(value) + ");");
+ } else if (name.equals("icon")) {
+ Icon icon = (Icon) TypeManager.convertFromString(value, Icon.class);
+ tabInfo.setIcon(icon);
+ compiledTabInfo.appendInitializationCode(id + ".setIcon(" + TypeManager.getJavaCode(icon) + ");");
+ } else if (name.equals("enabled")) {
+ boolean enabled = (Boolean) TypeManager.convertFromString(value, Boolean.class);
+ tabInfo.setEnabled(enabled);
+ compiledTabInfo.appendInitializationCode(id + ".setEnabled(" + enabled + ");");
+ } else if (name.equals("disabledIcon")) {
+ Icon disabledIcon = (Icon) TypeManager.convertFromString(value, Icon.class);
+ tabInfo.setDisabledIcon(disabledIcon);
+ compiledTabInfo.appendInitializationCode(id + ".setDisabledIcon(" + TypeManager.getJavaCode(disabledIcon) + ");");
+ } else if (name.equals("mnemonic")) {
+ int mnemonic = (Character) TypeManager.convertFromString(value, char.class);
+ tabInfo.setMnemonic(mnemonic);
+ compiledTabInfo.appendInitializationCode(id + ".setMnemonic(" + mnemonic + ");");
+ } else if (name.equals("displayedMnemonicIndex")) {
+ int displayedMnemonicIndex = (Integer) TypeManager.convertFromString(value, int.class);
+ tabInfo.setDisplayedMnemonicIndex(displayedMnemonicIndex);
+ compiledTabInfo.appendInitializationCode(id + ".setDisplayedMnemonicIndex(" + displayedMnemonicIndex + ");");
+ } else if (name.equals("foreground")) {
+ Color foreground = (Color) TypeManager.convertFromString(value, Color.class);
+ tabInfo.setForeground(foreground);
+ compiledTabInfo.appendInitializationCode(id + ".setForeground(" + TypeManager.getJavaCode(foreground) + ");");
+ } else if (name.equals("background")) {
+ Color background = (Color) TypeManager.convertFromString(value, Color.class);
+ tabInfo.setBackground(background);
+ compiledTabInfo.appendInitializationCode(id + ".setBackground(" + TypeManager.getJavaCode(background) + ");");
+ } else if (name.equals("id")) {
+ // ignore, already handled
+ } else {
+ compiler.reportError("The <tab> tag does not support the attribute '" + name + "'");
+ }
+ }
+
+ public void setAttributes(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, Element tag, JAXXCompiler compiler) throws CompilerException {
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Attr attribute = (Attr) children.item(i);
+ String name = attribute.getName();
+ String value = attribute.getValue();
+ if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ setAttribute(compiledTabInfo, tabs, name, value, compiler);
+ }
+ }
+ }
+
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TableHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Table;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TableHandler extends DefaultComponentHandler {
+
+ public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3);
+
+ public TableHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Table.class);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException {
+ try {
+ if (object instanceof CompiledTable) {
+ CellHandler.setAttribute(((CompiledTable) object).getTableConstraints(), propertyName, stringValue);
+ } else {
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+ } catch (UnsupportedAttributeException e) {
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+ }
+
+ class CompiledTable extends CompiledObject {
+
+ private List<Integer> rowSpans = new ArrayList<Integer>();
+ private GridBagConstraints tableConstraints;
+ private GridBagConstraints rowConstraints = null;
+ private GridBagConstraints cellConstraints = null;
+ private boolean emptyCell;
+
+ public CompiledTable(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ tableConstraints = new GridBagConstraints();
+ tableConstraints.gridx = -1;
+ tableConstraints.gridy = -1;
+ tableConstraints.insets = DEFAULT_INSETS;
+ }
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("Table does not accept constraints");
+ }
+ GridBagConstraints c = getCellConstraints();
+ if (c == null) {
+ compiler.reportError("Table tag may only contain row tags");
+ return;
+ }
+ if (!emptyCell) {
+ compiler.reportError("Table cells may only have one child component");
+ }
+ while (rowSpans.size() < c.gridx + c.gridwidth) {
+ rowSpans.add(null);
+ }
+ for (int x = c.gridx; x < c.gridx + c.gridwidth; x++) {
+ rowSpans.set(x, c.gridheight);
+ }
+
+ super.addChild(child, TypeManager.getJavaCode(c), compiler);
+
+ emptyCell = false;
+ }
+
+ public GridBagConstraints getTableConstraints() {
+ return tableConstraints;
+ }
+
+ public GridBagConstraints getRowConstraints() {
+ return rowConstraints;
+ }
+
+ public GridBagConstraints getCellConstraints() {
+ return cellConstraints;
+ }
+
+ public void newRow() {
+ tableConstraints.gridy++;
+ tableConstraints.gridx = -1;
+ rowConstraints = (GridBagConstraints) tableConstraints.clone();
+
+ for (int x = 0; x < rowSpans.size(); x++) {
+ int rowSpan = rowSpans.get(x);
+ if (rowSpan > 0) {
+ rowSpans.set(x, rowSpan - 1);
+ }
+ }
+ }
+
+ public void newCell() {
+ emptyCell = true;
+ rowConstraints.gridx++;
+ while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) > 0) {
+ rowConstraints.gridx++;
+ }
+ cellConstraints = (GridBagConstraints) rowConstraints.clone();
+ }
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledTable(id, getBeanClass(), compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,734 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.validator;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.beans.JAXXBeanInfo;
+import jaxx.compiler.beans.JAXXPropertyDescriptor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidator;
+import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.beans.IntrospectionException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+public class BeanValidatorHandler extends DefaultObjectHandler {
+
+ public static final String TAG = "BeanValidator";
+ public static final String BEAN_ATTRIBUTE = "bean";
+ public static final String BEAN_CLASS_ATTRIBUTE = "beanClass";
+ public static final String BEAN_INITIALIZER_ATTRIBUTE = "beanInitializer";
+ public static final String ERROR_LIST_MODEL_ATTRIBUTE = "errorListModel";
+ public static final String ERROR_TABLE_MODEL_ATTRIBUTE = "errorTableModel";
+ public static final String ERROR_LIST_ATTRIBUTE = "errorList";
+ public static final String ERROR_TABLE_ATTRIBUTE = "errorTable";
+ public static final String ERROR_LIST_MODEL_DEFAULT = "errors";
+ public static final String ERROR_TABLE_MODEL_DEFAULT = "errors2";
+ public static final String ERROR_LIST_DEFAULT = "errorList";
+ public static final String ERROR_TABLE_DEFAULT = "errorTable";
+ public static final String AUTOFIELD_ATTRIBUTE = "autoField";
+ public static final String UI_CLASS_ATTRIBUTE = "uiClass";
+ public static final String STRICT_MODE_ATTRIBUTE = "strictMode";
+ public static final String CONTEXT_NAME_ATTRIBUTE = "contextName";
+ //public static final String SCOPE_ATTRIBUTE = "scope";
+ public static final String PARENT_VALIDATOR_ATTRIBUTE = "parentValidator";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static Log log = LogFactory.getLog(BeanValidatorHandler.class);
+ protected static Map<JAXXCompiler, List<CompiledBeanValidator>> validators = new HashMap<JAXXCompiler, List<CompiledBeanValidator>>();
+ protected static Map<JAXXCompiler, List<String>> validatedComponents = new HashMap<JAXXCompiler, List<String>>();
+
+ public BeanValidatorHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, SwingValidator.class);
+ }
+
+ @Override
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) {
+ return new CompiledBeanValidator(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+ if (!tag.getLocalName().equals(FieldValidatorHandler.TAG)) {
+ compiler.reportError("tag '" + tag.getParentNode().getLocalName() + "' may only contain " + FieldValidatorHandler.TAG + " as children, but found : " + tag.getLocalName());
+ } else {
+ compiler.compileFirstPass(tag);
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+
+ super.compileSecondPass(tag, compiler);
+
+ CompiledBeanValidator info = (CompiledBeanValidator) objectMap.get(tag);
+
+ boolean error = info.addErrorListModel(tag, this, compiler);
+
+ if (!error) {
+ error = info.addErrorList(tag, compiler);
+ }
+
+ if (!error) {
+ error = info.addErrorTableModel(tag, this, compiler);
+ }
+
+ if (!error) {
+ error = info.addErrorTable(tag, compiler);
+ }
+
+ if (!error) {
+ error = info.addUiClass(this, compiler);
+ }
+
+ if (!error) {
+ error = info.addBean(tag, this, compiler);
+ }
+
+ /*if (!error) {
+ error = info.addContextName(this, compiler);
+ }*/
+
+ /*if (!error) {
+ error = info.addScope(this, compiler);
+ }*/
+
+ if (!error) {
+ error = info.addParentValidator(tag, this, compiler);
+ }
+
+ if (error) {
+ log.warn("error were detected in second compile pass of CompiledObject [" + info + "]");
+ }
+
+ // close the compiled object
+ compiler.closeComponent(info);
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ // open the compiled object
+ compiler.openInvisibleComponent(object);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(propertyName + " : " + stringValue + " for " + object);
+ }
+ // delegate to the compiled object with is statefull (but not the tag handler)
+ object.addProperty(propertyName, stringValue);
+ }
+
+ /**
+ * The compiled objet representing a BeanValidator to be generated in JAXXObject
+ *
+ * @author chemit
+ */
+ public static class CompiledBeanValidator extends CompiledObject {
+
+ protected Map<String, String> fields;
+ protected Map<String, String> excludeFields;
+ protected String bean;
+ protected String beanClass;
+ protected String contextName;
+ protected String uiClass;
+ protected String errorListModel;
+ protected String errorList;
+ protected Boolean autoField;
+ protected Boolean strictMode;
+ protected JAXXBeanInfo beanDescriptor;
+ protected String errorTableModel;
+ protected String errorTable;
+ protected String parentValidator;
+
+ public CompiledBeanValidator(String id, ClassDescriptor objectClass, JAXXCompiler compiler) {
+ //TC-20090524 Use the real class descriptor, not the one by default,
+ //TC-20090524 otherwise can not override the validator class while generation
+ //super(id, objectClass, compiler);
+ super(id, getDescriptor(objectClass, compiler), compiler);
+ fields = new TreeMap<String, String>();
+ excludeFields = new TreeMap<String, String>();
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("validator objectClass " + super.getObjectClass());
+ }
+ }
+
+ protected static ClassDescriptor getDescriptor(ClassDescriptor objectClass, JAXXCompiler compiler) {
+ ClassDescriptor result = objectClass;
+ Class<?> validatorClass = compiler.getConfiguration().getValidatorClass();
+ result = ClassDescriptorLoader.getClassDescriptor(validatorClass);
+ return result;
+ }
+
+ public Map<String, String> getFields() {
+ return fields;
+ }
+
+ public Map<String, String> getExcludeFields() {
+ return excludeFields;
+ }
+
+ public void setFields(Map<String, String> fields) {
+ this.fields = fields;
+ }
+
+ public void setExcludeFields(Map<String, String> excludeFields) {
+ this.excludeFields = excludeFields;
+ }
+
+ @Override
+ public void addProperty(String property, String value) {
+
+ if (BEAN_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ bean = value.trim();
+ }
+ return;
+ }
+
+ if (CONTEXT_NAME_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ contextName = value.trim();
+ }
+ return;
+ }
+
+ if (BEAN_CLASS_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ beanClass = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_LIST_MODEL_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorListModel = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_LIST_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorList = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_TABLE_MODEL_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorTableModel = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_TABLE_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorTable = value.trim();
+ }
+ return;
+ }
+
+ if (UI_CLASS_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ uiClass = value.trim();
+ }
+ return;
+ }
+
+ if (AUTOFIELD_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ autoField = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class);
+ }
+ return;
+ }
+
+ if (STRICT_MODE_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ strictMode = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class);
+ }
+ return;
+ }
+
+ if (PARENT_VALIDATOR_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ parentValidator = value.trim();
+ }
+ return;
+ }
+
+ throw new CompilerException("property " + property + " is not allowed on object " + this);
+ }
+
+ public String getBean() {
+ return bean;
+ }
+
+ public String getErrorListModel() {
+ return errorListModel;
+ }
+
+ public boolean getAutoField() {
+ return autoField != null && autoField;
+ }
+
+ public boolean getStrictMode() {
+ return strictMode != null && strictMode;
+ }
+
+ public String getUiClass() {
+ return uiClass;
+ }
+
+ public String getBeanClass() {
+ return beanClass;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public String getParentValidator() {
+ return parentValidator;
+ }
+
+ public JAXXBeanInfo getBeanDescriptor(JAXXCompiler compiler) {
+ if (beanDescriptor == null && foundBean()) {
+
+ String beanClassName = null;
+ try {
+ //TC-20090111 beanClass is mandatory
+ // get the real bean class name (from bean or beanClass)
+ /*if (beanClass != null) {
+ beanClassName = beanClass;
+ } else {
+ beanClassName = compiler.getSymbolTable().getClassTagIds().get(bean);
+ if (beanClassName == null) {
+ compiler.reportError("could not find class of the bean '" + bean + "'");
+ return null;
+ }
+ }*/
+ ClassDescriptor beanClassDescriptor = ClassDescriptorLoader.getClassDescriptor(beanClass);
+ beanDescriptor = DefaultObjectHandler.getJAXXBeanInfo(beanClassDescriptor);
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("could not load class " + beanClassName);
+ } catch (IntrospectionException e) {
+ compiler.reportError("could not load class " + beanClassName);
+ }
+ }
+ return beanDescriptor;
+ }
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ // do nothing
+ compiler.reportError("can not add CompiledObject in the tag '" + TAG + " (only field tags)");
+ }
+
+ public boolean foundBean() {
+ return !(beanClass == null || beanClass.isEmpty());
+ }
+
+ protected boolean addUiClass(BeanValidatorHandler handler, JAXXCompiler compiler) {
+ boolean withError = false;
+ if (uiClass == null && compiler.getConfiguration().getDefaultErrorUI() != null) {
+ uiClass = compiler.getConfiguration().getDefaultErrorUI().getName();
+ }
+ if (uiClass != null) {
+ try {
+ ClassDescriptor uiClazz = ClassDescriptorLoader.getClassDescriptor(uiClass);
+ if (!ClassDescriptorLoader.getClassDescriptor(AbstractBeanValidatorUI.class).isAssignableFrom(uiClazz)) {
+ compiler.reportError("attribute 'ui' :'" + uiClass + "' is not assignable from class " + AbstractBeanValidatorUI.class);
+ withError = true;
+ } else {
+ String code = handler.getSetPropertyCode(getJavaCode(), UI_CLASS_ATTRIBUTE, uiClazz.getName() + ".class", compiler);
+ appendAdditionCode(code);
+ }
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("class not found '" + uiClass + "'");
+ withError = true;
+ }
+ }
+
+ return withError;
+ }
+
+ protected boolean addErrorListModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (errorListModel == null) {
+ // try with the default "errors"
+ if (!compiler.checkReference(tag, ERROR_LIST_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) {
+ return false;
+ }
+ errorListModel = ERROR_LIST_MODEL_DEFAULT;
+ } else {
+ if (errorListModel.startsWith("{") && errorListModel.endsWith("}")) {
+ // this is a script, no check here
+ errorListModel = errorListModel.substring(1, errorListModel.length() - 1).trim();
+ } else if (!compiler.checkReference(tag, errorListModel, true, ERROR_LIST_MODEL_ATTRIBUTE)) {
+ // errorListModel is not defined
+ return true;
+ }
+ }
+
+ String code = handler.getSetPropertyCode(getJavaCode(), ERROR_LIST_MODEL_ATTRIBUTE, errorListModel, compiler);
+ appendAdditionCode(code);
+
+ return false;
+
+ }
+
+ protected boolean addErrorTableModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (errorTableModel == null) {
+ // try with the default "errors"
+ if (!compiler.checkReference(tag, ERROR_TABLE_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) {
+ return false;
+ }
+ errorTableModel = ERROR_TABLE_MODEL_DEFAULT;
+ } else {
+ if (errorTableModel.startsWith("{") && errorTableModel.endsWith("}")) {
+ // this is a script, no check here
+ errorTableModel = errorTableModel.substring(1, errorTableModel.length() - 1).trim();
+ } else if (!compiler.checkReference(tag, errorTableModel, true, ERROR_TABLE_MODEL_ATTRIBUTE)) {
+ // errorListModel is not defined
+ return true;
+ }
+ }
+
+ String code = handler.getSetPropertyCode(getJavaCode(), ERROR_TABLE_MODEL_ATTRIBUTE, errorTableModel, compiler);
+ appendAdditionCode(code);
+
+ return false;
+
+ }
+
+ /*protected boolean addContextName(BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (contextName != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), CONTEXT_NAME_ATTRIBUTE, TypeManager.getJavaCode(contextName), compiler);
+ appendAdditionCode(code);
+ }
+ return false;
+ }*/
+
+ /*protected boolean addScope(BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (scope != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), SCOPE_ATTRIBUTE, TypeManager.getJavaCode(scope), compiler);
+ appendAdditionCode(code);
+ }
+ return false;
+ }*/
+ protected boolean addParentValidator(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (parentValidator != null) {
+ String initializer;
+ if (parentValidator.startsWith("{") && parentValidator.endsWith("}")) {
+
+ // todo : should be able to bind
+ initializer = parentValidator.substring(1, parentValidator.length() - 1);
+
+ } else {
+ // the attribute referes an existing widget
+ if (!compiler.checkReference(tag, parentValidator, true, PARENT_VALIDATOR_ATTRIBUTE)) {
+ // parentValidator is not defined
+ return true;
+ }
+ initializer = parentValidator;
+ }
+ String code = handler.getSetPropertyCode(getJavaCode(), PARENT_VALIDATOR_ATTRIBUTE, initializer, compiler);
+ appendAdditionCode(code);
+ }
+ return false;
+ }
+
+ protected boolean addErrorList(Element tag, JAXXCompiler compiler) {
+
+ if (errorList == null) {
+ // try with the default "errorList"
+ if (!compiler.checkReference(tag, ERROR_LIST_DEFAULT, false, ERROR_LIST_ATTRIBUTE)) {
+ return false;
+ }
+ errorList = ERROR_LIST_DEFAULT;
+ } else {
+ if (!compiler.checkReference(tag, errorList, true, ERROR_LIST_ATTRIBUTE)) {
+ return true;
+ }
+ }
+
+ String code = SwingValidatorUtil.class.getName() + ".registerErrorListMouseListener(" + errorList + ");";
+ appendAdditionCode(code);
+
+ return false;
+ }
+
+ protected boolean addErrorTable(Element tag, JAXXCompiler compiler) {
+
+ if (errorTable == null) {
+ // try with the default "errorList"
+ if (!compiler.checkReference(tag, ERROR_TABLE_DEFAULT, false, ERROR_TABLE_ATTRIBUTE)) {
+ return false;
+ }
+ errorTable = ERROR_TABLE_DEFAULT;
+ } else {
+ if (!compiler.checkReference(tag, errorTable, true, ERROR_TABLE_ATTRIBUTE)) {
+ return true;
+ }
+ }
+
+ String code = SwingValidatorUtil.class.getName() + ".registerErrorTableMouseListener(" + errorTable + ");";
+ appendAdditionCode(code);
+
+ return false;
+ }
+
+ protected boolean addBean(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+
+ if (beanClass == null || beanClass.isEmpty()) {
+ // try to guest beanClass from bean attribute
+ if (bean != null && !bean.isEmpty()) {
+ beanClass = compiler.getSymbolTable().getClassTagIds().get(bean);
+ if (beanClass == null) {
+ compiler.reportError("could not find class of the bean '" + bean + "', and no beanClass was setted");
+ return true;
+ }
+ }
+ }
+ if (beanClass == null) {
+ compiler.reportError("tag '" + tag + "' requires a 'beanClass' attribute, and could not guest it from 'bean' attribute (no bean attribute setted...)");
+ return true;
+ }
+
+ JAXXBeanInfo beanInfo = getBeanDescriptor(compiler);
+ if (beanInfo == null) {
+ compiler.reportError(tag, "could not find descriptor of class " + beanClass);
+ return true;
+ }
+
+ String beanInitializer = null;
+ if (bean != null) {
+
+ if (bean.startsWith("{") && bean.endsWith("}")) {
+
+ // just has an intializer
+ beanInitializer = bean.substring(1, bean.length() - 1);
+ // this is not a real bean, so delete it
+ bean = null;
+ } else {
+
+ if (!compiler.checkReference(tag, bean, true, BEAN_ATTRIBUTE)) {
+ // could not find bean in compiled object
+ return true;
+ }
+
+ if (isBeanUsedByValidator(compiler, bean)) {
+ compiler.reportError("the bean '" + bean + "' is already used in another the validator, can not used it in '" + tag + "'");
+ return true;
+ }
+
+ /*if (beanInitializer != null) {
+ compiler.reportWarning("tag '" + tag + "' found a 'bean' and a 'beanInitializer' attributes, 'beanInitializer' is skipped");
+ }*/
+ beanInitializer = bean;
+ }
+ }
+
+ if (beanInitializer != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), BEAN_ATTRIBUTE, compiler.checkJavaCode(beanInitializer), compiler);
+ appendAdditionCode(code);
+ }
+
+ String beanClassName = beanInfo.getJAXXBeanDescriptor().getClassDescriptor().getName();
+ // contextName must be in constructor to able to init validator with his correct contextName
+ setConstructorParams(beanClassName + ".class, " + TypeManager.getJavaCode(contextName));
+ // add generic type to validator
+ setGenericTypes(new String[]{beanClassName});
+
+ if (getAutoField()) {
+ registerAutoFieldBean(tag, compiler, beanInfo);
+ }
+
+ if (getBeanDescriptor(compiler) != null) {
+
+ // add fieldrepresentation invocations
+ addFieldRepresentations(tag, compiler);
+
+ // register the validator in compiler
+ registerValidator(compiler, this);
+
+ }
+
+ return false;
+ }
+
+ private void registerValidator(JAXXCompiler compiler, CompiledBeanValidator compiledBeanValidator) {
+ List<CompiledBeanValidator> vals = validators.get(compiler);
+ if (vals == null) {
+ vals = new ArrayList<CompiledBeanValidator>();
+ validators.put(compiler, vals);
+ }
+ vals.add(compiledBeanValidator);
+ List<String> ids = validatedComponents.get(compiler);
+ if (ids == null) {
+ ids = new ArrayList<String>();
+ validatedComponents.put(compiler, ids);
+ }
+ ids.addAll(compiledBeanValidator.getFields().values());
+ }
+
+ protected void addFieldRepresentations(Element tag, JAXXCompiler compiler) {
+ for (Entry<String, String> entry : fields.entrySet()) {
+ String propertyName = entry.getKey();
+ String component = entry.getValue();
+ if (!checkBeanProperty(compiler, propertyName)) {
+ // property not find on bean
+ continue;
+ }
+ if (!compiler.checkReference(tag, component, true, null)) {
+ // editor component not find on ui
+ continue;
+ }
+ /*if (compiler.isComponentUsedByValidator(component)) {
+ // component is already used by another validator
+ compiler.reportError("component '" + component + "' is already used by another validator.");
+ continue;
+ }*/
+ String keyCode = TypeManager.getJavaCode(propertyName);
+ appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" + keyCode + ", " + component + ");");
+ }
+ }
+
+ protected void registerAutoFieldBean(Element tag, JAXXCompiler compiler, JAXXBeanInfo beanInfo) {
+ for (JAXXPropertyDescriptor beanProperty : beanInfo.getJAXXPropertyDescriptors()) {
+ String descriptionName = beanProperty.getName();
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("try to bind on bean " + beanInfo.getJAXXBeanDescriptor().getName() + " property " + descriptionName);
+ }
+ if (beanProperty.getWriteMethodDescriptor() == null) {
+ // read-only property
+ continue;
+ }
+ if (fields.containsKey(descriptionName)) {
+ // already defined in field
+ continue;
+ }
+ if (excludeFields.containsKey(descriptionName)) {
+ // exclude field
+ continue;
+ }
+ if (!compiler.checkReference(tag, descriptionName, getStrictMode(), null)) {
+ // no editor component found
+ continue;
+ }
+ // ok add the field mapping
+ registerField(descriptionName, descriptionName, compiler);
+ }
+
+ for (Entry<String, String> entry : excludeFields.entrySet()) {
+ String key = entry.getKey();
+ if (fields.containsKey(key)) {
+ compiler.reportWarning("field '" + key + "' can not be used and excluded at same time ! (field is skipped) for validator " + this);
+ fields.remove(key);
+ }
+ }
+ }
+
+ public void registerField(String id, String component, JAXXCompiler compiler) {
+ if (fields.containsKey(id)) {
+ compiler.reportError("duplicate field '" + id + "' for validator " + this);
+ } else {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("add field <" + id + ":" + component + ">");
+ }
+ fields.put(id, component);
+ }
+ }
+
+ public void registerExcludeField(String id, String component, JAXXCompiler compiler) {
+ if (excludeFields.containsKey(id)) {
+ compiler.reportError("duplicate field '" + id + "' for validator " + this);
+ } else {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("add excludeField <" + id + ":" + component + ">");
+ }
+ excludeFields.put(id, component);
+ }
+ }
+
+ protected boolean checkBeanProperty(JAXXCompiler compiler, String propertyName) {
+
+ for (JAXXPropertyDescriptor beanProperty : getBeanDescriptor(compiler).getJAXXPropertyDescriptors()) {
+ if (beanProperty.getName().equals(propertyName)) {
+ if (beanProperty.getWriteMethodDescriptor() == null) {
+ // read-onlyproperty
+ compiler.reportError("could not bind the readonly property '" + propertyName + "' on bean [" + getBean() + "] ");
+ return false;
+ }
+ return true;
+ }
+ }
+ compiler.reportError("could not find the property '" + propertyName + "' on bean [" + getBean() + "] ");
+ return false;
+ }
+ }
+
+ /**
+ * Test if a given bean is attached to a validator.
+ *
+ * @param compiler current compiler to use
+ * @param beanId the bean to test
+ * @return <code>true</code> if the given bean is attached to a validator, <code>false</code> otherwise
+ */
+ public static boolean isBeanUsedByValidator(JAXXCompiler compiler, String beanId) {
+ List<CompiledBeanValidator> beanValidatorList = validators.get(compiler);
+ if (beanValidatorList != null) {
+ for (CompiledBeanValidator validator : beanValidatorList) {
+ if (beanId.equals(validator.getBean())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param compiler compiler to use
+ * @return <code>true</code> if some validators were detected, <code>false</code> otherwise
+ */
+ public static boolean hasValidator(JAXXCompiler compiler) {
+ List<CompiledBeanValidator> beanValidatorList = validators.get(compiler);
+ return beanValidatorList != null && !beanValidatorList.isEmpty();
+ }
+
+ /**
+ * Test if a given CompiledObject is attached to a validator.
+ *
+ * @param compiler compiler to use
+ * @param componentId the compiled object to test
+ * @return <code>true</code> if the given compiled object is attached to a validator, <code>false</code> otherwise
+ */
+ public static boolean isComponentUsedByValidator(JAXXCompiler compiler, String componentId) {
+ List<String> ids = validatedComponents.get(compiler);
+ return ids != null && ids.contains(componentId);
+ }
+
+ public static List<CompiledBeanValidator> getValidators(JAXXCompiler compiler) {
+ return validators.get(compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.validator;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+public class ExcludeFieldValidatorHandler implements TagHandler {
+
+ public static final String TAG = "excludeField";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String COMPONENT_ATTRIBUTE = "component";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ExcludeFieldValidatorHandler.class);
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+ //todo check there is no child
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.debug(tag);
+ }
+
+ if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag);
+ return;
+ }
+
+ CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent();
+ if (!info.getAutoField()) {
+ compiler.reportError(TAG + " tag can not be used without an 'autoField' validator : " + tag);
+ return;
+ }
+ String name = tag.getAttribute(NAME_ATTRIBUTE);
+ String component = tag.getAttribute(COMPONENT_ATTRIBUTE);
+ if (name == null || name.trim().isEmpty()) {
+ compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
+ return;
+ }
+ name = name.trim();
+ if (component == null || component.trim().isEmpty()) {
+ // try to use the name as component
+ if (!compiler.checkReference(tag, name, false, name)) {
+ compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found");
+ return;
+ }
+ component = name;
+ }
+ component = component.trim();
+
+ // check component is not already used by this compiled object
+ if (info.getFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator");
+ return;
+ }
+ if (info.getExcludeFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator");
+ return;
+ }
+ // check component exist (again perharps, but let the error knows exactly which tag failed...)
+ if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) {
+ // add a field
+ info.registerField(name, component, compiler);
+ }
+
+
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.validator;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+public class FieldValidatorHandler implements TagHandler {
+
+ public static final String TAG = "field";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String COMPONENT_ATTRIBUTE = "component";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(FieldValidatorHandler.class);
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+ //todo check there is no child
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+
+ if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag);
+ return;
+ }
+
+ CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent();
+
+ String name = tag.getAttribute(NAME_ATTRIBUTE);
+ String component = tag.getAttribute(COMPONENT_ATTRIBUTE);
+ if (name == null || name.trim().isEmpty()) {
+ compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
+ return;
+ }
+ name = name.trim();
+ if (component == null || component.trim().isEmpty()) {
+ // try to use the name as component
+ if (!compiler.checkReference(tag, name, false, name)) {
+ compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found");
+ return;
+ }
+ component = name;
+ }
+ component = component.trim();
+
+ // check component is not already used by this compiled object
+ if (info.getFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator");
+ return;
+ }
+ // check component exist (again perharps, but let the error knows exactly which tag failed...)
+ if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) {
+ // add a field
+ info.registerField(name, component, compiler);
+ }
+
+
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,117 @@
+package jaxx.compiler.tools;
+
+import jaxx.compiler.tags.*;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.beans.JAXXPropertyDescriptor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+/** Generates information about a tag for use on the jaxxframework.org web site. */
+public class PrintTagInfo {
+ /**
+ * Displays information about the class name in arg[0].
+ *
+ * @param arg command-line arguments
+ * @throws Exception if an error occurs
+ */
+ public static void main(String[] arg) throws Exception {
+ if (arg.length < 1) {
+ throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate");
+ }
+ String firstarg = arg[0];
+ boolean toFile = false;
+ BufferedWriter w;
+ if (firstarg.startsWith("file:")) {
+ w = new BufferedWriter(new FileWriter(firstarg.substring(5)));
+ toFile = true;
+ } else {
+ w = new BufferedWriter(new OutputStreamWriter(System.out));
+ }
+
+ try {
+ JAXXCompilerLaunchor.loadLibraries(false);
+ for (int i = toFile ? 1 : 0; i < arg.length; i++) {
+ String className = arg[i];
+ treateClass(w, className);
+ }
+ } finally {
+ w.flush();
+ w.close();
+ }
+
+ }
+
+ protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException {
+
+ ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className);
+ DefaultObjectHandler handler = TagManager.getTagHandler(beanClass);
+
+ DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass());
+
+ // dump all bean properties
+ w.append("Properties in ").append(String.valueOf(beanClass));
+ w.newLine();
+ JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
+ JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
+ for (JAXXPropertyDescriptor property : properties) {
+ if (property.getWriteMethodDescriptor() == null) {
+ continue;
+ }
+
+ boolean found = false;
+ String name = property.getName();
+ for (JAXXPropertyDescriptor superProperty : superProperties) {
+ if (superProperty.getName().equals(name)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (property.getPropertyType() == null) {
+ System.err.println(name + " has null type");
+ } else {
+ w.append("{{EquivalentAttribute|");
+ w.append(name);
+ w.append("|");
+ w.append(className.replace('.', '/'));
+ w.append("|set");
+ w.append(org.apache.commons.lang.StringUtils.capitalize(name));
+ w.append("|");
+ w.append(JAXXCompiler.getCanonicalName(property.getPropertyType()));
+ w.append("}}");
+ w.append("|-");
+ w.newLine();
+ }
+ }
+ }
+
+ w.newLine();
+ w.newLine();
+
+ // dump all bound methods
+ dumpMethods(w, beanClass, handler);
+ }
+
+ protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException {
+ MethodDescriptor[] methods = beanClass.getMethodDescriptors();
+ w.append("Bound methods in ").append(String.valueOf(beanClass));
+ w.newLine();
+ for (MethodDescriptor method : methods) {
+ try {
+ if (handler.isMemberBound(method.getName())) {
+ w.append("* <tt>").append(method.getName()).append("()</tt>");
+ w.newLine();
+ }
+ } catch (Throwable e) {
+ // ignore ?
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/AbstractContextNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,19 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractContextNode implements ContextNode {
+ private List<ContextNode> arguments = new ArrayList<ContextNode>();
+
+
+ @Override
+ public void addArgument(ContextNode node) {
+ arguments.add(node);
+ }
+
+ @Override
+ public ContextNode[] getArguments() {
+ return arguments.toArray(new ContextNode[arguments.size()]);
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/CapturedObject.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,146 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class CapturedObject extends AbstractContextNode {
+ private String className;
+ private ObjectHandler handler;
+ /** Maps children to their constraints. */
+ private Map<CapturedObject, ContextNode> children = new LinkedHashMap<CapturedObject, ContextNode>();
+ private CapturedObject parent;
+ private Map<String, String> properties = new LinkedHashMap<String, String>();
+ private Map<String, Object> additionalData = new HashMap<String, Object>();
+ private StringBuffer innerXML = new StringBuffer();
+ private StringBuffer script = new StringBuffer();
+ private boolean inlineable = true;
+ private JAXXCapture capture;
+
+ public CapturedObject(ObjectHandler handler, String className, JAXXCapture capture) {
+ this.handler = handler;
+ this.className = className;
+ this.capture = capture;
+ }
+
+
+ public ObjectHandler getObjectHandler() {
+ return handler;
+ }
+
+
+ public void addChild(CapturedObject child, ContextNode constraints) {
+ children.put(child, constraints);
+ child.setParent(this);
+ }
+
+
+ public CapturedObject[] getChildren() {
+ return children.keySet().toArray(new CapturedObject[children.size()]);
+ }
+
+
+ public CapturedObject getParent() {
+ return parent;
+ }
+
+
+ public void setParent(CapturedObject parent) {
+ this.parent = parent;
+ }
+
+
+ public ContextNode getConstraints(CapturedObject child) {
+ return children.get(child);
+ }
+
+
+ public String getClassName() {
+ return className;
+ }
+
+
+ public String getProperty(String key) {
+ return properties.get(key);
+ }
+
+
+ public void setProperty(String key, String value) {
+ properties.put(key, value);
+ }
+
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+
+ public Object getAdditionalData(String key) {
+ return additionalData.get(key);
+ }
+
+
+ public void setAdditionalData(String key, Object value) {
+ additionalData.put(key, value);
+ }
+
+
+ public Map<String, Object> getAdditionalData() {
+ return additionalData;
+ }
+
+
+ public void setInlineable(boolean inlineable) {
+ this.inlineable = inlineable;
+ }
+
+
+ public boolean isInlineable() {
+ try {
+ return script.length() == 0 && !Component.class.isAssignableFrom(Class.forName(className, true, capture.getClassLoader())) && inlineable;
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public void appendInnerXML(String xml) {
+ if (this.innerXML.length() > 0) {
+ this.innerXML.append(JAXXCompiler.getLineSeparator());
+ }
+ this.innerXML.append(xml);
+ }
+
+
+ public String getInnerXML() {
+ return innerXML.toString();
+ }
+
+
+ public void appendScriptCode(String script) {
+ if (this.script.length() > 0) {
+ this.script.append(JAXXCompiler.getLineSeparator());
+ }
+ this.script.append(script);
+ }
+
+
+ public String getScriptCode() {
+ return script.toString();
+ }
+
+
+ public String getXML(JAXXCapture capture) {
+ return getObjectHandler().getXML(this, capture);
+ }
+
+ @Override
+ public String toString() {
+ return "CapturedObject[" + getProperty("id") + ", " + className + "]";
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/ContextNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,8 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public interface ContextNode {
+
+ void addArgument(ContextNode node);
+
+ ContextNode[] getArguments();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/JAXXCapture.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,378 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+import jaxx.compiler.ClassMap;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tools.jaxxcapture.handlers.JTabbedPaneHandler;
+import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler;
+import jaxx.compiler.tools.jaxxcapture.handlers.TableHandler;
+import jaxx.compiler.types.TypeManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
+
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JTabbedPane;
+import javax.swing.JWindow;
+import javax.swing.SwingUtilities;
+import java.awt.AWTEvent;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.EventQueue;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.MouseEvent;
+import java.beans.XMLEncoder;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class JAXXCapture {
+
+ private static ClassMap<Object> objectHandlers = new ClassMap<Object>();
+
+ static {
+ //TODO make a serviceLoader mecanism to allow inter-module loading
+ objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(Object.class), new ObjectHandler());
+ objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), new JTabbedPaneHandler());
+ try {
+ objectHandlers.put(ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Table"), new TableHandler());
+ } catch (ClassNotFoundException e) {
+ System.err.println(e);
+ }
+ }
+ private Map<String, Object> sourceObjects = new HashMap<String, Object>();
+ private Map<String, CapturedObject> capturedObjects = new HashMap<String, CapturedObject>();
+ private ClassLoader classLoader;
+ private int count;
+
+ private static class CaptureEventQueue extends EventQueue {
+
+ private ClassLoader classLoader;
+
+ private CaptureEventQueue(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ @Override
+ public void dispatchEvent(AWTEvent event) {
+ if (event.getID() == MouseEvent.MOUSE_PRESSED && ((MouseEvent) event).isControlDown()) {
+ Component target = ((MouseEvent) event).getComponent();
+ if (!(target instanceof Window)) {
+ target = SwingUtilities.getWindowAncestor(target);
+ }
+ if (target instanceof JFrame) {
+ target = ((JFrame) target).getContentPane();
+ } else if (target instanceof JDialog) {
+ target = ((JDialog) target).getContentPane();
+ }
+ if (target instanceof JWindow) {
+ target = ((JWindow) target).getContentPane();
+ }
+ if (target != null) {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ JAXXCapture capture = new JAXXCapture(classLoader);
+ capture.applyNames(target);
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ XMLEncoder encoder = new XMLEncoder(buffer);
+ encoder.writeObject(target);
+ encoder.close();
+ try {
+ System.err.println(new String(buffer.toByteArray()));
+ System.out.println(capture.convertToJAXX(new ByteArrayInputStream(buffer.toByteArray())));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ super.dispatchEvent(event);
+ }
+ }
+
+ private JAXXCapture(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public Map<String, CapturedObject> getCapturedObjects() {
+ return capturedObjects;
+ }
+
+ private void applyNames(Component target) {
+ String name = target.getName();
+ if (name == null || sourceObjects.containsKey(name) || !CompiledObject.isValidID(name)) {
+ do {
+ name = "Object" + ++count;
+ } while (sourceObjects.containsKey(name));
+ }
+ target.setName(name);
+ assert !sourceObjects.containsKey(name) : "ID " + name + " is already registered";
+ sourceObjects.put(name, target);
+
+ if (target instanceof Container) {
+ Container container = (Container) target;
+ for (int i = 0; i < container.getComponentCount(); i++) {
+ applyNames(container.getComponent(i));
+ }
+ }
+ }
+
+ public static String getText(Element tag) { // NOT a safe general-purpose implementation!
+ return ((Text) tag.getChildNodes().item(0)).getData();
+ }
+
+ private String getArgumentsCode(ContextNode[] arguments) {
+ StringBuffer result = new StringBuffer();
+ result.append('(');
+ for (int i = 0; i < arguments.length; i++) {
+ if (i != 0) {
+ result.append(", ");
+ }
+ result.append(getJavaCode(arguments[i]));
+ }
+ result.append(')');
+ return result.toString();
+ }
+
+ public String getJavaCode(ContextNode node) {
+ StringBuffer result = new StringBuffer();
+ if (node instanceof PropertyNode) {
+ ContextNode[] arguments = node.getArguments();
+ result.append(arguments.length == 0 ? "get" : "set");
+ result.append(org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty()));
+ result.append(getArgumentsCode(arguments));
+ } else if (node instanceof MethodNode) {
+ result.append((((MethodNode) node).getMethodName()));
+ result.append(getArgumentsCode(node.getArguments()));
+ } else if (node instanceof CapturedObject) {
+ CapturedObject object = (CapturedObject) node;
+ if (object.isInlineable()) {
+ result.append("new ");
+ result.append(object.getClassName());
+ result.append(getArgumentsCode(node.getArguments()));
+ } else {
+ String id = object.getProperty("id");
+ assert id != null;
+ result.append(id);
+ }
+ } else if (node instanceof ValueNode) {
+ result.append(TypeManager.getJavaCode(((ValueNode) node).getValue()));
+ } else if (node instanceof LiteralNode) {
+ result.append(((LiteralNode) node).getJavaCode());
+ } else {
+ throw new IllegalArgumentException("unrecognized node type: " + node);
+ }
+ return result.toString();
+ }
+
+ // returns the best matching method for the specified argument types
+ private static Method getMethod(Class<?> target, String methodName, Class<?>[] arguments) {
+ try {
+ // use the package-private class java.beans.ReflectionUtils to resolve the method. This isn't 100% safe, but it's better than
+ // having to rewrite the resolution myself.
+ Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils");
+ Method getMethod = reflectionUtils.getDeclaredMethod("getMethod", new Class<?>[]{Class.class, String.class, Class[].class});
+ getMethod.setAccessible(true);
+ return (Method) getMethod.invoke(null, target, methodName, arguments);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // returns the best matching constructor for the specified argument types
+ private static Constructor<?> getConstructor(Class<?> target, Class<?>[] arguments) {
+ try {
+ // use the package-private class java.beans.ReflectionUtils to resolve the constructor. This isn't 100% safe, but it's better than
+ // having to rewrite the resolution myself.
+ Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils");
+ Method getConstructor = reflectionUtils.getDeclaredMethod("getConstructor", new Class<?>[]{Class.class, Class[].class});
+ getConstructor.setAccessible(true);
+ return (Constructor<?>) getConstructor.invoke(null, target, arguments);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Object createInstance(CapturedObject object) {
+ try {
+ ContextNode[] argumentNodes = object.getArguments();
+ Object[] arguments = new Object[argumentNodes.length];
+ Class<?>[] argumentTypes = new Class<?>[argumentNodes.length];
+ for (int j = 0; j < argumentNodes.length; j++) {
+ if (argumentNodes[j] instanceof ValueNode) {
+ arguments[j] = ((ValueNode) argumentNodes[j]).getValue();
+ argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null;
+ } else if (argumentNodes[j] instanceof CapturedObject) {
+ arguments[j] = createInstance((CapturedObject) argumentNodes[j]);
+ argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null;
+ }
+ }
+ Constructor<?> constructor = getConstructor(Class.forName(object.getClassName(), true, classLoader), argumentTypes);
+ return constructor.newInstance(arguments);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getJavaCode(Stack/*<ContextNode>*/ context) {
+ CapturedObject contextCapturedObject = (CapturedObject) context.get(0);
+ StringBuffer result = new StringBuffer();
+ int start = 1;
+ for (int i = context.size() - 1; i > 1; i--) {
+ if (context.get(i) instanceof CapturedObject) {
+ start = i;
+ contextCapturedObject = (CapturedObject) context.get(i);
+ break;
+ }
+ }
+ Object contextObject = sourceObjects.get(contextCapturedObject.getProperty("id"));
+ Class<?> contextClass = contextObject != null ? contextObject.getClass() : null;
+
+ for (int i = start; i < context.size(); i++) {
+ ContextNode node = (ContextNode) context.get(i);
+ if (contextObject != null && (node instanceof MethodNode || node instanceof PropertyNode)) {
+ // need to follow the call chain so we can insert typecasts as necessary
+ try {
+ String methodName;
+ ContextNode[] argumentNodes = node.getArguments();
+ if (node instanceof MethodNode) {
+ methodName = ((MethodNode) node).getMethodName();
+ } else {
+ methodName = (argumentNodes.length == 0 ? "get" : "set") + org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty());
+ }
+ Object[] arguments = new Object[argumentNodes.length];
+ Class<?>[] argumentTypes = new Class<?>[argumentNodes.length];
+ for (int j = 0; j < argumentNodes.length; j++) {
+ if (argumentNodes[j] instanceof ValueNode) {
+ arguments[j] = ((ValueNode) argumentNodes[j]).getValue();
+ argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null;
+ } else if (argumentNodes[j] instanceof CapturedObject) {
+ arguments[j] = createInstance((CapturedObject) argumentNodes[j]);
+ argumentTypes[j] = arguments[j].getClass();
+ } else if (argumentNodes[j] instanceof LiteralNode) {
+ arguments[j] = ((LiteralNode) argumentNodes[j]).getValue();
+ argumentTypes[j] = arguments[j].getClass();
+ } else {
+ throw new IllegalArgumentException("unsupported argument type: " + argumentNodes[j]);
+ }
+ }
+
+ Method method = getMethod(contextClass, methodName, argumentTypes);
+ if (method == null) {
+ // could not find method in contextClass, must be defined in a subclass -- insert a typecast
+ result.insert(0, "((" + getOutputName(contextObject.getClass()) + ") ");
+ result.append(')');
+ method = getMethod(contextObject.getClass(), methodName, argumentTypes);
+ }
+ if (method == null) {
+ throw new RuntimeException("could not find method " + methodName + Arrays.asList(argumentTypes) + " in " + contextObject.getClass() + " (context: " + context + ")");
+ }
+ contextObject = method.invoke(contextObject, arguments);
+ contextClass = method.getReturnType();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (i > start) {
+ result.append('.');
+ }
+
+ result.append(getJavaCode(node));
+ }
+ return result + ";";
+ }
+
+ private String getOutputName(Class<?> c) {
+ return c.getName();
+ }
+
+ public CapturedObject processObject(Element objectTag, Stack<ContextNode> context) {
+ String className = objectTag.getAttribute("class");
+ ObjectHandler handler;
+ if (className.length() > 0) {
+ try {
+ ClassDescriptor descriptor = ClassDescriptorLoader.getClassDescriptor(className, classLoader);
+ handler = (ObjectHandler) objectHandlers.get(descriptor);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ handler = (ObjectHandler) objectHandlers.get(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ }
+
+ return handler.processObject(objectTag, context, this);
+ }
+
+ private synchronized String convertToJAXX(InputStream beansXML) throws IOException {
+ try {
+ Document document = JAXXCompiler.parseDocument(beansXML);
+ Element rootElement = document.getDocumentElement();
+ NodeList nodes = rootElement.getChildNodes();
+ Stack<ContextNode> context = new Stack<ContextNode>();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node child = nodes.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) child;
+ if (!element.getTagName().equals("object")) {
+ throw new Error("expected tag 'object', found '" + element.getTagName() + "'");
+ }
+ CapturedObject root = processObject(element, context);
+ for (CapturedObject object : capturedObjects.values()) { // add all orphan objects to the root, so any non-inlineable ones have their XML created
+ if (object.getParent() == null && object != root) {
+ root.addChild(object, null);
+ }
+ }
+ return root.getXML(this);
+ }
+ }
+ return null;
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } finally {
+ reset();
+ }
+ }
+
+ private void reset() {
+ sourceObjects.clear();
+ capturedObjects.clear();
+ count = 0;
+ }
+
+ public static void main(String[] arg) throws Exception {
+ File file = new File(arg[0]);
+ JarFile jarFile = new JarFile(file);
+ ClassLoader classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()});
+ Thread.currentThread().setContextClassLoader(classLoader);
+ EventQueue systemQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ systemQueue.push(new CaptureEventQueue(classLoader));
+ Manifest mf = jarFile.getManifest();
+ String mainClassName = mf.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
+ Class<?> mainClass = Class.forName(mainClassName, true, classLoader);
+ Method main = mainClass.getMethod("main", String[].class);
+ main.invoke(null, new Object[]{new String[0]});
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/LiteralNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,20 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class LiteralNode extends AbstractContextNode {
+ private String javaCode;
+ private Object value;
+
+ public LiteralNode(String javaCode, Object value) {
+ this.javaCode = javaCode;
+ this.value = value;
+ }
+
+
+ public String getJavaCode() {
+ return javaCode;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/MethodNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,19 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class MethodNode extends AbstractContextNode {
+ private String methodName;
+
+ public MethodNode(String methodName) {
+ this.methodName = methodName;
+ }
+
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ @Override
+ public String toString() {
+ return "Method[" + methodName + ", " + java.util.Arrays.asList(getArguments()) + "]";
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/PropertyNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,19 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class PropertyNode extends AbstractContextNode {
+ private String property;
+
+ public PropertyNode(String property) {
+ this.property = property;
+ }
+
+
+ public String getProperty() {
+ return property;
+ }
+
+
+ public String toString() {
+ return "Property[" + property + ", " + java.util.Arrays.asList(getArguments()) + "]";
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/ValueNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,14 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class ValueNode extends AbstractContextNode {
+ private Object value;
+
+ public ValueNode(Object value) {
+ this.value = value;
+ }
+
+
+ public Object getValue() {
+ return value;
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/handlers/JTabbedPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+package jaxx.compiler.tools.jaxxcapture.handlers;
+
+import jaxx.compiler.tools.jaxxcapture.ContextNode;
+import jaxx.compiler.tools.jaxxcapture.JAXXCapture;
+import jaxx.compiler.tools.jaxxcapture.MethodNode;
+import org.w3c.dom.Element;
+
+import java.util.Arrays;
+import java.util.Stack;
+
+public class JTabbedPaneHandler extends ObjectHandler {
+
+ @Override
+ protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ String methodName = tag.getAttribute("method");
+ if (methodName.equals("addTab")) {
+ MethodNode addTab = new MethodNode(methodName);
+ context.push(addTab);
+ processChildren(tag, context, capture);
+ context.pop();
+ System.err.println(Arrays.asList(addTab.getArguments()));
+ } else {
+ super.evaluateMethod(tag, context, capture);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/handlers/ObjectHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,323 @@
+package jaxx.compiler.tools.jaxxcapture.handlers;
+
+import jaxx.compiler.JavaFile;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.tools.jaxxcapture.CapturedObject;
+import jaxx.compiler.tools.jaxxcapture.ContextNode;
+import jaxx.compiler.tools.jaxxcapture.JAXXCapture;
+import jaxx.compiler.tools.jaxxcapture.LiteralNode;
+import jaxx.compiler.tools.jaxxcapture.MethodNode;
+import jaxx.compiler.tools.jaxxcapture.PropertyNode;
+import jaxx.compiler.tools.jaxxcapture.ValueNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.awt.Container;
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Stack;
+
+public class ObjectHandler {
+ private static int count;
+
+ protected CapturedObject createCapturedObject(String className, JAXXCapture capture) {
+ return new CapturedObject(this, className, capture);
+ }
+
+
+ // returns true if the tag has any "void" children
+ protected boolean processChildren(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ boolean result = false;
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element innerTag = (Element) child;
+ if (innerTag.getTagName().equals("void")) {
+ result = true;
+ }
+ evaluate(innerTag, context, capture);
+ }
+ }
+ return result;
+ }
+
+
+ protected void evaluateProperty(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ // determine containing object
+ CapturedObject contextObject = null;
+ for (int i = context.size() - 1; i >= 0; i--) {
+ if (context.get(i) instanceof CapturedObject) {
+ contextObject = (CapturedObject) context.get(i);
+ break;
+ }
+ }
+ assert contextObject != null;
+
+ String property = tag.getAttribute("property");
+ if (!property.equals("actionCommand")) { // filter out actionCommand due to screwiness in XMLEncoder's handling of it
+ Object current = context.peek();
+ PropertyNode newContext = new PropertyNode(property);
+ context.push(newContext);
+ boolean voidChildren = processChildren(tag, context, capture);
+
+ ContextNode[] arguments = newContext.getArguments();
+ if (arguments.length == 1) {
+ if (current instanceof CapturedObject && arguments[0] instanceof ValueNode) // simple property assignment
+ {
+ ((CapturedObject) current).setProperty(property, dataBindingEncode(String.valueOf(((ValueNode) arguments[0]).getValue())));
+ } else if (current instanceof CapturedObject && arguments[0] instanceof CapturedObject && ((CapturedObject) arguments[0]).isInlineable()) // simple data binding
+ {
+ ((CapturedObject) current).setProperty(property, "{" + capture.getJavaCode(arguments[0]) + "}");
+ } else {
+ contextObject.setInlineable(false);
+ contextObject.appendScriptCode(capture.getJavaCode(context));
+ }
+ } else if (!voidChildren) {
+ contextObject.setInlineable(false);
+ contextObject.appendScriptCode(capture.getJavaCode(context));
+ }
+
+ assert context.peek() == newContext;
+ context.pop();
+ }
+ }
+
+
+ protected void evaluateAdd(CapturedObject contextObject, CapturedObject child, ContextNode constraints) {
+ contextObject.addChild(child, constraints);
+ }
+
+
+ protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ // determine containing object
+ CapturedObject contextObject = null;
+ for (int i = context.size() - 1; i >= 0; i--) {
+ if (context.get(i) instanceof CapturedObject) {
+ contextObject = (CapturedObject) context.get(i);
+ break;
+ }
+ }
+ assert contextObject != null;
+
+ try {
+ String methodName = tag.getAttribute("method");
+ MethodNode newContext = new MethodNode(methodName);
+ context.push(newContext);
+ boolean voidChildren = processChildren(tag, context, capture);
+ boolean add = false;
+
+ ContextNode[] arguments = newContext.getArguments();
+ if (methodName.equals("add") && arguments.length >= 1 && arguments[0] instanceof CapturedObject) {
+ Class<?> contextClass = Class.forName(contextObject.getClassName(), true, capture.getClassLoader());
+ if (Container.class.isAssignableFrom(contextClass)) {
+ add = true;
+ evaluateAdd(contextObject, (CapturedObject) arguments[0], null);
+ }
+ }
+
+ if (!voidChildren && !add) {
+ contextObject.appendScriptCode(capture.getJavaCode(context));
+ }
+
+ assert context.peek() == newContext;
+ context.pop();
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ protected void evaluate(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ String tagName = tag.getTagName();
+ if (tagName.equals("object")) {
+ String fieldName = tag.getAttribute("field");
+ ContextNode currentNode = context.peek();
+ if (fieldName.length() > 0) {
+ try {
+ String className = tag.getAttribute("class");
+ Field field = Class.forName(className, true, capture.getClassLoader()).getField(fieldName);
+ Object value = field.get(null);
+ currentNode.addArgument(new LiteralNode(className + "." + fieldName, value));
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ currentNode.addArgument(capture.processObject(tag, context));
+ }
+ } else if (tagName.equals("void")) {
+ String property = tag.getAttribute("property");
+ if (property.length() > 0) {
+ evaluateProperty(tag, context, capture);
+ } else {
+ evaluateMethod(tag, context, capture);
+ }
+ } else if (tagName.equals("string")) {
+ context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag)));
+ } else if (tagName.equals("boolean")) {
+ context.peek().addArgument(new ValueNode(Boolean.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("char")) {
+ context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag).charAt(0)));
+ } else if (tagName.equals("short")) {
+ context.peek().addArgument(new ValueNode(Short.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("int")) {
+ context.peek().addArgument(new ValueNode(Integer.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("long")) {
+ context.peek().addArgument(new ValueNode(Long.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("float")) {
+ context.peek().addArgument(new ValueNode(Float.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("double")) {
+ context.peek().addArgument(new ValueNode(Double.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("null")) {
+ context.peek().addArgument(new ValueNode(null));
+ } else {
+ System.err.println("unsupported tag: " + tag.getTagName());
+ }
+ }
+
+
+ private static String dataBindingEncode(String value) {
+ return value.replaceAll("\\{", "\\\\{").replaceAll("\\}", "\\\\}");
+ }
+
+
+ public CapturedObject processObject(Element objectTag, Stack<ContextNode> context, JAXXCapture capture) {
+ String className = objectTag.getAttribute("class");
+ if (className.length() > 0) {
+ CapturedObject capturedObject = createCapturedObject(className, capture);
+ context.push(capturedObject);
+ NodeList children = objectTag.getChildNodes();
+ String id = objectTag.getAttribute("id");
+ if (id.length() == 0 || capture.getCapturedObjects().containsKey(id)) {
+ id = "Auto" + ++count;
+ }
+ assert !capture.getCapturedObjects().containsKey(id);
+ capture.getCapturedObjects().put(id, capturedObject);
+ capturedObject.setProperty("id", id);
+ // process object's name before anything else
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) child;
+ if (element.getTagName().equals("void") && element.getAttribute("property").equals("name")) {
+ evaluate(element, context, capture);
+ String name = capturedObject.getProperty("name");
+ if (name != null && !capture.getCapturedObjects().containsKey(name)) {
+ capture.getCapturedObjects().put(name, capturedObject);
+ capturedObject.setProperty("id", name);
+ capturedObject.getProperties().remove("name");
+ }
+ }
+ }
+ }
+ // process remaining children
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) child;
+ if (!element.getTagName().equals("void") || !element.getAttribute("property").equals("name")) {
+ evaluate(element, context, capture);
+ }
+ }
+ }
+ assert context.peek() == capturedObject;
+ context.pop();
+
+ return capturedObject;
+ } else {
+ CapturedObject result = capture.getCapturedObjects().get(objectTag.getAttribute("idref"));
+ if (result == null) {
+ throw new RuntimeException("Internal error: could not find tag with id " + objectTag.getAttribute("idref"));
+ }
+ result.setInlineable(false); // we have at least two references to it, and so can't inline it
+ return result;
+ }
+ }
+
+
+ private static String xmlEncode(String src) {
+ return src.replaceAll("'", "&").replaceAll("<", "<");
+ }
+
+
+ public String getXML(CapturedObject object, JAXXCapture capture) {
+ StringBuffer result = new StringBuffer();
+ result.append('<');
+ String className = object.getClassName();
+ if (className.startsWith("javax.swing.")) {
+ className = className.substring("javax.swing.".length());
+ }
+ result.append(className);
+ Map<String, String> properties = object.getProperties();
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ result.append(' ');
+ result.append(e.getKey());
+ result.append("='");
+ result.append(xmlEncode(e.getValue()));
+ result.append('\'');
+ }
+ ContextNode[] arguments = object.getArguments();
+ if (arguments != null && arguments.length > 0) {
+ result.append(" constructorParams='");
+ for (int j = 0; j < arguments.length; j++) {
+ if (j != 0) {
+ result.append(", ");
+ }
+ result.append(capture.getJavaCode(arguments[j]));
+ }
+ result.append('\'');
+ }
+ boolean tagClosed = false;
+
+ String children = getChildXML(object, capture);
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+ if (children != null && children.length() > 0) {
+ if (!tagClosed) {
+ tagClosed = true;
+ result.append('>');
+ result.append(lineSeparator);
+ }
+ result.append(children);
+ }
+
+ String script = object.getScriptCode();
+ if (script != null && script.length() > 0) {
+ if (!tagClosed) {
+ tagClosed = true;
+ result.append('>');
+ result.append(lineSeparator);
+ }
+ result.append(" <script>");
+ result.append(lineSeparator);
+ result.append(JavaFile.indent(script, 4, false, lineSeparator));
+ result.append(lineSeparator);
+ result.append(" </script>");
+ result.append(lineSeparator);
+ }
+ if (tagClosed) {
+ result.append("</");
+ result.append(className);
+ result.append('>');
+ } else {
+ result.append("/>");
+ }
+ return result.toString();
+ }
+
+
+ protected String getChildXML(CapturedObject object, JAXXCapture capture) {
+ StringBuffer result = new StringBuffer();
+ CapturedObject[] children = object.getChildren();
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+ for (CapturedObject aChildren : children) {
+ if (!aChildren.isInlineable()) {
+ result.append(JavaFile.indent(aChildren.getXML(capture), 2, false, lineSeparator));
+ result.append(lineSeparator);
+ }
+ }
+ return result.toString();
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/handlers/TableHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,14 @@
+package jaxx.compiler.tools.jaxxcapture.handlers;
+
+import jaxx.compiler.tools.jaxxcapture.CapturedObject;
+import jaxx.compiler.tools.jaxxcapture.JAXXCapture;
+
+public class TableHandler extends ObjectHandler {
+
+ @Override
+ protected CapturedObject createCapturedObject(String className, JAXXCapture capture) {
+ CapturedObject result = new CapturedObject(this, "javax.swing.JPanel", capture);
+ result.setProperty("layout", "{new GridBagLayout()}");
+ return result;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/ColorConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.awt.Color;
+import java.lang.reflect.Field;
+
+public class ColorConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ Color color = (Color) object;
+ return "new Color(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type != Color.class) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ if (string.length() == 7 && string.charAt(0) == '#') {
+ return new Color(Integer.parseInt(string.substring(1), 16));
+ }
+ try {
+ Field color = Color.class.getField(string);
+ return color.get(null);
+ } catch (NoSuchFieldException e) {
+ throw new IllegalArgumentException("colors must be of the form #xxxxxx ('#' followed by six hexadecimal digits), or the name of a constant field in java.awt.Color (found: '" + string + "')");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/GridBagConstraintsConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.awt.GridBagConstraints;
+
+public class GridBagConstraintsConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ GridBagConstraints g = (GridBagConstraints) object;
+ return "new GridBagConstraints(" + g.gridx + ", " + g.gridy + ", " + g.gridwidth + ", " + g.gridheight + ", " +
+ g.weightx + ", " + g.weighty + ", " + g.anchor + ", " + g.fill + ", " +
+ TypeManager.getJavaCode(g.insets) + ", " + g.ipadx + ", " + g.ipady + ")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ throw new UnsupportedOperationException("GridBagConstraints must be represented using Java code");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/InsetsConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.awt.Insets;
+import java.util.StringTokenizer;
+
+public class InsetsConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ Insets insets = (Insets) object;
+ return "new Insets(" + insets.top + ", " + insets.left + ", " + insets.bottom + ", " + insets.right + ")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type != Insets.class) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ StringTokenizer tokenizer = new StringTokenizer(string, ",");
+ int count = tokenizer.countTokens();
+ if (count == 1) {
+ int i = Integer.parseInt(tokenizer.nextToken().trim());
+ return new Insets(i, i, i, i);
+ }
+ if (count == 4) {
+ int[] insets = new int[count];
+ for (int i = 0; tokenizer.hasMoreTokens(); i++) {
+ insets[i] = Integer.parseInt(tokenizer.nextToken().trim());
+ }
+ return new Insets(insets[0], insets[1], insets[2], insets[3]);
+ }
+ throw new IllegalArgumentException("unable to convert string '" + string + "' to Insets");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/KeyStrokeConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import javax.swing.KeyStroke;
+
+public class KeyStrokeConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ return "KeyStroke.getKeyStroke(\"" + object.toString() + "\")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type != KeyStroke.class) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ return KeyStroke.getKeyStroke(string);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/PrimitiveConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import jaxx.compiler.JAXXCompiler;
+
+public class PrimitiveConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ if (object instanceof Boolean) {
+ return String.valueOf(((Boolean) object).booleanValue());
+ }
+ if (object instanceof Byte) {
+ return String.valueOf(((Byte) object).byteValue());
+ }
+ if (object instanceof Short) {
+ return String.valueOf(((Short) object).shortValue());
+ }
+ if (object instanceof Integer) {
+ return String.valueOf(((Integer) object).intValue());
+ }
+ if (object instanceof Long) {
+ return String.valueOf(((Long) object).longValue()) + "L";
+ }
+ if (object instanceof Float) {
+ return String.valueOf(((Float) object).floatValue()) + "F";
+ }
+ if (object instanceof Double) {
+ return String.valueOf(((Double) object).doubleValue());
+ }
+ if (object instanceof String) {
+ return '"' + JAXXCompiler.escapeJavaString((String) object) + '"';
+ }
+ throw new IllegalArgumentException("unsupported object: " + object);
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type == String.class || type == Object.class || type == null) {
+ return string;
+ }
+ if (type == int.class || type == Integer.class) {
+ return Integer.valueOf(string);
+ }
+ if (type == boolean.class || type == Boolean.class) {
+ if (string.toLowerCase().equals("true")) {
+ return Boolean.TRUE;
+ }
+ if (string.toLowerCase().equals("false")) {
+ return Boolean.FALSE;
+ }
+ throw new IllegalArgumentException("expected 'true' or 'false', found '" + string + "'");
+ }
+ if (type == byte.class || type == Byte.class) {
+ return Byte.valueOf(string);
+ }
+ if (type == short.class || type == Short.class) {
+ return Short.valueOf(string);
+ }
+ if (type == long.class || type == Long.class) {
+ return Long.valueOf(string);
+ }
+ if (type == float.class || type == Float.class) {
+ return Float.valueOf(string);
+ }
+ if (type == double.class || type == Double.class) {
+ return Double.valueOf(string);
+ }
+ if (type == char.class || type == Character.class) {
+ if (string.length() == 1) {
+ return string.charAt(0);
+ }
+ throw new IllegalArgumentException("expected a single character, found '" + string + "'");
+ }
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/TypeConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+public interface TypeConverter {
+
+ String getJavaCode(Object object);
+
+ Object convertFromString(String string, Class<?> type);
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/TypeManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TypeManager {
+
+ private static Map<Class<?>, TypeConverter> converters = new HashMap<Class<?>, TypeConverter>();
+
+ private TypeManager() { /* not instantiable */ }
+
+ public static void registerTypeConverter(Class<?> type, TypeConverter converter) {
+ converters.put(type, converter);
+ }
+
+ public static TypeConverter getTypeConverter(Class<?> type) {
+ return converters.get(type);
+ }
+
+ public static String getJavaCode(Object object) {
+ if (object == null) {
+ return "null";
+ }
+ TypeConverter converter = getTypeConverter(object.getClass());
+ if (converter == null) {
+ throw new IllegalArgumentException("unsupported type: " + object.getClass());
+ }
+ return converter.getJavaCode(object);
+ }
+
+ public static Object convertFromString(String string, Class<?> type) {
+ TypeConverter converter = getTypeConverter(type);
+ if (converter == null) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ return converter.convertFromString(string, type);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,3 +0,0 @@
-jaxx.compiler.JAXXObjectGenerator
-jaxx.compiler.SwingGenerator
-jaxx.compiler.ValidatorGenerator
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,3 @@
+jaxx.compiler.generators.JAXXObjectGenerator
+jaxx.compiler.generators.SwingGenerator
+jaxx.compiler.generators.ValidatorGenerator
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1 @@
+jaxx.compiler.spi.DefaultInitializer
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,3 +0,0 @@
-jaxx.DefaultInitializer
-jaxx.SwingInitializer
-jaxx.tags.validator.ValidatorInitializer
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-07 14:22:07 UTC (rev 1562)
@@ -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.JAXXContext
+jaxx.runtime.context.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
@@ -32,7 +32,7 @@
Le nom qui est facultatif permet de pouvoir distinguer plusieurs données d'un même type dans le context. Si le nom
n'est pas utilisé pour caractériser une données on fixera alors sa valeur à *null*.
-Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.JAXXContextEntryDef*.
+Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.context.JAXXContextEntryDef*.
Les méthodes de lecture
***********************
@@ -87,7 +87,7 @@
Cette entrée spéciale ne sera pas stockée avec les autres entrées afin d'optimiser les algorithmes d'injection et de
restitution.
-jaxx.runtime.JAXXInitialContext
+jaxx.runtime.context.JAXXInitialContext
*******************************
On a implanté un second type de context qui lui peut servir à l'initialisation des JAXXObject.
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/JavaFileParserTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,57 @@
+package jaxx.compiler;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.JavaFileParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+
+public class JavaFileParserTest {
+
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(JavaFileParserTest.class);
+
+ static File basedir;
+
+ @BeforeClass
+ public static void initBaseDir() {
+ // get maven env basedir
+ String basedir = System.getenv("basedir");
+ if (basedir == null) {
+ basedir = new File("").getAbsolutePath();
+ }
+ JavaFileParserTest.basedir = new File(basedir);
+ }
+
+ @Test
+ public void testParseJavaSourceFile() throws Exception {
+
+ File testSourceRoot = new File(basedir, "src" + File.separator + "test" + File.separator + "java");
+ Assert.assertTrue(testSourceRoot.exists());
+
+ File src = new File(testSourceRoot, getClass().getName().replaceAll("\\.", File.separator) + ".java");
+ Assert.assertTrue(src.exists());
+ log.info("trying parsing file " + src);
+ Reader reader = new FileReader(src);
+ try {
+ ClassDescriptor result = JavaFileParser.parseJavaFile("TestParserJava", reader, getClass().getClassLoader());
+ Assert.assertNotNull(result);
+
+ } catch (CompilerException e) {
+ log.error("could not parse file " + src + " for reason " + e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/JavaMethodTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,52 @@
+package jaxx.compiler;
+
+import jaxx.compiler.JavaMethod;
+import jaxx.compiler.JavaMethod.MethodOrder;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.reflect.Modifier;
+import java.util.EnumSet;
+
+/** @author chemit */
+public class JavaMethodTest {
+
+ @Test
+ public void testGetMethodOrderScope() {
+ EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class);
+
+ EnumSet<MethodOrder> constants;
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.STATIC);
+
+ Assert.assertEquals(1, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.statics));
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PUBLIC);
+
+ Assert.assertEquals(8, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.constructors));
+ Assert.assertTrue(constants.contains(MethodOrder.JAXXObject));
+ Assert.assertTrue(constants.contains(MethodOrder.JAXXContext));
+ Assert.assertTrue(constants.contains(MethodOrder.JAXXValidation));
+ Assert.assertTrue(constants.contains(MethodOrder.events));
+ Assert.assertTrue(constants.contains(MethodOrder.publicGetters));
+ Assert.assertTrue(constants.contains(MethodOrder.publicSetters));
+ Assert.assertTrue(constants.contains(MethodOrder.otherPublic));
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PROTECTED);
+
+ Assert.assertEquals(3, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.protectedGetters));
+ Assert.assertTrue(constants.contains(MethodOrder.protecteds));
+ Assert.assertTrue(constants.contains(MethodOrder.createMethod));
+
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PRIVATE);
+ Assert.assertEquals(3, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.createMethod));
+ Assert.assertTrue(constants.contains(MethodOrder.packageLocal));
+ Assert.assertTrue(constants.contains(MethodOrder.privates));
+
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,34 @@
+package jaxx.compiler.beans;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.beans.Introspector;
+
+/** @author chemit */
+public class BeanIntoUtilTest {
+
+ @Test
+ public void testExtraBeanInfoPath() {
+ BeanInfoUtil.reset();
+ String[] searchPath0 = Introspector.getBeanInfoSearchPath();
+
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing");
+
+ String[] searchPath = Introspector.getBeanInfoSearchPath();
+ Assert.assertEquals(searchPath0.length + 1, searchPath.length);
+
+ BeanInfoUtil.reset();
+ Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length);
+
+ String packageName = getClass().getPackage().getName() + ".dummy";
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName);
+
+ searchPath = Introspector.getBeanInfoSearchPath();
+ Assert.assertEquals(searchPath0.length + 2, searchPath.length);
+ Assert.assertEquals(packageName, searchPath[searchPath.length - 1]);
+
+ BeanInfoUtil.reset();
+ Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/ClassDescriptorTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,59 @@
+package jaxx.compiler.reflect;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+
+public class ClassDescriptorTest {
+
+ /*@Test
+ public void testGetClassDescriptor() throws Exception {
+ ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode");
+ }*/
+ @Test
+ public void testBuiltInClassName() throws ClassNotFoundException, NoSuchMethodException {
+ ClassDescriptor object = ClassDescriptorLoader.getClassDescriptor("java.lang.Object");
+ MethodDescriptor toString = object.getMethodDescriptor("toString");
+ assertEquals(toString.getName(), "toString");
+ assertEquals(toString.getParameterTypes().length, 0);
+
+ MethodDescriptor equals = object.getMethodDescriptor("equals", object);
+ assertEquals(equals.getName(), "equals");
+ assertEquals(equals.getParameterTypes().length, 1);
+ assertEquals(equals.getParameterTypes()[0], object);
+ }
+
+ @Test
+ public void testBuiltInClass() throws ClassNotFoundException, NoSuchMethodException {
+ ClassDescriptor object1 = ClassDescriptorLoader.getClassDescriptor("java.lang.Object");
+ ClassDescriptor object2 = ClassDescriptorLoader.getClassDescriptor(Object.class);
+ assertEquals(object1, object2);
+ }
+
+ @Test
+ public void testUserClassName() throws ClassNotFoundException, NoSuchMethodException {
+ ClassDescriptor me = ClassDescriptorLoader.getClassDescriptor(ClassDescriptorTest.class.getName(), getClass().getClassLoader());
+ MethodDescriptor testUserClassName = me.getMethodDescriptor("testUserClassName");
+ assertEquals(testUserClassName.getName(), "testUserClassName");
+ assertEquals(testUserClassName.getParameterTypes().length, 0);
+ }
+
+ @Test(expected = ClassNotFoundException.class)
+ public void testWrongCase() throws ClassNotFoundException {
+ //try {
+ //ClassDescriptor object =
+ ClassDescriptorLoader.getClassDescriptor("jaxx.junit.classdescriptortest", getClass().getClassLoader());
+ // fail("Found descriptor using wrong case: " + object);
+ //}
+ //catch (ClassNotFoundException e) {
+ //}
+ }
+
+ @Test
+ public void testArrays() throws ClassNotFoundException {
+ ClassDescriptor intArray = ClassDescriptorLoader.getClassDescriptor(int[].class);
+ assertNotNull(intArray);
+ ClassDescriptor objectArray = ClassDescriptorLoader.getClassDescriptor(Object[].class);
+ assertNotNull(objectArray);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,138 @@
+package jaxx.compiler.tags;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.swing.JPopupMenu;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+public class TagManagerTest {
+
+ protected JAXXCompiler compiler;
+
+ public static class TestHandler extends DefaultObjectHandler {
+
+ public TestHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ }
+ }
+
+ @BeforeClass
+ public static void initTagManaer() throws Exception {
+
+ TagManager.reset(true);
+
+ }
+
+ @Before
+ public void setUp() {
+ JAXXCompilerLaunchor.newLaunchor();
+ compiler = JAXXCompilerLaunchor.createDummyCompiler(JAXXCompiler.class.getClassLoader());
+// compiler = new JAXXCompiler(JAXXCompiler.class.getClassLoader());
+ compiler.addImport("javax.swing.*");
+
+ }
+
+ @Test
+ public void testRegisterBean() {
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(InputStream.class), TestHandler.class);
+
+ Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(InputStream.class)) instanceof TestHandler);
+ Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(FileInputStream.class)) instanceof TestHandler);
+ }
+
+ @Test
+ public void testRegisterDefaultNamespace() {
+
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(OutputStream.class), TestHandler.class);
+
+ TagManager.registerDefaultNamespace("OutputStream", "java.io.*");
+ Assert.assertTrue("Could not find handler for OutputStream despite default namespace", TagManager.getTagHandler(null, "OutputStream", compiler) instanceof TestHandler);
+
+ PrintStream oldErr = System.err;
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(buffer));
+ TagManager.registerDefaultNamespace("OutputStream", "java.dummy.*");
+ Assert.assertNull("Found handler for OutputStream despite ambiguous default namespace", TagManager.getTagHandler(null, "OutputStream", compiler));
+ System.setErr(oldErr);
+ Assert.assertTrue("No errors were produced with an ambiguous default namespace", buffer.size() > 0);
+ Assert.assertTrue(buffer.size() > 0);
+ }
+
+ @Test
+ public void testResolveClassName() {
+ Assert.assertEquals("Could not resolve class name 'Object'", TagManager.resolveClassName("Object", compiler), "java.lang.Object");
+ Assert.assertEquals("Could not resolve class name 'java.lang.Object'", TagManager.resolveClassName("java.lang.Object", compiler), "java.lang.Object");
+ Assert.assertNull("Unexpectedly resolved class name 'java.awt.Object'", TagManager.resolveClassName("java.awt.Object", compiler));
+ }
+
+ @Test
+ public void testPackages() {
+ Assert.assertNull("Unexpectedly found handler for java.awt.JButton", TagManager.getTagHandler(null, "java.awt.JButton", compiler));
+ Assert.assertNotNull("Did not find handler for JButton with default namespace of java.awt.*", TagManager.getTagHandler("java.awt.*", "JButton", compiler));
+ Assert.assertNull("Unexpectedly found handler for java.awt.*:JButton", TagManager.getTagHandler("java.awt.*", "JButton", true, compiler));
+ Assert.assertNotNull("Did not find handler for javax.swing.JButton", TagManager.getTagHandler(null, "javax.swing.JButton", compiler));
+ Assert.assertNotNull("Did not find handler for JButton with default namespace of java.swing.*", TagManager.getTagHandler("java.swing.*", "JButton", compiler));
+ Assert.assertNotNull("Did not find handler for javax.swing.*:JButton", TagManager.getTagHandler("javax.swing.*", "JButton", true, compiler));
+ }
+
+ @Test
+ public void testImport() throws Exception {
+ Assert.assertNull("Found handler for ActionListener despite no java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler));
+
+ compiler.addImport("java.awt.event.*");
+
+ Assert.assertNotNull("Did not find ActionListener with java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler));
+ }
+
+ @Test
+ public void testAmbiguousImport() throws Exception {
+ compiler.addImport("java.sql.*");
+ Assert.assertNotNull("Did not find java.sql.Date with only java.sql.* imported", TagManager.getTagHandler(null, "Date", compiler));
+
+ PrintStream oldErr = System.err;
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(buffer));
+ compiler.addImport("java.util.*");
+ TagManager.reset(true);
+ Assert.assertNull("Still found a handler for Date with an ambiguous import", TagManager.getTagHandler(null, "Date", compiler));
+ System.setErr(oldErr);
+ Assert.assertTrue("No errors were produced with an ambiguous import", buffer.size() > 0);
+
+ compiler.addImport("java.util.Date");
+ Assert.assertNotNull("Did not find java.util.Date with a disambiguating import", TagManager.getTagHandler(null, "Date", compiler));
+ }
+
+ @Test
+ public void testInnerClass() {
+ TagHandler handler = TagManager.getTagHandler(null, "JPopupMenu.Separator", compiler);
+ Assert.assertTrue("Unable to resolve tag <JPopupMenu.Separator>", handler instanceof DefaultComponentHandler);
+ Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName()));
+
+ handler = TagManager.getTagHandler(null, "javax.swing.JPopupMenu.Separator", compiler);
+ Assert.assertTrue("Unable to resolve tag <javax.swing.JPopupMenu.Separator>", handler instanceof DefaultComponentHandler);
+ Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName()));
+ }
+
+ @Test
+ public void testWrongCase() {
+ Assert.assertNull("Unexpectedly found handler for 'object'", TagManager.getTagHandler(null, "object", compiler));
+ Assert.assertNull("Unexpectedly found handler for 'tagmanagertest'", TagManager.getTagHandler(null, "tagmanagertest", compiler));
+ }
+
+ @Test
+ public void testAliasing() {
+ Assert.assertEquals("ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("ButtonGroup", compiler));
+ Assert.assertEquals("javax.swing.ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("javax.swing.ButtonGroup", compiler));
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/ColorConverterTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,51 @@
+package jaxx.compiler.types;
+
+import jaxx.compiler.types.ColorConverter;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.Color;
+
+public class ColorConverterTest {
+
+ ColorConverter converter;
+
+ @Before
+ public void setUp() {
+ converter = new ColorConverter();
+ }
+
+ @Test
+ public void testHexValue() {
+ Color value = (Color) converter.convertFromString("#3000FF", Color.class);
+ Assert.assertEquals(value, new Color(48, 0, 255));
+ }
+
+ @Test
+ public void testUpperCaseConstant() {
+ Color value = (Color) converter.convertFromString("RED", Color.class);
+ Assert.assertEquals(value, Color.RED);
+ }
+
+ @Test
+ public void testLowerCaseConstant() {
+ Color value = (Color) converter.convertFromString("blue", Color.class);
+ Assert.assertEquals(value, Color.blue);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingHash() {
+ converter.convertFromString("ABCDEF", Color.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidNumber() {
+ converter.convertFromString("#ABCDEG", Color.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidConstant() {
+ converter.convertFromString("rEd", Color.class);
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/InsetsConverterTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+package jaxx.compiler.types;
+
+import jaxx.compiler.types.InsetsConverter;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.Insets;
+
+public class InsetsConverterTest {
+
+ InsetsConverter converter;
+
+ @Before
+ public void setUp() {
+ converter = new InsetsConverter();
+ }
+
+ @Test
+ public void testSingleValue() {
+ Insets value = (Insets) converter.convertFromString("3", Insets.class);
+ Assert.assertEquals(value, new Insets(3, 3, 3, 3));
+ }
+
+ @Test
+ public void testFourValues() {
+ Insets value = (Insets) converter.convertFromString("3, 0, 12, 1000000", Insets.class);
+ Assert.assertEquals(value, new Insets(3, 0, 12, 1000000));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testTwoValues() {
+ converter.convertFromString("0, 4", Insets.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testThreeValues() {
+ converter.convertFromString("0, 4, 9", Insets.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidNumber() {
+ converter.convertFromString("0, 4, 9, A", Insets.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testBadFormatting() {
+ converter.convertFromString("0 - 1 - 2 - 3", Insets.class);
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/PrimitiveConverterTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,113 @@
+package jaxx.compiler.types;
+
+import jaxx.compiler.types.PrimitiveConverter;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PrimitiveConverterTest {
+
+ PrimitiveConverter converter;
+
+
+ @Before
+ public void setUp() {
+ converter = new PrimitiveConverter();
+ }
+
+ @Test
+ public void testBoolean() {
+ Boolean value = (Boolean) converter.convertFromString("true", Boolean.class);
+ Assert.assertTrue(value);
+
+ value = (Boolean) converter.convertFromString("false", Boolean.class);
+ Assert.assertFalse(value);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testBoolean2() {
+ converter.convertFromString("yes", Boolean.class);
+ }
+
+ @Test
+ public void testByte() {
+ Byte value = (Byte) converter.convertFromString(String.valueOf(Byte.MAX_VALUE), Byte.class);
+ Assert.assertEquals(value.byteValue(), Byte.MAX_VALUE);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testByte2() {
+
+ converter.convertFromString(String.valueOf(1 + Byte.MAX_VALUE), Byte.class);
+ }
+
+ @Test
+ public void testShort() {
+ Short value = (Short) converter.convertFromString(String.valueOf(Short.MAX_VALUE), Short.class);
+ Assert.assertEquals(value.shortValue(), Short.MAX_VALUE);
+
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testShort2() {
+
+ converter.convertFromString(String.valueOf(1 + Short.MAX_VALUE), Short.class);
+ }
+
+ @Test
+ public void testInteger() {
+ Integer value = (Integer) converter.convertFromString(String.valueOf(Integer.MAX_VALUE), Integer.class);
+ Assert.assertEquals(value.intValue(), Integer.MAX_VALUE);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInteger2() {
+
+ converter.convertFromString(String.valueOf(1L + Integer.MAX_VALUE), Integer.class);
+ }
+
+ @Test
+ public void testLong() {
+ Long value = (Long) converter.convertFromString(String.valueOf(Long.MAX_VALUE), Long.class);
+ Assert.assertEquals(value.longValue(), Long.MAX_VALUE);
+ }
+
+ @Test
+ public void testFloat() {
+ Float value = (Float) converter.convertFromString("3.1415", Float.class);
+ Assert.assertTrue(value == 3.1415f);
+ }
+
+ @Test
+ public void testDouble() {
+ Double value = (Double) converter.convertFromString("3.1415", Double.class);
+ Assert.assertTrue(value == 3.1415);
+ }
+
+ @Test
+ public void testCharacter() {
+ Character value = (Character) converter.convertFromString("A", Character.class);
+ Assert.assertEquals(value.charValue(), 'A');
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCharacter2() {
+
+ converter.convertFromString("12", Character.class);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCharacter3() {
+ converter.convertFromString("", Character.class);
+ }
+
+ @Test
+ public void testString() {
+ String value = (String) converter.convertFromString("Test", String.class);
+ Assert.assertEquals(value, "Test");
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,29 +20,36 @@
*/
package jaxx.demo;
-import java.util.Stack;
-import javax.swing.JPanel;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+
+import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
+
import jaxx.demo.component.swing.*;
import jaxx.demo.component.jaxx.*;
import jaxx.demo.component.jaxx.editor.*;
import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
-import jaxx.demo.component.jaxx.tree.FullNavigationTreeDemo;
+import jaxx.demo.component.jaxx.navigation.FullNavigationTreeDemo;
import jaxx.demo.feature.databinding.BeanDataBindingDemo;
import jaxx.demo.feature.validation.*;
import jaxx.demo.fun.*;
import static org.nuiton.i18n.I18n.n_;
-
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXContextEntryDef;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.CardLayout2;
-import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.tree.*;
-import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.Stack;
+import javax.swing.JPanel;
+
/**
*
* @author chemit
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -29,7 +29,7 @@
<script><![CDATA[
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.tree.*;
+import jaxx.runtime.swing.navigation.*;
import java.util.Locale;
public DemoConfig getConfig() {
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -21,9 +21,9 @@
package jaxx.demo;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXInitialContext;
-import jaxx.runtime.swing.tree.NavigationTreeNode;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
@@ -33,8 +33,8 @@
import java.net.URL;
import java.util.Locale;
import javax.swing.SwingUtilities;
-import jaxx.runtime.DefaultApplicationContext;
-import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.context.DefaultApplicationContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,7 +20,7 @@
*/
package jaxx.demo;
-import jaxx.runtime.DefaultApplicationContext;
+import jaxx.runtime.context.DefaultApplicationContext;
import jaxx.runtime.swing.ErrorDialogUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,49 +18,69 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
##%*
-->
-
-<jaxx.demo.DemoPanel>
- <script><![CDATA[
-//localeEditor.loadI18nBundles();
-]]>
- </script>
- <Table id='demoPanel' fill='both'>
- <row>
- <cell>
- <JLabel text='Empty I18n editor:' labelFor='{localeEmptyEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeEmptyEditor' />
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='I18n editor:' labelFor='{localeEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeEditor'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='I18n editor with no text :' labelFor='{localeWithNoTextEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoTextEditor'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
- showText='false'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='I18n editor with no icon :' labelFor='{localeWithNoIconEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoIconEditor'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
- showIcon='false'/>
- </cell>
- </row>
- </Table>
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+import jaxx.runtime.swing.editor.I18nEditor;
+import org.nuiton.i18n.I18n;
+import java.util.Arrays;
+
+protected Border getPopupBorder(String text) {
+ if (text==null || text.trim().isEmpty()) {
+ return null;
+ }
+ return new TitledBorder(_(text));
+}
+]]>
+ </script>
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell>
+ <JPanel border='{new TitledBorder(_("jaxxdemo.i18neditor.configuration"))}'
+ layout='{new GridLayout(0,1)}'>
+
+ <JCheckBox id='showText'
+ text='jaxxdemo.i18neditor.showText'
+ selected='true'/>
+
+ <JCheckBox id='showIcon'
+ text='jaxxdemo.i18neditor.showIcon'
+ selected='true'/>
+
+ <JCheckBox id='showPopupText'
+ text='jaxxdemo.i18neditor.showPopupText'
+ selected='true'/>
+
+ <JCheckBox id='showPopupIcon'
+ text='jaxxdemo.i18neditor.showPopupIcon'
+ selected='true'/>
+
+ <JPanel>
+ <JLabel text='jaxxdemo.i18neditor.popupBorderText'
+ labelFor='{popupBorderText}'/>
+ <JTextField id='popupBorderText'
+ text='{_("i18neditor.popup.title")}'/>
+ </JPanel>
+
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <I18nEditor id='editor'
+ showText='{showText.isSelected()}'
+ showIcon='{showIcon.isSelected()}'
+ showPopupText='{showPopupText.isSelected()}'
+ showPopupIcon='{showPopupIcon.isSelected()}'
+ popupBorder='{getPopupBorder(popupBorderText.getText())}'
+ locales='{Arrays.asList(I18n.getLoader().getLocales())}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel border='{new TitledBorder(_("jaxxdemo.i18neditor.selected.locale"))}'
+ text='{editor.getSelectedLocale()}'/>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,135 +18,165 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
##%*
-->
-
-<jaxx.demo.DemoPanel>
- <script><![CDATA[
-import jaxx.runtime.swing.editor.NumberEditor;
-
-void $afterCompleteSetup() {
- positifIntegerEditor.init();
- positifIntegerEditor2.init();
- normalIntegerEditor.init();
- normalIntegerEditor2.init();
- positifFloatEditor.init();
- positifFloatEditor2.init();
- normalFloatEditor.init();
- normalFloatEditor2.init();
-}
-]]>
- </script>
-
- <!-- model -->
- <NumberEditorDemoModel id='demoModel'/>
-
- <Table id='demoPanel' insets='0' fill='both'>
- <row>
- <cell weightx='0.5'>
- <JLabel horizontalAlignment='center' text='numbereditor.type'/>
- </cell>
- <cell weightx='0.25'>
- <JLabel horizontalAlignment='center' text='numbereditor.without.auto.popup'/>
- </cell>
- <cell weightx='0.25'>
- <JLabel horizontalAlignment='center' text='numbereditor.with.auto.popup'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.positive.int", demoModel.getPositifInteger())}'/>
- </cell>
- <cell>
- <NumberEditor id='positifIntegerEditor'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifIntegerEditor2'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor2'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor2'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor2'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row>
- </Table>
-
-</jaxx.demo.DemoPanel>
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+import jaxx.runtime.swing.editor.NumberEditor;
+
+void $afterCompleteSetup() {
+ editor.init();
+}
+]]>
+ </script>
+
+ <!-- model -->
+ <NumberEditorDemoModel id='demoModel'/>
+
+ <Table id='demoPanel' insets='0' fill='both'>
+ <row>
+ <cell>
+ <JPanel border='{new TitledBorder(_("jaxxdemo.numbereditor.configuration"))}'
+ layout='{new GridLayout(0,1)}'>
+
+ <JCheckBox id='useFloat'
+ text='jaxxdemo.numbereditor.useFloat'
+ selected='true'/>
+
+ <JCheckBox id='useSign'
+ text='jaxxdemo.numbereditor.useSign'
+ selected='true'/>
+
+ <JCheckBox id='showPopupButton'
+ text='jaxxdemo.numbereditor.showPopupButton'
+ selected='true'/>
+
+ <JCheckBox id='showResetButton'
+ text='jaxxdemo.numbereditor.showReset'
+ selected='true'/>
+
+ <JCheckBox id='autoPopup'
+ text='jaxxdemo.numbereditor.autoPopup'
+ selected='false'/>
+
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <NumberEditor id='editor'
+ constructorParams='this'
+ bean='{demoModel}'
+ property='{useFloat.isSelected() ? "floatProperty" : "integerProperty"}'
+ useFloat='{useFloat.isSelected()}'
+ useSign='{useSign.isSelected()}'
+ autoPopup='{autoPopup.isSelected()}'
+ showPopupButton='{showPopupButton.isSelected()}'
+ showReset='{showResetButton.isSelected()}' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JPanel border='{new TitledBorder(_("jaxxdemo.numbereditor.model"))}'
+ layout='{new GridLayout(0,1)}'>
+ <JLabel text='{_("jaxxdemo.numbereditor.model.int", demoModel.getIntegerProperty())}'/>
+ <JLabel text='{_("jaxxdemo.numbereditor.model.float", demoModel.getFloatProperty())}'/>
+
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
+ <!--row>
+ <cell>
+ <NumberEditor id='positifIntegerEditor'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifIntegerEditor2'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor2'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor2'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor2'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ </row-->
+
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -30,56 +30,80 @@
*/
public class NumberEditorDemoModel {
+ public static final String INTEGER_PROPERTY = "integerProperty";
+ public static final String FLOAT_PROPERTY = "floatProperty";
protected PropertyChangeSupport p;
- protected int positifInteger;
- protected int normalInteger;
- protected float positifFloat;
- protected float normalFloat;
+ protected int integerProperty;
+ protected float floatProperty;
+// protected int positifInteger;
+// protected int normalInteger;
+// protected float positifFloat;
+// protected float normalFloat;
public NumberEditorDemoModel() {
p = new PropertyChangeSupport(this);
}
- public float getNormalFloat() {
- return normalFloat;
+ public float getFloatProperty() {
+ return floatProperty;
}
- public int getNormalInteger() {
- return normalInteger;
+ public int getIntegerProperty() {
+ return integerProperty;
}
- public float getPositifFloat() {
- return positifFloat;
+ public void setFloatProperty(float floatProperty) {
+ float old = this.floatProperty;
+ this.floatProperty = floatProperty;
+ p.firePropertyChange(FLOAT_PROPERTY, old, floatProperty);
}
- public int getPositifInteger() {
- return positifInteger;
+ public void setIntegerProperty(int integerProperty) {
+ int old = this.integerProperty;
+ this.integerProperty = integerProperty;
+ p.firePropertyChange(INTEGER_PROPERTY, old, integerProperty);
}
- public void setNormalFloat(float normalFloat) {
- float old = this.normalFloat;
- this.normalFloat = normalFloat;
- p.firePropertyChange("normalFloat", old, normalFloat);
- }
-
- public void setNormalInteger(int normalInteger) {
- int old = this.normalInteger;
- this.normalInteger = normalInteger;
- p.firePropertyChange("normalInteger", old, normalInteger);
- }
-
- public void setPositifFloat(float positifFloat) {
- float old = this.positifFloat;
- this.positifFloat = positifFloat;
- p.firePropertyChange("positifFloat", old, positifFloat);
- }
-
- public void setPositifInteger(int positifInteger) {
- int old = this.positifInteger;
- this.positifInteger = positifInteger;
- p.firePropertyChange("positifInteger", old, positifInteger);
- }
-
+//
+// public float getNormalFloat() {
+// return normalFloat;
+// }
+//
+// public int getNormalInteger() {
+// return normalInteger;
+// }
+//
+// public float getPositifFloat() {
+// return positifFloat;
+// }
+//
+// public int getPositifInteger() {
+// return positifInteger;
+// }
+//
+// public void setNormalFloat(float normalFloat) {
+// float old = this.normalFloat;
+// this.normalFloat = normalFloat;
+// p.firePropertyChange("normalFloat", old, normalFloat);
+// }
+//
+// public void setNormalInteger(int normalInteger) {
+// int old = this.normalInteger;
+// this.normalInteger = normalInteger;
+// p.firePropertyChange("normalInteger", old, normalInteger);
+// }
+//
+// public void setPositifFloat(float positifFloat) {
+// float old = this.positifFloat;
+// this.positifFloat = positifFloat;
+// p.firePropertyChange("positifFloat", old, positifFloat);
+// }
+//
+// public void setPositifInteger(int positifInteger) {
+// int old = this.positifInteger;
+// this.positifInteger = positifInteger;
+// p.firePropertyChange("positifInteger", old, positifInteger);
+// }
public void addPropertyChangeListener(PropertyChangeListener listener) {
p.addPropertyChangeListener(listener);
}
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,99 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+<JPanel layout='{new BorderLayout()}'>
+
+ <Object id='data' javaBean='helper.getSelectedBean(this)'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+String getType(Object data) {
+ if (data == null) {
+ return "no type";
+ }
+ if (data instanceof java.util.List<?>) {
+ java.util.List<?> l = (java.util.List<?>) data;
+ if (l.isEmpty()) {
+ return "Empty collection";
+ }
+ return "Collection of " + l.size() + " " + l.get(0).getClass().getSimpleName() + "(s)";
+ }
+ return data.getClass().getSimpleName();
+}
+
+String getContent(Object data) {
+ if (data == null) {
+ return "no content";
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (data instanceof java.util.List) {
+ for (Object o : ((java.util.List)data)) {
+ buffer.append(o).append("\n");
+ }
+ } else {
+ buffer.append(data);
+ }
+ return buffer.toString();
+}
+
+ImageIcon getImage(Object data) {
+ if (data == null) {
+ return null;
+ }
+ if (data instanceof Movie) {
+ return SwingUtil.createIcon(((Movie)data).getImage());
+ }
+ if (data instanceof People) {
+ return SwingUtil.createIcon(((People)data).getImage());
+ }
+ return null;
+}
+ ]]>
+ </script>
+
+ <JSplitPane id='splitPane'
+ orientation='{JSplitPane.VERTICAL_SPLIT}'
+ resizeWeight='0.5'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'>
+ <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}'
+ editable='false'
+ font-size='11'
+ text='{getContent(getData())}'/>
+ </JScrollPane>
+
+ <JScrollPane border='{new TitledBorder("Picture")}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
+ minimumSize='{SwingUtil.newMinDimension()}'>
+
+ <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/>
+
+ </JScrollPane>
+
+ </JSplitPane>
+</JPanel>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,82 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'
+ useOnlyVisibleComponentDimension='true'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+helper.createModel(this);
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" };
+}
+
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ navigation.setSelectionInterval(0, 0);
+ splitPane.resetToPreferredSizes();
+ }
+ });
+ // expand the tree
+ SwingUtil.expandTree(navigation);
+ // auto-expand node when selected
+ SwingUtil.addExpandOnClickListener(navigation);
+}
+ ]]>
+ </script>
+
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_NEVER}'>
+
+ <JTree id="navigation"
+ font-size='11'
+ rootVisible='false'
+ showsRootHandles='false'
+ model='{helper.createTreeModel(this)}'
+ selectionModel="{helper.createTreeHandler(this)}"/>
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />-->
+
+ </JScrollPane>
+
+ <JPanel id="content" layout="{contentLayout}" />
+
+ </JSplitPane>
+
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,242 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation;
+
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import static jaxx.runtime.context.JAXXContextEntryDef.newListDef;
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.decorator.DecoratorUtils;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
+import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class FullNavigationTreeHelper extends NavigationTreeHelper {
+
+ static {
+ // register decorator one for all
+
+ DecoratorUtils.register(
+ Movie.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - "));
+
+ DecoratorUtils.register(
+ People.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " "));
+ }
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+ /**
+ * where the movies are hold in context
+ */
+ static public final JAXXContextEntryDef<List<Movie>> MOVIES = JAXXContextEntryDef.newListDef("movies");
+ /**
+ * where the actors are hold in context
+ */
+ static public final JAXXContextEntryDef<List<People>> ACTORS = JAXXContextEntryDef.newListDef("actors");
+
+ public FullNavigationTreeHelper() {
+ super("full");
+ }
+
+ /**
+ * Create the model and store it in the given context.
+ *
+ * @param context the context where to hold the model
+ */
+ public void createModel(JAXXContext context) {
+ People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
+ People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
+ People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
+
+ Movie m = new Movie("0", "Nacho libre", 1996, "/jaxx/demo/images/nacho.jpg");
+ m.addActor(a);
+ m.addActor(a2);
+ m.addActor(a3);
+
+ Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m2.addActor(a);
+ m2.addActor(a2);
+
+ MOVIES.setContextValue(context, Arrays.asList(m, m2));
+ ACTORS.setContextValue(context, Arrays.asList(a, a2, a3));
+ }
+
+ @Override
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
+
+ List<Movie> movies = MOVIES.getContextValue(context);
+ List<People> actors = ACTORS.getContextValue(context);
+
+ if (log.isDebugEnabled()) {
+ log.debug("for " + movies.size() + " movie(s)");
+ }
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/", context, BaseContent.class,
+ null);
+
+ Decorator<Movie> mDecorator = DecoratorUtils.get(Movie.class.getSimpleName());
+ Decorator<People> pDecorator = DecoratorUtils.get(People.class.getSimpleName());
+
+ // construction du noeud root
+ // il ne contient pas de context et ne sera pas visible
+ NavigationTreeNode rootNode = builder.buildEmptyRoot(null, "$root");
+
+ // construction du noeud avec les films recupere la liste des films
+ // dans le context avec la clef movies
+ // navigation path = $root/movies
+ NavigationTreeNode moviesNode = builder.build(
+ rootNode,
+ _("movies"),
+ newListDef("movies"),
+ "movies",
+ null,
+ null);
+
+ for (Movie m : movies) {
+
+ // navigation path = $root/movies/m.id
+ NavigationTreeNode movieNode = builder.build(
+ moviesNode,
+ mDecorator,
+ "..[@id=\"" + m.getId() + "\"]",
+ m.getId(),
+ null,
+ null);
+
+ // navigation path = $root/movies/m.id/actors
+ NavigationTreeNode actorsNode = builder.build(
+ movieNode,
+ _("actors"),
+ "../actors",
+ "actors",
+ null,
+ null);
+
+ for (People p : m.getActors()) {
+ // navigation path = $root/movies/m.id/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ }
+
+ // construction du noeud avec les acteurs
+ NavigationTreeNode actorsNode = builder.build(rootNode, _("actors"),
+ newListDef("actors"),
+ "actors", null, null);
+
+ for (People p : actors) {
+ // navigation path = $root/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ NavigationTreeModel model = builder.getModel();
+
+ if (log.isDebugEnabled()) {
+ builder.printModel(model.getRoot());
+ }
+
+ // save tree model in context
+ setTreeModel(context, model);
+ return model;
+ }
+
+ @Override
+ public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("create handler");
+ }
+
+ NavigationTreeHandler handler;
+
+ handler = new NavigationTreeHandlerWithCardLayout(
+ getPrefix(),
+ context,
+ Strategy.PER_NODE) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected NavigationTreeModel getNavigationTreeModel() {
+ return getSafeTreeModel(getContext());
+ }
+
+ @Override
+ protected JPanel getContentContainer() {
+ return getContext().getContent();
+ }
+
+ @Override
+ protected CardLayout2 getContentLayout() {
+ return getContext().getContentLayout();
+ }
+
+ @Override
+ protected void treateError(Exception e) {
+ ErrorDialogUI.showError(e);
+ }
+
+ @Override
+ public FullNavigationTreeDemo getContext() {
+ return (FullNavigationTreeDemo) this.context;
+ }
+ };
+ // on ne peut selectionner qu'un seul noeud a la fois
+ handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+
+ // save handler in ui context
+ setTreeHandler(context, handler);
+ return handler;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,128 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,118 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -106,12 +106,14 @@
edit=Edit
edit2=Edit 2
edit3=Edit 3
+editor.getSelectedLocale()=
form.ratio=Ratio
form.text=Text
form.text2=Text 2
form2.ratio=Form 2 Ratio
form2.text=Form 2 Text
form2.text2=Form 2 Text 2
+i18neditor.popup.title=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>.
jaxxdemo.action.about=About...
jaxxdemo.action.about.tip=About JAXXDemo...
@@ -138,6 +140,13 @@
jaxxdemo.config.configFileName.description=Configuration file name
jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
jaxxdemo.config.ui.locale=Locale of the application
+jaxxdemo.i18neditor.configuration=Configuration
+jaxxdemo.i18neditor.popupBorderText=Popup title
+jaxxdemo.i18neditor.selected.locale=Selected Language
+jaxxdemo.i18neditor.showIcon=Show icons
+jaxxdemo.i18neditor.showPopupIcon=Show icons in popup
+jaxxdemo.i18neditor.showPopupText=Show texts in popup
+jaxxdemo.i18neditor.showText=Show text
jaxxdemo.init.closed=JAXXDemo was closed at %1$s
jaxxdemo.init.context.done=Context initialized in %1$s
jaxxdemo.init.ui.done=UI initialized.
@@ -146,6 +155,15 @@
jaxxdemo.menu.help=
jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded.
jaxxdemo.message.goto.site=Go to JAXXDemo Web site
+jaxxdemo.numbereditor.autoPopup=
+jaxxdemo.numbereditor.configuration=
+jaxxdemo.numbereditor.model=
+jaxxdemo.numbereditor.model.float=
+jaxxdemo.numbereditor.model.int=
+jaxxdemo.numbereditor.showPopupButton=
+jaxxdemo.numbereditor.showReset=
+jaxxdemo.numbereditor.useFloat=
+jaxxdemo.numbereditor.useSign=
jaxxdemo.title.about=About JAXXDemo...
jaxxdemo.tree.component.jaxx=JAXX Components
jaxxdemo.tree.component.jaxx.editor=Editors
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -106,12 +106,14 @@
edit=Editer
edit2=Editer 2
edit3=Editer 3
+editor.getSelectedLocale()=
form.ratio=Form \: ratio
form.text=Form \: text
form.text2=Form \: text2
form2.ratio=Form2 \: ratio
form2.text=Form2 \: text
form2.text2=Form2 \: text2
+i18neditor.popup.title=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>.
jaxxdemo.action.about=A propos
jaxxdemo.action.about.tip=A propos de JAXX Demo...
@@ -138,6 +140,13 @@
jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES)
+jaxxdemo.i18neditor.configuration=Configuration
+jaxxdemo.i18neditor.popupBorderText=Titre de la popup
+jaxxdemo.i18neditor.selected.locale=Langue s\u00E9lectionn\u00E9e
+jaxxdemo.i18neditor.showIcon=Afficher les icones
+jaxxdemo.i18neditor.showPopupIcon=Afficher les icones dans la popup
+jaxxdemo.i18neditor.showPopupText=Afficher les textes dans la popup
+jaxxdemo.i18neditor.showText=Afficher le text
jaxxdemo.init.closed=JAXX Demo a \u00E9t\u00E9 ferm\u00E9 \u00E0 %1$s
jaxxdemo.init.context.done=Initialisation du contexte termin\u00E9e en %1$s.
jaxxdemo.init.ui.done=Initialisation de l'interface graphique termin\u00E9e.
@@ -146,6 +155,15 @@
jaxxdemo.menu.help=Aide
jaxxdemo.message.config.loaded=Configuration de JAXX Demo v. %1$s charg\u00E9e.
jaxxdemo.message.goto.site=Acc\u00E9der au site de JAXX Demo (%1$s)
+jaxxdemo.numbereditor.autoPopup=Affichage automatique popup
+jaxxdemo.numbereditor.configuration=Configuration
+jaxxdemo.numbereditor.model=R\u00E9sultat
+jaxxdemo.numbereditor.model.float=Valeur d\u00E9cimale \: %1$s
+jaxxdemo.numbereditor.model.int=Valeur enti\u00E8re \: %1$s
+jaxxdemo.numbereditor.showPopupButton=Afficher le boutton de popup
+jaxxdemo.numbereditor.showReset=Afficher le boutton de reset
+jaxxdemo.numbereditor.useFloat=Utiliser les d\u00E9cimales
+jaxxdemo.numbereditor.useSign=Utiliser le signe
jaxxdemo.title.about=A propos de JAXX Demo...
jaxxdemo.tree.component.jaxx=Composants JAXX
jaxxdemo.tree.component.jaxx.editor=Editeurs
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -6,7 +6,8 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
log4j.logger.jaxx.demo=INFO
-#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeCellRenderer=DEBUG
-#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeNodeRenderer=DEBUG
-#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeModel=DEBUG
+log4j.logger.jaxx.runtime.swing.editor.I18nEditor=INFO
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeCellRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeNodeRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeModel=DEBUG
log4j.logger.org.nuiton=WARN
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,240 +0,0 @@
-package jaxx;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * A Base64 Encoder/Decoder.
- * <p/>
- * <p/>
- * This class is used to encode and decode data in Base64 format as described in RFC 1521.
- * <p/>
- * <p/>
- * This is "Open Source" software and released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a> license.<br>
- * It is provided "as is" without warranty of any kind.<br>
- * Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.<br>
- * Home page: <a href="http://www.source-code.biz">www.source-code.biz</a><br>
- * <p/>
- * <p/>
- * Version history:<br>
- * 2003-07-22 Christian d'Heureuse (chdh): Module created.<br>
- * 2005-08-11 chdh: Lincense changed from GPL to LGPL.<br>
- * 2006-11-21 chdh:<br>
- * Method encode(String) renamed to encodeString(String).<br>
- * Method decode(String) renamed to decodeString(String).<br>
- * New method encode(byte[],int) added.<br>
- * New method decode(String) added.<br>
- */
-
-public class Base64Coder {
-
- // Mapping table from 6-bit nibbles to Base64 characters.
- private static char[] map1 = new char[64];
-
- static {
- int i = 0;
- for (char c = 'A'; c <= 'Z'; c++) {
- map1[i++] = c;
- }
- for (char c = 'a'; c <= 'z'; c++) {
- map1[i++] = c;
- }
- for (char c = '0'; c <= '9'; c++) {
- map1[i++] = c;
- }
- map1[i++] = '+';
- map1[i] = '/';
- }
-
- // Mapping table from Base64 characters to 6-bit nibbles.
- private static byte[] map2 = new byte[128];
-
- static {
- for (int i = 0; i < map2.length; i++) {
- map2[i] = -1;
- }
- for (int i = 0; i < 64; i++) {
- map2[map1[i]] = (byte) i;
- }
- }
-
- /**
- * Read the object from Base64 string.
- *
- * @param s the string representation of serialized object.
- * @param gzip if gzip stream
- * @return the deserialize object
- * @throws java.io.IOException if any io pb
- * @throws ClassNotFoundException if class not found ?
- */
- public static Object deserialize(String s, boolean gzip) throws IOException,
- ClassNotFoundException {
- byte[] data = Base64Coder.decode(s);
- InputStream stream = new ByteArrayInputStream(data);
- if (gzip) {
- stream = new GZIPInputStream(stream);
- }
- ObjectInputStream ois = new ObjectInputStream(stream);
- Object o = ois.readObject();
- ois.close();
- return o;
- }
-
- /**
- * Write the object to a Base64 string.
- *
- * @param o the object to serialize
- * @param gzip if gzip stream
- * @return the string representation
- * @throws java.io.IOException if any io pb
- */
- public static String serialize(Object o, boolean gzip) throws IOException {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- ObjectOutputStream oos;
- if (gzip) {
- oos = new ObjectOutputStream(new GZIPOutputStream(stream));
- } else {
- oos = new ObjectOutputStream(stream);
- }
- oos.writeObject(o);
- oos.close();
- return new String(Base64Coder.encode(stream.toByteArray()));
- }
-
- /**
- * Encodes a string into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param s a String to be encoded.
- * @return A String with the Base64 encoded data.
- */
- public static String encodeString(String s) {
- return new String(encode(s.getBytes()));
- }
-
- /**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param in an array containing the data bytes to be encoded.
- * @return A character array with the Base64 encoded data.
- */
- public static char[] encode(byte[] in) {
- return encode(in, in.length);
- }
-
- /**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param in an array containing the data bytes to be encoded.
- * @param iLen number of bytes to process in <code>in</code>.
- * @return A character array with the Base64 encoded data.
- */
- public static char[] encode(byte[] in, int iLen) {
- int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
- int oLen = ((iLen + 2) / 3) * 4; // output length including padding
- char[] out = new char[oLen];
- int ip = 0;
- int op = 0;
- while (ip < iLen) {
- int i0 = in[ip++] & 0xff;
- int i1 = ip < iLen ? in[ip++] & 0xff : 0;
- int i2 = ip < iLen ? in[ip++] & 0xff : 0;
- int o0 = i0 >>> 2;
- int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
- int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
- int o3 = i2 & 0x3F;
- out[op++] = map1[o0];
- out[op++] = map1[o1];
- out[op] = op < oDataLen ? map1[o2] : '=';
- op++;
- out[op] = op < oDataLen ? map1[o3] : '=';
- op++;
- }
- return out;
- }
-
- /**
- * Decodes a string from Base64 format.
- *
- * @param s a Base64 String to be decoded.
- * @return A String containing the decoded data.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static String decodeString(String s) {
- return new String(decode(s));
- }
-
- /**
- * Decodes a byte array from Base64 format.
- *
- * @param s a Base64 String to be decoded.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static byte[] decode(String s) {
- return decode(s.toCharArray());
- }
-
- /**
- * Decodes a byte array from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded data.
- *
- * @param in a character array containing the Base64 encoded data.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static byte[] decode(char[] in) {
- int iLen = in.length;
- if (iLen % 4 != 0) {
- throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
- }
- while (iLen > 0 && in[iLen - 1] == '=') {
- iLen--;
- }
- int oLen = (iLen * 3) / 4;
- byte[] out = new byte[oLen];
- int ip = 0;
- int op = 0;
- while (ip < iLen) {
- int i0 = in[ip++];
- int i1 = in[ip++];
- int i2 = ip < iLen ? in[ip++] : 'A';
- int i3 = ip < iLen ? in[ip++] : 'A';
- if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) {
- throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
- }
- int b0 = map2[i0];
- int b1 = map2[i1];
- int b2 = map2[i2];
- int b3 = map2[i3];
- if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) {
- throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
- }
- int o0 = (b0 << 2) | (b1 >>> 4);
- int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
- int o2 = ((b2 & 3) << 6) | b3;
- out[op++] = (byte) o0;
- if (op < oLen) {
- out[op++] = (byte) o1;
- }
- if (op < oLen) {
- out[op++] = (byte) o2;
- }
- }
- return out;
- }
-
- // Dummy constructor.
- private Base64Coder() {
- }
-
-} // end class Base64Coder
-
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,240 @@
+package jaxx.runtime;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * A Base64 Encoder/Decoder.
+ * <p/>
+ * <p/>
+ * This class is used to encode and decode data in Base64 format as described in RFC 1521.
+ * <p/>
+ * <p/>
+ * This is "Open Source" software and released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a> license.<br>
+ * It is provided "as is" without warranty of any kind.<br>
+ * Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.<br>
+ * Home page: <a href="http://www.source-code.biz">www.source-code.biz</a><br>
+ * <p/>
+ * <p/>
+ * Version history:<br>
+ * 2003-07-22 Christian d'Heureuse (chdh): Module created.<br>
+ * 2005-08-11 chdh: Lincense changed from GPL to LGPL.<br>
+ * 2006-11-21 chdh:<br>
+ * Method encode(String) renamed to encodeString(String).<br>
+ * Method decode(String) renamed to decodeString(String).<br>
+ * New method encode(byte[],int) added.<br>
+ * New method decode(String) added.<br>
+ */
+
+public class Base64Coder {
+
+ // Mapping table from 6-bit nibbles to Base64 characters.
+ private static char[] map1 = new char[64];
+
+ static {
+ int i = 0;
+ for (char c = 'A'; c <= 'Z'; c++) {
+ map1[i++] = c;
+ }
+ for (char c = 'a'; c <= 'z'; c++) {
+ map1[i++] = c;
+ }
+ for (char c = '0'; c <= '9'; c++) {
+ map1[i++] = c;
+ }
+ map1[i++] = '+';
+ map1[i] = '/';
+ }
+
+ // Mapping table from Base64 characters to 6-bit nibbles.
+ private static byte[] map2 = new byte[128];
+
+ static {
+ for (int i = 0; i < map2.length; i++) {
+ map2[i] = -1;
+ }
+ for (int i = 0; i < 64; i++) {
+ map2[map1[i]] = (byte) i;
+ }
+ }
+
+ /**
+ * Read the object from Base64 string.
+ *
+ * @param s the string representation of serialized object.
+ * @param gzip if gzip stream
+ * @return the deserialize object
+ * @throws java.io.IOException if any io pb
+ * @throws ClassNotFoundException if class not found ?
+ */
+ public static Object deserialize(String s, boolean gzip) throws IOException,
+ ClassNotFoundException {
+ byte[] data = Base64Coder.decode(s);
+ InputStream stream = new ByteArrayInputStream(data);
+ if (gzip) {
+ stream = new GZIPInputStream(stream);
+ }
+ ObjectInputStream ois = new ObjectInputStream(stream);
+ Object o = ois.readObject();
+ ois.close();
+ return o;
+ }
+
+ /**
+ * Write the object to a Base64 string.
+ *
+ * @param o the object to serialize
+ * @param gzip if gzip stream
+ * @return the string representation
+ * @throws java.io.IOException if any io pb
+ */
+ public static String serialize(Object o, boolean gzip) throws IOException {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ if (gzip) {
+ oos = new ObjectOutputStream(new GZIPOutputStream(stream));
+ } else {
+ oos = new ObjectOutputStream(stream);
+ }
+ oos.writeObject(o);
+ oos.close();
+ return new String(Base64Coder.encode(stream.toByteArray()));
+ }
+
+ /**
+ * Encodes a string into Base64 format.
+ * No blanks or line breaks are inserted.
+ *
+ * @param s a String to be encoded.
+ * @return A String with the Base64 encoded data.
+ */
+ public static String encodeString(String s) {
+ return new String(encode(s.getBytes()));
+ }
+
+ /**
+ * Encodes a byte array into Base64 format.
+ * No blanks or line breaks are inserted.
+ *
+ * @param in an array containing the data bytes to be encoded.
+ * @return A character array with the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in) {
+ return encode(in, in.length);
+ }
+
+ /**
+ * Encodes a byte array into Base64 format.
+ * No blanks or line breaks are inserted.
+ *
+ * @param in an array containing the data bytes to be encoded.
+ * @param iLen number of bytes to process in <code>in</code>.
+ * @return A character array with the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in, int iLen) {
+ int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
+ int oLen = ((iLen + 2) / 3) * 4; // output length including padding
+ char[] out = new char[oLen];
+ int ip = 0;
+ int op = 0;
+ while (ip < iLen) {
+ int i0 = in[ip++] & 0xff;
+ int i1 = ip < iLen ? in[ip++] & 0xff : 0;
+ int i2 = ip < iLen ? in[ip++] & 0xff : 0;
+ int o0 = i0 >>> 2;
+ int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
+ int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+ int o3 = i2 & 0x3F;
+ out[op++] = map1[o0];
+ out[op++] = map1[o1];
+ out[op] = op < oDataLen ? map1[o2] : '=';
+ op++;
+ out[op] = op < oDataLen ? map1[o3] : '=';
+ op++;
+ }
+ return out;
+ }
+
+ /**
+ * Decodes a string from Base64 format.
+ *
+ * @param s a Base64 String to be decoded.
+ * @return A String containing the decoded data.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static String decodeString(String s) {
+ return new String(decode(s));
+ }
+
+ /**
+ * Decodes a byte array from Base64 format.
+ *
+ * @param s a Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(String s) {
+ return decode(s.toCharArray());
+ }
+
+ /**
+ * Decodes a byte array from Base64 format.
+ * No blanks or line breaks are allowed within the Base64 encoded data.
+ *
+ * @param in a character array containing the Base64 encoded data.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(char[] in) {
+ int iLen = in.length;
+ if (iLen % 4 != 0) {
+ throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
+ }
+ while (iLen > 0 && in[iLen - 1] == '=') {
+ iLen--;
+ }
+ int oLen = (iLen * 3) / 4;
+ byte[] out = new byte[oLen];
+ int ip = 0;
+ int op = 0;
+ while (ip < iLen) {
+ int i0 = in[ip++];
+ int i1 = in[ip++];
+ int i2 = ip < iLen ? in[ip++] : 'A';
+ int i3 = ip < iLen ? in[ip++] : 'A';
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) {
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ }
+ int b0 = map2[i0];
+ int b1 = map2[i1];
+ int b2 = map2[i2];
+ int b3 = map2[i3];
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) {
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ }
+ int o0 = (b0 << 2) | (b1 >>> 4);
+ int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
+ int o2 = ((b2 & 3) << 6) | b3;
+ out[op++] = (byte) o0;
+ if (op < oLen) {
+ out[op++] = (byte) o1;
+ }
+ if (op < oLen) {
+ out[op++] = (byte) o2;
+ }
+ }
+ return out;
+ }
+
+ // Dummy constructor.
+ private Base64Coder() {
+ }
+
+} // end class Base64Coder
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -34,6 +34,7 @@
*
* @param e the event which triggered the binding
*/
+ @Override
public void propertyChange(PropertyChangeEvent e) {
object.processDataBinding(dest);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -39,6 +39,7 @@
*
* @param e the event which triggered the binding
*/
+ @Override
public void propertyChange(PropertyChangeEvent e) {
object.removeDataBinding(dest);
object.applyDataBinding(dest);
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,400 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Container;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.regex.Pattern;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Un contexte de données qui permet l'utilisation des bindings sur les
- * entrées du contexte.
- *
- * TODO javadoc
- *
- * @author tony
- * @since 1.3
- */
-public abstract class DataContext {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(DataContext.class);
- /** le context qui contient les données */
- protected final DefaultJAXXContext delegate;
- /** la definition de l'entree actuallement selectionnee */
- protected DataContextEntry<?> currentEntry;
- /** to manage properties modifications */
- protected final PropertyChangeSupport pcs;
- protected DataContextEntry<?>[] entries;
- protected final String[] DEFAULT_JAXX_PCS;
-
- public abstract String getContextPath(Object... e);
-
- public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) {
- this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS;
- this.entries = entries;
- delegate = new DefaultJAXXContext() {
-
- @Override
- protected void setUi(JAXXObject ui) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Class<O> clazz) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- protected JAXXObject getUi() {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- protected void setParentContext(JAXXContext parentContext) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- protected JAXXContext getParentContext() {
- return null;
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- if (log.isTraceEnabled()) {
- log.trace(klazz + " - " + name);
- }
- super.removeContextValue(klazz, name);
- }
-
- @Override
- public <T> void setContextValue(T o, String name) {
- if (log.isTraceEnabled()) {
- log.trace(name + " - " + o.getClass());
- }
- super.setContextValue(o, name);
- }
- };
- pcs = new PropertyChangeSupport(this);
- }
-
- public DefaultJAXXContext getDelegate() {
- return delegate;
- }
-
- public Iterable<? extends DataContextEntry<?>> iterateOnAll() {
- return new Iterable<DataContextEntry<?>>() {
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- return new DataContextEntryIterator(entries);
- }
- };
- }
-
- public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) {
- return new Iterable<DataContextEntry<?>>() {
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- return new DataContextEntryIterator(entries, level);
- }
- };
- }
-
- public Iterable<? extends DataContextEntry<?>> reverseIterateOnAll() {
-
- return new Iterable<DataContextEntry<?>>() {
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- return new DataContextEntryIterator(entries, true);
- }
- };
- }
-
- public DataContextEntry<?> getCurrentEntry() {
- return currentEntry;
- }
-
- public DataContextEntry<?> getEntry(String path) {
- for (DataContextEntry<?> scope : reverseIterateOnAll()) {
- if (scope.acceptPath(path)) {
- return scope;
- }
- }
- return null;
- }
-
- public DataContextEntry<?> getEntry(Class<?> type) {
- for (DataContextEntry<?> scope : iterateOnAll()) {
- if (scope.acceptType(type)) {
- return scope;
- }
- }
- return null;
- }
-
- public <T> T getContextValue(DataContextEntry<T> entry, String key) {
- String contextKey = getKey(entry, key);
- T result = delegate.getContextValue(entry.getKlass(), contextKey);
- return result;
- }
-
- public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
- String contextKey = getKey(entry, key);
- delegate.setContextValue(value, contextKey);
- }
-
- public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
- String contextKey = getKey(entry, key);
- delegate.removeContextValue(value.getClass(), contextKey);
- }
-
- @SuppressWarnings("unchecked")
- public void updateSelectedData(String path, Object data, UpdateDataContext updator) {
-
- if (log.isDebugEnabled()) {
- log.debug("----------------------------------------------------------------");
- }
- if (currentEntry != null) {
-
- if (log.isDebugEnabled()) {
- log.debug("remove from old entry " + currentEntry);
- }
- for (DataContextEntry<?> s : currentEntry) {
- if (log.isDebugEnabled()) {
- log.debug("remove entry " + s);
- }
- updator.onRemovingData(this, s);
- }
- }
-
- currentEntry = getEntry(path);
-
- if (log.isDebugEnabled()) {
- log.debug("new entry " + currentEntry + " for path " + path);
- }
-
- if (currentEntry != null) {
-
- for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) {
-
- if (log.isDebugEnabled()) {
- log.debug("add entry " + s);
- }
- updator.onAddingData(this, s, path);
- }
- }
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public synchronized boolean hasListeners(String propertyName) {
- return pcs.hasListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
- return pcs.getPropertyChangeListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- return pcs.getPropertyChangeListeners();
- }
-
- public void removeJaxxPropertyChangeListener() {
- PropertyChangeListener[] toRemove = Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
- if (toRemove == null || toRemove.length == 0) {
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("before remove : " + getPropertyChangeListeners().length);
- log.debug("toRemove : " + toRemove.length);
- }
- for (PropertyChangeListener listener : toRemove) {
- removePropertyChangeListener(listener);
- }
- if (log.isDebugEnabled()) {
- log.debug("after remove : " + getPropertyChangeListeners().length);
- }
- }
-
- protected void firePropertyChange(String name, Object oldValue, Object newValue) {
- pcs.firePropertyChange(name, oldValue, newValue);
- }
-
- protected String getKey(DataContextEntry<?> entry, String key) {
- String result = null;
- if (key != null) {
- result = entry.hashCode() + "#" + key;
- }
- return result;
- }
-
- public void close() throws Exception {
- clear();
-
- // suppression des ecouteurs
-
- for (PropertyChangeListener l : getPropertyChangeListeners()) {
- removePropertyChangeListener(l);
- }
- }
-
- public void clear() {
- delegate.clear();
- }
-
- public static abstract class DataContextEntry<E> implements Iterable<DataContextEntry<?>> {
-
- private final int level;
- private final DataContextEntry<?> previous;
- private final DataContextEntry<?>[] parents;
- private Class<E> klass;
-
- public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
- this.previous = previous;
- this.level = previous.level + 1;
- this.klass = klass;
- this.parents = new DataContextEntry<?>[level];
- int i = level;
- while (i > 0) {
- parents[--i] = previous;
- previous = previous.previous;
- }
- }
-
- public DataContextEntry(Class<E> klass) {
- this.level = 0;
- this.klass = klass;
- this.previous = null;
- this.parents = new DataContextEntry<?>[0];
- }
-
- public Class<E> getKlass() {
- return klass;
- }
-
- public int getLevel() {
- return level;
- }
-
- public DataContextEntry<?>[] getParents() {
- return parents;
- }
-
- public abstract Pattern getPattern();
-
- public abstract String getContextPath(Object... args);
-
- public boolean acceptPath(String path) {
- return getPattern().matcher(path).matches();
- }
-
- public boolean acceptType(Class<?> type) {
- return klass.isAssignableFrom(type);
- }
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- int length = parents.length;
- DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1];
- System.arraycopy(parents, 0, t, 0, length);
- t[length] = this;
- return new DataContextEntryIterator(t, true);
- }
-
- @Override
- public String toString() {
- return super.toString() + "<type: " + klass.getSimpleName() + ">";
- }
- }
-
- public static interface UpdateDataContext<D extends DataContext> {
-
- void onRemovingData(D context, DataContextEntry<D> entry);
-
- void onAddingData(D context, DataContextEntry<D> entry, String path);
- }
-
- public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> {
-
- protected final DataContextEntry<?>[] datas;
- protected final boolean reverse;
- protected final int level;
- protected int index;
-
- public DataContextEntryIterator(DataContextEntry<?>[] datas) {
- this(datas, false, -1);
- }
-
- public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
- this(datas, false, level);
- }
-
- public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
- this(datas, reverse, -1);
- }
-
- DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
- this.datas = datas;
- this.reverse = reverse;
- if (reverse) {
- index = datas.length;
- } else {
- index = -1;
- }
- this.level = level;
- }
-
- @Override
- public boolean hasNext() {
- if (reverse) {
- return index > 0;
- } else {
- return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level);
- }
- }
-
- @Override
- public DataContextEntry<?> next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- if (reverse) {
- index--;
- } else {
- index++;
- }
- return datas[index];
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,281 +0,0 @@
-package jaxx.runtime;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.lang.annotation.*;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * The default context to be used for an application.
- *
- * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate
- * some classes asked via {@link #getContextValue(java.lang.Class)} and
- * {@link #getContextValue(java.lang.Class, java.lang.String)} methods.
- *
- * To registred a such class, just annotate your class with {@link AutoLoad}.
- *
- * @author chemit
- * @since 1.2
- * @see DefaultJAXXContext
- */
-public class DefaultApplicationContext extends DefaultJAXXContext {
-
- /**
- * A class annotated @AutoLoad is used by context to auto
- * instanciate the class when required.
- *
- * Note : A such class always have a public default constructor.
- *
- * @author chemit
- * @version 1.0, 21/02/09
- * @since 1.2
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public static @interface AutoLoad {
- //TODO use this to add a method to init
-
- String initMethod() default "";
- }
-
- /**
- * A class annotated @MethodAccess is used by context to obtain the value
- * of an entry via a declared method.
- *
- * Note : A such class must have a method called {@link #methodName()} with
- * a single String parameter.
- *
- * @author chemit
- * @version 1.0, 21/02/09
- * @since 1.2
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public static @interface MethodAccess {
-
- /**
- * Define a forward to a target class. When the target class
- * will be asked with method {@link #getContextValue(java.lang.Class, java.lang.String)}
- * it will be delegating to this class.
- *
- * @return the forwarded class
- */
- Class<?> target() default Object.class;
-
- /**
- * @return the name of the method to access data
- */
- String methodName();
- }
- /**
- * Map of forwarded classes (key) to classes (values).
- */
- protected Map<Class<?>, Class<?>> forwards;
-
- public DefaultApplicationContext() {
- super();
- forwards = new HashMap<Class<?>, Class<?>>();
- pcs = new PropertyChangeSupport(this);
- }
-
- public DefaultApplicationContext(JAXXObject ui) {
- super(ui);
- }
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
-
- /** to manage properties modifications */
- protected PropertyChangeSupport pcs;
-
- @SuppressWarnings({"unchecked"})
- @Override
- public <T> T getContextValue(Class<T> clazz, String name) {
- Object value = null;
- MethodAccess access;
-
- Class<?> realClass;
-
- if (forwards.containsKey(clazz)) {
- // this is a forward class
- realClass = forwards.get(clazz);
- // always call the forwarder with no name
- value = getContextValue(realClass, null);
- if (log.isDebugEnabled()) {
- log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")");
- }
-
- } else {
- realClass = clazz;
- value = super.getContextValue(realClass, name);
- }
-
- if (value == null) {
- AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
-
- if (anno == null) {
- // no annotation, so do nothing
- return null;
- }
-
- if (name != null) {
- throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
- }
- value = newInstance(clazz);
- if (!anno.initMethod().trim().isEmpty()){
- // apply method on class
- newAccess(clazz, value, anno.initMethod().trim());
- }
- if (log.isDebugEnabled()) {
- log.debug("new instance " + clazz + " : " + value);
- }
- // save new instance
- setContextValue(value, null);
- }
-
- access = realClass.getAnnotation(MethodAccess.class);
-
- if (access != null) {
- if (name == null) {
- if (access.target() != Object.class) {
- // register forward
- Class<?> targetClass = access.target();
- if (!forwards.containsKey(targetClass)) {
- // register forward
- forwards.put(targetClass, clazz);
- if (log.isDebugEnabled()) {
- log.debug("register forward from " + targetClass + " to " + clazz);
- }
- }
- }
- } else {
- // specialized access
- value = newAccess(realClass, value, access.methodName(), name);
- }
- }
- return (T) value;
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- Entry<Class<?>, Class<?>> entry;
- if (name == null && forwards.containsValue(klazz)) {
- // remove forward
- Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
- while (itr.hasNext()) {
- entry = itr.next();
- if (entry.getValue().equals(klazz)) {
- itr.remove();
- if (log.isDebugEnabled()) {
- log.debug("removed forward from " + entry.getKey() + " to " + klazz);
- }
- break;
- }
- }
- }
- //FIXME should update forwards state
- super.removeContextValue(klazz, name);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public synchronized boolean hasListeners(String propertyName) {
- return pcs.hasListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
- return pcs.getPropertyChangeListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- return pcs.getPropertyChangeListeners();
- }
-
- protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
-
- Object value = null;
-
- Constructor<?> constructor = null;
- try {
- constructor = clazz.getConstructor();
- // auto instanciate the class
- if (constructor == null) {
- throw new IllegalArgumentException(clazz + " has no public constructor");
- }
- } catch (NoSuchMethodException ex) {
- throw new IllegalArgumentException(ex);
- } catch (SecurityException ex) {
- throw new IllegalArgumentException(ex);
- }
- try {
- value = constructor.newInstance();
-
- } catch (InstantiationException ex) {
- throw new IllegalArgumentException(ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException(ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- return value;
- }
-
- protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException {
- Object value;
- try {
- Method m = clazz.getMethod(methodName, String.class);
- value = m.invoke(parent, name);
- return value;
- } catch (NoSuchMethodException ex) {
- throw new IllegalArgumentException(ex);
- } catch (SecurityException ex) {
- throw new IllegalArgumentException(ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException(ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- }
-
- protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException {
- Object value;
- try {
- Method m = clazz.getMethod(methodName);
- value = m.invoke(parent);
- return value;
- } catch (NoSuchMethodException ex) {
- throw new IllegalArgumentException(ex);
- } catch (SecurityException ex) {
- throw new IllegalArgumentException(ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException(ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- }
-
- protected void firePropertyChange(String name, Object oldValue, Object newValue) {
- pcs.firePropertyChange(name, oldValue, newValue);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,214 +0,0 @@
-package jaxx.runtime;
-
-import static jaxx.runtime.JAXXContextEntryDef.newDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.awt.Container;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation.
- * <p/>
- * The values are store in a {@link Map} but we can not use directly the values as key.
- * <p/>
- * Because, it does not work if we add for the same object multi entries (named and unamed)...
- * <p/>
- * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value.
- *
- * @author chemit
- */
-public class DefaultJAXXContext implements JAXXContext {
-
- protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = newDef(JAXXContext.class);
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
- /** l'ui auquel est rattache le context */
- protected JAXXObject ui;
- /** le context parent */
- protected JAXXContext parentContext;
- /** les données contenues dans le context */
- protected final Map<JAXXContextEntryDef<?>, Object> data;
-
- public DefaultJAXXContext() {
- data = new HashMap<JAXXContextEntryDef<?>, Object>();
- }
-
- public DefaultJAXXContext(JAXXObject ui) {
- this();
- this.ui = ui;
- }
-
- @Override
- public <T> void setContextValue(T o) {
- setContextValue(o, null);
- }
-
- @Override
- public <T> void setContextValue(T o, String name) {
- if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) {
- setParentContext((JAXXContext) o);
- return;
- }
- JAXXContextEntryDef<?> entry = getKey(name, o.getClass());
- // first remove entry
- Object oldValue = remove0(o.getClass(), name);
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("remove value " + oldValue.getClass() + " for " + entry);
- }
- }
- // then can put safely
- data.put(entry, o);
- }
-
- @Override
- public <T> T getContextValue(Class<T> clazz) {
- return getContextValue(clazz, null);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override
- public <T> T getContextValue(Class<T> clazz, String name) {
- if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) {
- return (T) getParentContext();
- }
- for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
- if (entry.getKey().accept(clazz, name)) {
- return (T) entry.getValue();
- }
- }
-
- // no value found in this context, will try in the parent context
- if (JAXXContext.class == clazz) {
- // no seek in the parent context, since we are already looking for it
- return null;
- }
-
- JAXXContext parent = getParentContext();
- if (parent == null) {
- // no parent context, so no value find
- return null;
- }
- // seek in parent context
- return parent.getContextValue(clazz, name);
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz) {
- removeContextValue(klazz, null);
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- remove0(klazz, name);
- }
-
- @Override
- public <O extends Container> O getParentContainer(Class<O> clazz) {
- return this.getParentContainer(ui, clazz);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
- if (ui == null) {
- throw new IllegalStateException("no ui attached to this context");
- }
- if (top == null) {
- throw new IllegalArgumentException("top parameter can not be null");
- }
- if (!Container.class.isAssignableFrom(top.getClass())) {
- throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class);
- }
- Container parent = ((Container) top).getParent();
- if (parent != null && !clazz.isAssignableFrom(parent.getClass())) {
- parent = getParentContainer(parent, clazz);
- }
- return (O) parent;
- }
-
- /**
- * Obtain all the keys of data for a given type.
- *
- * @param klass the type of searched keys
- * @return the array of all names of keys for the given type of data
- * @since 1.3
- */
- public String[] getKeys(Class<?> klass) {
- List<String> keys = new java.util.ArrayList<String>();
- for (JAXXContextEntryDef<?> key : data.keySet()) {
- if (key.getKlass() == klass) {
- keys.add(key.getName());
- }
- }
- return keys.toArray(new String[keys.size()]);
-
- }
-
- public void clear() {
- data.clear();
- }
-
- protected JAXXObject getUi() {
- return ui;
- }
-
- protected void setUi(JAXXObject ui) {
- this.ui = ui;
- }
-
- protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) {
- return JAXXContextEntryDef.newDef(name, klass);
- }
-
- @SuppressWarnings({"unchecked"})
- protected <T> T remove0(Class<T> klazz, String name) {
- if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) {
- JAXXContext old = getParentContext();
- setParentContext(null);
- return (T) old;
- }
- JAXXContextEntryDef<?> entry = null;
- for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
- if (entryDef.accept(klazz, name)) {
- entry = entryDef;
- break;
- }
- }
- if (entry != null) {
- return (T) data.remove(entry);
- }
-
- if (JAXXContext.class == klazz) {
- return null;
- }
- // try in parentContext
- JAXXContext parent = getParentContext();
-
- if (parent == null) {
- return null;
- }
-
- if (parent instanceof DefaultJAXXContext) {
- return ((DefaultJAXXContext) parent).remove0(klazz, name);
- }
-
- return null;
- }
-
- protected JAXXContext getParentContext() {
- return parentContext;
- }
-
- protected void setParentContext(JAXXContext parentContext) {
- if (parentContext instanceof JAXXObject) {
- // keep the real context, not the ui
- parentContext = ((JAXXObject) parentContext).getDelegateContext();
- }
- this.parentContext = parentContext;
- }
-}
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,5 +1,8 @@
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.
*
@@ -12,7 +15,7 @@
*
* @param parentContent the context of the parent of the ui (can be null if no parent is required)
* @param datas other datas to inject in initial context
- * @return the {@link jaxx.runtime.JAXXInitialContext} to be injected in the ui via the constructor of the {@link jaxx.runtime.JAXXObject}
+ * @return the {@link jaxx.runtime.context.JAXXInitialContext} to be injected in the ui via the constructor of the {@link jaxx.runtime.JAXXObject}
*/
JAXXInitialContext init(JAXXContext parentContent, Object... datas);
Deleted: 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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,107 +0,0 @@
-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);
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,119 +0,0 @@
-package jaxx.runtime;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * To qualify an entry in a {@link JAXXContext}.
- * <p/>
- * Use the factory methods <code>newDef</code> and <code>newListDef</code< to obtain new instances.
- *
- * @param <O> type of the entry associated to the definition
- * @author chemit
- */
-public class JAXXContextEntryDef<O> implements java.io.Serializable {
-
- /** name of the entry, can be nuill for a unamed entry. */
- protected String name;
-
- /** class of the entry, can not be null */
- protected Class<O> klass;
-
- private static final long serialVersionUID = 1L;
-
- public static <O> JAXXContextEntryDef<O> newDef(Class<O> klass) {
- return newDef(null, klass);
- }
-
- public static <O> JAXXContextEntryDef<O> newDef(String name, Class<O> klass) {
- return new JAXXContextEntryDef<O>(name, klass);
- }
-
- public static <O> JAXXContextEntryDef<List<O>> newListDef() {
- return newListDef(null);
- }
-
- @SuppressWarnings({"unchecked"})
- public static <O> JAXXContextEntryDef<List<O>> newListDef(String name) {
- JAXXContextEntryDef contextEntryDef = new JAXXContextEntryDef<List<O>>(name, JAXXContextEntryDef.<O>castList());
- contextEntryDef.klass = List.class;
- return contextEntryDef;
- }
-
-
- public String getName() {
- return name;
- }
-
- public Class<O> getKlass() {
- return klass;
- }
-
- public O getContextValue(JAXXContext context) {
- return context.getContextValue(klass, name);
- }
-
- public void removeContextValue(JAXXContext context) {
- context.removeContextValue(klass, name);
- }
-
- public void setContextValue(JAXXContext context, O value) {
- context.setContextValue(value, name);
- }
-
- @Override
- public String toString() {
- return super.toString() + "<" + klass + ":" + name + ">";
- }
-
- protected JAXXContextEntryDef(Class<O> klass) {
- this(null, klass);
- }
-
- protected JAXXContextEntryDef(String name, Class<O> klass) {
- if (klass == null) {
- throw new IllegalArgumentException("class can not be null");
- }
- this.name = name;
- this.klass = klass;
- }
-
- @SuppressWarnings({"unchecked"})
- protected static <O> Class<List<O>> castList() {
- return (Class<List<O>>) Collections.emptyList().getClass();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof JAXXContextEntryDef)) {
- return false;
- }
- JAXXContextEntryDef that = (JAXXContextEntryDef) o;
- return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null);
-
- }
-
- @Override
- public int hashCode() {
- int result = (name != null ? name.hashCode() : 0);
- return 31 * result + klass.hashCode();
- }
-
- public boolean accept(Class<?> klass, String name) {
- if (klass == Object.class && this.klass != Object.class) {
- // try on name only
- return (this.name != null && name != null && this.name.equals(name));
- }
- return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
- || (this.name != null && name != null && this.name.equals(name)));
- }
-
- public boolean accept2(Class<?> klass, String name) {
- return !(klass == Object.class && this.klass != Object.class) &&
- this.klass.isAssignableFrom(klass) && (this.name == null &&
- name == null || (this.name != null && name != null && this.name.equals(name)));
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,105 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Container;
-import java.util.Map.Entry;
-
-/**
- * An initial context to be inject in a {@link JAXXObject}.
- * <p/>
- * The method {@link #add(Object)} register a simple value.
- * <p/>
- * The method {@link #add(String, Object)} register a named value.
- * <p/>
- * The method {@link #to(JAXXContext)} inject in the {@link JAXXObject} the values registred in the initial context.
- * <p/>
- * The initial context is also a "limited" {@link JAXXContext}, since we can only use the two methods
- * <p/>
- * {@link #getContextValue(Class)} or {@link #getContextValue(Class, String)}.
- *
- * @see JAXXContext
- */
-public class JAXXInitialContext extends DefaultJAXXContext {
-
- public JAXXInitialContext() {
- super();
- }
-
- /**
- * Register a simple (none named) value in the context.
- *
- * @param value the value to be registred in the context
- * @return the instance of the context
- */
- public JAXXInitialContext add(Object value) {
- return add((String) null, value);
- }
-
- /**
- * Register a named value in the context.
- *
- * @param name the name of the value
- * @param value the value to registred
- * @return the instance of the context
- */
- public JAXXInitialContext add(String name, Object value) {
- super.setContextValue(value, name);
- return this;
- }
-
- /**
- * Register a named value in the context.
- *
- * @param <O> type of data to add
- * @param def definition of entry
- * @param value the value to registred
- * @return the instance of the context
- */
- public <O> JAXXInitialContext add(JAXXContextEntryDef<O> def, O value) {
- def.setContextValue(this, value);
- return this;
- }
-
- /**
- * Inject all the registed values into the {@link JAXXObject}
- *
- * @param dst the object to fill.
- */
- public void to(JAXXContext dst) {
- if (parentContext != null) {
- dst.setContextValue(parentContext);
- }
- for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
- dst.setContextValue(entry.getValue(), entry.getKey().getName());
- }
- }
-
- @Override
- public void setContextValue(Object o) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public void setContextValue(Object o, String name) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Class<O> clazz) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
- throw new RuntimeException("not implemented");
- }
-}
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,30 +4,42 @@
*/
package jaxx.runtime;
-/** The <code>JAXXObject</code> interface is implemented by all classes produced by the JAXX compiler. */
+import java.util.Map;
+import jaxx.runtime.context.JAXXContext;
+
+/**
+ * The <code>JAXXObject</code> interface is implemented by all classes
+ * produced by the JAXX compiler.
+ */
public interface JAXXObject extends JAXXContext {
+
/**
* Retrieves an object defined in an XML tag by its ID.
*
* @param id the id of the component to retrieve
* @return the object
*/
- public Object getObjectById(String id);
+ Object getObjectById(String id);
/**
* Pretrieves the dictonary of knwon objects indexed by their ids.
*
* @return the dictonary of objects.
*/
- public java.util.Map<String, Object> get$objectMap();
+ Map<String, Object> get$objectMap();
- public void applyDataBinding(String id);
+ /**
+ *
+ * @return the {@link JAXXContext} attached to the object
+ */
+ JAXXContext getDelegateContext();
+ /**
+ * Apply the data bind by name and then process it.
+ * @param id the id of the databinding
+ */
+ void applyDataBinding(String id);
- public void removeDataBinding(String id);
-
- public jaxx.runtime.JAXXContext getDelegateContext();
-
/**
* Processes a data binding by name. Data binding names are comprised of an object ID and a property name:
* for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is
@@ -36,8 +48,14 @@
*
* @param dest the name of the data binding to run
*/
- public void processDataBinding(String dest);
+ void processDataBinding(String dest);
+ /**
+ * Remove a databinding by name.
+ *
+ * @param id the name of databinding to remove
+ */
+ void removeDataBinding(String id);
/**
* All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
@@ -48,5 +66,5 @@
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
- public void firePropertyChange(String name, Object oldValue, Object newValue);
-}
\ No newline at end of file
+ void firePropertyChange(String name, Object oldValue, Object newValue);
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,7 +4,7 @@
*/
package jaxx.runtime;
-import jaxx.css.Stylesheet;
+import jaxx.runtime.css.Stylesheet;
import java.io.Serializable;
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,5 @@
package jaxx.runtime;
-import jaxx.runtime.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@@ -169,6 +168,8 @@
}
/**
+ * TODO move this to JAXXComboBox.
+ *
* Fill a combo box model with some datas, and select after all the given object
*
* @param combo the combo to fill
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,7 @@
package jaxx.runtime;
-import jaxx.Base64Coder;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -84,6 +85,21 @@
}
}
+ /**
+ * Method to initialize the context of a ui.
+ *
+ * @param ui the ui
+ * @param parentContext the context to set in ui
+ */
+ public static void initContext(JAXXObject ui, JAXXContext parentContext) {
+
+ if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) {
+ ((jaxx.runtime.context.JAXXInitialContext) parentContext).to(ui);
+ } else {
+ ui.setContextValue(parentContext);
+ }
+ }
+
public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) {
WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer);
List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null;
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,401 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import java.awt.Container;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.regex.Pattern;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Un contexte de données qui permet l'utilisation des bindings sur les
+ * entrées du contexte.
+ *
+ * TODO javadoc
+ *
+ * @author tony
+ * @since 1.3
+ */
+public abstract class DataContext {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(DataContext.class);
+ /** le context qui contient les données */
+ protected final DefaultJAXXContext delegate;
+ /** la definition de l'entree actuallement selectionnee */
+ protected DataContextEntry<?> currentEntry;
+ /** to manage properties modifications */
+ protected final PropertyChangeSupport pcs;
+ protected DataContextEntry<?>[] entries;
+ protected final String[] DEFAULT_JAXX_PCS;
+
+ public abstract String getContextPath(Object... e);
+
+ public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) {
+ this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS;
+ this.entries = entries;
+ delegate = new DefaultJAXXContext() {
+
+ @Override
+ protected void setUi(JAXXObject ui) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Class<O> clazz) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ protected JAXXObject getUi() {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ protected void setParentContext(JAXXContext parentContext) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ protected JAXXContext getParentContext() {
+ return null;
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ if (log.isTraceEnabled()) {
+ log.trace(klazz + " - " + name);
+ }
+ super.removeContextValue(klazz, name);
+ }
+
+ @Override
+ public <T> void setContextValue(T o, String name) {
+ if (log.isTraceEnabled()) {
+ log.trace(name + " - " + o.getClass());
+ }
+ super.setContextValue(o, name);
+ }
+ };
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ public DefaultJAXXContext getDelegate() {
+ return delegate;
+ }
+
+ public Iterable<? extends DataContextEntry<?>> iterateOnAll() {
+ return new Iterable<DataContextEntry<?>>() {
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ return new DataContextEntryIterator(entries);
+ }
+ };
+ }
+
+ public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) {
+ return new Iterable<DataContextEntry<?>>() {
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ return new DataContextEntryIterator(entries, level);
+ }
+ };
+ }
+
+ public Iterable<? extends DataContextEntry<?>> reverseIterateOnAll() {
+
+ return new Iterable<DataContextEntry<?>>() {
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ return new DataContextEntryIterator(entries, true);
+ }
+ };
+ }
+
+ public DataContextEntry<?> getCurrentEntry() {
+ return currentEntry;
+ }
+
+ public DataContextEntry<?> getEntry(String path) {
+ for (DataContextEntry<?> scope : reverseIterateOnAll()) {
+ if (scope.acceptPath(path)) {
+ return scope;
+ }
+ }
+ return null;
+ }
+
+ public DataContextEntry<?> getEntry(Class<?> type) {
+ for (DataContextEntry<?> scope : iterateOnAll()) {
+ if (scope.acceptType(type)) {
+ return scope;
+ }
+ }
+ return null;
+ }
+
+ public <T> T getContextValue(DataContextEntry<T> entry, String key) {
+ String contextKey = getKey(entry, key);
+ T result = delegate.getContextValue(entry.getKlass(), contextKey);
+ return result;
+ }
+
+ public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
+ String contextKey = getKey(entry, key);
+ delegate.setContextValue(value, contextKey);
+ }
+
+ public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
+ String contextKey = getKey(entry, key);
+ delegate.removeContextValue(value.getClass(), contextKey);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void updateSelectedData(String path, Object data, UpdateDataContext updator) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("----------------------------------------------------------------");
+ }
+ if (currentEntry != null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("remove from old entry " + currentEntry);
+ }
+ for (DataContextEntry<?> s : currentEntry) {
+ if (log.isDebugEnabled()) {
+ log.debug("remove entry " + s);
+ }
+ updator.onRemovingData(this, s);
+ }
+ }
+
+ currentEntry = getEntry(path);
+
+ if (log.isDebugEnabled()) {
+ log.debug("new entry " + currentEntry + " for path " + path);
+ }
+
+ if (currentEntry != null) {
+
+ for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("add entry " + s);
+ }
+ updator.onAddingData(this, s, path);
+ }
+ }
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ public void removeJaxxPropertyChangeListener() {
+ PropertyChangeListener[] toRemove = Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ if (toRemove == null || toRemove.length == 0) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("before remove : " + getPropertyChangeListeners().length);
+ log.debug("toRemove : " + toRemove.length);
+ }
+ for (PropertyChangeListener listener : toRemove) {
+ removePropertyChangeListener(listener);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("after remove : " + getPropertyChangeListeners().length);
+ }
+ }
+
+ protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
+
+ protected String getKey(DataContextEntry<?> entry, String key) {
+ String result = null;
+ if (key != null) {
+ result = entry.hashCode() + "#" + key;
+ }
+ return result;
+ }
+
+ public void close() throws Exception {
+ clear();
+
+ // suppression des ecouteurs
+
+ for (PropertyChangeListener l : getPropertyChangeListeners()) {
+ removePropertyChangeListener(l);
+ }
+ }
+
+ public void clear() {
+ delegate.clear();
+ }
+
+ public static abstract class DataContextEntry<E> implements Iterable<DataContextEntry<?>> {
+
+ private final int level;
+ private final DataContextEntry<?> previous;
+ private final DataContextEntry<?>[] parents;
+ private Class<E> klass;
+
+ public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
+ this.previous = previous;
+ this.level = previous.level + 1;
+ this.klass = klass;
+ this.parents = new DataContextEntry<?>[level];
+ int i = level;
+ while (i > 0) {
+ parents[--i] = previous;
+ previous = previous.previous;
+ }
+ }
+
+ public DataContextEntry(Class<E> klass) {
+ this.level = 0;
+ this.klass = klass;
+ this.previous = null;
+ this.parents = new DataContextEntry<?>[0];
+ }
+
+ public Class<E> getKlass() {
+ return klass;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public DataContextEntry<?>[] getParents() {
+ return parents;
+ }
+
+ public abstract Pattern getPattern();
+
+ public abstract String getContextPath(Object... args);
+
+ public boolean acceptPath(String path) {
+ return getPattern().matcher(path).matches();
+ }
+
+ public boolean acceptType(Class<?> type) {
+ return klass.isAssignableFrom(type);
+ }
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ int length = parents.length;
+ DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1];
+ System.arraycopy(parents, 0, t, 0, length);
+ t[length] = this;
+ return new DataContextEntryIterator(t, true);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<type: " + klass.getSimpleName() + ">";
+ }
+ }
+
+ public static interface UpdateDataContext<D extends DataContext> {
+
+ void onRemovingData(D context, DataContextEntry<D> entry);
+
+ void onAddingData(D context, DataContextEntry<D> entry, String path);
+ }
+
+ public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> {
+
+ protected final DataContextEntry<?>[] datas;
+ protected final boolean reverse;
+ protected final int level;
+ protected int index;
+
+ public DataContextEntryIterator(DataContextEntry<?>[] datas) {
+ this(datas, false, -1);
+ }
+
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
+ this(datas, false, level);
+ }
+
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
+ this(datas, reverse, -1);
+ }
+
+ DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
+ this.datas = datas;
+ this.reverse = reverse;
+ if (reverse) {
+ index = datas.length;
+ } else {
+ index = -1;
+ }
+ this.level = level;
+ }
+
+ @Override
+ public boolean hasNext() {
+ if (reverse) {
+ return index > 0;
+ } else {
+ return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level);
+ }
+ }
+
+ @Override
+ public DataContextEntry<?> next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ if (reverse) {
+ index--;
+ } else {
+ index++;
+ }
+ return datas[index];
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,282 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.lang.annotation.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The default context to be used for an application.
+ *
+ * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate
+ * some classes asked via {@link #getContextValue(java.lang.Class)} and
+ * {@link #getContextValue(java.lang.Class, java.lang.String)} methods.
+ *
+ * To registred a such class, just annotate your class with {@link AutoLoad}.
+ *
+ * @author chemit
+ * @since 1.2
+ * @see DefaultJAXXContext
+ */
+public class DefaultApplicationContext extends DefaultJAXXContext {
+
+ /**
+ * A class annotated @AutoLoad is used by context to auto
+ * instanciate the class when required.
+ *
+ * Note : A such class always have a public default constructor.
+ *
+ * @author chemit
+ * @version 1.0, 21/02/09
+ * @since 1.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface AutoLoad {
+ //TODO use this to add a method to init
+
+ String initMethod() default "";
+ }
+
+ /**
+ * A class annotated @MethodAccess is used by context to obtain the value
+ * of an entry via a declared method.
+ *
+ * Note : A such class must have a method called {@link #methodName()} with
+ * a single String parameter.
+ *
+ * @author chemit
+ * @version 1.0, 21/02/09
+ * @since 1.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface MethodAccess {
+
+ /**
+ * Define a forward to a target class. When the target class
+ * will be asked with method {@link #getContextValue(java.lang.Class, java.lang.String)}
+ * it will be delegating to this class.
+ *
+ * @return the forwarded class
+ */
+ Class<?> target() default Object.class;
+
+ /**
+ * @return the name of the method to access data
+ */
+ String methodName();
+ }
+ /**
+ * Map of forwarded classes (key) to classes (values).
+ */
+ protected Map<Class<?>, Class<?>> forwards;
+
+ public DefaultApplicationContext() {
+ super();
+ forwards = new HashMap<Class<?>, Class<?>>();
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ public DefaultApplicationContext(JAXXObject ui) {
+ super(ui);
+ }
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
+
+ /** to manage properties modifications */
+ protected PropertyChangeSupport pcs;
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ Object value = null;
+ MethodAccess access;
+
+ Class<?> realClass;
+
+ if (forwards.containsKey(clazz)) {
+ // this is a forward class
+ realClass = forwards.get(clazz);
+ // always call the forwarder with no name
+ value = getContextValue(realClass, null);
+ if (log.isDebugEnabled()) {
+ log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")");
+ }
+
+ } else {
+ realClass = clazz;
+ value = super.getContextValue(realClass, name);
+ }
+
+ if (value == null) {
+ AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
+
+ if (anno == null) {
+ // no annotation, so do nothing
+ return null;
+ }
+
+ if (name != null) {
+ throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
+ }
+ value = newInstance(clazz);
+ if (!anno.initMethod().trim().isEmpty()){
+ // apply method on class
+ newAccess(clazz, value, anno.initMethod().trim());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("new instance " + clazz + " : " + value);
+ }
+ // save new instance
+ setContextValue(value, null);
+ }
+
+ access = realClass.getAnnotation(MethodAccess.class);
+
+ if (access != null) {
+ if (name == null) {
+ if (access.target() != Object.class) {
+ // register forward
+ Class<?> targetClass = access.target();
+ if (!forwards.containsKey(targetClass)) {
+ // register forward
+ forwards.put(targetClass, clazz);
+ if (log.isDebugEnabled()) {
+ log.debug("register forward from " + targetClass + " to " + clazz);
+ }
+ }
+ }
+ } else {
+ // specialized access
+ value = newAccess(realClass, value, access.methodName(), name);
+ }
+ }
+ return (T) value;
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ Entry<Class<?>, Class<?>> entry;
+ if (name == null && forwards.containsValue(klazz)) {
+ // remove forward
+ Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
+ while (itr.hasNext()) {
+ entry = itr.next();
+ if (entry.getValue().equals(klazz)) {
+ itr.remove();
+ if (log.isDebugEnabled()) {
+ log.debug("removed forward from " + entry.getKey() + " to " + klazz);
+ }
+ break;
+ }
+ }
+ }
+ //FIXME should update forwards state
+ super.removeContextValue(klazz, name);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
+
+ Object value = null;
+
+ Constructor<?> constructor = null;
+ try {
+ constructor = clazz.getConstructor();
+ // auto instanciate the class
+ if (constructor == null) {
+ throw new IllegalArgumentException(clazz + " has no public constructor");
+ }
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ try {
+ value = constructor.newInstance();
+
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ return value;
+ }
+
+ protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException {
+ Object value;
+ try {
+ Method m = clazz.getMethod(methodName, String.class);
+ value = m.invoke(parent, name);
+ return value;
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+
+ protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException {
+ Object value;
+ try {
+ Method m = clazz.getMethod(methodName);
+ value = m.invoke(parent);
+ return value;
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+
+ protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,215 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import static jaxx.runtime.context.JAXXContextEntryDef.newDef;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.Container;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation.
+ * <p/>
+ * The values are store in a {@link Map} but we can not use directly the values as key.
+ * <p/>
+ * Because, it does not work if we add for the same object multi entries (named and unamed)...
+ * <p/>
+ * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value.
+ *
+ * @author chemit
+ */
+public class DefaultJAXXContext implements JAXXContext {
+
+ protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = newDef(JAXXContext.class);
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
+ /** l'ui auquel est rattache le context */
+ protected JAXXObject ui;
+ /** le context parent */
+ protected JAXXContext parentContext;
+ /** les données contenues dans le context */
+ protected final Map<JAXXContextEntryDef<?>, Object> data;
+
+ public DefaultJAXXContext() {
+ data = new HashMap<JAXXContextEntryDef<?>, Object>();
+ }
+
+ public DefaultJAXXContext(JAXXObject ui) {
+ this();
+ this.ui = ui;
+ }
+
+ @Override
+ public <T> void setContextValue(T o) {
+ setContextValue(o, null);
+ }
+
+ @Override
+ public <T> void setContextValue(T o, String name) {
+ if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) {
+ setParentContext((JAXXContext) o);
+ return;
+ }
+ JAXXContextEntryDef<?> entry = getKey(name, o.getClass());
+ // first remove entry
+ Object oldValue = remove0(o.getClass(), name);
+ if (oldValue != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("remove value " + oldValue.getClass() + " for " + entry);
+ }
+ }
+ // then can put safely
+ data.put(entry, o);
+ }
+
+ @Override
+ public <T> T getContextValue(Class<T> clazz) {
+ return getContextValue(clazz, null);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) {
+ return (T) getParentContext();
+ }
+ for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
+ if (entry.getKey().accept(clazz, name)) {
+ return (T) entry.getValue();
+ }
+ }
+
+ // no value found in this context, will try in the parent context
+ if (JAXXContext.class == clazz) {
+ // no seek in the parent context, since we are already looking for it
+ return null;
+ }
+
+ JAXXContext parent = getParentContext();
+ if (parent == null) {
+ // no parent context, so no value find
+ return null;
+ }
+ // seek in parent context
+ return parent.getContextValue(clazz, name);
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz) {
+ removeContextValue(klazz, null);
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ remove0(klazz, name);
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Class<O> clazz) {
+ return this.getParentContainer(ui, clazz);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
+ if (ui == null) {
+ throw new IllegalStateException("no ui attached to this context");
+ }
+ if (top == null) {
+ throw new IllegalArgumentException("top parameter can not be null");
+ }
+ if (!Container.class.isAssignableFrom(top.getClass())) {
+ throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class);
+ }
+ Container parent = ((Container) top).getParent();
+ if (parent != null && !clazz.isAssignableFrom(parent.getClass())) {
+ parent = getParentContainer(parent, clazz);
+ }
+ return (O) parent;
+ }
+
+ /**
+ * Obtain all the keys of data for a given type.
+ *
+ * @param klass the type of searched keys
+ * @return the array of all names of keys for the given type of data
+ * @since 1.3
+ */
+ public String[] getKeys(Class<?> klass) {
+ List<String> keys = new java.util.ArrayList<String>();
+ for (JAXXContextEntryDef<?> key : data.keySet()) {
+ if (key.getKlass() == klass) {
+ keys.add(key.getName());
+ }
+ }
+ return keys.toArray(new String[keys.size()]);
+
+ }
+
+ public void clear() {
+ data.clear();
+ }
+
+ protected JAXXObject getUi() {
+ return ui;
+ }
+
+ protected void setUi(JAXXObject ui) {
+ this.ui = ui;
+ }
+
+ protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) {
+ return JAXXContextEntryDef.newDef(name, klass);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected <T> T remove0(Class<T> klazz, String name) {
+ if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) {
+ JAXXContext old = getParentContext();
+ setParentContext(null);
+ return (T) old;
+ }
+ JAXXContextEntryDef<?> entry = null;
+ for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
+ if (entryDef.accept(klazz, name)) {
+ entry = entryDef;
+ break;
+ }
+ }
+ if (entry != null) {
+ return (T) data.remove(entry);
+ }
+
+ if (JAXXContext.class == klazz) {
+ return null;
+ }
+ // try in parentContext
+ JAXXContext parent = getParentContext();
+
+ if (parent == null) {
+ return null;
+ }
+
+ if (parent instanceof DefaultJAXXContext) {
+ return ((DefaultJAXXContext) parent).remove0(klazz, name);
+ }
+
+ return null;
+ }
+
+ protected JAXXContext getParentContext() {
+ return parentContext;
+ }
+
+ protected void setParentContext(JAXXContext parentContext) {
+ if (parentContext instanceof JAXXObject) {
+ // keep the real context, not the ui
+ parentContext = ((JAXXObject) parentContext).getDelegateContext();
+ }
+ this.parentContext = parentContext;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java (from rev 1560, 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/JAXXContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,107 @@
+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);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,119 @@
+package jaxx.runtime.context;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * To qualify an entry in a {@link JAXXContext}.
+ * <p/>
+ * Use the factory methods <code>newDef</code> and <code>newListDef</code< to obtain new instances.
+ *
+ * @param <O> type of the entry associated to the definition
+ * @author chemit
+ */
+public class JAXXContextEntryDef<O> implements java.io.Serializable {
+
+ /** name of the entry, can be nuill for a unamed entry. */
+ protected String name;
+
+ /** class of the entry, can not be null */
+ protected Class<O> klass;
+
+ private static final long serialVersionUID = 1L;
+
+ public static <O> JAXXContextEntryDef<O> newDef(Class<O> klass) {
+ return newDef(null, klass);
+ }
+
+ public static <O> JAXXContextEntryDef<O> newDef(String name, Class<O> klass) {
+ return new JAXXContextEntryDef<O>(name, klass);
+ }
+
+ public static <O> JAXXContextEntryDef<List<O>> newListDef() {
+ return newListDef(null);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public static <O> JAXXContextEntryDef<List<O>> newListDef(String name) {
+ JAXXContextEntryDef contextEntryDef = new JAXXContextEntryDef<List<O>>(name, JAXXContextEntryDef.<O>castList());
+ contextEntryDef.klass = List.class;
+ return contextEntryDef;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<O> getKlass() {
+ return klass;
+ }
+
+ public O getContextValue(JAXXContext context) {
+ return context.getContextValue(klass, name);
+ }
+
+ public void removeContextValue(JAXXContext context) {
+ context.removeContextValue(klass, name);
+ }
+
+ public void setContextValue(JAXXContext context, O value) {
+ context.setContextValue(value, name);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<" + klass + ":" + name + ">";
+ }
+
+ protected JAXXContextEntryDef(Class<O> klass) {
+ this(null, klass);
+ }
+
+ protected JAXXContextEntryDef(String name, Class<O> klass) {
+ if (klass == null) {
+ throw new IllegalArgumentException("class can not be null");
+ }
+ this.name = name;
+ this.klass = klass;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected static <O> Class<List<O>> castList() {
+ return (Class<List<O>>) Collections.emptyList().getClass();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof JAXXContextEntryDef)) {
+ return false;
+ }
+ JAXXContextEntryDef that = (JAXXContextEntryDef) o;
+ return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (name != null ? name.hashCode() : 0);
+ return 31 * result + klass.hashCode();
+ }
+
+ public boolean accept(Class<?> klass, String name) {
+ if (klass == Object.class && this.klass != Object.class) {
+ // try on name only
+ return (this.name != null && name != null && this.name.equals(name));
+ }
+ return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
+ || (this.name != null && name != null && this.name.equals(name)));
+ }
+
+ public boolean accept2(Class<?> klass, String name) {
+ return !(klass == Object.class && this.klass != Object.class) &&
+ this.klass.isAssignableFrom(klass) && (this.name == null &&
+ name == null || (this.name != null && name != null && this.name.equals(name)));
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,105 @@
+package jaxx.runtime.context;
+
+import java.awt.Container;
+import java.util.Map.Entry;
+
+/**
+ * An initial context to be inject in a {@link JAXXObject}.
+ * <p/>
+ * The method {@link #add(Object)} register a simple value.
+ * <p/>
+ * The method {@link #add(String, Object)} register a named value.
+ * <p/>
+ * The method {@link #to(JAXXContext)} inject in the {@link JAXXObject} the values registred in the initial context.
+ * <p/>
+ * The initial context is also a "limited" {@link JAXXContext}, since we can only use the two methods
+ * <p/>
+ * {@link #getContextValue(Class)} or {@link #getContextValue(Class, String)}.
+ *
+ * @see JAXXContext
+ */
+public class JAXXInitialContext extends DefaultJAXXContext {
+
+ public JAXXInitialContext() {
+ super();
+ }
+
+ /**
+ * Register a simple (none named) value in the context.
+ *
+ * @param value the value to be registred in the context
+ * @return the instance of the context
+ */
+ public JAXXInitialContext add(Object value) {
+ return add((String) null, value);
+ }
+
+ /**
+ * Register a named value in the context.
+ *
+ * @param name the name of the value
+ * @param value the value to registred
+ * @return the instance of the context
+ */
+ public JAXXInitialContext add(String name, Object value) {
+ super.setContextValue(value, name);
+ return this;
+ }
+
+ /**
+ * Register a named (or not) value in the context.
+ *
+ * @param <O> type of data to add
+ * @param def definition of entry
+ * @param value the value to registred
+ * @return the instance of the context
+ */
+ public <O> JAXXInitialContext add(JAXXContextEntryDef<O> def, O value) {
+ def.setContextValue(this, value);
+ return this;
+ }
+
+ /**
+ * Inject all the registed values into the {@link JAXXObject}
+ *
+ * @param dst the object to fill.
+ */
+ public void to(JAXXContext dst) {
+ if (parentContext != null) {
+ dst.setContextValue(parentContext);
+ }
+ for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
+ dst.setContextValue(entry.getValue(), entry.getKey().getName());
+ }
+ }
+
+ @Override
+ public void setContextValue(Object o) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public void setContextValue(Object o, String name) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Class<O> clazz) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
+ throw new RuntimeException("not implemented");
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -9,6 +9,7 @@
* track of which data bindings are in effect.
*/
public class DataBinding {
+
private String id;
public DataBinding(String id) {
@@ -28,4 +29,4 @@
public int hashCode() {
return id.hashCode();
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -10,12 +10,12 @@
import java.util.WeakHashMap;
public class Pseudoclasses {
+
public static final String NO_PSEUDOCLASS = "no pseudoclass";
-
private static Map<Object, Map<String, List<PropertyValue>>> properties = new WeakHashMap<Object, Map<String, List<PropertyValue>>>();
+ private static class PropertyValue implements Comparable<PropertyValue> {
- private static class PropertyValue implements Comparable<PropertyValue> {
private Object value;
private int id;
@@ -32,6 +32,7 @@
return id;
}
+ @Override
public int compareTo(PropertyValue o) {
return getId() - o.getId();
}
@@ -41,14 +42,14 @@
if (!(o instanceof PropertyValue)) {
return false;
}
- PropertyValue value = (PropertyValue) o;
- if (value.getId() != getId()) {
+ PropertyValue that = (PropertyValue) o;
+ if (that.getId() != getId()) {
return false;
}
- if (value.getValue() == null) {
+ if (that.getValue() == null) {
return getValue() == null;
}
- return value.getValue().equals(getValue());
+ return that.getValue().equals(getValue());
}
@Override
@@ -118,8 +119,9 @@
parent.applyDataBinding(((DataBinding) value).getId());
}
return value;
- } else
+ } else {
return currentValue;
+ }
}
public static Object removeProperty(JAXXObject parent, Object object, String property, Object oldValue, Object currentValue, int id) {
@@ -134,8 +136,9 @@
propertyRemoved(object, property, wrap(oldValue), id);
value = getCurrentValue(object, property);
return value;
- } else
+ } else {
return currentValue;
+ }
}
public static Object wrap(boolean value) {
@@ -173,4 +176,4 @@
public static Object wrap(Object value) {
return value;
}
-}
\ No newline at end of file
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/Rule.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.css;
+
+import java.util.Map;
+
+public class Rule implements java.io.Serializable, Comparable<Rule> {
+
+ public static final String INLINE_ATTRIBUTE = "<inline attribute>";
+ public static final String DATA_BINDING = "<data binding>";
+ private Selector[] selectors;
+ private Map<String, String> properties;
+ private static final long serialVersionUID = 1L;
+
+ public Rule(Selector[] selectors, Map<String, String> properties) {
+ this.selectors = selectors;
+ java.util.Arrays.sort(selectors);
+ this.properties = properties;
+ }
+
+ public Rule(Selector[] selectors, String[] keys, String[] values) {
+ this.selectors = selectors;
+ java.util.Arrays.sort(selectors);
+ this.properties = new java.util.HashMap<String, String>();
+ if (keys.length != values.length) {
+ throw new IllegalArgumentException("keys and values must have the same number of entries");
+ }
+ for (int i = 0; i < keys.length; i++) {
+ properties.put(keys[i], values[i]);
+ }
+ }
+
+ public Selector[] getSelectors() {
+ return selectors;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public int compareTo(Rule o) {
+ return selectors[0].compareTo(o.selectors[0]); // they are already sorted so we only need to compare the highest-ranked from each one
+ }
+
+ @Override
+ public String toString() {
+ return "Rule[" + java.util.Arrays.asList(selectors) + ", " + properties + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/Selector.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.css;
+
+public class Selector implements java.io.Serializable, Comparable<Selector> {
+
+ public static final int NEVER_APPLIES = 0;
+ public static final int PSEUDOCLASS_APPLIES_INHERIT_ONLY = 1;
+ public static final int PSEUDOCLASS_APPLIES = 2;
+ public static final int ALWAYS_APPLIES_INHERIT_ONLY = 3;
+ public static final int ALWAYS_APPLIES = 4;
+ private String javaClassName;
+ private String styleClass;
+ private String pseudoClass;
+ private String id;
+ private boolean inline;
+ private static final long serialVersionUID = 1L;
+
+ public Selector(String javaClassName, String styleClass, String pseudoClass, String id) {
+ this(javaClassName, styleClass, pseudoClass, id, false);
+ }
+
+ public Selector(String javaClassName, String styleClass, String pseudoClass, String id, boolean inline) {
+ this.javaClassName = javaClassName;
+ this.styleClass = styleClass;
+ this.pseudoClass = pseudoClass;
+ this.id = id;
+ this.inline = inline;
+ }
+
+ public String getJavaClassName() {
+ return javaClassName;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+ public String getPseudoClass() {
+ return pseudoClass;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public boolean isInline() {
+ return inline;
+ }
+
+ @Override
+ public int compareTo(Selector selector) {
+ if (inline && !selector.inline) {
+ return 1;
+ }
+ if (!inline && selector.inline) {
+ return -1;
+ }
+ if (pseudoClass != null && selector.pseudoClass == null) {
+ return 1;
+ }
+ if (pseudoClass == null && selector.pseudoClass != null) {
+ return -1;
+ }
+ if (id != null && selector.id == null) {
+ return 1;
+ }
+ if (id == null && selector.id != null) {
+ return -1;
+ }
+ if (styleClass != null && selector.styleClass == null) {
+ return 1;
+ }
+ if (styleClass == null && selector.styleClass != null) {
+ return -1;
+ }
+ if (javaClassName != null && selector.javaClassName == null) {
+ return 1;
+ }
+ if (javaClassName == null && selector.javaClassName != null) {
+ return -1;
+ }
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "Selector[" + javaClassName + ", " + styleClass + ", " + pseudoClass + ", " + id + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/Stylesheet.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.css;
+
+public class Stylesheet implements java.io.Serializable {
+
+ private Rule[] rules;
+ private static final long serialVersionUID = 1L;
+
+ public Stylesheet() {
+ rules = new Rule[0];
+ }
+
+ public Stylesheet(Rule[] rules) {
+ this.rules = rules;
+ java.util.Arrays.sort(rules);
+ }
+
+ public Rule[] getRules() {
+ return rules;
+ }
+
+ public void add(Rule newRule) {
+ Rule[] oldRules = rules;
+ rules = new Rule[oldRules.length + 1];
+ System.arraycopy(oldRules, 0, rules, 0, oldRules.length);
+ rules[rules.length - 1] = newRule;
+ java.util.Arrays.sort(rules);
+ }
+
+ public void add(Rule[] newRules) {
+ Rule[] oldRules = rules;
+ rules = new Rule[oldRules.length + newRules.length];
+ System.arraycopy(oldRules, 0, rules, 0, oldRules.length);
+ System.arraycopy(newRules, 0, rules, oldRules.length, newRules.length);
+ java.util.Arrays.sort(rules);
+ }
+
+ @Override
+ public String toString() {
+ return "Stylesheet" + java.util.Arrays.asList(rules);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class HBoxBeanInfo extends SimpleBeanInfo {
+
+ @Override
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", HBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", HBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", HBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", HBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -19,7 +19,7 @@
import javax.swing.AbstractButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
Modified: 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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,7 +20,7 @@
public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
private static final long serialVersionUID = 1L;
- protected Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
+ protected final Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
protected boolean showIcon;
protected boolean showText;
@@ -51,11 +51,21 @@
public String getText(Locale locale) {
String text = null;
if (showText) {
- text = locale.getDisplayName(Locale.getDefault());
+ 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;
@@ -81,10 +91,12 @@
firePropertyChange("showText", old, showText);
}
- public synchronized Icon getIcon(Locale locale) {
- if (!showIcon) {
- return null;
- }
+ 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;
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class VBoxBeanInfo extends SimpleBeanInfo {
+
+ @Override
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", VBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", VBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", VBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", VBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,150 @@
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.JTree;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+
+/**
+ * To help getting and setting navigation tree objects from a {@link JAXXContext}.
+ * <p/>
+ * There is six types of data which can be hold in a context :
+ * <ul>
+ * <li>tree : the tree </li>
+ * <li>tree model : the navigation tree model</li>
+ * <li>tree handler : the navigation tree handler</li>
+ * <li>selected path : the navigation path of the selected node</li>
+ * <li>selected node : the selected node</li>
+ * <li>selected bean : the selected bean</li>
+ * </ul>
+ *
+ * To make possible the use of more than one navigation tree system in a same
+ * context, we <b>MUST</b> distinguish the context entries definition. For this
+ * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}.
+ * <p/>
+ * Here is the keys mapping :
+ * <ul>
+ * <li>tree : {@code prefix + "-tree"}</li>
+ * <li>tree model : {@code prefix + "-tree-model"}</li>
+ * <li>tree handler : {@code prefix + "-tree-handler"}</li>
+ * <li>selected path : {@code prefix + "-selected-path"}</li>
+ * <li>selected node : {@code prefix + "-selected-node"}</li>
+ * <li>selected bean : {@code prefix + "-selected-bean"}</li>
+ * </ul>
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeContextHelper {
+
+ protected final String prefix;
+ protected JAXXContextEntryDef<String> selectedPathContextEntry;
+ protected JAXXContextEntryDef<Object> selectedBeanContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry;
+ protected JAXXContextEntryDef<JTree> treeContextEntry;
+
+ public NavigationTreeContextHelper(String prefix) {
+ this.prefix = prefix;
+ treeContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree", JTree.class);
+ treeModelContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-model", NavigationTreeModel.class);
+ treeHandlerContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-handler", NavigationTreeHandler.class);
+ selectedBeanContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-bean", Object.class);
+ selectedNodeContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-node", NavigationTreeNode.class);
+ selectedPathContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-path", String.class);
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public JTree getTree(JAXXContext context) {
+ JTree r = getTreeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeModel getTreeModel(JAXXContext context) {
+ NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeHandler getTreeHandler(JAXXContext context) {
+ NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public String getSelectedPath(JAXXContext context) {
+ String r = getSelectedPathContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeNode getSelectedNode(JAXXContext context) {
+ NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public Object getSelectedBean(JAXXContext context) {
+ Object r = getSelectedBeanContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public void setTreeModel(JAXXContext context, NavigationTreeModel model) {
+ getTreeModelContextEntry().setContextValue(context, model);
+ }
+
+ public void setTree(JAXXContext context, JTree tree) {
+ getTreeContextEntry().setContextValue(context, tree);
+ }
+
+ public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) {
+ getTreeHandlerContextEntry().setContextValue(context, handler);
+ }
+
+ public void setSelectedPath(JAXXContext context, String path) {
+ if (path == null) {
+ getSelectedPathContextEntry().removeContextValue(context);
+ } else {
+ getSelectedPathContextEntry().setContextValue(context, path);
+ }
+ }
+
+ public void setSelectedNode(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ getSelectedNodeContextEntry().removeContextValue(context);
+ } else {
+ getSelectedNodeContextEntry().setContextValue(context, node);
+ }
+ }
+
+ public void setSelectedBean(JAXXContext context, Object bean) {
+ if (bean == null) {
+ getSelectedBeanContextEntry().removeContextValue(context);
+ } else {
+ getSelectedBeanContextEntry().setContextValue(context, bean);
+ }
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() {
+ return treeModelContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() {
+ return treeHandlerContextEntry;
+ }
+
+ protected JAXXContextEntryDef<Object> getSelectedBeanContextEntry() {
+ return selectedBeanContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() {
+ return selectedNodeContextEntry;
+ }
+
+ protected JAXXContextEntryDef<String> getSelectedPathContextEntry() {
+ return selectedPathContextEntry;
+ }
+
+ protected JAXXContextEntryDef<JTree> getTreeContextEntry() {
+ return treeContextEntry;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,275 @@
+package jaxx.runtime.swing.navigation;
+
+import java.awt.Component;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The handler of a navigation tree.
+ *
+ * This is also the selection model to use, since we must check before moving
+ * from a node we can not just listen selection model changed, we must control
+ * it.
+ *
+ * @author tony
+ * @since 1.7.2
+ */
+public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandler.class);
+
+ /**
+ * Strategy of instanciation of ui.
+ * <p/>
+ * For a given {@code node}, the method {@link #getId(NavigationTreeNode)}
+ * returns the id of ui to use.
+ */
+ public enum Strategy {
+
+ /**
+ * instanciate a ui for a node
+ */
+ PER_NODE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getFullPath();
+ }
+ },
+ /**
+ * instanciate only one a ui for a type,nodes will share the instanciation
+ */
+ PER_UI_TYPE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getUIClass().getName();
+ }
+ };
+
+ public abstract String getId(NavigationTreeNode node);
+ }
+ /**
+ * UI which contains navigation tree
+ */
+ protected JAXXContext context;
+ /**
+ * UI Instanciation strategy
+ */
+ protected Strategy strategy;
+ /**
+ * JAXXContext access helper.
+ *
+ * @since 1.7.2
+ */
+ protected NavigationTreeContextHelper contextHelper;
+
+ protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
+ this.contextHelper = new NavigationTreeContextHelper(contextPrefix);
+ this.context = context;
+ this.strategy = strategy;
+ addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
+ // do not treate this if no path changed
+ return;
+ }
+ NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+ selectNodeUI(node);
+ }
+ });
+ }
+
+ /**
+ * @return le modèle de navigation associé
+ */
+ protected abstract NavigationTreeModel getNavigationTreeModel();
+
+ /**
+ * @return le composent actuellement visible associé au noeud courant ou
+ * au noeud précédent lors d'un changement de noeud.
+ */
+ protected abstract Component getCurrentUI();
+
+ /**
+ * @param node le noeud associé à l'ui à retrouver
+ * @return l'ui associé au novueau noeud sélectionné
+ */
+ protected abstract Component getUI(NavigationTreeNode node);
+
+ /**
+ * @param component le composent actuellement visible
+ * @return <code>true</code> si le composent a bien été fermé, <code>false</code> sinon
+ * @throws Exception if any
+ */
+ protected abstract boolean closeUI(Component component) throws Exception;
+
+ /**
+ * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return la nouvelle ui associée au noeud
+ * @throws Exception if any
+ */
+ protected abstract Component createUI(NavigationTreeNode node) throws Exception;
+
+ /**
+ * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
+ *
+ * @param newUI l'ui associé au noeud sélectionné à ouvrir
+ * @param node le node de l'ui a ouvrir
+ * @throws Exception if any
+ */
+ protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception;
+
+ /**
+ * Traitement des exceptions.
+ *
+ * @param e l'erreur recontrée (ou null si pas d"erreur)
+ */
+ protected abstract void treateError(Exception e);
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ public NavigationTreeContextHelper getContextHelper() {
+ return contextHelper;
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ if (path.equals(getSelectionPath())) {
+ // stay on same node, can skip
+ if (log.isDebugEnabled()) {
+ log.debug("skip stay on path " + path);
+ }
+ return;
+ }
+ Component component = getCurrentUI();
+
+ try {
+ if (!closeUI(component)) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing node canceled!");
+ }
+ // can not changed current node
+ return;
+ }
+ } catch (Exception ex) {
+ treateError(ex);
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will select path " + path);
+ }
+ // ok can safely select the new path
+ super.setSelectionPath(path);
+ }
+
+ protected void selectNodeUI(NavigationTreeNode node) {
+
+ try {
+
+ String path = node.getFullPath();
+
+ if (log.isTraceEnabled()) {
+ log.trace(path);
+ }
+
+ Component newUI = getUI(node);
+
+ // now, we are free to open the ui associated with the selected node in navigation
+
+ // get the bean associated with the node
+ Object data = getNavigationTreeModel().getBean(path);
+
+ // save it in context (must be done before init ui)
+ addSelectedBeanInContext(node, data);
+
+ if (newUI == null) {
+
+ // a new ui instance is required
+ newUI = createUI(node);
+ }
+
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // save in context current node context path
+ helper.setSelectedPath(ctxt, node.getFullPath());
+
+ // save in context current node
+ helper.setSelectedNode(ctxt, node);
+
+ // really open the ui associated with the selected node
+ openUI(newUI, node);
+
+ } catch (Exception e) {
+ // remove data from context
+
+ // if any error, go back to previvous node
+ treateError(e);
+ }
+ }
+
+ /**
+ * Prepare le context a utiliser pour initialiser une nouvelle ui.
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return le context à utiliser pour instancier l'ui
+ * @throws Exception if any
+ */
+ protected JAXXContext createUIContext(NavigationTreeNode node) throws Exception {
+
+ if (node.getUIHandlerClass() == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("no action associated with ui " + node.getUIClass());
+ }
+ // no action associated, just
+ return getContext();
+ }
+
+ JAXXAction action = node.getUIHandlerClass().newInstance();
+
+ // init context with
+ JAXXInitialContext uiContext = action.init(getContext());
+ return uiContext;
+ }
+
+ protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass()));
+ }
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // remove previous selected bean
+ //TODO-TC-20091004 should have an automatic clean context method while
+ // quiting a node ?
+ helper.setSelectedBean(ctxt, null);
+
+ if (data != null) {
+
+ helper.setSelectedBean(ctxt, data);
+ //FIXME-TC-20091004 : should really remove this, this is not context safe
+ //todo should we not use this to avoid conflict in context ?
+ //context.setContextValue(data);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,100 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JPanel;
+import java.awt.Component;
+
+/**
+ * Simple {@link NavigationTreeHandler} implementation with a {@link CardLayout2} to manage components to
+ * associated with tree's nodes.
+ * <p/>
+ * For each node, the ui associated has a constraints in a cardlayout which is the node context path.
+ * <p/>
+ * A single container managed by the cardlayout is used to display the components associated with tree's nodes.
+ *
+ * @author chemit
+ */
+public abstract class NavigationTreeHandlerWithCardLayout extends NavigationTreeHandler {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class);
+
+ /**
+ * All components associated with a tree's node is displayed in a single container.
+ *
+ * @return the containter of components
+ */
+ protected abstract JPanel getContentContainer();
+
+ /**
+ * the cardlayout managing components associated with tree node. The constraints
+ * of each component is the node contextPath.
+ *
+ * @return the layout used to display components associated with tree's nodes.
+ */
+ protected abstract CardLayout2 getContentLayout();
+
+ public NavigationTreeHandlerWithCardLayout(String contextPrefix, JAXXObject context, Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ if (getContentContainer() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context);
+ }
+ if (getContentLayout() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context);
+ }
+ }
+
+ @Override
+ protected Component getCurrentUI() {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ return layout.getVisibleComponent(container);
+ }
+
+ @Override
+ protected Component getUI(NavigationTreeNode node) {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ String constraints = strategy.getId(node);
+ return layout.contains(constraints) ? layout.getComponent(container, constraints) : null;
+ }
+
+ @Override
+ protected void openUI(Component newUI, NavigationTreeNode node) throws Exception {
+
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ // switch layout
+ String constraints = strategy.getId(node);
+ layout.show(container, constraints);
+ }
+
+ @Override
+ protected boolean closeUI(Component component) throws Exception {
+ // by default, we says that component was succesfull closed
+ return true;
+ }
+
+ @Override
+ protected Component createUI(NavigationTreeNode node) throws Exception {
+
+ JAXXContext uiContext = createUIContext(node);
+
+ JAXXObject newUI = node.getUIClass().getConstructor(JAXXContext.class).newInstance(uiContext);
+
+ if (log.isDebugEnabled()) {
+ log.debug("instanciate new ui " + newUI);
+ }
+ String constraints = strategy.getId(node);
+ getContentContainer().add((Component) newUI, constraints);
+ return (Component) newUI;
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,141 @@
+package jaxx.runtime.swing.navigation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Pattern;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Helper object associated to a given navigation tree system.
+ *
+ * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
+ *
+ * @author chemit
+ * @since 1.7.2
+ * @see NavigationTreeModel
+ */
+public abstract class NavigationTreeHelper extends NavigationTreeContextHelper {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHelper.class);
+
+ /**
+ * Create the tree model.
+ *
+ * @param context the context to associate with fresh model
+ * @return the new model build with data from the given context
+ */
+ public abstract NavigationTreeModel createTreeModel(JAXXContext context);
+
+ /**
+ * Create the tree handler.
+ *
+ * @param context the context to associate with fresh handler
+ * @return the new handler
+ */
+ public abstract NavigationTreeHandler createTreeHandler(JAXXObject context);
+
+ public NavigationTreeHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+
+ public Object getContextValue(JAXXContext context, String path) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.getBean(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation à partir de son path.
+ *
+ * @param context le contexte applicatif
+ * @param path le path absolue du noeud dans l'arbre
+ */
+ public void selectNode(JAXXContext context, String path) {
+ NavigationTreeNode node = findNode(context, path);
+ if (log.isDebugEnabled()) {
+ log.debug(path + " :: " + node);
+ }
+ if (node != null) {
+ selectNode(context, node);
+ }
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation.
+ *
+ * @param context le contexte applicatif
+ * @param node le noeud à sélectionner dans l'arbre
+ */
+ public void selectNode(JAXXContext context, NavigationTreeNode node) {
+
+
+ NavigationTreeModel navigationModel = getSafeTreeModel(context);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ TreePath path = new TreePath(navigationModel.getPathToRoot(node));
+ JTree tree = getSafeTree(context);
+ tree.setSelectionPath(path);
+ tree.scrollPathToVisible(path);
+ }
+
+ public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException {
+ NavigationTreeModel treeModel = getTreeModel(context);
+ if (treeModel == null) {
+ throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context);
+ }
+ return treeModel;
+ }
+
+ public JTree getSafeTree(JAXXContext context) throws NullPointerException {
+ JTree tree = getTree(context);
+ if (tree == null) {
+ throw new NullPointerException("could not find tree with key " + getTreeContextEntry() + " in context " + context);
+ }
+ return tree;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,246 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.context.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Model of the tree used for a navigation tree.
+ * <p/>
+ * Il est composé de {@link NavigationTreeNode}
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeModel extends DefaultTreeModel {
+
+ static private final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see NavigationTreeNode#getNodePath()
+ * @see NavigationTreeNode#getFullPath()
+ */
+ protected final String pathSeparator;
+ /**
+ * Context to retrieve beans
+ */
+ private JAXXContext context;
+
+ public NavigationTreeModel(String pathSeparator, JAXXContext context) {
+ super(null);
+ this.pathSeparator = pathSeparator;
+ this.context = context;
+ }
+
+ @Override
+ public NavigationTreeNode getRoot() {
+ return (NavigationTreeNode) super.getRoot();
+ }
+
+ /**
+ * Search from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the root node, or <code>null</code> if not find.
+ */
+ public NavigationTreeNode findNode(String path) {
+ return findNode(getRoot(), path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, String regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, Pattern regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Search from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
+ return findNode(root, path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes)
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
+ return findNode(root, path, regex == null ? null : Pattern.compile(regex));
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
+ if (regex != null) {
+ Matcher matcher = regex.matcher(path);
+ if (!matcher.matches() || matcher.groupCount() < 1) {
+ log.warn("no matching regex " + regex + " to " + path);
+ return null;
+ }
+ path = matcher.group(1);
+ if (log.isDebugEnabled()) {
+ log.debug("matching regex " + regex + " : " + path);
+ }
+ }
+ StringTokenizer stk = new StringTokenizer(path, pathSeparator);
+ NavigationTreeNode result = root;
+ // pas the first token (matches the root node)
+ if (root.isRoot() && stk.hasMoreTokens()) {
+ String rootPath = stk.nextToken();
+ if (!rootPath.equals(root.getNodePath())) {
+ return null;
+ }
+ }
+ while (stk.hasMoreTokens()) {
+ result = result.getChild(stk.nextToken());
+ }
+ return result;
+ }
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node from given navigation path.
+ *
+ * @param navigationPath the current context path of the node
+ * @return the value associated in context with the given navigation path
+ */
+ public Object getBean(String navigationPath) {
+ Object result;
+ NavigationTreeNode node = findNode(navigationPath, (Pattern) null);
+ result = getBean(node);
+ return result;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param node the current node
+ * @return the value associated in context with the given node.
+ */
+ public Object getBean(NavigationTreeNode node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getBean(getContext());
+ }
+
+ @Override
+ public void nodeChanged(TreeNode node) {
+ nodeChanged(node, false);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ @Override
+ public void nodeStructureChanged(TreeNode node) {
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep reload
+ reload(n, true);
+ super.nodeStructureChanged(node);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ public void nodeChanged(TreeNode node, boolean deep) {
+
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
+ reload(n, deep);
+ super.nodeChanged(node);
+ }
+
+ protected void reload(NavigationTreeNode node) {
+ reload(node, false);
+ }
+
+ protected void reload(NavigationTreeNode node, boolean deep) {
+ if (node == null) {
+ return;
+ }
+ node.reload(getContext());
+
+ if (deep) {
+ Enumeration<?> childs = node.children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode o = (NavigationTreeNode) childs.nextElement();
+ reload(o, true);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,242 @@
+package jaxx.runtime.swing.navigation;
+
+import java.util.Enumeration;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.decorator.Decorator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This object is design to build a {@link NavigationTreeModel}.
+ *
+ * @author chemit
+ * @since 17.2
+ */
+public class NavigationTreeModelBuilder {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModelBuilder.class);
+ /**
+ * The model dealed by the builder.
+ *
+ * <b>Note:</b> It is a good idea to keep only one instance of the model.
+ * If reset is required, should empty the model but not reinstanciate it.
+ */
+ protected NavigationTreeModel model;
+ /**
+ * default ui class to use if node does not define an ui class
+ */
+ protected Class<? extends JAXXObject> defaultUIClass;
+ /**
+ * [optional] default action class
+ */
+ protected Class<? extends JAXXAction> defaultUIHandlerClass;
+
+ public NavigationTreeModelBuilder(String pathSeparator, JAXXContext context, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass) {
+ this(defaultUIClass, defaultUIHandlerClass, new NavigationTreeModel(pathSeparator, context));
+ }
+
+ public NavigationTreeModelBuilder(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, NavigationTreeModel model) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ }
+
+ public NavigationTreeModel getModel() {
+ return model;
+ }
+
+ public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, null);
+ addI18nNodeRenderer(node, "");
+ return addChildNode(null, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, null, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
+
+ if (node.getUIClass() == null) {
+ // no ui is associated with this node, use the default one
+ node.setUIClass(defaultUIClass);
+ }
+
+ if (node.getUIHandlerClass() == null) {
+ // no ui handler associated with this node, use the default one
+ node.setUIHandlerClass(defaultUIHandlerClass);
+ }
+ if (parentNode == null) {
+ model.setRoot(node);
+ } else {
+ parentNode.add(node);
+ }
+ model.nodeStructureChanged(parentNode);
+ return node;
+ }
+
+ public NavigationTreeNode removeChildNode(NavigationTreeNode node) {
+ NavigationTreeNode parentNode = node.getParent();
+ model.removeNodeFromParent(node);
+ return parentNode;
+ }
+
+ public void addI18nNodeRenderer(NavigationTreeNode node, String libelle) {
+ node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle));
+ }
+
+ public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator) {
+ node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator));
+ }
+
+ public void addNodeJaxxClasses(
+ NavigationTreeNode node,
+ Class<? extends JAXXObject> uIClass,
+ Class<? extends JAXXAction> uIHandlerClass) {
+ node.setUIClass(uIClass);
+ node.setUIHandlerClass(uIHandlerClass);
+ }
+
+ public void printModel(NavigationTreeNode node) {
+ if (node == null) {
+ return;
+ }
+ log.info("node " + node.getFullPath() + ", jxpath: " + node.getJaxxContextEntryPath() + ", entryContextDef: " + node.getJaxxContextEntryDef());
+ if (log.isDebugEnabled()) {
+ log.debug("node userObject" + node.getUserObject());
+ log.debug("value from node " + node.getBean(getModel().getContext()));
+ log.debug("value from model " + getModel().getBean(node));
+ }
+ Enumeration<?> children = node.children();
+ while (children.hasMoreElements()) {
+ printModel((NavigationTreeNode) children.nextElement());
+ }
+ }
+
+ public static abstract class ChildBuilder<O> {
+
+ protected NavigationTreeModelBuilder builder;
+
+ protected ChildBuilder(NavigationTreeModelBuilder builder) {
+ this.builder = builder;
+ }
+
+ protected abstract void init(Class<? extends O> klass);
+
+ protected abstract Decorator<? extends O> getDecorator(O child);
+
+ protected abstract String getJXPath(O child);
+
+ protected abstract String getNavigationPath(O child);
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, java.util.Collection<? extends O> beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.isEmpty()) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, O[] beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.length == 0) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,424 @@
+package jaxx.runtime.swing.navigation;
+
+import java.util.Enumeration;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Node of the {@link NavigationTreeModel}.
+ *
+ * Each node is associated with :
+ * <ul>
+ * <li> a {@code bean} coming from a {@link JAXXContext} </li>
+ * <li> a {@code uiClass} to build the associated ui </li>
+ * </ul>
+ * <p/>
+ * To retrieve the bean from the context, there is a huge logic in the
+ * method {@link #getBean(JAXXContext)}.
+ *
+ * In few words, if the {@link #jaxxContextEntryDef} is defined, it means
+ * that the object is taken from the {@code context}.
+ * <p/>
+ * Otherwise, find the first ancestor with an context entry and retrieve from
+ * here the bean.
+ * <p/>
+ * Then go down to the initial node by applying the jxpath expressions
+ * {@link #jaxxContextEntryPath} of each node on road back.
+ * <p/>
+ *
+ * To identify easly a node, each node has a {@link #path} and a
+ * {@link #fullPath} (full path from root node).
+ * <p/>
+ *
+ * To display the node we use a {@link NavigationTreeNodeRenderer} which is in
+ * fact the {@link #userObject}, the object can be synch with the bean via the
+ * {@link NavigationTreeNodeRenderer#reload(java.lang.Object)} method.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @see NavigationTreeNodeRenderer
+ * @since 1.7.2
+ */
+public class NavigationTreeNode extends DefaultMutableTreeNode {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeNode.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see #path
+ * @see #fullPath
+ */
+ protected final String pathSeparator;
+ /**
+ * The node path.
+ * <p/>
+ * Used to build the {@link #fullPath} which gives a unique identifier of the
+ * node.
+ * @see #pathSeparator
+ * @see #fullPath
+ */
+ protected String path;
+ /**
+ * The full path for the node from the rood node.
+ * <p/>
+ * This path is build by appending nodes {@link #path} from the root node
+ * to this node, between each path we introduce the {@link #pathSeparator}.
+ * <p>
+ * Exemple :
+ * <pre>
+ * root
+ * $root
+ * `-- child1
+ * `-- child2
+ * </pre>
+ * will given {@code $root/child1/child2}.
+ * @see #pathSeparator
+ * @see #path
+ */
+ protected String fullPath;
+ /**
+ * The UI class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIClass} will be used while
+ * building the model.
+ */
+ protected Class<? extends JAXXObject> uIClass;
+ /**
+ * The UI handler class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIHandlerClass} will be used
+ * while building the model.
+ */
+ protected Class<? extends JAXXAction> uIHandlerClass;
+ /**
+ * The context entry definition to retrieve the bean.
+ *
+ * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
+ * node.
+ */
+ protected JAXXContextEntryDef<?> jaxxContextEntryDef;
+ /**
+ * The jxPath to process to obtain real {@code bean} from the data retrieve
+ * in the context.
+ *
+ * <b>Note:</b> If not set -no jxpath will be apply on the bean from context.
+ */
+ protected String jaxxContextEntryPath;
+ /**
+ * The bean associated with the node ( the value can be obtain via the
+ * method {@link #getBean(JAXXContext)} or directly set via method
+ * {@link #setBean(Object)}.
+ * <p/>
+ * cache of bean associated with bean to improve performance
+ */
+ protected transient Object bean;
+ /**
+ * The type of the related bean associated with the node.
+ * <p/>
+ * Note: This type is here to override the NodeRenderer internalClass, since
+ * we could need to override this data.
+ * <p/>
+ * If this property is let to null, then we will use the NodeRenderer one
+ */
+ protected Class<?> internalClass;
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
+ this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef);
+ } else if (jaxxContextEntryDef instanceof String) {
+ this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
+ } else if (jaxxContextEntryDef != null) {
+ // wrong context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
+ }
+ }
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ /**
+ *
+ * @return the text node renderer (store in {@link #userObject} property.
+ */
+ public NavigationTreeNodeRenderer getRenderer() {
+ NavigationTreeNodeRenderer render = null;
+ Object o = getUserObject();
+ if (o != null && o instanceof NavigationTreeNodeRenderer) {
+ render = (NavigationTreeNodeRenderer) o;
+ }
+ return render;
+ }
+
+ public void setRenderer(NavigationTreeNodeRenderer renderer) {
+ // clear all cache
+ bean = null;
+ setUserObject(renderer);
+ }
+
+ public String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ public String getNodePath() {
+ return path;
+ }
+
+ public void setNodePath(String navigationPath) {
+ this.path = navigationPath;
+ }
+
+ public Class<? extends JAXXObject> getUIClass() {
+ return uIClass;
+ }
+
+ public void setUIClass(Class<? extends JAXXObject> uIClass) {
+ this.uIClass = uIClass;
+ }
+
+ public void setInternalClass(Class<?> internalClass) {
+ this.internalClass = internalClass;
+ }
+
+ public Class<? extends JAXXAction> getUIHandlerClass() {
+ return uIHandlerClass;
+ }
+
+ public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
+ this.uIHandlerClass = uIHandlerClass;
+ }
+
+ public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
+ return jaxxContextEntryDef;
+ }
+
+ public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }
+
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ public Class<?> getInternalClass() {
+ if (internalClass == null && getRenderer() != null) {
+ return getRenderer().getInternalClass();
+ }
+ return internalClass;
+ }
+
+ /** @return the fully context path of the node from the root node to this. */
+ public String getFullPath() {
+ if (fullPath == null) {
+ StringBuilder sb = new StringBuilder();
+ for (TreeNode treeNode : getPath()) {
+ NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
+ sb.append(pathSeparator).append(myNode.getNodePath());
+ }
+ fullPath = sb.substring(1);
+ }
+ return fullPath;
+ }
+
+ @Override
+ public NavigationTreeNode getChildAt(int index) {
+ return (NavigationTreeNode) super.getChildAt(index);
+ }
+
+ @Override
+ public NavigationTreeNode getParent() {
+ return (NavigationTreeNode) super.getParent();
+ }
+
+ /**
+ * @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.
+ */
+ public NavigationTreeNode getChild(String path) {
+ Enumeration<?> childs = children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode son = (NavigationTreeNode) childs.nextElement();
+ if (path.equals(son.getNodePath())) {
+ return son;
+ }
+ }
+ return null;
+ }
+
+ public Object getBean() {
+ return bean;
+ }
+
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ public void reload(JAXXContext context) {
+
+ // clear bean cache
+ bean = null;
+
+ // clear context navigation cache
+ fullPath = null;
+
+ NavigationTreeNodeRenderer renderer = getRenderer();
+ if (renderer == null) {
+ // this can't be !
+ throw new NullPointerException("could not find the renderer for node " + this);
+ }
+
+ Object b = getBean(context);
+
+ renderer.reload(b);
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context to seek
+ * @return the value associated in context with the given context path
+ */
+ public Object getBean(JAXXContext context) {
+ if (bean != null) {
+ // use cached bean
+ return bean;
+ }
+ Object result;
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
+ // the node maps directly a value in context, with no jxpath resolving
+ result = getJaxxContextEntryDef().getContextValue(context);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+ // find the first ancestor node with a context def
+ NavigationTreeNode parentNode = getFirstAncestorWithDef();
+ if (parentNode == null) {
+ log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")");
+ // todo must be an error
+ // no parent found
+ return null;
+ }
+ Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("could not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+ // save in cache
+ parentNode.setBean(parentBean);
+ if (this == parentNode) {
+ // current node is the node matching the context entry value and no jxpath is found
+ return parentBean;
+ }
+ if (jaxxContextEntryPath == null) {
+ // todo must be an error
+ log.warn("must find a jaxxContextEntryPath on node (" + this + ")");
+ return null;
+ }
+ String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode);
+ if (jxpathExpression == null) {
+ /// todo must be an error
+ log.warn("could not build jxpath from node " + parentNode + " to " + this);
+ // could not retreave the jxpath...
+ return null;
+ }
+ if (jxpathExpression.startsWith("[")) {
+ // special case when we want to access a collection
+ jxpathExpression = '.' + jxpathExpression;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ result = jxcontext.getValue(jxpathExpression);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ // find a node with a direct link with the context
+ return this;
+ }
+ // the node is not linked to context
+ // seek in his parent
+ NavigationTreeNode ancestor = getParent();
+ return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
+ }
+
+ protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
+ if (parentNode == this) {
+ // reach the parent limit node, return the expr computed
+ return expr;
+ }
+ int firstIndex = expr.indexOf("..");
+ int lastIndex = expr.lastIndexOf("..");
+ if (firstIndex == -1) {
+ // this is a error, since current node is not parent limit node,
+ // we must find somewhere a way to go up in nodes
+ throw new IllegalArgumentException(expr + " should contains at least one \"..\"");
+ }
+ if (firstIndex != 0) {
+ // this is a error, the ../ must be at the beginning of the expression
+ throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr);
+ }
+ NavigationTreeNode ancestor = getParent();
+ if (firstIndex == lastIndex) {
+ // found only one go up, so must be substitute by the parent node context
+ String newExpr = expr.substring(2);
+ //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2);
+ if (getParent().equals(parentNode)) {
+ // parent node is the final parent node, so no substitution needed
+ return newExpr;
+ }
+ // ancestor must have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath == null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not ");
+ }
+ newExpr = ancestor.jaxxContextEntryPath + newExpr;
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+ // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath != null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition");
+ }
+ // substitute the last ..[/] and delegate to ancestor
+ String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2));
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,44 @@
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.tree.TreeCellRenderer;
+
+/**
+ * Text Renderer of a {@link NavigationTreeNode}.
+ * <p/>
+ * This object will be placed as the {@link NavigationTreeNode#userObject} of
+ * nodes.
+ * <p/>
+ *
+ * In that way, we can use the {@link #toString()} value to render the node
+ * without writing any {@link TreeCellRenderer}.
+ * <p/>
+ * To rebuild the renderer text of a node use the method {@link #reload(Object)}
+ * with the {@code bean} provides by the model for the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public interface NavigationTreeNodeRenderer extends java.io.Serializable {
+
+ /**
+ *
+ * @return the render value of the node
+ */
+ @Override
+ String toString();
+
+ /**
+ *
+ * Can override the the node internal class for display purpose.
+ *
+ * @return the type of data to be displayed.
+ */
+ Class<?> getInternalClass();
+
+ /**
+ * Reload the render value from the {@code bean} of node.
+ *
+ * @param bean the bean associated to the node to render
+ */
+ void reload(Object bean);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,53 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.decorator.Decorator;
+
+/**
+ * Decorator Renderer of a {@link NavigationTreeNode}.
+ *
+ * Apply a {@link Decorator} to the {@code bean} associated to the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Decorator
+ */
+ protected final Decorator<?> decorator;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) {
+ this.internalClass = decorator.getInternalClass();
+ this.decorator = decorator;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object bean) {
+ try {
+ text = decorator.toString(bean);
+
+ } catch (Exception e) {
+ text = "";
+ }
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,48 @@
+package jaxx.runtime.swing.navigation;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * I18n label Renderer of a {@link NavigationTreeNode}.
+ *
+ * Just apply a i18n translation on the given {@link #libelle}.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Static i18n label to render
+ */
+ protected final String libelle;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererI18nImpl(String libelle) {
+ this.libelle = libelle;
+ this.internalClass = String.class;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object data) {
+ text = _(libelle);
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h1>JAXX - tree utilities</h1>
+
+ This package contains all the classes of the navigation tree framework.
+
+ <p>
+ Replace the previous framework from package
+ <code>jaxx.runtime.swing.navigation</code>
+ </p>
+ </body>
+</html>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html
___________________________________________________________________
Added: svn:mergeinfo
+
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.wizard;
import javax.swing.SwingWorker;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,7 +4,7 @@
import java.beans.PropertyChangeListener;
import java.util.Date;
import javax.swing.SwingWorker.StateValue;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -2,8 +2,8 @@
import java.awt.Window;
import javax.swing.ImageIcon;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.beanutils.ConstructorUtils;
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,117 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package jaxx.runtime;
-
-import jaxx.runtime.DefaultApplicationContext.AutoLoad;
-import jaxx.runtime.DefaultApplicationContext.MethodAccess;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author tony
- */
-public class DefaultApplicationContextTest {
-
- static int helloCount;
- static int helloGetCount;
-
- @AutoLoad
- @MethodAccess(methodName = "hello", target = String.class)
- public static class Hello {
-
- public Hello() {
- helloCount++;
- }
-
- public String hello(String name) {
- helloGetCount++;
- return "hello " + name;
- }
- }
- DefaultApplicationContext context;
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- helloCount = 0;
- helloGetCount = 0;
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- context = new DefaultApplicationContext();
- assertEquals(0, helloCount);
- assertEquals(0, helloGetCount);
- }
-
- @After
- public void tearDown() {
- context = null;
- helloCount = helloGetCount = 0;
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testAutoLoadNamed() {
- context.getContextValue(Hello.class, "fakeName");
- }
-
- @Test
- public void testAutoLoad() {
- Hello hello = context.getContextValue(Hello.class);
- assertNotNull(hello);
- assertEquals(1, helloCount);
-
- Hello hello2 = context.getContextValue(Hello.class);
- assertNotNull(hello2);
- assertEquals(1, helloCount);
- assertEquals(hello, hello2);
- }
-
- @Test
- public void testForward() {
- context.getContextValue(Hello.class);
- assertEquals(1, helloCount);
- String response = context.getContextValue(String.class, "John");
- assertNotNull(response);
- assertEquals(1, helloGetCount);
- assertEquals(new Hello().hello("John"), response);
- }
-
- @Test
- public void testRemove() {
- String response;
-
- context.getContextValue(Hello.class);
- assertEquals(1, helloCount);
- assertEquals(1, context.forwards.size());
- response = context.getContextValue(String.class, "John");
- assertNotNull(response);
-
- context.removeContextValue(Hello.class);
- assertEquals(0, context.forwards.size());
- response = context.getContextValue(String.class, "John");
- assertEquals(1, helloCount);
- assertNull(response);
-
- // reinstanciate the service
- context.getContextValue(Hello.class);
- assertEquals(2, helloCount);
- assertEquals(1, context.forwards.size());
-
- // no effect with a name
- context.removeContextValue(Hello.class, "fake");
- assertEquals(1, context.forwards.size());
- context.getContextValue(Hello.class);
- assertEquals(2, helloCount);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,299 +0,0 @@
-package jaxx.runtime;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.awt.Container;
-import java.util.Map;
-
-/** @author chemit */
-public class DefaultJAXXContextTest {
-
- DefaultJAXXContext ctxt;
-
- @Before
- public void initContext() throws Exception {
-
- // instanciate a new empty context
- ctxt = new DefaultJAXXContext();
- }
-
- @Test(expected = IllegalStateException.class)
- public void testParentContainerFail_IllegalStateException() throws Exception {
- ctxt.getParentContainer(Container.class);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testParentContainerFail_IllegalStateException2() throws Exception {
- ctxt.getParentContainer("null", Container.class);
- }
-
-
- @Test(expected = IllegalArgumentException.class)
- public void testParentContainerFail_IllegalArgumentException() throws Exception {
-
- // attach a fake ui (which is NOT a Container)
- ctxt.setUi(new MyJAXXObject());
- ctxt.getParentContainer(Container.class);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParentContainerFail_IllegalArgumentException2() throws Exception {
-
- // attach a fake ui (which is NOT a Container)
- ctxt.setUi(new MyJAXXObject());
- ctxt.getParentContainer(null, Container.class);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParentContainerFail_IllegalArgumentException3() throws Exception {
-
- // attach a fake ui (which is NOT a Container)
- ctxt.setUi(new MyJAXXObject());
- ctxt.getParentContainer("null", Container.class);
- }
-
- @Test
- public void testGetParentContext() throws Exception {
- JAXXContext expected, result;
- expected = null;
- result = ctxt.getContextValue(JAXXContext.class);
- Assert.assertEquals(expected, result);
-
- DefaultJAXXContext parentContext = new DefaultJAXXContext();
-
- ctxt.setContextValue(parentContext);
-
- expected = parentContext;
- result = ctxt.getContextValue(JAXXContext.class);
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValue() throws Exception {
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
-
- expected = "yo";
- ctxt.setContextValue(expected);
- result = ctxt.getContextValue(String.class);
- Assert.assertEquals(expected, result);
-
- expected = "ya";
- ctxt.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
-
- expected = "yi";
- ctxt.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValueInParentContext() throws Exception {
-
- // attach parent context
- JAXXContext parentContext = new DefaultJAXXContext();
- ctxt.setContextValue(parentContext);
-
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
-
- expected = "yo";
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- parentContext.setContextValue(expected);
- result = ctxt.getContextValue(String.class);
- Assert.assertEquals(expected, result);
-
- expected = "ya";
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertNull(result);
- parentContext.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
-
- expected = "yi";
- result = ctxt.getContextValue(String.class, "second");
- parentContext.setContextValue(expected, "second");
- Assert.assertEquals("ya", result);
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValue2() throws Exception {
-
- // attach parent context
- JAXXContext parentContext = new DefaultJAXXContext();
- ctxt.setContextValue(parentContext);
-
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- result = ctxt.getContextValue(String.class, "yo");
- Assert.assertNull(result);
-
- expected = "yo";
- ctxt.setContextValue(expected, "yo");
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- result = ctxt.getContextValue(String.class, "yo");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValueInParentParentContext() throws Exception {
-
- // attach parent parent context
- JAXXContext parentParentContext = new DefaultJAXXContext();
- JAXXContext parentContext = new DefaultJAXXContext();
- parentContext.setContextValue(parentParentContext);
- ctxt.setContextValue(parentContext);
-
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
-
- expected = "yo";
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- parentParentContext.setContextValue(expected);
- result = ctxt.getContextValue(String.class);
- Assert.assertEquals(expected, result);
-
- expected = "ya";
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertNull(result);
- parentParentContext.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
-
- expected = "yi";
- result = ctxt.getContextValue(String.class, "second");
- parentParentContext.setContextValue(expected, "second");
- Assert.assertEquals("ya", result);
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testEntrySet() throws Exception {
- Object o = new Object();
-
- ctxt.setContextValue(o);
-
- Assert.assertEquals(1, ctxt.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.setContextValue(o, "named");
-
- Assert.assertEquals(2, ctxt.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.removeContextValue(Object.class);
- Assert.assertEquals(1, ctxt.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.removeContextValue(Object.class);
- Assert.assertEquals(1, ctxt.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.removeContextValue(Object.class, "named");
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
-
- }
-
- @Test
- public void testEntrySetWithParent() throws Exception {
-
- DefaultJAXXContext parentContext = new DefaultJAXXContext();
-
- ctxt.setContextValue(parentContext);
-
- class Object2 {
-
- }
- Object o = new Object2();
-
- parentContext.setContextValue(o);
-
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(1, parentContext.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
-
- parentContext.setContextValue(o, "named");
-
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(2, parentContext.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
-
- parentContext.removeContextValue(Object2.class);
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(1, parentContext.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
-
- parentContext.removeContextValue(Object2.class);
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(1, parentContext.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
-
- ctxt.removeContextValue(Object2.class, "named");
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(0, parentContext.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
-
- }
-
- private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject {
-
- public Object getObjectById(String id) {
- return null;
- }
-
- public Map<String, Object> get$objectMap() {
- return null;
- }
-
- public void applyDataBinding(String id) {
- }
-
- public void removeDataBinding(String id) {
- }
-
- public JAXXContext getDelegateContext() {
- return null;
- }
-
- public void processDataBinding(String dest) {
- }
-
- public void firePropertyChange(String name, Object oldValue, Object newValue) {
- }
-
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,113 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.context.DefaultApplicationContext.AutoLoad;
+import jaxx.runtime.context.DefaultApplicationContext.MethodAccess;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author tony
+ */
+public class DefaultApplicationContextTest {
+
+ static int helloCount;
+ static int helloGetCount;
+
+ @AutoLoad
+ @MethodAccess(methodName = "hello", target = String.class)
+ public static class Hello {
+
+ public Hello() {
+ helloCount++;
+ }
+
+ public String hello(String name) {
+ helloGetCount++;
+ return "hello " + name;
+ }
+ }
+ DefaultApplicationContext context;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ helloCount = 0;
+ helloGetCount = 0;
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ context = new DefaultApplicationContext();
+ assertEquals(0, helloCount);
+ assertEquals(0, helloGetCount);
+ }
+
+ @After
+ public void tearDown() {
+ context = null;
+ helloCount = helloGetCount = 0;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testAutoLoadNamed() {
+ context.getContextValue(Hello.class, "fakeName");
+ }
+
+ @Test
+ public void testAutoLoad() {
+ Hello hello = context.getContextValue(Hello.class);
+ assertNotNull(hello);
+ assertEquals(1, helloCount);
+
+ Hello hello2 = context.getContextValue(Hello.class);
+ assertNotNull(hello2);
+ assertEquals(1, helloCount);
+ assertEquals(hello, hello2);
+ }
+
+ @Test
+ public void testForward() {
+ context.getContextValue(Hello.class);
+ assertEquals(1, helloCount);
+ String response = context.getContextValue(String.class, "John");
+ assertNotNull(response);
+ assertEquals(1, helloGetCount);
+ assertEquals(new Hello().hello("John"), response);
+ }
+
+ @Test
+ public void testRemove() {
+ String response;
+
+ context.getContextValue(Hello.class);
+ assertEquals(1, helloCount);
+ assertEquals(1, context.forwards.size());
+ response = context.getContextValue(String.class, "John");
+ assertNotNull(response);
+
+ context.removeContextValue(Hello.class);
+ assertEquals(0, context.forwards.size());
+ response = context.getContextValue(String.class, "John");
+ assertEquals(1, helloCount);
+ assertNull(response);
+
+ // reinstanciate the service
+ context.getContextValue(Hello.class);
+ assertEquals(2, helloCount);
+ assertEquals(1, context.forwards.size());
+
+ // no effect with a name
+ context.removeContextValue(Hello.class, "fake");
+ assertEquals(1, context.forwards.size());
+ context.getContextValue(Hello.class);
+ assertEquals(2, helloCount);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,300 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.Container;
+import java.util.Map;
+
+/** @author chemit */
+public class DefaultJAXXContextTest {
+
+ DefaultJAXXContext ctxt;
+
+ @Before
+ public void initContext() throws Exception {
+
+ // instanciate a new empty context
+ ctxt = new DefaultJAXXContext();
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testParentContainerFail_IllegalStateException() throws Exception {
+ ctxt.getParentContainer(Container.class);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testParentContainerFail_IllegalStateException2() throws Exception {
+ ctxt.getParentContainer("null", Container.class);
+ }
+
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParentContainerFail_IllegalArgumentException() throws Exception {
+
+ // attach a fake ui (which is NOT a Container)
+ ctxt.setUi(new MyJAXXObject());
+ ctxt.getParentContainer(Container.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParentContainerFail_IllegalArgumentException2() throws Exception {
+
+ // attach a fake ui (which is NOT a Container)
+ ctxt.setUi(new MyJAXXObject());
+ ctxt.getParentContainer(null, Container.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParentContainerFail_IllegalArgumentException3() throws Exception {
+
+ // attach a fake ui (which is NOT a Container)
+ ctxt.setUi(new MyJAXXObject());
+ ctxt.getParentContainer("null", Container.class);
+ }
+
+ @Test
+ public void testGetParentContext() throws Exception {
+ JAXXContext expected, result;
+ expected = null;
+ result = ctxt.getContextValue(JAXXContext.class);
+ Assert.assertEquals(expected, result);
+
+ DefaultJAXXContext parentContext = new DefaultJAXXContext();
+
+ ctxt.setContextValue(parentContext);
+
+ expected = parentContext;
+ result = ctxt.getContextValue(JAXXContext.class);
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValue() throws Exception {
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+
+ expected = "yo";
+ ctxt.setContextValue(expected);
+ result = ctxt.getContextValue(String.class);
+ Assert.assertEquals(expected, result);
+
+ expected = "ya";
+ ctxt.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+
+ expected = "yi";
+ ctxt.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValueInParentContext() throws Exception {
+
+ // attach parent context
+ JAXXContext parentContext = new DefaultJAXXContext();
+ ctxt.setContextValue(parentContext);
+
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+
+ expected = "yo";
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ parentContext.setContextValue(expected);
+ result = ctxt.getContextValue(String.class);
+ Assert.assertEquals(expected, result);
+
+ expected = "ya";
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertNull(result);
+ parentContext.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+
+ expected = "yi";
+ result = ctxt.getContextValue(String.class, "second");
+ parentContext.setContextValue(expected, "second");
+ Assert.assertEquals("ya", result);
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValue2() throws Exception {
+
+ // attach parent context
+ JAXXContext parentContext = new DefaultJAXXContext();
+ ctxt.setContextValue(parentContext);
+
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ result = ctxt.getContextValue(String.class, "yo");
+ Assert.assertNull(result);
+
+ expected = "yo";
+ ctxt.setContextValue(expected, "yo");
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ result = ctxt.getContextValue(String.class, "yo");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValueInParentParentContext() throws Exception {
+
+ // attach parent parent context
+ JAXXContext parentParentContext = new DefaultJAXXContext();
+ JAXXContext parentContext = new DefaultJAXXContext();
+ parentContext.setContextValue(parentParentContext);
+ ctxt.setContextValue(parentContext);
+
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+
+ expected = "yo";
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ parentParentContext.setContextValue(expected);
+ result = ctxt.getContextValue(String.class);
+ Assert.assertEquals(expected, result);
+
+ expected = "ya";
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertNull(result);
+ parentParentContext.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+
+ expected = "yi";
+ result = ctxt.getContextValue(String.class, "second");
+ parentParentContext.setContextValue(expected, "second");
+ Assert.assertEquals("ya", result);
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testEntrySet() throws Exception {
+ Object o = new Object();
+
+ ctxt.setContextValue(o);
+
+ Assert.assertEquals(1, ctxt.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.setContextValue(o, "named");
+
+ Assert.assertEquals(2, ctxt.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.removeContextValue(Object.class);
+ Assert.assertEquals(1, ctxt.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.removeContextValue(Object.class);
+ Assert.assertEquals(1, ctxt.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.removeContextValue(Object.class, "named");
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
+
+ }
+
+ @Test
+ public void testEntrySetWithParent() throws Exception {
+
+ DefaultJAXXContext parentContext = new DefaultJAXXContext();
+
+ ctxt.setContextValue(parentContext);
+
+ class Object2 {
+
+ }
+ Object o = new Object2();
+
+ parentContext.setContextValue(o);
+
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(1, parentContext.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
+
+ parentContext.setContextValue(o, "named");
+
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(2, parentContext.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
+
+ parentContext.removeContextValue(Object2.class);
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(1, parentContext.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
+
+ parentContext.removeContextValue(Object2.class);
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(1, parentContext.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
+
+ ctxt.removeContextValue(Object2.class, "named");
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(0, parentContext.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
+
+ }
+
+ private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject {
+
+ public Object getObjectById(String id) {
+ return null;
+ }
+
+ public Map<String, Object> get$objectMap() {
+ return null;
+ }
+
+ public void applyDataBinding(String id) {
+ }
+
+ public void removeDataBinding(String id) {
+ }
+
+ public JAXXContext getDelegateContext() {
+ return null;
+ }
+
+ public void processDataBinding(String dest) {
+ }
+
+ public void firePropertyChange(String name, Object oldValue, Object newValue) {
+ }
+
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation
___________________________________________________________________
Added: svn:mergeinfo
+
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/tree/NavigationTreeModelTest.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,8 +1,11 @@
-package jaxx.runtime.swing.tree;
+package jaxx.runtime.swing.navigation;
-import jaxx.runtime.DefaultJAXXContext;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
+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.context.JAXXContextEntryDef;
import org.junit.Assert;
import org.junit.Test;
@@ -82,7 +85,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
* as a bean.
* <p/>
* Tree is like this
@@ -202,7 +205,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.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/I18nEditor.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -30,19 +30,26 @@
<String id='selectedToolTipText' javaBean='null'/>
<String id='notSelectedToolTipText' javaBean='null'/>
+ <Border id='popupBorder' javaBean='new TitledBorder(_("i18neditor.popup.title"))'/>
+
<Boolean id='showText' javaBean='Boolean.TRUE'/>
<Boolean id='showIcon' javaBean='Boolean.TRUE'/>
+ <Boolean id='showPopupText' javaBean='Boolean.TRUE'/>
+ <Boolean id='showPopupIcon' javaBean='Boolean.TRUE'/>
<Boolean id='popupVisible' javaBean='Boolean.FALSE'/>
<java.util.List id='locales' javaBean='null' genericType='Locale'/>
<Locale id='selectedLocale' javaBean='Locale.getDefault()'/>
- <jaxx.runtime.swing.LocaleListCellRenderer id='renderer' javaBean='new LocaleListCellRenderer(showIcon , showText)' showIcon='{isShowIcon()}' showText='{isShowText()}'/>
+ <jaxx.runtime.swing.LocaleListCellRenderer id='renderer'
+ showIcon='{isShowIcon()}'
+ showText='{isShowText()}'
+ javaBean='new LocaleListCellRenderer(showIcon , showText)'/>
<!-- popup to change sorted property-->
<JPopupMenu id='popup'
- border='{new TitledBorder(_("i18neditor.popup.title"))}'
+ border='{getPopupBorder()}'
onPopupMenuWillBecomeInvisible='button.setSelected(false)'
onPopupMenuCanceled='button.setSelected(false)'>
<JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/>
@@ -74,6 +81,9 @@
public static final String SELECTED_LOCALE_PROPERTY = "selectedLocale";
public static final String SHOW_ICON_PROPERTY = "showIcon";
public static final String SHOW_TEXT_PROPERTY = "showText";
+public static final String SHOW_POPUP_ICON_PROPERTY = "showPopupIcon";
+public static final String SHOW_POPUP_TEXT_PROPERTY = "showPopupText";
+public static final String POPUP_BORDER_PROPERTY = "popupBorder";
public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
@Override
@@ -82,9 +92,8 @@
if (log.isDebugEnabled()) {
log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
}
- log.info(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
+ log.info(name + " <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
if (LOCALES_PROPERTY.equals(name)) {
- Locale oldLocale = getSelectedLocale();
java.util.Collection<?> newLocales = (java.util.Collection<?>) evt.getNewValue();
// mise a jour de la popup
boolean oldShowText = renderer.isShowText();
@@ -94,8 +103,8 @@
for (Object o : newLocales) {
Locale l = (Locale) o;
boolean selected = l.equals(selectedLocale);
- String text = renderer.getText(l);
- Icon icon = renderer.getIcon(l);
+ String text = isShowPopupText() ? renderer.getText(l) : null;
+ Icon icon = isShowPopupIcon() ? renderer.getIcon(l) : null;
JRadioButtonMenuItem b = new JRadioButtonMenuItem(text, icon, selected);
popup.add(b);
b.addActionListener(this);
@@ -120,6 +129,18 @@
processDataBinding("button.text");
return;
}
+ if (SHOW_POPUP_ICON_PROPERTY.equals(name)) {
+ rebuildPopup();
+ return;
+ }
+ if (SHOW_POPUP_TEXT_PROPERTY.equals(name)) {
+ rebuildPopup();
+ return;
+ }
+ if (POPUP_BORDER_PROPERTY.equals(name)) {
+ popup.setBorder((Border)evt.getNewValue());
+ return;
+ }
if (POPUP_VISIBLE_PROPERTY.equals(name)) {
Boolean newValue = (Boolean) evt.getNewValue();
if (newValue == null || !newValue) {
@@ -165,6 +186,26 @@
setLocales(java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales()));
}
+protected void rebuildPopup() {
+ log.debug("start rebuild");
+ try {
+ for (Component c : popup.getComponents()) {
+ if (c instanceof JRadioButtonMenuItem) {
+ JRadioButtonMenuItem b = (JRadioButtonMenuItem) c;
+ Locale l = (Locale) b.getClientProperty("locale");
+ String text = isShowPopupText() ? renderer.getSafeText(l) : null;
+ Icon icon = isShowPopupIcon() ? renderer.getSafeIcon(l) : null;
+ b.setIcon(icon);
+ b.setText(text);
+ log.debug("text=" + text);
+ log.debug("icon=" + icon);
+ }
+ }
+ } finally {
+ popup.invalidate();
+ }
+}
+
protected String getTip(Locale l) {
boolean selected = l.equals(selectedLocale);
String tip = selected ? getSelectedTip(l):getNotSelectedTip(l);
@@ -197,9 +238,10 @@
@Override
public void run() {
getPopup().pack();
+ JToggleButton invoker = getButton();
Dimension dim = getPopup().getPreferredSize();
- JToggleButton invoker = getButton();
- getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
+ Dimension invokerDim = invoker.getSize();
+ getPopup().show(invoker, (int) (invokerDim.getWidth() - dim.getWidth()), invoker.getHeight());
// getPopup().setVisible(true);
}
};
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -32,8 +32,8 @@
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.config.model.CategoryModel;
@@ -59,7 +59,7 @@
* @param defaultCategory la categorie a selectionner
* @return l'ui instanciate
*/
- public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ public static ConfigUI newConfigUI(jaxx.runtime.context.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
final ConfigUI ui = new ConfigUI(tx);
Deleted: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,70 +0,0 @@
-aboutframe.about=About
-aboutframe.license=License
-aboutframe.ok=OK
-aboutframe.thirdparty=Third party
-columnselector.action.tip=Select the columns
-config.action.quit=Quit
-config.action.quit.tip=Quit the configuration editor
-config.action.reset=Cancel
-config.action.reset.tip=Cancel the modifications for the category
-config.action.save=Save
-config.action.save.tip=Save the modifications for the category
-config.category.saved=The category '%1$s' was modified \:
-config.choice.cancel=Cancel
-config.choice.continue=Continue
-config.choice.doNotSave=Do not save
-config.choice.ok=Ok
-config.choice.save=Save
-config.defaultValue=Default value
-config.defaultValue.tip=Default value of the option
-config.descrition=Description
-config.error.category.already.exists=category with name '%1$s' does already exist\!
-config.error.category.not.found=category with name '%1$s' does not exist\!
-config.key=Key
-config.key.tip=Key of the option
-config.message.quit.invalid.category=The category '%1$s' is not valid\!
-config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
-config.modified=Option was modified (previous value \: %1$s)
-config.no.option.selected=< No selected option >
-config.option.final=This option can not be modified
-config.option.label=Option '%1$s' (%2$s)
-config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' >
-config.title=Preferences
-config.title.need.confirm=A confirmation is required
-config.title.will.reload.application=The application need to be restarted
-config.unmodifiable=Can not be modified
-config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
-config.value=Value
-config.value.tip=Value of the option
-entitycombobox.action.reset.tip=Reset the selected value
-entitycombobox.action.sort.tip=Change the sorted property
-entitycombobox.popup.label=Object '%1$s'
-entitycombobox.popup.title=Change the sorted property
-entitycombobox.sort.off=Click to activate the sort on this property
-entitycombobox.sort.on=This is the property actually used
-entitycombobox.unknown.type=Object of unkown type
-errorUI.action.close=Close
-errorUI.message=An error wad detected...
-errorUI.title=Error...
-i18neditor.empty.locales=< No locale to select >
-i18neditor.popup.title=Change language
-i18neditor.selected=Selected language \: %1$s
-i18neditor.unselected=Select this langage \: %1$s
-memorywidget.memory=%d/%dMb
-numbereditor..=.
-numbereditor.0=0
-numbereditor.1=1
-numbereditor.2=2
-numbereditor.3=3
-numbereditor.4=4
-numbereditor.5=5
-numbereditor.6=6
-numbereditor.7=7
-numbereditor.8=8
-numbereditor.9=9
-numbereditor.action.reset.tip=Reset
-numbereditor.action.show.tip=Show numeric panel
-numbereditor.clearAll=C
-numbereditor.clearOne=CE
-numbereditor.toggleSign=+/-
-timeeditor.H=H
Deleted: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,71 +0,0 @@
-aboutframe.about=\u00C0 propos
-aboutframe.license=Licence
-aboutframe.ok=OK
-aboutframe.thirdparty=Tierce partie
-columnselector.action.tip=S\u00E9lectionner les colonnes
-config.action.quit=Quitter
-config.action.quit.tip=Quitter l'\u00E9diteur de configuration
-config.action.reset=Annuler
-config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
-config.action.save=Enregistrer
-config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
-config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
-config.choice.cancel=Annuler
-config.choice.continue=Continuer
-config.choice.doNotSave=Ne pas enregistrer
-config.choice.ok=Ok
-config.choice.save=Enregistrer
-config.defaultValue=Valeur par d\u00E9faut
-config.defaultValue.tip=Valeur par d\u00E9faut de l'option
-config.descrition=Description
-config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\!
-config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\!
-config.key=Clef
-config.key.tip=Clef de l'option
-config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
-config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
-config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
-config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
-config.option.final=Option non modifiable
-config.option.label=Option '%1$s' (%2$s)
-config.option.modified=Valeur modifi\u00E9e < nouvelle valeur \: '%1$s' - ancienne valeur \: '%2$s' >
-config.option.valid=Valeur non valide
-config.title=Pr\u00E9f\u00E9rences
-config.title.need.confirm=Une confirmation de votre part est requise...
-config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
-config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
-config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
-config.value=Valeur
-config.value.tip=Valeur de l'option
-entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
-entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
-entitycombobox.popup.label=Objet '%1$s'
-entitycombobox.popup.title=Modifier le tri
-entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s'
-entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s'
-entitycombobox.unknown.type=Objet de type inconnu
-errorUI.action.close=Fermer
-errorUI.message=Une erreur est survenue \!
-errorUI.title=Erreur...
-i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
-i18neditor.popup.title=Changer de langue
-i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
-i18neditor.unselected=Pour utiliser cette langue \: %1$s
-memorywidget.memory=%d/%dMo
-numbereditor..=.
-numbereditor.0=0
-numbereditor.1=1
-numbereditor.2=2
-numbereditor.3=3
-numbereditor.4=4
-numbereditor.5=5
-numbereditor.6=6
-numbereditor.7=7
-numbereditor.8=8
-numbereditor.9=9
-numbereditor.action.reset.tip=R\u00E9initialiser
-numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
-numbereditor.clearAll=C
-numbereditor.clearOne=CE
-numbereditor.toggleSign=+/-
-timeeditor.H=H
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,70 +1,70 @@
-aboutframe.about=
-aboutframe.license=
-aboutframe.ok=
-aboutframe.thirdparty=
-columnselector.action.tip=
-config.action.quit=
-config.action.quit.tip=
-config.action.reset=
-config.action.reset.tip=
-config.action.save=
-config.action.save.tip=
-config.category.saved=
-config.choice.cancel=
-config.choice.continue=
-config.choice.doNotSave=
-config.choice.ok=
-config.choice.save=
-config.defaultValue=
-config.defaultValue.tip=
-config.descrition=
-config.error.category.already.exists=
-config.error.category.not.found=
-config.key=
-config.key.tip=
-config.message.quit.invalid.category=
-config.message.quit.valid.and.modified.category=
-config.modified=
-config.no.option.selected=
-config.option.final=
-config.option.label=
-config.option.modified=
-config.title=
-config.title.need.confirm=
-config.title.will.reload.application=
-config.unmodifiable=
-config.unvalid=
-config.value=
-config.value.tip=
-entitycombobox.action.reset.tip=
-entitycombobox.action.sort.tip=
-entitycombobox.popup.label=
-entitycombobox.popup.title=
-entitycombobox.sort.off=
-entitycombobox.sort.on=
-entitycombobox.unknown.type=
-errorUI.action.close=
-errorUI.message=
-errorUI.title=
-i18neditor.empty.locales=
-i18neditor.popup.title=
-i18neditor.selected=
-i18neditor.unselected=
-memorywidget.memory=
-numbereditor..=
-numbereditor.0=
-numbereditor.1=
-numbereditor.2=
-numbereditor.3=
-numbereditor.4=
-numbereditor.5=
-numbereditor.6=
-numbereditor.7=
-numbereditor.8=
-numbereditor.9=
-numbereditor.action.reset.tip=
-numbereditor.action.show.tip=
-numbereditor.clearAll=
-numbereditor.clearOne=
-numbereditor.toggleSign=
-timeeditor.H=
+aboutframe.about=About
+aboutframe.license=License
+aboutframe.ok=OK
+aboutframe.thirdparty=Third party
+columnselector.action.tip=Select the columns
+config.action.quit=Quit
+config.action.quit.tip=Quit the configuration editor
+config.action.reset=Cancel
+config.action.reset.tip=Cancel the modifications for the category
+config.action.save=Save
+config.action.save.tip=Save the modifications for the category
+config.category.saved=The category '%1$s' was modified \:
+config.choice.cancel=Cancel
+config.choice.continue=Continue
+config.choice.doNotSave=Do not save
+config.choice.ok=Ok
+config.choice.save=Save
+config.defaultValue=Default value
+config.defaultValue.tip=Default value of the option
+config.descrition=Description
+config.error.category.already.exists=category with name '%1$s' does already exist\!
+config.error.category.not.found=category with name '%1$s' does not exist\!
+config.key=Key
+config.key.tip=Key of the option
+config.message.quit.invalid.category=The category '%1$s' is not valid\!
+config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
+config.modified=Option was modified (previous value \: %1$s)
+config.no.option.selected=< No selected option >
+config.option.final=This option can not be modified
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' >
+config.title=Preferences
+config.title.need.confirm=A confirmation is required
+config.title.will.reload.application=The application need to be restarted
+config.unmodifiable=Can not be modified
+config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
+config.value=Value
+config.value.tip=Value of the option
+entitycombobox.action.reset.tip=Reset the selected value
+entitycombobox.action.sort.tip=Change the sorted property
+entitycombobox.popup.label=Object '%1$s'
+entitycombobox.popup.title=Change the sorted property
+entitycombobox.sort.off=Click to activate the sort on this property
+entitycombobox.sort.on=This is the property actually used
+entitycombobox.unknown.type=Object of unkown type
+errorUI.action.close=Close
+errorUI.message=An error wad detected...
+errorUI.title=Error...
+i18neditor.empty.locales=< No locale to select >
+i18neditor.popup.title=Change language
+i18neditor.selected=Selected language \: %1$s
+i18neditor.unselected=Select this langage \: %1$s
+memorywidget.memory=%d/%dMb
+numbereditor..=.
+numbereditor.0=0
+numbereditor.1=1
+numbereditor.2=2
+numbereditor.3=3
+numbereditor.4=4
+numbereditor.5=5
+numbereditor.6=6
+numbereditor.7=7
+numbereditor.8=8
+numbereditor.9=9
+numbereditor.action.reset.tip=Reset
+numbereditor.action.show.tip=Show numeric panel
+numbereditor.clearAll=C
+numbereditor.clearOne=CE
+numbereditor.toggleSign=+/-
+timeeditor.H=H
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,70 +1,71 @@
-aboutframe.about=
-aboutframe.license=
-aboutframe.ok=
-aboutframe.thirdparty=
-columnselector.action.tip=
-config.action.quit=
-config.action.quit.tip=
-config.action.reset=
-config.action.reset.tip=
-config.action.save=
-config.action.save.tip=
-config.category.saved=
-config.choice.cancel=
-config.choice.continue=
-config.choice.doNotSave=
-config.choice.ok=
-config.choice.save=
-config.defaultValue=
-config.defaultValue.tip=
-config.descrition=
-config.error.category.already.exists=
-config.error.category.not.found=
-config.key=
-config.key.tip=
-config.message.quit.invalid.category=
-config.message.quit.valid.and.modified.category=
-config.modified=
-config.no.option.selected=
-config.option.final=
-config.option.label=
-config.option.modified=
-config.title=
-config.title.need.confirm=
-config.title.will.reload.application=
-config.unmodifiable=
-config.unvalid=
-config.value=
-config.value.tip=
-entitycombobox.action.reset.tip=
-entitycombobox.action.sort.tip=
-entitycombobox.popup.label=
-entitycombobox.popup.title=
-entitycombobox.sort.off=
-entitycombobox.sort.on=
-entitycombobox.unknown.type=
-errorUI.action.close=
-errorUI.message=
-errorUI.title=
-i18neditor.empty.locales=
-i18neditor.popup.title=
-i18neditor.selected=
-i18neditor.unselected=
-memorywidget.memory=
-numbereditor..=
-numbereditor.0=
-numbereditor.1=
-numbereditor.2=
-numbereditor.3=
-numbereditor.4=
-numbereditor.5=
-numbereditor.6=
-numbereditor.7=
-numbereditor.8=
-numbereditor.9=
-numbereditor.action.reset.tip=
-numbereditor.action.show.tip=
-numbereditor.clearAll=
-numbereditor.clearOne=
-numbereditor.toggleSign=
-timeeditor.H=
+aboutframe.about=\u00C0 propos
+aboutframe.license=Licence
+aboutframe.ok=OK
+aboutframe.thirdparty=Tierce partie
+columnselector.action.tip=S\u00E9lectionner les colonnes
+config.action.quit=Quitter
+config.action.quit.tip=Quitter l'\u00E9diteur de configuration
+config.action.reset=Annuler
+config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
+config.action.save=Enregistrer
+config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
+config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
+config.choice.cancel=Annuler
+config.choice.continue=Continuer
+config.choice.doNotSave=Ne pas enregistrer
+config.choice.ok=Ok
+config.choice.save=Enregistrer
+config.defaultValue=Valeur par d\u00E9faut
+config.defaultValue.tip=Valeur par d\u00E9faut de l'option
+config.descrition=Description
+config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\!
+config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\!
+config.key=Clef
+config.key.tip=Clef de l'option
+config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
+config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
+config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
+config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
+config.option.final=Option non modifiable
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Valeur modifi\u00E9e < nouvelle valeur \: '%1$s' - ancienne valeur \: '%2$s' >
+config.option.valid=Valeur non valide
+config.title=Pr\u00E9f\u00E9rences
+config.title.need.confirm=Une confirmation de votre part est requise...
+config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
+config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
+config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
+config.value=Valeur
+config.value.tip=Valeur de l'option
+entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
+entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
+entitycombobox.popup.label=Objet '%1$s'
+entitycombobox.popup.title=Modifier le tri
+entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.unknown.type=Objet de type inconnu
+errorUI.action.close=Fermer
+errorUI.message=Une erreur est survenue \!
+errorUI.title=Erreur...
+i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
+i18neditor.popup.title=Changer de langue
+i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
+i18neditor.unselected=Pour utiliser cette langue \: %1$s
+memorywidget.memory=%d/%dMo
+numbereditor..=.
+numbereditor.0=0
+numbereditor.1=1
+numbereditor.2=2
+numbereditor.3=3
+numbereditor.4=4
+numbereditor.5=5
+numbereditor.6=6
+numbereditor.7=7
+numbereditor.8=8
+numbereditor.9=9
+numbereditor.action.reset.tip=R\u00E9initialiser
+numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
+numbereditor.clearAll=C
+numbereditor.clearOne=CE
+numbereditor.toggleSign=+/-
+timeeditor.H=H
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -117,7 +117,9 @@
* @since 1.3
*/
protected String helpsetIndexI18nSuffix;
- protected boolean skip;
+ /**
+ *
+ */
protected ClassLoader cl;
@Override
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,35 +18,39 @@
*##%*/
package org.nuiton.jaxx.plugin;
-import jaxx.beaninfos.BeanInfoUtil;
-import jaxx.compiler.CompilerOptions;
+import jaxx.compiler.CompilerConfiguration;
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.runtime.JAXXContext;
-import jaxx.tags.TagManager;
+import jaxx.compiler.beans.BeanInfoUtil;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+import jaxx.compiler.tags.TagManager;
+import jaxx.runtime.context.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.codehaus.plexus.util.DirectoryScanner;
+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.lang.reflect.Modifier;
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.compiler.CompiledObjectDecorator;
-import jaxx.compiler.HelpRootCompiledObjectDecorator;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
-import org.apache.maven.project.MavenProject;
-import org.nuiton.io.FileUpdaterHelper;
-import org.nuiton.io.MirroredFileUpdater;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
/**
* Classe permettant de transformer des sources jaxx vers du source java.
@@ -57,62 +61,72 @@
* @requiresDependencyResolution compile
* @requiresProject
*/
-public class JaxxGeneratorMojo extends AbstractJaxxMojo {
+public class JaxxGeneratorMojo extends AbstractJaxxMojo implements CompilerConfiguration {
/**
- * Le compilateur à utiliser (par défaut celui de Swing)
- *
- * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.SwingCompiler"
+ * Default includes to use, if none provided
*/
- protected String compilerFQN;
+ private static final String[] INCLUDES = {"**\\/*.jaxx"};
/**
- * Le compilateur à utiliser (par défaut celui de Swing)
+ * Repertoire sources des fichiers jaxx a generer.
*
- * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
+ * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
*/
- protected String validatorFQN;
+ protected File src;
/**
- * chemin du repertoire de generation des resources.
+ * pour filter les fichiers a traiter
*
- * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
+ * @parameter expression="${jaxx.includes}"
*/
- protected File outResource;
+ protected String[] includes;
/**
- * chemin du repertoire de compilation des resources.
+ * pour filter les fichiers a ne pas traiter
*
- * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
+ * @parameter expression="${jaxx.excludes}"
*/
- protected File outClass;
+ protected String[] excludes;
/**
- * Repertoire sources des fichiers jaxx a generer.
+ * Le compilateur à utiliser (par défaut celui de Swing)
*
- * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
+ * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler"
*/
- protected File src;
+ protected String compilerFQN;
/**
- * pour optimizer le code compile ou genere ?
+ * Le compilateur à utiliser (par défaut celui de Swing)
*
- * @parameter expression="${jaxx.optimize}" default-value="false"
+ * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
*/
- protected boolean optimize;
+ protected String validatorFQN;
/**
- * les options de la compilation
+ * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * to be used on {@link jaxx.runtime.JAXXObject}.
+ * <p/>
+ * Must not be abstract.
*
- * @parameter expression="${jaxx.javaOpts}"
+ * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext"
+ * @required
*/
- protected String javaOpts = null;
+ protected String jaxxContextFQN;
/**
- * pour filter les fichiers a traiter
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
*
- * @parameter expression="${jaxx.includes}"
+ * @parameter expression="${jaxx.defaultErrorUIFQN}"
+ *
+ * @see jaxx.runtime.validator.swing.SwingValidator
*/
- protected String[] includes;
+ protected String defaultErrorUIFQN;
/**
- * pour filter les fichiers a ne pas traiter
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
*
- * @parameter expression="${jaxx.excludes}"
+ * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
+ *
+ * @see jaxx.compiler.CompiledObjectDecorator
*/
- protected String[] excludes;
+ protected String defaultDecoratorFQN;
/**
* flag to include in compiler classpath the java sources directories (src and outJava).
* <p/>
@@ -156,6 +170,19 @@
*/
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.
@@ -172,16 +199,6 @@
*/
protected boolean resetAfterCompile;
/**
- * 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.jaxxContextImplementorClass}" default-value="jaxx.runtime.DefaultJAXXContext"
- * @required
- */
- protected String jaxxContextImplementorClass;
- /**
* 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[])}
@@ -197,39 +214,10 @@
/**
* list of fqn of class toimport for all generated jaxx files
*
- * @parameter expression="${jaxx.extraImports}"
- *
- * @deprecated Prefer use of extraImportList as a string, so
- * could be use in properties section.
- */
- protected String[] extraImports;
- /**
- * list of fqn of class toimport for all generated jaxx files
- *
* @parameter expression="${jaxx.extraImportList}"
*/
protected String extraImportList;
/**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultErrorUIFQN}"
- *
- * @see jaxx.runtime.validator.swing.SwingValidator
- */
- protected String defaultErrorUIFQN;
- /**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultDecorator}" default-value="jaxx.compiler.DefaultCompiledObjectDecorator"
- *
- * @see jaxx.compiler.CompiledObjectDecorator
- */
- protected String defaultDecoratorFQN;
- /**
* a flag to use UIManager to retreave icons.
*
* @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
@@ -264,27 +252,41 @@
*/
protected String helpBrokerFQN;
/**
- * 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;
protected String[] files;
- private static final String[] INCLUDES = {"**\\/*.jaxx"};
- protected CompilerOptions options;
+ /**
+ *
+ */
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;
@SuppressWarnings("unchecked")
@Override
public boolean init() throws Exception {
- if (skip) {
- return true;
- }
if (generateHelp) {
// check there is some bundle
@@ -292,24 +294,7 @@
throw new MojoFailureException("you must set the helpIdStore property.");
}
}
- skip = false;
- checkJaxxContextImplementorClass();
-
- if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
- // register extra path
- BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
- }
- if (!outResource.exists()) {
- outResource.mkdirs();
- }
-
- if (!outJava.exists()) {
- outJava.mkdirs();
- }
-
- fixCompileSourceRoots();
-
if (addSourcesToClassPath || addProjectClassPath) {
cl = initClassLoader(project, getLog());
Thread.currentThread().setContextClassLoader(cl);
@@ -318,55 +303,44 @@
//cl = Thread.currentThread().getContextClassLoader();
}
-
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
-
- // check the validator class is correct
+ 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);
}
- DirectoryScanner ds;
- ds = new DirectoryScanner();
- ds.setBasedir(src);
- boolean noIncludes = includes == null || includes.length == 0;
- ds.setIncludes(noIncludes ? INCLUDES : includes);
+ if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
+ // register extra path
+ BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
+ }
- if (excludes != null && excludes.length > 0) {
- ds.setExcludes(excludes);
+ if (!outJava.exists()) {
+ outJava.mkdirs();
}
- ds.scan();
- String[] filesFind = ds.getIncludedFiles();
- if (verbose) {
- getLog().info("jaxx - discover " + filesFind.length + " jaxx file(s). ");
+ fixCompileSourceRoots();
+
+ boolean noIncludes = includes == null || includes.length == 0;
+
+ if (noIncludes) {
+ includes = INCLUDES;
}
-
updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
- if (force) {
- // we will regenerate all files
- this.files = filesFind;
- } else {
- // filter files
- List<String> listFiles = new ArrayList<String>();
+ Map<File, String[]> result = new HashMap<File, String[]>();
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
- for (String file : filesFind) {
- if (updater.isFileUpToDate(new File(src, file))) {
- if (verbose) {
- getLog().info("jaxx - skip file [" + file + "].");
- }
- } else {
- if (verbose) {
- getLog().info("jaxx - detect modify file [" + file + "].");
- }
- listFiles.add(file);
- }
- }
- this.files = listFiles.toArray(new String[listFiles.size()]);
+ this.files = result.get(src);
+
+ if (files == null || files.length == 0) {
+ getLog().warn("No files to treate.");
+ return false;
}
if (extraImportList != null && !extraImportList.isEmpty()) {
@@ -379,9 +353,7 @@
getLog().info("extra imports " + java.util.Arrays.toString(imports));
}
extraImports = imports;
-
}
- options = toCompilerOptions();
if (verbose) {
printInit();
@@ -391,12 +363,7 @@
@Override
public void doAction() throws MojoExecutionException {
- if (skip) {
- if (verbose) {
- getLog().info("jaxx - skip!");
- }
- return;
- }
+
getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
try {
@@ -404,7 +371,7 @@
// force compiler init from here, not in a static block
TagManager.reset(verbose);
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options);
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
boolean success = launchor.compile();
getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
@@ -432,43 +399,121 @@
}
}
- public CompilerOptions toCompilerOptions() {
- CompilerOptions result = new CompilerOptions();
- result.setClassPath(src.getPath());
- if (javaOpts != null && !"".equals(javaOpts)) {
- result.setJavacOpts(javaOpts);
- }
- result.setCompilerClass(compilerClass);
- result.setValidatorFQN(validatorFQN);
- result.setValidatorClass(validatorClass);
- result.setKeepJavaFiles(true);
- result.setOptimize(optimize);
- result.setJavacTargetDirectory(outClass);
- result.setTargetDirectory(outJava);
- result.setVerbose(verbose);
- result.setI18nable(i18nable);
- result.setAddLogger(addLogger);
- result.setProfile(profile);
- result.setResetAfterCompile(resetAfterCompile);
- result.setJaxxContextImplementorClass(jaxxContextImplementorClass);
- result.setExtraImports(extraImports);
- result.setDefaultErrorUI(defaultErrorUIClass);
- result.setUseUIManagerForIcon(useUIManagerForIcon);
- result.setDefaultDecoratorClass(defaultDecoratorClass);
- result.setGenerateHelp(generateHelp);
- result.setHelpBrokerFQN(helpBrokerFQN);
- result.setHelpsetTitleI18nSuffix(helpsetTitleI18nSuffix);
- result.setHelpsetIndexI18nSuffix(helpsetIndexI18nSuffix);
- result.setHelpsetTocI18nSuffix(helpsetTocI18nSuffix);
- result.setHelpSetName(helpSetName);
- result.setHelpsetI18nPrefix(helpsetI18nPrefix);
+ @Override
+ public File getTargetDirectory() {
+ return outJava;
+ }
- if (cl != null) {
- result.setClassLoader(cl);
- }
- return result;
+ @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
@@ -491,7 +536,7 @@
}
protected void printInit() {
- getLog().info(options.toString());
+ getLog().info(toString());
getLog().info("includes : " + Arrays.toString(includes));
for (String file : files) {
getLog().info("will generate " + file);
@@ -514,24 +559,6 @@
}
}
- protected void checkJaxxContextImplementorClass() {
- if (jaxxContextImplementorClass == null) {
- throw new IllegalArgumentException("jaxxContextImplementor can not be null");
- }
- try {
- Class<?> jaxxContextImplementor = Class.forName(jaxxContextImplementorClass);
- if (!JAXXContext.class.isAssignableFrom(jaxxContextImplementor)) {
- throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' does not implements " + JAXXContext.class);
- }
- if (Modifier.isAbstract(jaxxContextImplementor.getModifiers())) {
- throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' can not be abstract.");
-
- }
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("could not find jaxxContextImplementor class : " + jaxxContextImplementorClass);
- }
- }
-
protected void generateHelp() throws IOException {
Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
if (helpIds.isEmpty()) {
Modified: 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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -209,12 +209,7 @@
@Override
public boolean init() throws Exception {
- if (skip) {
- return true;
- }
-
if (!helpIdStore.exists()) {
- skip = true;
getLog().info("no helpIdStore to react at " + helpIdStore);
return false;
}
@@ -239,7 +234,6 @@
target.mkdirs();
}
-
helpIds = new SortedProperties();
InputStream stream = new FileInputStream(helpIdStore);
@@ -252,24 +246,15 @@
// no ids detected
getLog().warn("no helpIds detected, will skip.");
- skip = true;
return false;
}
- skip = false;
return true;
}
@Override
public void doAction() throws Exception {
- if (skip) {
- if (verbose) {
- getLog().info("jaxx - skip!");
- }
- return;
- }
-
if (i18nable) {
List<URL> lUrls = new java.util.ArrayList<URL>();
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,6 @@
package org.nuiton.jaxx.plugin;
-import jaxx.Base64Coder;
+import jaxx.runtime.Base64Coder;
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerLaunchor;
import jaxx.runtime.JAXXObjectDescriptor;
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -2,8 +2,7 @@
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.runtime.DefaultJAXXContext;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.DefaultJAXXContext;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.SystemStreamLog;
@@ -162,31 +161,31 @@
@Test
public void ErrorJaxxContextImplementorClass() throws Exception {
JaxxGeneratorMojo mojo = getMojo();
- mojo.jaxxContextImplementorClass = null;
+ mojo.jaxxContextFQN = null;
try {
mojo.init();
fail();
- } catch (IllegalArgumentException e) {
+ } catch (NullPointerException e) {
assertTrue(true);
}
- mojo.jaxxContextImplementorClass = String.class.getName();
+ mojo.jaxxContextFQN = String.class.getName();
try {
mojo.init();
fail();
- } catch (IllegalArgumentException e) {
+ } catch (MojoExecutionException e) {
assertTrue(true);
}
+//
+// mojo.jaxxContextFQN = JAXXContext.class.getName();
+// try {
+// mojo.init();
+// fail();
+// } catch (IllegalArgumentException e) {
+// assertTrue(true);
+// }
- mojo.jaxxContextImplementorClass = JAXXContext.class.getName();
- try {
- mojo.init();
- fail();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName();
+ mojo.jaxxContextFQN = DefaultJAXXContext.class.getName();
mojo.init();
assertTrue(true);
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,6 @@
package org.nuiton.jaxx.plugin;
-import jaxx.runtime.DefaultJAXXContext;
+import jaxx.runtime.context.DefaultJAXXContext;
import org.nuiton.util.FileUtil;
import java.io.File;
@@ -8,7 +8,8 @@
import org.nuiton.plugin.AbstractMojoTest;
import static org.junit.Assert.*;
-/** Base test case for a jaxx:generate goal.
+/**
+ * Base test case for a jaxx:generate goal.
*
* Use {@link AbstractMojoTest} from {@code maven-helper-plugin}.
*
@@ -26,10 +27,10 @@
@Override
protected void setUpMojo(JaxxGeneratorMojo mojo, File pomFile) throws Exception {
super.setUpMojo(mojo, pomFile);
- mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName();
- mojo.compilerFQN = jaxx.compiler.SwingCompiler.class.getName();
+ mojo.jaxxContextFQN = DefaultJAXXContext.class.getName();
+ mojo.compilerFQN = jaxx.compiler.JAXXCompiler.class.getName();
mojo.validatorFQN = jaxx.runtime.validator.swing.SwingValidator.class.getName();
- mojo.defaultDecoratorFQN = jaxx.compiler.DefaultCompiledObjectDecorator.class.getName();
+ mojo.defaultDecoratorFQN = jaxx.compiler.decorators.DefaultCompiledObjectDecorator.class.getName();
}
protected void checkPattern(JaxxGeneratorMojo mojo, String pattern, boolean required, String... files) throws IOException {
@@ -52,6 +53,10 @@
}
protected void assertNumberJaxxFiles(int expectedNbFiles) {
- assertEquals(expectedNbFiles, getMojo().files.length);
+ if (expectedNbFiles == 0) {
+ assertTrue(getMojo().files == null || getMojo().files.length == 0);
+ } else {
+ assertEquals(expectedNbFiles, getMojo().files.length);
+ }
}
}
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<resetAfterCompile>false</resetAfterCompile>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<i18nable>true</i18nable>
<force>true</force>
<verbose>true</verbose>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>false</i18nable>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/ClassReferences/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>false</addLogger>
<includes>
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-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,8 +14,8 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
- <jaxxContextImplementorClass>java.lang.String</jaxxContextImplementorClass>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
+ <jaxxContextFQN>java.lang.String</jaxxContextFQN>
<force>true</force>
</configuration>
</plugin>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/errors/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/force/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<i18nable>false</i18nable>
<force>true</force>
<verbose>true</verbose>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/Initializers/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/InnerClasses/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>false</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/OverridingDataBindings/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/Script/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/SpecialSubclassing/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>true</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,8 +1,8 @@
-<JList>
+<JAXXList>
<item value='1'/>
<item value='2'/>
<item value='2'/>
<item value='3'/>
<item value='3'/>
<item value='3'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,4 +1,4 @@
-<JList>
+<JAXXList>
<item label='This item doesn&t have a value'/>
<item label='Neither does this one'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -15,7 +15,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>false</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/Evolution74Test/ok/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: branches/jaxx-2.X/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-07 14:22:07 UTC (rev 1562)
@@ -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.JAXXContext
+jaxx.runtime.context.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
@@ -32,7 +32,7 @@
Le nom qui est facultatif permet de pouvoir distinguer plusieurs données d'un même type dans le context. Si le nom
n'est pas utilisé pour caractériser une données on fixera alors sa valeur à *null*.
-Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.JAXXContextEntryDef*.
+Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.context.JAXXContextEntryDef*.
Les méthodes de lecture
***********************
@@ -87,7 +87,7 @@
Cette entrée spéciale ne sera pas stockée avec les autres entrées afin d'optimiser les algorithmes d'injection et de
restitution.
-jaxx.runtime.JAXXInitialContext
+jaxx.runtime.context.JAXXInitialContext
*******************************
On a implanté un second type de context qui lui peut servir à l'initialisation des JAXXObject.
1
0
Author: tchemit
Date: 2009-10-06 06:59:00 +0200 (Tue, 06 Oct 2009)
New Revision: 1561
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.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/resources/org/nuiton/jaxx/plugin/Evolution74Test/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx
Removed:
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.jaxx
Log:
[Evolution #74] : pouvoir generer les classes swing (JComboBox, JList,...)
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -39,38 +39,47 @@
// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
+
+ // check boxes
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
- //TC-20091005 : JAXXComboBox and JComboBox are not the same
-// TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
-// TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+
+ // combo boxes
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class);
+ // radio boxes
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
+
+ // Lists
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JList.class), JListHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JAXXListHandler.class);
+
+ // Trees
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTree.class), JTreeHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JAXXTreeHandler.class);
+
+ // Windows
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
+
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JListHandler.class);
- TagManager.registerTag("javax.swing.*", "JList", new JListHandler(ClassDescriptorLoader.getClassDescriptor(JAXXList.class)));
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JTreeHandler.class);
- TagManager.registerTag("javax.swing.*", "JTree", new JTreeHandler(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class)));
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*");
TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*");
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.swing;
+
+import jaxx.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptor;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXList;
+import jaxx.tags.DefaultComponentHandler;
+import jaxx.types.TypeManager;
+import org.w3c.dom.Element;
+
+import javax.swing.event.ListSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXListHandler extends DefaultComponentHandler {
+ public JAXXListHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ //TODO Add the correct generic type
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.swing;
+
+import jaxx.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptor;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.tags.DefaultComponentHandler;
+import jaxx.types.TypeManager;
+import org.w3c.dom.Element;
+
+import javax.swing.event.TreeSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXTreeHandler extends DefaultComponentHandler {
+ public JAXXTreeHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException {
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ tree.appendAdditionCode(addMethod + "(" + id + ");");
+ createItems(tree, item.getChildren(), id + ".addChild", compiler);
+ }
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = tree.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = tree.getId() + "$items";
+ tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ createItems(tree, items, listName + ".add", compiler);
+ tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -35,6 +35,7 @@
NodeList children = tag.getChildNodes();
if (children.getLength() > 0) {
compiler.reportError("JComboBox does not accept childs");
+ throw new CompilerException("JComboBox does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,28 +1,22 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
package jaxx.tags.swing;
import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Item;
-import jaxx.runtime.swing.JAXXList;
import jaxx.tags.DefaultComponentHandler;
-import jaxx.types.TypeManager;
import org.w3c.dom.Element;
import javax.swing.event.ListSelectionListener;
import java.io.IOException;
-import java.util.List;
+import javax.swing.JList;
+import org.w3c.dom.NodeList;
public class JListHandler extends DefaultComponentHandler {
+
public JListHandler(ClassDescriptor beanClass) {
super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JList.class);
}
@Override
@@ -35,27 +29,11 @@
}
@Override
- public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-
- @Override
public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
- super.compileChildrenSecondPass(tag, compiler);
- CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
- List<Item> items = list.getItems();
- if (items != null && !items.isEmpty()) {
- String listName = list.getId() + "$items";
- //TODO Add the correct generic type
- list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
- for (Item item : items) {
- String id = item.getId();
- CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
- compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
- compiler.registerCompiledObject(compiledItem);
- list.appendAdditionCode(listName + ".add(" + id + ");");
- }
- list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JList does not accept childs");
+ throw new CompilerException("JList does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,28 +1,22 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
package jaxx.tags.swing;
import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Item;
-import jaxx.runtime.swing.JAXXTree;
import jaxx.tags.DefaultComponentHandler;
-import jaxx.types.TypeManager;
import org.w3c.dom.Element;
import javax.swing.event.TreeSelectionListener;
import java.io.IOException;
-import java.util.List;
+import javax.swing.JTree;
+import org.w3c.dom.NodeList;
public class JTreeHandler extends DefaultComponentHandler {
+
public JTreeHandler(ClassDescriptor beanClass) {
super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTree.class);
}
@Override
@@ -36,31 +30,11 @@
}
@Override
- public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-
- private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException {
- for (Item item : items) {
- String id = item.getId();
- CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
- compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
- compiler.registerCompiledObject(compiledItem);
- tree.appendAdditionCode(addMethod + "(" + id + ");");
- createItems(tree, item.getChildren(), id + ".addChild", compiler);
- }
- }
-
- @Override
public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
- super.compileChildrenSecondPass(tag, compiler);
- CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent();
- List<Item> items = tree.getItems();
- if (items != null && !items.isEmpty()) {
- String listName = tree.getId() + "$items";
- tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
- createItems(tree, items, listName + ".add", compiler);
- tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");");
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JTree does not accept childs");
+ throw new CompilerException("JTree does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -97,10 +97,7 @@
<JScrollPane id='navigationPane'>
<JTree id='navigation'
model='{getTreeHelper().createTreeModel(this)}'
- selectionModel="{getTreeHelper().createTreeHandler(this)}">
- <!--cellRenderer='{new NavigationTreeCellRenderer(this)}'>-->
- <!--cellRenderer='{new NavigationTreeCellRenderer(this,185)}'>-->
- </JTree>
+ selectionModel="{getTreeHelper().createTreeHandler(this)}"/>
</JScrollPane>
<JPanel id='content'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -40,7 +40,7 @@
<JPanel id='demoPanel' layout='{new BorderLayout()}'>
<JSplitPane constraints='BorderLayout.CENTER'>
<JScrollPane>
- <JTree id='nav' rootVisible='{false}'>
+ <JAXXTree id='nav' rootVisible='{false}'>
<!-- Allow to diplay associated pane without value -->
<item id='stringItemParent' label='String' value='{String.class}'>
<item id='string1Item' label='String1' value='{new String("Ceci est un String")}' selected='true'/>
@@ -49,7 +49,7 @@
<item id='dateItemParent' label='Date' value='{Date.class}'>
<item id='dateItem' label='CurrentDate' value='{new Date()}'/>
</item>
- </JTree>
+ </JAXXTree>
</JScrollPane>
<!-- Card panel, only ItemNavigationPanel children is allowed -->
<ItemNavigationCardPanel id="content">
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -18,62 +18,62 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
##%*
-->
-<jaxx.demo.DemoPanel>
- <Table id='demoPanel'>
- <row>
- <cell>
- <JLabel text='Supported Swing components:'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JScrollPane>
- <JList>
- <item value='JApplet'/>
- <item value='JButton'/>
- <item value='JCheckBox'/>
- <item value='JCheckBoxMenuItem'/>
- <item value='JColorChooser'/>
- <item value='JComboBox'/>
- <item value='JDesktopPane'/>
- <item value='JDialog'/>
- <item value='JEditorPane'/>
- <item value='JFileChooser'/>
- <item value='JFormattedTextField'/>
- <item value='JFrame'/>
- <item value='JInternalFrame'/>
- <item value='JLabel'/>
- <item value='JLayeredPane'/>
- <item value='JList'/>
- <item value='JMenu'/>
- <item value='JMenuBar'/>
- <item value='JMenuItem'/>
- <item value='JOptionPane'/>
- <item value='JPanel'/>
- <item value='JPasswordField'/>
- <item value='JPopupMenu'/>
- <item value='JProgressBar'/>
- <item value='JRadioButton'/>
- <item value='JRadioButtonMenuItem'/>
- <item value='JScrollBar'/>
- <item value='JScrollPane'/>
- <item value='JSeparator'/>
- <item value='JSlider'/>
- <item value='JSpinner'/>
- <item value='JSplitPane'/>
- <item value='JTabbedPane'/>
- <item value='JTable'/>
- <item value='JTextArea'/>
- <item value='JTextField'/>
- <item value='JTextPane'/>
- <item value='JToggleButton'/>
- <item value='JToolBar'/>
- <item value='JTree'/>
- <item value='JWindow'/>
- </JList>
- </JScrollPane>
- </cell>
- </row>
- </Table>
+<jaxx.demo.DemoPanel>
+ <Table id='demoPanel'>
+ <row>
+ <cell>
+ <JLabel text='Supported Swing components:'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JScrollPane>
+ <JAXXList>
+ <item value='JApplet'/>
+ <item value='JButton'/>
+ <item value='JCheckBox'/>
+ <item value='JCheckBoxMenuItem'/>
+ <item value='JColorChooser'/>
+ <item value='JComboBox'/>
+ <item value='JDesktopPane'/>
+ <item value='JDialog'/>
+ <item value='JEditorPane'/>
+ <item value='JFileChooser'/>
+ <item value='JFormattedTextField'/>
+ <item value='JFrame'/>
+ <item value='JInternalFrame'/>
+ <item value='JLabel'/>
+ <item value='JLayeredPane'/>
+ <item value='JList'/>
+ <item value='JMenu'/>
+ <item value='JMenuBar'/>
+ <item value='JMenuItem'/>
+ <item value='JOptionPane'/>
+ <item value='JPanel'/>
+ <item value='JPasswordField'/>
+ <item value='JPopupMenu'/>
+ <item value='JProgressBar'/>
+ <item value='JRadioButton'/>
+ <item value='JRadioButtonMenuItem'/>
+ <item value='JScrollBar'/>
+ <item value='JScrollPane'/>
+ <item value='JSeparator'/>
+ <item value='JSlider'/>
+ <item value='JSpinner'/>
+ <item value='JSplitPane'/>
+ <item value='JTabbedPane'/>
+ <item value='JTable'/>
+ <item value='JTextArea'/>
+ <item value='JTextField'/>
+ <item value='JTextPane'/>
+ <item value='JToggleButton'/>
+ <item value='JToolBar'/>
+ <item value='JTree'/>
+ <item value='JWindow'/>
+ </JAXXList>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,84 +0,0 @@
-package org.nuiton.jaxx.plugin;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXCompilerLaunchor;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import org.apache.maven.plugin.logging.SystemStreamLog;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ComboBoxTest extends JaxxBaseTest {
-
- @Test
- public void ok() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
- mojo.execute();
- checkPattern(mojo, "swingComboBox", true, "org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.java");
- assertNumberJaxxFiles(2);
- }
-
- @SuppressWarnings({"unchecked"})
- @Test
- public void error() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
- // init mojo to get alls files to treate
- mojo.init();
-
- assertNumberJaxxFiles(1);
-
- mojo.setLog(new SystemStreamLog() {
-
- @Override
- public boolean isErrorEnabled() {
- return false;
- }
-
- @Override
- public void error(Throwable error) {
- //do nothing
- }
-
- @Override
- public void error(CharSequence content) {
- //do nothing
- }
-
- @Override
- public void error(CharSequence content, Throwable error) {
- //do nothing
- }
- });
- Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers");
- Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount");
-
- fieldCompilers.setAccessible(true);
- fieldErrorCount.setAccessible(true);
-
-
- // execute mjo on each jaxx file to produce the error
- for (String file : mojo.files) {
- log.info("test bad file " + file);
- mojo.files = new String[]{file};
- try {
- mojo.doAction();
- // should never pass
- fail();
- } catch (MojoExecutionException e) {
- // ok jaxx compiler failed
- assertTrue(true);
-
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get();
- Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor);
- assertEquals(1, compilers.size());
- //JAXXCompiler compiler;
- //compiler = compilers.values().iterator().next();
- Integer nberrors = (Integer) fieldErrorCount.get(launchor);
- assertTrue(nberrors != null && nberrors > 0);
- }
- }
- }
-}
Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java (from rev 1560, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java)
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,98 @@
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class Evolution74Test extends JaxxBaseTest {
+
+ @Test
+ public void ok() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ mojo.execute();
+ assertNumberJaxxFiles(6);
+
+ checkPattern(mojo, "JComboBox", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.java");
+ checkPattern(mojo, "JComboBox", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.java");
+ checkPattern(mojo, "JAXXComboBox", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.java");
+ checkPattern(mojo, "JAXXComboBox", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.java");
+
+ checkPattern(mojo, "JList", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.java");
+ checkPattern(mojo, "JList", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.java");
+ checkPattern(mojo, "JAXXList", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.java");
+ checkPattern(mojo, "JAXXList", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.java");
+
+ checkPattern(mojo, "JTree", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.java");
+ checkPattern(mojo, "JTree", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.java");
+ checkPattern(mojo, "JAXXTree", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.java");
+ checkPattern(mojo, "JAXXTree", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.java");
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Test
+ public void error() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ // init mojo to get alls files to treate
+ mojo.init();
+
+ assertNumberJaxxFiles(3);
+
+ mojo.setLog(new SystemStreamLog() {
+
+ @Override
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ @Override
+ public void error(Throwable error) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ //do nothing
+ }
+ });
+ Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers");
+ Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount");
+
+ fieldCompilers.setAccessible(true);
+ fieldErrorCount.setAccessible(true);
+
+
+ // execute mjo on each jaxx file to produce the error
+ for (String file : mojo.files) {
+ log.info("test bad file " + file);
+ mojo.files = new String[]{file};
+ try {
+ mojo.doAction();
+ // should never pass
+ fail();
+ } catch (MojoExecutionException e) {
+ // ok jaxx compiler failed
+ assertTrue(true);
+
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get();
+ Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor);
+ assertEquals(1, compilers.size());
+ //JAXXCompiler compiler;
+ //compiler = compilers.values().iterator().next();
+ Integer nberrors = (Integer) fieldErrorCount.get(launchor);
+ assertTrue(nberrors != null && nberrors > 0);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JList>
+<JAXXList>
<item value='Working' selected='true'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JList>
+<JAXXList>
<item value='Failed!'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JTree>
+<JAXXTree>
<item value='Working' selected='true'/>
-</JTree>
\ No newline at end of file
+</JAXXTree>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JTree>
+<JAXXTree>
<item value='Failed!'/>
-</JTree>
\ No newline at end of file
+</JAXXTree>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test
___________________________________________________________________
Added: svn:mergeinfo
+
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JList>
+ <item value='OK'/>
+</JList>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JTree>
+ <item value='OK'/>
+</JTree>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml 2009-10-06 04:59:00 UTC (rev 1561)
@@ -18,7 +18,7 @@
<force>true</force>
<verbose>true</verbose>
<includes>
- <value>**/ComboBoxTest/error/*.jaxx</value>
+ <value>**/Evolution74Test/error/*.jaxx</value>
</includes>
</configuration>
</plugin>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,4 +1,4 @@
-<JAXXComboBox id='comboBox'>
- <item value='OK' selected='true'/>
+<JAXXComboBox>
+ <item value='OK'/>
</JAXXComboBox>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JAXXList>
+ <item value='OK'/>
+</JAXXList>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JAXXTree>
+ <item value='OK'/>
+</JAXXTree>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,2 +1,2 @@
-<JComboBox id='swingComboBox'/>
\ No newline at end of file
+<JComboBox/>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1 @@
+<JList/>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,2 @@
+
+<JTree/>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml 2009-10-06 04:59:00 UTC (rev 1561)
@@ -17,7 +17,7 @@
<outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
- <value>**/ComboBoxTest/ok/*.jaxx</value>
+ <value>**/Evolution74Test/ok/*.jaxx</value>
</includes>
</configuration>
</plugin>
1
0
Author: tchemit
Date: 2009-10-05 21:16:52 +0200 (Mon, 05 Oct 2009)
New Revision: 1560
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.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/decorator/JXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx
Log:
simplify modules + refactor NavigationTree and Decorator api + add real JComboBox tag handler (incompatible with JAXX 1.X)
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.swing;
+
+import jaxx.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptor;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXComboBox;
+import jaxx.tags.DefaultComponentHandler;
+import jaxx.types.TypeManager;
+import org.w3c.dom.Element;
+
+import java.awt.event.ItemListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXComboBoxHandler extends DefaultComponentHandler {
+
+ public JAXXComboBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class);
+ addProxyEventInfo("getSelectedItem", ItemListener.class);
+ }
+
+ @Override
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,99 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+<JPanel layout='{new BorderLayout()}'>
+
+ <Object id='data' javaBean='helper.getSelectedBean(this)'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+String getType(Object data) {
+ if (data == null) {
+ return "no type";
+ }
+ if (data instanceof java.util.List<?>) {
+ java.util.List<?> l = (java.util.List<?>) data;
+ if (l.isEmpty()) {
+ return "Empty collection";
+ }
+ return "Collection of " + l.size() + " " + l.get(0).getClass().getSimpleName() + "(s)";
+ }
+ return data.getClass().getSimpleName();
+}
+
+String getContent(Object data) {
+ if (data == null) {
+ return "no content";
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (data instanceof java.util.List) {
+ for (Object o : ((java.util.List)data)) {
+ buffer.append(o).append("\n");
+ }
+ } else {
+ buffer.append(data);
+ }
+ return buffer.toString();
+}
+
+ImageIcon getImage(Object data) {
+ if (data == null) {
+ return null;
+ }
+ if (data instanceof Movie) {
+ return SwingUtil.createIcon(((Movie)data).getImage());
+ }
+ if (data instanceof People) {
+ return SwingUtil.createIcon(((People)data).getImage());
+ }
+ return null;
+}
+ ]]>
+ </script>
+
+ <JSplitPane id='splitPane'
+ orientation='{JSplitPane.VERTICAL_SPLIT}'
+ resizeWeight='0.5'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'>
+ <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}'
+ editable='false'
+ font-size='11'
+ text='{getContent(getData())}'/>
+ </JScrollPane>
+
+ <JScrollPane border='{new TitledBorder("Picture")}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
+ minimumSize='{SwingUtil.newMinDimension()}'>
+
+ <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/>
+
+ </JScrollPane>
+
+ </JSplitPane>
+</JPanel>
\ No newline at end of file
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,82 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'
+ useOnlyVisibleComponentDimension='true'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+helper.createModel(this);
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" };
+}
+
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ navigation.setSelectionInterval(0, 0);
+ splitPane.resetToPreferredSizes();
+ }
+ });
+ // expand the tree
+ SwingUtil.expandTree(navigation);
+ // auto-expand node when selected
+ SwingUtil.addExpandOnClickListener(navigation);
+}
+ ]]>
+ </script>
+
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_NEVER}'>
+
+ <JTree id="navigation"
+ font-size='11'
+ rootVisible='false'
+ showsRootHandles='false'
+ model='{helper.createTreeModel(this)}'
+ selectionModel="{helper.createTreeHandler(this)}"/>
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />-->
+
+ </JScrollPane>
+
+ <JPanel id="content" layout="{contentLayout}" />
+
+ </JSplitPane>
+
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,244 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.tree;
+
+import java.util.Arrays;
+
+import static jaxx.runtime.JAXXContextEntryDef.newListDef;
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.JAXXContext;
+
+
+import javax.swing.JPanel;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.decorator.DecoratorUtils;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.tree.NavigationTreeHandler;
+import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy;
+import jaxx.runtime.swing.tree.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.tree.NavigationTreeHelper;
+import jaxx.runtime.swing.tree.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.tree.NavigationTreeNode;
+import jaxx.runtime.swing.tree.NavigationTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class FullNavigationTreeHelper extends NavigationTreeHelper {
+
+ static {
+ // register decorator one for all
+
+ DecoratorUtils.register(
+ Movie.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - "));
+
+ DecoratorUtils.register(
+ People.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " "));
+ }
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+ /**
+ * where the movies are hold in context
+ */
+ static public final JAXXContextEntryDef<List<Movie>> MOVIES = JAXXContextEntryDef.newListDef("movies");
+ /**
+ * where the actors are hold in context
+ */
+ static public final JAXXContextEntryDef<List<People>> ACTORS = JAXXContextEntryDef.newListDef("actors");
+
+ public FullNavigationTreeHelper() {
+ super("full");
+ }
+
+ /**
+ * Create the model and store it in the given context.
+ *
+ * @param context the context where to hold the model
+ */
+ public void createModel(JAXXContext context) {
+ People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
+ People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
+ People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
+
+ Movie m = new Movie("0", "Nacho libre", 1996, "/jaxx/demo/images/nacho.jpg");
+ m.addActor(a);
+ m.addActor(a2);
+ m.addActor(a3);
+
+ Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m2.addActor(a);
+ m2.addActor(a2);
+
+ MOVIES.setContextValue(context, Arrays.asList(m, m2));
+ ACTORS.setContextValue(context, Arrays.asList(a, a2, a3));
+ }
+
+ @Override
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
+
+ List<Movie> movies = MOVIES.getContextValue(context);
+ List<People> actors = ACTORS.getContextValue(context);
+
+ if (log.isDebugEnabled()) {
+ log.debug("for " + movies.size() + " movie(s)");
+ }
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/", context, BaseContent.class,
+ null);
+
+ Decorator<Movie> mDecorator = DecoratorUtils.get(Movie.class.getSimpleName());
+ Decorator<People> pDecorator = DecoratorUtils.get(People.class.getSimpleName());
+
+ // construction du noeud root
+ // il ne contient pas de context et ne sera pas visible
+ NavigationTreeNode rootNode = builder.buildEmptyRoot(null, "$root");
+
+ // construction du noeud avec les films recupere la liste des films
+ // dans le context avec la clef movies
+ // navigation path = $root/movies
+ NavigationTreeNode moviesNode = builder.build(
+ rootNode,
+ _("movies"),
+ newListDef("movies"),
+ "movies",
+ null,
+ null);
+
+ for (Movie m : movies) {
+
+ // navigation path = $root/movies/m.id
+ NavigationTreeNode movieNode = builder.build(
+ moviesNode,
+ mDecorator,
+ "..[@id=\"" + m.getId() + "\"]",
+ m.getId(),
+ null,
+ null);
+
+ // navigation path = $root/movies/m.id/actors
+ NavigationTreeNode actorsNode = builder.build(
+ movieNode,
+ _("actors"),
+ "../actors",
+ "actors",
+ null,
+ null);
+
+ for (People p : m.getActors()) {
+ // navigation path = $root/movies/m.id/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ }
+
+ // construction du noeud avec les acteurs
+ NavigationTreeNode actorsNode = builder.build(rootNode, _("actors"),
+ newListDef("actors"),
+ "actors", null, null);
+
+ for (People p : actors) {
+ // navigation path = $root/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ NavigationTreeModel model = builder.getModel();
+
+ if (log.isDebugEnabled()) {
+ builder.printModel(model.getRoot());
+ }
+
+ // save tree model in context
+ setTreeModel(context, model);
+ return model;
+ }
+
+ @Override
+ public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("create handler");
+ }
+
+ NavigationTreeHandler handler;
+
+ handler = new NavigationTreeHandlerWithCardLayout(
+ getPrefix(),
+ context,
+ Strategy.PER_NODE) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected NavigationTreeModel getNavigationTreeModel() {
+ return getSafeTreeModel(getContext());
+ }
+
+ @Override
+ protected JPanel getContentContainer() {
+ return getContext().getContent();
+ }
+
+ @Override
+ protected CardLayout2 getContentLayout() {
+ return getContext().getContentLayout();
+ }
+
+ @Override
+ protected void treateError(Exception e) {
+ ErrorDialogUI.showError(e);
+ }
+
+ @Override
+ public FullNavigationTreeDemo getContext() {
+ return (FullNavigationTreeDemo) this.context;
+ }
+ };
+ // on ne peut selectionner qu'un seul noeud a la fois
+ handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+
+ // save handler in ui context
+ setTreeHandler(context, handler);
+ return handler;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,128 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,118 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.tree;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,34 @@
+package jaxx.runtime.decorator;
+
+/**
+ * A simple contract to define a String decorator on any java objet.
+ *
+ * @param <O> the type of data to decorate
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.Decorator})
+ */
+public abstract class Decorator<O> implements java.io.Serializable {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Type of the data to decorate
+ */
+ protected final Class<O> internalClass;
+
+ public Decorator(Class<O> internalClass) throws NullPointerException {
+ if (internalClass == null) {
+ throw new NullPointerException("internalClass can not be null.");
+ }
+ this.internalClass = internalClass;
+ }
+
+ /**
+ * @param bean the bean to decorate
+ * @return the string value of the given bean
+ */
+ public abstract String toString(Object bean);
+
+ public Class<O> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,294 @@
+package jaxx.runtime.decorator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.StringTokenizer;
+import jaxx.runtime.decorator.JXPathDecorator.JXPathComparator;
+import jaxx.runtime.decorator.JXPathDecorator.Context;
+
+/**
+ *
+ * Some usefull methods on {@link Decorator} to create, decorators and obtain decorators.
+ *
+ * To create a new decorator, use one of the methods :
+ * <ul>
+ * <li>{@link #newPropertyDecorator(Class, String)}</li>
+ * <li>{@link #newJXPathDecorator(Class, String)}</li>
+ * <li>{@link #newMultiJXPathDecorator(Class, String, String)})</li>
+ * <li>{@link #newMultiJXPathDecorator(Class, String, String, String)})</li>
+ * </ul>
+ * <p/>
+ *
+ * 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 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)}.
+ * <p/>
+ *
+ * @author tony
+ * @since 1.7.2 (was previously {@code jaxx.runtime.DecoratorUtils})
+ */
+public class DecoratorUtils {
+
+ /**
+ * Registred decorators.
+ */
+ protected static List<DecoratorContext<?>> decorators;
+
+ /**
+ * Factory method to instanciate a new {@link PropertyDecorator} for the
+ * given class {@link O} and a readable property name.
+ *
+ * @param internalClass the class of the objects decorated by the new decorator
+ * @param property the property
+ * @param <O> the generic type of class to be decorated by the new decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if internalClass parameter is null.
+ */
+ public static <O> PropertyDecorator<O> newPropertyDecorator(Class<O> internalClass, String property)
+ throws IllegalArgumentException, NullPointerException {
+ return new PropertyDecorator<O>(internalClass, property);
+ }
+
+ /**
+ * Factory method to instanciate a new {@link JXPathDecorator} for the
+ * given class {@link O} and expression.
+ *
+ * @param internalClass the class of the objects decorated by the new decorator
+ * @param expression the expression to use to decorated objects
+ * @param <O> the generic type of class to be decorated by the new decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if internalClass parameter is null.
+ */
+ public static <O> JXPathDecorator<O> newJXPathDecorator(Class<O> internalClass, String expression)
+ throws IllegalArgumentException, NullPointerException {
+
+ Context<O> context = createJXPathContext(expression);
+ return new JXPathDecorator<O>(internalClass, expression, context);
+ }
+
+ public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass,
+ String expression,
+ String separator)
+ throws IllegalArgumentException, NullPointerException {
+
+ return newMultiJXPathDecorator(internalClass, expression, separator, separator);
+ }
+
+ public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass,
+ String expression,
+ String separator,
+ String separatorReplacement)
+ throws IllegalArgumentException, NullPointerException {
+
+ Context<O>[] contexts = createMultiJXPathContext(expression, separator, separatorReplacement);
+
+ return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts);
+ }
+
+ public static <T> Decorator<T> get(String context) {
+ Decorator<T> result = get(null, context);
+ return result;
+ }
+
+ public static <T> Decorator<T> get(Class<T> type, String context) {
+ DecoratorContext<T> decoratorContext = getDecoratorContext(type, context);
+ Decorator<T> result = decoratorContext == null ? null : decoratorContext.getDecorator();
+ return result;
+ }
+
+ /**
+ * Register a new decorator in the cache.
+ *
+ * @param <T> type of data decorated
+ * @param context the name decorator
+ * @param decorator the decorator to register
+ */
+ public static <T> void register(String context, Decorator<T> decorator) {
+
+ DecoratorContext<T> result = getDecoratorContext(decorator.getInternalClass(), context);
+
+ if (result != null) {
+ throw new IllegalArgumentException("there is an already register decorator " + result);
+ }
+
+ if (decorators == null) {
+ decorators = new java.util.ArrayList<DecoratorContext<?>>();
+ }
+ decorators.add(new DecoratorContext<T>(context, decorator));
+ }
+
+ public static void clear() {
+ if (decorators != null) {
+ decorators.clear();
+ }
+ }
+
+ /**
+ * Sort a list of data based on the first token property of a given context
+ * in a given decorator.
+ *
+ * @param <O> type of data to sort
+ * @param decorator the decorator to use to sort
+ * @param datas the list of data to sort
+ * @param pos the index of context to used in decorator to obtain sorted property.
+ */
+ public static <O> void sort(JXPathDecorator<O> decorator, List<O> datas, int pos) {
+ Comparator<O> c = null;
+ boolean cachedComparator = false;
+ try {
+ c = decorator.getComparator(pos);
+ cachedComparator = c instanceof JXPathComparator<?>;
+
+ if (cachedComparator) {
+ ((JXPathComparator<O>) c).init(decorator, datas);
+ }
+ Collections.sort(datas, c);
+ } finally {
+ if (cachedComparator) {
+ ((JXPathComparator<?>) c).clear();
+ }
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected static <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) {
+ DecoratorContext<T> result = null;
+ if (decorators != null) {
+ for (DecoratorContext<?> d : decorators) {
+ if (type == null) {
+ if (d.accept(context)) {
+ result = (DecoratorContext<T>) d;
+ break;
+ }
+ continue;
+ }
+ if (d.accept(type, context)) {
+ result = (DecoratorContext<T>) d;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static class DecoratorContext<T> {
+
+ final String context;
+ final Decorator<T> decorator;
+
+ public DecoratorContext(String context, Decorator<T> decorator) {
+ this.context = context;
+ this.decorator = decorator;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public Decorator<T> getDecorator() {
+ return decorator;
+ }
+
+ public Class<T> getType() {
+ return decorator.getInternalClass();
+ }
+
+ public boolean accept(Class<?> type, String context) {
+ return getType().isAssignableFrom(type) && accept(context);
+ }
+
+ public boolean accept(String context) {
+ return ((this.context == null && context == null) || (this.context != null && this.context.equals(context)));
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<type: " + getType().getName() + ", context :" + context + ">";
+ }
+ }
+
+ public static <O> Context<O> createJXPathContext(String expression) {
+ List<String> lTokens = new ArrayList<String>();
+ StringBuilder buffer = new StringBuilder();
+ int size = expression.length();
+ int end = -1;
+ int start;
+ while ((start = expression.indexOf("${", end + 1)) > -1) {
+ if (start > end + 1) {
+ // prefix of next jxpath token
+ buffer.append(expression.substring(end + 1, start));
+ }
+ // seek end of jxpath
+ end = expression.indexOf("}", start + 1);
+ if (end == -1) {
+ throw new IllegalArgumentException("could not find the rigth brace starting at car " + start + " : " + expression.substring(start + 2));
+ }
+ String jxpath = expression.substring(start + 2, end);
+ // not allowed ${ inside a jxpath token
+ if (jxpath.indexOf("${") > -1) {
+ throw new IllegalArgumentException("could not find a ${ inside a jxpath expression at car " + (start + 2) + " : " + jxpath);
+ }
+ // save the jxpath token
+ lTokens.add(jxpath);
+ // replace jxpath token in expresion with a string format variable
+ buffer.append("%").append(lTokens.size());
+ }
+ if (size > (end + 1)) {
+ // suffix after end jxpath (or all expression if no jxpath)
+ buffer.append(expression.substring(end + 1));
+ }
+ return new Context<O>(buffer.toString(), lTokens.toArray(new String[lTokens.size()]));
+ }
+
+ public static <O> Context<O>[] createMultiJXPathContext(String expression, String separator, String separatorReplacement) {
+ int sep = expression.indexOf(separator);
+ if (sep == -1) {
+ Context<O>[] result = newInstance(1);
+ result[0] = createJXPathContext(expression);
+ return result;
+ }
+
+ List<String> tokens = new ArrayList<String>();
+ StringTokenizer stk = new StringTokenizer(expression, separator);
+ while (stk.hasMoreTokens()) {
+ tokens.add(stk.nextToken());
+ }
+
+ int nbTokens = tokens.size();
+ Context<O>[] contexts = newInstance(nbTokens);
+ for (int i = 0; i < nbTokens; i++) {
+ StringBuilder buffer = new StringBuilder(expression.length());
+ for (int j = 0; j < nbTokens; j++) {
+ int index = (i + j) % nbTokens;
+ String str = tokens.get(index);
+ //todo replace %index with %j
+ buffer.append(separatorReplacement).append(str);
+ }
+ contexts[i] = createJXPathContext(buffer.substring(separatorReplacement.length()));
+ }
+ return contexts;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static <O> Context<O>[] newInstance(int size) {
+ // fixme how to instanciate a typed array with no checking warning ?
+ return new Context[size];
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,197 @@
+package jaxx.runtime.decorator;
+
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JXPath decorator based on {@link String#format(String, Object[])} method.
+ * <p/>
+ * To use it, give to him a expression where all jxpath to apply on bean are boxed in <code>${}</code>.
+ * <p/>
+ * After the jxpath token you must specifiy the formatter to apply of the jxpath token.
+ * <p/>
+ * For example :
+ * <pre>
+ * Decorator<Object> d = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class,"expr = ${expressions}$s");
+ * assert "expr = %1$s" == d.getExpression();
+ * assert 1 == d.getNbToken();
+ * assert java.util.Arrays.asList("expression") == d.getTokens();
+ * assert "expr = %1$s" == d.toString(d);
+ * </pre>
+ *
+ * @param <O> type of data to decorate
+ * @author chemit
+ * @see Decorator
+ * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecorat})
+ */
+public class JXPathDecorator<O> extends Decorator<O> {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(JXPathDecorator.class);
+ /** the computed context of the decorator */
+ protected Context<O> context;
+ /** nb jxpath tokens to compute */
+ protected int nbToken;
+ /** the initial expression used to compute the decorator context. */
+ protected String initialExpression;
+
+ protected JXPathDecorator(Class<O> internalClass, String expression, Context<O> context) throws IllegalArgumentException, NullPointerException {
+ super(internalClass);
+ this.initialExpression = expression;
+ if (context != null) {
+ setContext(context);
+ }
+ }
+
+ @Override
+ public String toString(Object bean) {
+ if (bean == null) {
+ return null;
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(bean);
+ Object[] args = new Object[nbToken];
+
+ for (int i = 0; i < nbToken; i++) {
+ try {
+ args[i] = getTokenValue(jxcontext, context.tokens[i]);
+ } catch (Exception e) {
+ log.error("can not obtain token " + context.tokens[i] + "on object " + bean + " for reason " + e.getMessage(), e);
+
+ }
+ }
+
+ return String.format(context.expression, args);
+ }
+
+ public String getProperty(int pos) {
+ return getTokens()[pos];
+ }
+
+ public String getExpression() {
+ return context.expression;
+ }
+
+ public String[] getTokens() {
+ return context.tokens;
+ }
+
+ public int getNbToken() {
+ return nbToken;
+ }
+
+ public String getInitialExpression() {
+ return initialExpression;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<" + context + ">";
+ }
+
+ public void setContext(Context<O> context) {
+ this.context = context;
+ this.nbToken = context.tokens.length;
+ // always reset comparator
+ //this.context.comparator = null;
+ if (log.isDebugEnabled()) {
+ log.debug(context);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected Comparator<O> getComparator(int pos) {
+ ensureTokenIndex(this, pos);
+ return context.getComparator(pos);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
+ // assume all values are comparable
+ return (Comparable<Comparable<?>>) jxcontext.getValue(token);
+ }
+
+ public static class JXPathComparator<O> implements Comparator<O> {
+
+ protected Map<O, Comparable<Comparable<?>>> valueCache;
+ private final String expression;
+
+ public JXPathComparator(String expression) {
+ this.expression = expression;
+ this.valueCache = new HashMap<O, Comparable<Comparable<?>>>();
+ }
+
+ @Override
+ public int compare(O o1, O o2) {
+ Comparable<Comparable<?>> c1 = valueCache.get(o1);
+ Comparable<Comparable<?>> c2 = valueCache.get(o2);
+ return c1.compareTo(c2);
+ }
+
+ public void clear() {
+ valueCache.clear();
+ }
+
+ public void init(JXPathDecorator<O> decorator, List<O> datas) {
+ clear();
+ for (O data : datas) {
+ JXPathContext jxcontext = JXPathContext.newContext(data);
+ Comparable<Comparable<?>> key = decorator.getTokenValue(jxcontext, expression);
+ valueCache.put(data, key);
+ }
+ }
+ }
+
+ public static class Context<O> implements java.io.Serializable {
+
+ /**
+ * expression to format using {@link String#format(String, Object[])}, all variables are compute
+ * using using the jxpath tokens.
+ */
+ protected String expression;
+ /** list of jxpath tokens to apply on expression */
+ protected String[] tokens;
+ protected transient Comparator<O> comparator;
+ private static final long serialVersionUID = 1L;
+
+ public Context(String expression, String[] tokens) {
+ this.expression = expression;
+ this.tokens = tokens;
+ }
+
+ public String getFirstProperty() {
+ return tokens[0];
+ }
+
+ public Comparator<O> getComparator(int pos) {
+ if (comparator == null) {
+ comparator = new JXPathComparator<O>(tokens[pos]);
+ }
+ return comparator;
+ }
+
+ public void setComparator(Comparator<O> comparator) {
+ this.comparator = comparator;
+ }
+
+ @Override
+ public String toString() {
+ return "<expression:" + expression + ", tokens:" + Arrays.toString(tokens) + ">";
+ }
+ }
+
+ protected static void ensureTokenIndex(JXPathDecorator<?> decorator, int pos) {
+ if (pos < -1 || pos > decorator.getNbToken()) {
+ throw new ArrayIndexOutOfBoundsException("token index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.nbToken + "]");
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,80 @@
+package jaxx.runtime.decorator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Comparator;
+
+/**
+ * TODO
+ *
+ * @param <O> type of data to decorate
+ * @author chemit
+ * @see Decorator
+ * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecorator})
+ */
+public class MultiJXPathDecorator<O> extends JXPathDecorator<O> {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class);
+ /**
+ * Contexts of the decorator
+ */
+ protected Context<O>[] contexts;
+ /**
+ * context separator
+ */
+ protected String separator;
+ /**
+ * context separator replacement
+ */
+ protected String separatorReplacement;
+
+ protected MultiJXPathDecorator(Class<O> internalClass, String expression,
+ String separator, String separatorReplacement,
+ Context<O>[] contexts) throws IllegalArgumentException, NullPointerException {
+ super(internalClass, expression, null);
+ this.separator = separator;
+ this.separatorReplacement = separatorReplacement;
+ this.contexts = contexts;
+
+ setContextIndex(0);
+
+ if (log.isDebugEnabled()) {
+ log.debug(expression + " --> " + this.context);
+ }
+ }
+
+ public void setContextIndex(int index) {
+ ensureContextIndex(this, index);
+ setContext(contexts[index]);
+ }
+
+ public int getNbContext() {
+ return contexts.length;
+ }
+
+ public String getSeparator() {
+ return separator;
+ }
+
+ public String getSeparatorReplacement() {
+ return separatorReplacement;
+ }
+
+ @Override
+ protected Comparator<O> getComparator(int pos) {
+ ensureContextIndex(this, pos);
+ Context<O> context1 = contexts[pos];
+ return context1.getComparator(0);
+ }
+
+ protected void ensureContextIndex(MultiJXPathDecorator<?> decorator, int pos) {
+ if (pos < -1 || pos > decorator.contexts.length) {
+ throw new ArrayIndexOutOfBoundsException("context index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.contexts.length + "]");
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,76 @@
+package jaxx.runtime.decorator;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+
+/**
+ * Simple property decorator based on {@link String#format(String, Object[])} method.
+ * <p/>
+ * To use it, give him a class and the property name to render.
+ * <p/>
+ * For example :
+ * <pre>
+ * Decorator<Object> d = DecoratorUtils.newPropertyDecorator(PropertyDecorator.class,"expressions");
+ * </pre>
+ *
+ * @param <O> type of data to decorate
+ * @author chemit
+ * @see Decorator
+ * @since 1.7.2 (was previously {@code jaxx.runtime.PropertyDecorator})
+ */
+public class PropertyDecorator<O> extends Decorator<O> {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(PropertyDecorator.class);
+ /**
+ * name of property
+ */
+ protected String property;
+ protected transient Method m;
+
+ @Override
+ public String toString(Object bean) {
+ try {
+ return getM().invoke(bean) + "";
+ } catch (Exception e) {
+ log.error("could not convert for reason : " + e, e);
+ return "";
+ }
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ protected PropertyDecorator(Class<O> internalClass, String property) throws NullPointerException {
+ super(internalClass);
+ if (property == null) {
+ throw new NullPointerException("property can not be null.");
+ }
+ this.property = property;
+ // init method
+ getM();
+ }
+
+ protected Method getM() {
+ if (m == null) {
+ for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(internalClass)) {
+ if (propertyDescriptor.getName().equals(property)) {
+ this.m = propertyDescriptor.getReadMethod();
+ break;
+ }
+ }
+ if (m == null) {
+ throw new IllegalArgumentException("could not find the property " + property + " in " + internalClass);
+ }
+ }
+ return m;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,47 @@
+package jaxx.runtime.decorator.swing;
+
+import jaxx.runtime.decorator.*;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+
+/**
+ * A {@link ListCellRenderer} which compute text with the given {@link #decorator}
+ * and leave the hand to the {@link #delegate} to perform the visual renderer.
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class DecoratorListCellRenderer implements ListCellRenderer {
+
+ /**
+ * Delegate cell renderer
+ */
+ protected ListCellRenderer delegate;
+ /**
+ * Decorator to produce text to render
+ */
+ protected Decorator<?> decorator;
+
+ public DecoratorListCellRenderer(Decorator<?> decorator) {
+ this(new DefaultListCellRenderer(), decorator);
+ }
+
+ public DecoratorListCellRenderer(ListCellRenderer delegate, Decorator<?> decorator) {
+ this.delegate = delegate;
+ this.decorator = decorator;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ if (value != null) {
+ if (value instanceof String) {
+ value = (String) value;
+ } else {
+ value = decorator.toString(value);
+ }
+ }
+ return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,43 @@
+package jaxx.runtime.decorator.swing;
+
+import jaxx.runtime.decorator.*;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * A {@link TableCellRenderer} which compute text with the given {@link #decorator}
+ * and leave the hand to the {@link #delegate} to perform the visual renderer.
+ *
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.swing.DecoratorTableCellRenderer}).
+ */
+public class DecoratorTableCellRenderer implements TableCellRenderer {
+
+ /**
+ * Delegate cell renderer
+ */
+ protected TableCellRenderer delegate;
+ /**
+ * Decorator to produce text to render
+ */
+ protected Decorator<?> decorator;
+
+ public DecoratorTableCellRenderer(Decorator<?> decorator) {
+ this(new DefaultTableCellRenderer(), decorator);
+ }
+
+ public DecoratorTableCellRenderer(TableCellRenderer delegate, Decorator<?> decorator) {
+ this.delegate = delegate;
+ this.decorator = decorator;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ if (value != null) {
+ value = decorator.toString(value);
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,150 @@
+package jaxx.runtime.swing.tree;
+
+import javax.swing.JTree;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+
+/**
+ * To help getting and setting navigation tree objects from a {@link JAXXContext}.
+ * <p/>
+ * There is six types of data which can be hold in a context :
+ * <ul>
+ * <li>tree : the tree </li>
+ * <li>tree model : the navigation tree model</li>
+ * <li>tree handler : the navigation tree handler</li>
+ * <li>selected path : the navigation path of the selected node</li>
+ * <li>selected node : the selected node</li>
+ * <li>selected bean : the selected bean</li>
+ * </ul>
+ *
+ * To make possible the use of more than one navigation tree system in a same
+ * context, we <b>MUST</b> distinguish the context entries definition. For this
+ * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}.
+ * <p/>
+ * Here is the keys mapping :
+ * <ul>
+ * <li>tree : {@code prefix + "-tree"}</li>
+ * <li>tree model : {@code prefix + "-tree-model"}</li>
+ * <li>tree handler : {@code prefix + "-tree-handler"}</li>
+ * <li>selected path : {@code prefix + "-selected-path"}</li>
+ * <li>selected node : {@code prefix + "-selected-node"}</li>
+ * <li>selected bean : {@code prefix + "-selected-bean"}</li>
+ * </ul>
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeContextHelper {
+
+ protected final String prefix;
+ protected JAXXContextEntryDef<String> selectedPathContextEntry;
+ protected JAXXContextEntryDef<Object> selectedBeanContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry;
+ protected JAXXContextEntryDef<JTree> treeContextEntry;
+
+ public NavigationTreeContextHelper(String prefix) {
+ this.prefix = prefix;
+ treeContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree", JTree.class);
+ treeModelContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-model", NavigationTreeModel.class);
+ treeHandlerContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-handler", NavigationTreeHandler.class);
+ selectedBeanContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-bean", Object.class);
+ selectedNodeContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-node", NavigationTreeNode.class);
+ selectedPathContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-path", String.class);
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public JTree getTree(JAXXContext context) {
+ JTree r = getTreeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeModel getTreeModel(JAXXContext context) {
+ NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeHandler getTreeHandler(JAXXContext context) {
+ NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public String getSelectedPath(JAXXContext context) {
+ String r = getSelectedPathContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeNode getSelectedNode(JAXXContext context) {
+ NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public Object getSelectedBean(JAXXContext context) {
+ Object r = getSelectedBeanContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public void setTreeModel(JAXXContext context, NavigationTreeModel model) {
+ getTreeModelContextEntry().setContextValue(context, model);
+ }
+
+ public void setTree(JAXXContext context, JTree tree) {
+ getTreeContextEntry().setContextValue(context, tree);
+ }
+
+ public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) {
+ getTreeHandlerContextEntry().setContextValue(context, handler);
+ }
+
+ public void setSelectedPath(JAXXContext context, String path) {
+ if (path == null) {
+ getSelectedPathContextEntry().removeContextValue(context);
+ } else {
+ getSelectedPathContextEntry().setContextValue(context, path);
+ }
+ }
+
+ public void setSelectedNode(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ getSelectedNodeContextEntry().removeContextValue(context);
+ } else {
+ getSelectedNodeContextEntry().setContextValue(context, node);
+ }
+ }
+
+ public void setSelectedBean(JAXXContext context, Object bean) {
+ if (bean == null) {
+ getSelectedBeanContextEntry().removeContextValue(context);
+ } else {
+ getSelectedBeanContextEntry().setContextValue(context, bean);
+ }
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() {
+ return treeModelContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() {
+ return treeHandlerContextEntry;
+ }
+
+ protected JAXXContextEntryDef<Object> getSelectedBeanContextEntry() {
+ return selectedBeanContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() {
+ return selectedNodeContextEntry;
+ }
+
+ protected JAXXContextEntryDef<String> getSelectedPathContextEntry() {
+ return selectedPathContextEntry;
+ }
+
+ protected JAXXContextEntryDef<JTree> getTreeContextEntry() {
+ return treeContextEntry;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,275 @@
+package jaxx.runtime.swing.tree;
+
+import java.awt.Component;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The handler of a navigation tree.
+ *
+ * This is also the selection model to use, since we must check before moving
+ * from a node we can not just listen selection model changed, we must control
+ * it.
+ *
+ * @author tony
+ * @since 1.7.2
+ */
+public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandler.class);
+
+ /**
+ * Strategy of instanciation of ui.
+ * <p/>
+ * For a given {@code node}, the method {@link #getId(NavigationTreeNode)}
+ * returns the id of ui to use.
+ */
+ public enum Strategy {
+
+ /**
+ * instanciate a ui for a node
+ */
+ PER_NODE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getFullPath();
+ }
+ },
+ /**
+ * instanciate only one a ui for a type,nodes will share the instanciation
+ */
+ PER_UI_TYPE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getUIClass().getName();
+ }
+ };
+
+ public abstract String getId(NavigationTreeNode node);
+ }
+ /**
+ * UI which contains navigation tree
+ */
+ protected JAXXContext context;
+ /**
+ * UI Instanciation strategy
+ */
+ protected Strategy strategy;
+ /**
+ * JAXXContext access helper.
+ *
+ * @since 1.7.2
+ */
+ protected NavigationTreeContextHelper contextHelper;
+
+ protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
+ this.contextHelper = new NavigationTreeContextHelper(contextPrefix);
+ this.context = context;
+ this.strategy = strategy;
+ addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
+ // do not treate this if no path changed
+ return;
+ }
+ NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+ selectNodeUI(node);
+ }
+ });
+ }
+
+ /**
+ * @return le modèle de navigation associé
+ */
+ protected abstract NavigationTreeModel getNavigationTreeModel();
+
+ /**
+ * @return le composent actuellement visible associé au noeud courant ou
+ * au noeud précédent lors d'un changement de noeud.
+ */
+ protected abstract Component getCurrentUI();
+
+ /**
+ * @param node le noeud associé à l'ui à retrouver
+ * @return l'ui associé au novueau noeud sélectionné
+ */
+ protected abstract Component getUI(NavigationTreeNode node);
+
+ /**
+ * @param component le composent actuellement visible
+ * @return <code>true</code> si le composent a bien été fermé, <code>false</code> sinon
+ * @throws Exception if any
+ */
+ protected abstract boolean closeUI(Component component) throws Exception;
+
+ /**
+ * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return la nouvelle ui associée au noeud
+ * @throws Exception if any
+ */
+ protected abstract Component createUI(NavigationTreeNode node) throws Exception;
+
+ /**
+ * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
+ *
+ * @param newUI l'ui associé au noeud sélectionné à ouvrir
+ * @param node le node de l'ui a ouvrir
+ * @throws Exception if any
+ */
+ protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception;
+
+ /**
+ * Traitement des exceptions.
+ *
+ * @param e l'erreur recontrée (ou null si pas d"erreur)
+ */
+ protected abstract void treateError(Exception e);
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ public NavigationTreeContextHelper getContextHelper() {
+ return contextHelper;
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ if (path.equals(getSelectionPath())) {
+ // stay on same node, can skip
+ if (log.isDebugEnabled()) {
+ log.debug("skip stay on path " + path);
+ }
+ return;
+ }
+ Component component = getCurrentUI();
+
+ try {
+ if (!closeUI(component)) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing node canceled!");
+ }
+ // can not changed current node
+ return;
+ }
+ } catch (Exception ex) {
+ treateError(ex);
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will select path " + path);
+ }
+ // ok can safely select the new path
+ super.setSelectionPath(path);
+ }
+
+ protected void selectNodeUI(NavigationTreeNode node) {
+
+ try {
+
+ String path = node.getFullPath();
+
+ if (log.isTraceEnabled()) {
+ log.trace(path);
+ }
+
+ Component newUI = getUI(node);
+
+ // now, we are free to open the ui associated with the selected node in navigation
+
+ // get the bean associated with the node
+ Object data = getNavigationTreeModel().getBean(path);
+
+ // save it in context (must be done before init ui)
+ addSelectedBeanInContext(node, data);
+
+ if (newUI == null) {
+
+ // a new ui instance is required
+ newUI = createUI(node);
+ }
+
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // save in context current node context path
+ helper.setSelectedPath(ctxt, node.getFullPath());
+
+ // save in context current node
+ helper.setSelectedNode(ctxt, node);
+
+ // really open the ui associated with the selected node
+ openUI(newUI, node);
+
+ } catch (Exception e) {
+ // remove data from context
+
+ // if any error, go back to previvous node
+ treateError(e);
+ }
+ }
+
+ /**
+ * Prepare le context a utiliser pour initialiser une nouvelle ui.
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return le context à utiliser pour instancier l'ui
+ * @throws Exception if any
+ */
+ protected JAXXContext createUIContext(NavigationTreeNode node) throws Exception {
+
+ if (node.getUIHandlerClass() == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("no action associated with ui " + node.getUIClass());
+ }
+ // no action associated, just
+ return getContext();
+ }
+
+ JAXXAction action = node.getUIHandlerClass().newInstance();
+
+ // init context with
+ JAXXInitialContext uiContext = action.init(getContext());
+ return uiContext;
+ }
+
+ protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass()));
+ }
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // remove previous selected bean
+ //TODO-TC-20091004 should have an automatic clean context method while
+ // quiting a node ?
+ helper.setSelectedBean(ctxt, null);
+
+ if (data != null) {
+
+ helper.setSelectedBean(ctxt, data);
+ //FIXME-TC-20091004 : should really remove this, this is not context safe
+ //todo should we not use this to avoid conflict in context ?
+ //context.setContextValue(data);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,100 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JPanel;
+import java.awt.Component;
+
+/**
+ * Simple {@link NavigationTreeHandler} implementation with a {@link CardLayout2} to manage components to
+ * associated with tree's nodes.
+ * <p/>
+ * For each node, the ui associated has a constraints in a cardlayout which is the node context path.
+ * <p/>
+ * A single container managed by the cardlayout is used to display the components associated with tree's nodes.
+ *
+ * @author chemit
+ */
+public abstract class NavigationTreeHandlerWithCardLayout extends NavigationTreeHandler {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class);
+
+ /**
+ * All components associated with a tree's node is displayed in a single container.
+ *
+ * @return the containter of components
+ */
+ protected abstract JPanel getContentContainer();
+
+ /**
+ * the cardlayout managing components associated with tree node. The constraints
+ * of each component is the node contextPath.
+ *
+ * @return the layout used to display components associated with tree's nodes.
+ */
+ protected abstract CardLayout2 getContentLayout();
+
+ public NavigationTreeHandlerWithCardLayout(String contextPrefix, JAXXObject context, Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ if (getContentContainer() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context);
+ }
+ if (getContentLayout() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context);
+ }
+ }
+
+ @Override
+ protected Component getCurrentUI() {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ return layout.getVisibleComponent(container);
+ }
+
+ @Override
+ protected Component getUI(NavigationTreeNode node) {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ String constraints = strategy.getId(node);
+ return layout.contains(constraints) ? layout.getComponent(container, constraints) : null;
+ }
+
+ @Override
+ protected void openUI(Component newUI, NavigationTreeNode node) throws Exception {
+
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ // switch layout
+ String constraints = strategy.getId(node);
+ layout.show(container, constraints);
+ }
+
+ @Override
+ protected boolean closeUI(Component component) throws Exception {
+ // by default, we says that component was succesfull closed
+ return true;
+ }
+
+ @Override
+ protected Component createUI(NavigationTreeNode node) throws Exception {
+
+ JAXXContext uiContext = createUIContext(node);
+
+ JAXXObject newUI = node.getUIClass().getConstructor(JAXXContext.class).newInstance(uiContext);
+
+ if (log.isDebugEnabled()) {
+ log.debug("instanciate new ui " + newUI);
+ }
+ String constraints = strategy.getId(node);
+ getContentContainer().add((Component) newUI, constraints);
+ return (Component) newUI;
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,141 @@
+package jaxx.runtime.swing.tree;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Pattern;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Helper object associated to a given navigation tree system.
+ *
+ * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
+ *
+ * @author chemit
+ * @since 1.7.2
+ * @see NavigationTreeModel
+ */
+public abstract class NavigationTreeHelper extends NavigationTreeContextHelper {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHelper.class);
+
+ /**
+ * Create the tree model.
+ *
+ * @param context the context to associate with fresh model
+ * @return the new model build with data from the given context
+ */
+ public abstract NavigationTreeModel createTreeModel(JAXXContext context);
+
+ /**
+ * Create the tree handler.
+ *
+ * @param context the context to associate with fresh handler
+ * @return the new handler
+ */
+ public abstract NavigationTreeHandler createTreeHandler(JAXXObject context);
+
+ public NavigationTreeHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+
+ public Object getContextValue(JAXXContext context, String path) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.getBean(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation à partir de son path.
+ *
+ * @param context le contexte applicatif
+ * @param path le path absolue du noeud dans l'arbre
+ */
+ public void selectNode(JAXXContext context, String path) {
+ NavigationTreeNode node = findNode(context, path);
+ if (log.isDebugEnabled()) {
+ log.debug(path + " :: " + node);
+ }
+ if (node != null) {
+ selectNode(context, node);
+ }
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation.
+ *
+ * @param context le contexte applicatif
+ * @param node le noeud à sélectionner dans l'arbre
+ */
+ public void selectNode(JAXXContext context, NavigationTreeNode node) {
+
+
+ NavigationTreeModel navigationModel = getSafeTreeModel(context);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ TreePath path = new TreePath(navigationModel.getPathToRoot(node));
+ JTree tree = getSafeTree(context);
+ tree.setSelectionPath(path);
+ tree.scrollPathToVisible(path);
+ }
+
+ public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException {
+ NavigationTreeModel treeModel = getTreeModel(context);
+ if (treeModel == null) {
+ throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context);
+ }
+ return treeModel;
+ }
+
+ public JTree getSafeTree(JAXXContext context) throws NullPointerException {
+ JTree tree = getTree(context);
+ if (tree == null) {
+ throw new NullPointerException("could not find tree with key " + getTreeContextEntry() + " in context " + context);
+ }
+ return tree;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,246 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Model of the tree used for a navigation tree.
+ * <p/>
+ * Il est composé de {@link NavigationTreeNode}
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeModel extends DefaultTreeModel {
+
+ static private final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see NavigationTreeNode#getNodePath()
+ * @see NavigationTreeNode#getFullPath()
+ */
+ protected final String pathSeparator;
+ /**
+ * Context to retrieve beans
+ */
+ private JAXXContext context;
+
+ public NavigationTreeModel(String pathSeparator, JAXXContext context) {
+ super(null);
+ this.pathSeparator = pathSeparator;
+ this.context = context;
+ }
+
+ @Override
+ public NavigationTreeNode getRoot() {
+ return (NavigationTreeNode) super.getRoot();
+ }
+
+ /**
+ * Search from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the root node, or <code>null</code> if not find.
+ */
+ public NavigationTreeNode findNode(String path) {
+ return findNode(getRoot(), path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, String regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, Pattern regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Search from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
+ return findNode(root, path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes)
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
+ return findNode(root, path, regex == null ? null : Pattern.compile(regex));
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
+ if (regex != null) {
+ Matcher matcher = regex.matcher(path);
+ if (!matcher.matches() || matcher.groupCount() < 1) {
+ log.warn("no matching regex " + regex + " to " + path);
+ return null;
+ }
+ path = matcher.group(1);
+ if (log.isDebugEnabled()) {
+ log.debug("matching regex " + regex + " : " + path);
+ }
+ }
+ StringTokenizer stk = new StringTokenizer(path, pathSeparator);
+ NavigationTreeNode result = root;
+ // pas the first token (matches the root node)
+ if (root.isRoot() && stk.hasMoreTokens()) {
+ String rootPath = stk.nextToken();
+ if (!rootPath.equals(root.getNodePath())) {
+ return null;
+ }
+ }
+ while (stk.hasMoreTokens()) {
+ result = result.getChild(stk.nextToken());
+ }
+ return result;
+ }
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node from given navigation path.
+ *
+ * @param navigationPath the current context path of the node
+ * @return the value associated in context with the given navigation path
+ */
+ public Object getBean(String navigationPath) {
+ Object result;
+ NavigationTreeNode node = findNode(navigationPath, (Pattern) null);
+ result = getBean(node);
+ return result;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param node the current node
+ * @return the value associated in context with the given node.
+ */
+ public Object getBean(NavigationTreeNode node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getBean(getContext());
+ }
+
+ @Override
+ public void nodeChanged(TreeNode node) {
+ nodeChanged(node, false);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ @Override
+ public void nodeStructureChanged(TreeNode node) {
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep reload
+ reload(n, true);
+ super.nodeStructureChanged(node);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ public void nodeChanged(TreeNode node, boolean deep) {
+
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
+ reload(n, deep);
+ super.nodeChanged(node);
+ }
+
+ protected void reload(NavigationTreeNode node) {
+ reload(node, false);
+ }
+
+ protected void reload(NavigationTreeNode node, boolean deep) {
+ if (node == null) {
+ return;
+ }
+ node.reload(getContext());
+
+ if (deep) {
+ Enumeration<?> childs = node.children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode o = (NavigationTreeNode) childs.nextElement();
+ reload(o, true);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,242 @@
+package jaxx.runtime.swing.tree;
+
+import java.util.Enumeration;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.decorator.Decorator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This object is design to build a {@link NavigationTreeModel}.
+ *
+ * @author chemit
+ * @since 17.2
+ */
+public class NavigationTreeModelBuilder {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModelBuilder.class);
+ /**
+ * The model dealed by the builder.
+ *
+ * <b>Note:</b> It is a good idea to keep only one instance of the model.
+ * If reset is required, should empty the model but not reinstanciate it.
+ */
+ protected NavigationTreeModel model;
+ /**
+ * default ui class to use if node does not define an ui class
+ */
+ protected Class<? extends JAXXObject> defaultUIClass;
+ /**
+ * [optional] default action class
+ */
+ protected Class<? extends JAXXAction> defaultUIHandlerClass;
+
+ public NavigationTreeModelBuilder(String pathSeparator, JAXXContext context, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass) {
+ this(defaultUIClass, defaultUIHandlerClass, new NavigationTreeModel(pathSeparator, context));
+ }
+
+ public NavigationTreeModelBuilder(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, NavigationTreeModel model) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ }
+
+ public NavigationTreeModel getModel() {
+ return model;
+ }
+
+ public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, null);
+ addI18nNodeRenderer(node, "");
+ return addChildNode(null, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, null, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
+
+ if (node.getUIClass() == null) {
+ // no ui is associated with this node, use the default one
+ node.setUIClass(defaultUIClass);
+ }
+
+ if (node.getUIHandlerClass() == null) {
+ // no ui handler associated with this node, use the default one
+ node.setUIHandlerClass(defaultUIHandlerClass);
+ }
+ if (parentNode == null) {
+ model.setRoot(node);
+ } else {
+ parentNode.add(node);
+ }
+ model.nodeStructureChanged(parentNode);
+ return node;
+ }
+
+ public NavigationTreeNode removeChildNode(NavigationTreeNode node) {
+ NavigationTreeNode parentNode = node.getParent();
+ model.removeNodeFromParent(node);
+ return parentNode;
+ }
+
+ public void addI18nNodeRenderer(NavigationTreeNode node, String libelle) {
+ node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle));
+ }
+
+ public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator) {
+ node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator));
+ }
+
+ public void addNodeJaxxClasses(
+ NavigationTreeNode node,
+ Class<? extends JAXXObject> uIClass,
+ Class<? extends JAXXAction> uIHandlerClass) {
+ node.setUIClass(uIClass);
+ node.setUIHandlerClass(uIHandlerClass);
+ }
+
+ public void printModel(NavigationTreeNode node) {
+ if (node == null) {
+ return;
+ }
+ log.info("node " + node.getFullPath() + ", jxpath: " + node.getJaxxContextEntryPath() + ", entryContextDef: " + node.getJaxxContextEntryDef());
+ if (log.isDebugEnabled()) {
+ log.debug("node userObject" + node.getUserObject());
+ log.debug("value from node " + node.getBean(getModel().getContext()));
+ log.debug("value from model " + getModel().getBean(node));
+ }
+ Enumeration<?> children = node.children();
+ while (children.hasMoreElements()) {
+ printModel((NavigationTreeNode) children.nextElement());
+ }
+ }
+
+ public static abstract class ChildBuilder<O> {
+
+ protected NavigationTreeModelBuilder builder;
+
+ protected ChildBuilder(NavigationTreeModelBuilder builder) {
+ this.builder = builder;
+ }
+
+ protected abstract void init(Class<? extends O> klass);
+
+ protected abstract Decorator<? extends O> getDecorator(O child);
+
+ protected abstract String getJXPath(O child);
+
+ protected abstract String getNavigationPath(O child);
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, java.util.Collection<? extends O> beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.isEmpty()) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, O[] beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.length == 0) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,424 @@
+package jaxx.runtime.swing.tree;
+
+import java.util.Enumeration;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Node of the {@link NavigationTreeModel}.
+ *
+ * Each node is associated with :
+ * <ul>
+ * <li> a {@code bean} coming from a {@link JAXXContext} </li>
+ * <li> a {@code uiClass} to build the associated ui </li>
+ * </ul>
+ * <p/>
+ * To retrieve the bean from the context, there is a huge logic in the
+ * method {@link #getBean(JAXXContext)}.
+ *
+ * In few words, if the {@link #jaxxContextEntryDef} is defined, it means
+ * that the object is taken from the {@code context}.
+ * <p/>
+ * Otherwise, find the first ancestor with an context entry and retrieve from
+ * here the bean.
+ * <p/>
+ * Then go down to the initial node by applying the jxpath expressions
+ * {@link #jaxxContextEntryPath} of each node on road back.
+ * <p/>
+ *
+ * To identify easly a node, each node has a {@link #path} and a
+ * {@link #fullPath} (full path from root node).
+ * <p/>
+ *
+ * To display the node we use a {@link NavigationTreeNodeRenderer} which is in
+ * fact the {@link #userObject}, the object can be synch with the bean via the
+ * {@link NavigationTreeNodeRenderer#reload(java.lang.Object)} method.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @see NavigationTreeNodeRenderer
+ * @since 1.7.2
+ */
+public class NavigationTreeNode extends DefaultMutableTreeNode {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeNode.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see #path
+ * @see #fullPath
+ */
+ protected final String pathSeparator;
+ /**
+ * The node path.
+ * <p/>
+ * Used to build the {@link #fullPath} which gives a unique identifier of the
+ * node.
+ * @see #pathSeparator
+ * @see #fullPath
+ */
+ protected String path;
+ /**
+ * The full path for the node from the rood node.
+ * <p/>
+ * This path is build by appending nodes {@link #path} from the root node
+ * to this node, between each path we introduce the {@link #pathSeparator}.
+ * <p>
+ * Exemple :
+ * <pre>
+ * root
+ * $root
+ * `-- child1
+ * `-- child2
+ * </pre>
+ * will given {@code $root/child1/child2}.
+ * @see #pathSeparator
+ * @see #path
+ */
+ protected String fullPath;
+ /**
+ * The UI class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIClass} will be used while
+ * building the model.
+ */
+ protected Class<? extends JAXXObject> uIClass;
+ /**
+ * The UI handler class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIHandlerClass} will be used
+ * while building the model.
+ */
+ protected Class<? extends JAXXAction> uIHandlerClass;
+ /**
+ * The context entry definition to retrieve the bean.
+ *
+ * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
+ * node.
+ */
+ protected JAXXContextEntryDef<?> jaxxContextEntryDef;
+ /**
+ * The jxPath to process to obtain real {@code bean} from the data retrieve
+ * in the context.
+ *
+ * <b>Note:</b> If not set -no jxpath will be apply on the bean from context.
+ */
+ protected String jaxxContextEntryPath;
+ /**
+ * The bean associated with the node ( the value can be obtain via the
+ * method {@link #getBean(JAXXContext)} or directly set via method
+ * {@link #setBean(Object)}.
+ * <p/>
+ * cache of bean associated with bean to improve performance
+ */
+ protected transient Object bean;
+ /**
+ * The type of the related bean associated with the node.
+ * <p/>
+ * Note: This type is here to override the NodeRenderer internalClass, since
+ * we could need to override this data.
+ * <p/>
+ * If this property is let to null, then we will use the NodeRenderer one
+ */
+ protected Class<?> internalClass;
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
+ this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef);
+ } else if (jaxxContextEntryDef instanceof String) {
+ this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
+ } else if (jaxxContextEntryDef != null) {
+ // wrong context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
+ }
+ }
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ /**
+ *
+ * @return the text node renderer (store in {@link #userObject} property.
+ */
+ public NavigationTreeNodeRenderer getRenderer() {
+ NavigationTreeNodeRenderer render = null;
+ Object o = getUserObject();
+ if (o != null && o instanceof NavigationTreeNodeRenderer) {
+ render = (NavigationTreeNodeRenderer) o;
+ }
+ return render;
+ }
+
+ public void setRenderer(NavigationTreeNodeRenderer renderer) {
+ // clear all cache
+ bean = null;
+ setUserObject(renderer);
+ }
+
+ public String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ public String getNodePath() {
+ return path;
+ }
+
+ public void setNodePath(String navigationPath) {
+ this.path = navigationPath;
+ }
+
+ public Class<? extends JAXXObject> getUIClass() {
+ return uIClass;
+ }
+
+ public void setUIClass(Class<? extends JAXXObject> uIClass) {
+ this.uIClass = uIClass;
+ }
+
+ public void setInternalClass(Class<?> internalClass) {
+ this.internalClass = internalClass;
+ }
+
+ public Class<? extends JAXXAction> getUIHandlerClass() {
+ return uIHandlerClass;
+ }
+
+ public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
+ this.uIHandlerClass = uIHandlerClass;
+ }
+
+ public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
+ return jaxxContextEntryDef;
+ }
+
+ public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }
+
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ public Class<?> getInternalClass() {
+ if (internalClass == null && getRenderer() != null) {
+ return getRenderer().getInternalClass();
+ }
+ return internalClass;
+ }
+
+ /** @return the fully context path of the node from the root node to this. */
+ public String getFullPath() {
+ if (fullPath == null) {
+ StringBuilder sb = new StringBuilder();
+ for (TreeNode treeNode : getPath()) {
+ NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
+ sb.append(pathSeparator).append(myNode.getNodePath());
+ }
+ fullPath = sb.substring(1);
+ }
+ return fullPath;
+ }
+
+ @Override
+ public NavigationTreeNode getChildAt(int index) {
+ return (NavigationTreeNode) super.getChildAt(index);
+ }
+
+ @Override
+ public NavigationTreeNode getParent() {
+ return (NavigationTreeNode) super.getParent();
+ }
+
+ /**
+ * @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.
+ */
+ public NavigationTreeNode getChild(String path) {
+ Enumeration<?> childs = children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode son = (NavigationTreeNode) childs.nextElement();
+ if (path.equals(son.getNodePath())) {
+ return son;
+ }
+ }
+ return null;
+ }
+
+ public Object getBean() {
+ return bean;
+ }
+
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ public void reload(JAXXContext context) {
+
+ // clear bean cache
+ bean = null;
+
+ // clear context navigation cache
+ fullPath = null;
+
+ NavigationTreeNodeRenderer renderer = getRenderer();
+ if (renderer == null) {
+ // this can't be !
+ throw new NullPointerException("could not find the renderer for node " + this);
+ }
+
+ Object b = getBean(context);
+
+ renderer.reload(b);
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context to seek
+ * @return the value associated in context with the given context path
+ */
+ public Object getBean(JAXXContext context) {
+ if (bean != null) {
+ // use cached bean
+ return bean;
+ }
+ Object result;
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
+ // the node maps directly a value in context, with no jxpath resolving
+ result = getJaxxContextEntryDef().getContextValue(context);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+ // find the first ancestor node with a context def
+ NavigationTreeNode parentNode = getFirstAncestorWithDef();
+ if (parentNode == null) {
+ log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")");
+ // todo must be an error
+ // no parent found
+ return null;
+ }
+ Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("could not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+ // save in cache
+ parentNode.setBean(parentBean);
+ if (this == parentNode) {
+ // current node is the node matching the context entry value and no jxpath is found
+ return parentBean;
+ }
+ if (jaxxContextEntryPath == null) {
+ // todo must be an error
+ log.warn("must find a jaxxContextEntryPath on node (" + this + ")");
+ return null;
+ }
+ String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode);
+ if (jxpathExpression == null) {
+ /// todo must be an error
+ log.warn("could not build jxpath from node " + parentNode + " to " + this);
+ // could not retreave the jxpath...
+ return null;
+ }
+ if (jxpathExpression.startsWith("[")) {
+ // special case when we want to access a collection
+ jxpathExpression = '.' + jxpathExpression;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ result = jxcontext.getValue(jxpathExpression);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ // find a node with a direct link with the context
+ return this;
+ }
+ // the node is not linked to context
+ // seek in his parent
+ NavigationTreeNode ancestor = getParent();
+ return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
+ }
+
+ protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
+ if (parentNode == this) {
+ // reach the parent limit node, return the expr computed
+ return expr;
+ }
+ int firstIndex = expr.indexOf("..");
+ int lastIndex = expr.lastIndexOf("..");
+ if (firstIndex == -1) {
+ // this is a error, since current node is not parent limit node,
+ // we must find somewhere a way to go up in nodes
+ throw new IllegalArgumentException(expr + " should contains at least one \"..\"");
+ }
+ if (firstIndex != 0) {
+ // this is a error, the ../ must be at the beginning of the expression
+ throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr);
+ }
+ NavigationTreeNode ancestor = getParent();
+ if (firstIndex == lastIndex) {
+ // found only one go up, so must be substitute by the parent node context
+ String newExpr = expr.substring(2);
+ //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2);
+ if (getParent().equals(parentNode)) {
+ // parent node is the final parent node, so no substitution needed
+ return newExpr;
+ }
+ // ancestor must have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath == null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not ");
+ }
+ newExpr = ancestor.jaxxContextEntryPath + newExpr;
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+ // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath != null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition");
+ }
+ // substitute the last ..[/] and delegate to ancestor
+ String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2));
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,44 @@
+package jaxx.runtime.swing.tree;
+
+import javax.swing.tree.TreeCellRenderer;
+
+/**
+ * Text Renderer of a {@link NavigationTreeNode}.
+ * <p/>
+ * This object will be placed as the {@link NavigationTreeNode#userObject} of
+ * nodes.
+ * <p/>
+ *
+ * In that way, we can use the {@link #toString()} value to render the node
+ * without writing any {@link TreeCellRenderer}.
+ * <p/>
+ * To rebuild the renderer text of a node use the method {@link #reload(Object)}
+ * with the {@code bean} provides by the model for the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public interface NavigationTreeNodeRenderer extends java.io.Serializable {
+
+ /**
+ *
+ * @return the render value of the node
+ */
+ @Override
+ String toString();
+
+ /**
+ *
+ * Can override the the node internal class for display purpose.
+ *
+ * @return the type of data to be displayed.
+ */
+ Class<?> getInternalClass();
+
+ /**
+ * Reload the render value from the {@code bean} of node.
+ *
+ * @param bean the bean associated to the node to render
+ */
+ void reload(Object bean);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,53 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.decorator.Decorator;
+
+/**
+ * Decorator Renderer of a {@link NavigationTreeNode}.
+ *
+ * Apply a {@link Decorator} to the {@code bean} associated to the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Decorator
+ */
+ protected final Decorator<?> decorator;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) {
+ this.internalClass = decorator.getInternalClass();
+ this.decorator = decorator;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object bean) {
+ try {
+ text = decorator.toString(bean);
+
+ } catch (Exception e) {
+ text = "";
+ }
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,48 @@
+package jaxx.runtime.swing.tree;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * I18n label Renderer of a {@link NavigationTreeNode}.
+ *
+ * Just apply a i18n translation on the given {@link #libelle}.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Static i18n label to render
+ */
+ protected final String libelle;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererI18nImpl(String libelle) {
+ this.libelle = libelle;
+ this.internalClass = String.class;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object data) {
+ text = _(libelle);
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h1>JAXX - tree utilities</h1>
+
+ This package contains all the classes of the navigation tree framework.
+
+ <p>
+ Replace the previous framework from package
+ <code>jaxx.runtime.swing.navigation</code>
+ </p>
+ </body>
+</html>
\ No newline at end of file
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,37 @@
+package jaxx.runtime.decorator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Data {
+
+ int pos;
+ String name;
+
+ protected static List<Data> generate(int nb) {
+ List<Data> datas = new ArrayList<Data>(nb);
+ for (int i = 0; i < nb; i++) {
+ datas.add(new Data(i, "name_" + (nb - i)));
+ }
+ return datas;
+ }
+
+ Data(int pos, String name) {
+ super();
+ this.pos = pos;
+ this.name = name;
+ }
+
+ public int getPos() {
+ return pos;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return "Data{pos=" + pos + ", name=\'" + name + '\'' + '}';
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,136 @@
+package jaxx.runtime.decorator;
+
+import jaxx.runtime.decorator.JXPathDecorator.Context;
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecoratorTest}).
+ */
+public class JXPathDecoratorTest {
+
+
+ protected JXPathDecorator<?> decorator;
+ protected String expected;
+ protected String result;
+
+ @After
+ public void after() {
+ decorator = null;
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullInternalClass() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(null, "hello");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace2() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha${hum}");
+ }
+
+ @Test
+ public void testNullBean() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "hello");
+ expected = "hello";
+ assertEquals(expected, decorator.getExpression());
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.getTokens().length);
+
+ result = decorator.toString(null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testNoJXPath() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "hello");
+ expected = "hello";
+ assertEquals(expected, decorator.getExpression());
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.getTokens().length);
+
+ result = decorator.toString(this);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testDecorator() throws Exception {
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
+ assertEquals("%1$s - %2$d", decorator.getExpression());
+ assertDecoratorInternal();
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}${nbToken}");
+ assertEquals("%1%2", decorator.getExpression());
+ assertDecoratorInternal();
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after");
+ assertEquals("before %1$s - %2$d after", decorator.getExpression());
+ assertDecoratorInternal();
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter");
+ assertEquals("before%1$s-%2$dafter", decorator.getExpression());
+ assertDecoratorInternal();
+ }
+
+ @Test
+ public void testSort() throws Exception {
+
+ List<Data> datas = Data.generate(10);
+
+ JXPathDecorator<Data> d = DecoratorUtils.newJXPathDecorator(Data.class, "${pos}$d ${name}$s");
+
+ List<Data> sortData = new ArrayList<Data>(datas);
+ DecoratorUtils.sort(d, sortData, 0);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ Collections.sort(datas, new Comparator<Data>() {
+ @Override
+ public int compare(Data o1, Data o2) {
+ return o1.name.compareTo(o2.name);
+ }
+ });
+ Context<Data> context = d.context;
+ context.setComparator(null);
+ DecoratorUtils.sort(d, sortData, 1);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ }
+
+
+ public void assertDecoratorInternal(String... tokens) {
+ assertTokens(tokens);
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ private void assertTokens(String... tokens) {
+ if (tokens.length == 0) {
+ tokens = new String[]{"expression", "nbToken"};
+ }
+ assertEquals(2, decorator.nbToken);
+ assertEquals(2, decorator.getTokens().length);
+ assertEquals(tokens[0], decorator.getTokens()[0]);
+ assertEquals(tokens[1], decorator.getTokens()[1]);
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,185 @@
+package jaxx.runtime.decorator;
+
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecoratorTest}).
+ */
+public class MultiJXPathDecoratorTest {
+
+ protected MultiJXPathDecorator<?> decorator;
+ protected String expected;
+ protected String result;
+
+ @After
+ public void after() {
+ decorator = null;
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullInternalClass() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(null, "hello", "#");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha", "#");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace2() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha${hum}", "#");
+ }
+
+ @Test
+ public void testNullBean() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "hello", "");
+ expected = "hello";
+ assertEquals(expected, decorator.getExpression());
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.getTokens().length);
+
+ result = decorator.toString(null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testMultiDecorator() throws Exception {
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - ");
+ assertEquals("%1$s - %2$d", decorator.getExpression());
+ assertDecoratorInternal();
+ assertEquals(2, decorator.contexts.length);
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s", decorator.getExpression());
+ assertTokens("nbToken", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - ");
+ assertEquals("%1$s - %2$d", decorator.getExpression());
+ assertDecoratorInternal();
+ assertEquals(2, decorator.contexts.length);
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s", decorator.getExpression());
+ assertTokens("nbToken", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testMultiDecorator2() throws Exception {
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - ");
+
+ assertEquals("%1$s - %2$d - %3$s", decorator.getExpression());
+ assertTokens("expression", "nbToken", "separator");
+ assertEquals(3, decorator.contexts.length);
+
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s - %3$s", decorator.getExpression());
+ assertTokens("nbToken", "separator", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(2);
+ assertEquals("%1$s - %2$s - %3$d", decorator.getExpression());
+ assertTokens("separator", "expression", "nbToken");
+
+ expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testMultiDecoratorWithMultiRef() throws Exception {
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - ");
+
+ assertEquals("%1$s - %2$d - %3$s %3$s", decorator.getExpression());
+ assertTokens("expression", "nbToken", "separator");
+ assertEquals(3, decorator.contexts.length);
+
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s %3$s - %3$s", decorator.getExpression());
+ assertTokens("nbToken", "separator", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(2);
+ assertEquals("%1$s %3$s - %2$s - %3$d", decorator.getExpression());
+ assertTokens("separator", "expression", "nbToken");
+
+ expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSort() throws Exception {
+
+ List<Data> datas = Data.generate(10);
+
+ MultiJXPathDecorator<Data> d = DecoratorUtils.newMultiJXPathDecorator(Data.class, "${pos}$d-${name}$s", "-");
+
+ List<Data> sortData = new ArrayList<Data>(datas);
+ DecoratorUtils.sort(d, sortData, 0);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ Collections.sort(datas, new Comparator<Data>() {
+
+ @Override
+ public int compare(Data o1, Data o2) {
+ return o1.name.compareTo(o2.name);
+ }
+ });
+ d.setContextIndex(1);
+ DecoratorUtils.sort(d, sortData, 1);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ }
+
+ public void assertDecoratorInternal(String... tokens) {
+ assertTokens(tokens);
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ private void assertTokens(String... tokens) {
+ if (tokens.length == 0) {
+ tokens = new String[]{"expression", "nbToken"};
+ }
+ assertEquals(tokens.length, decorator.nbToken);
+ assertEquals(tokens.length, decorator.getTokens().length);
+ for (int i = 0; i < tokens.length; i++) {
+ assertEquals(tokens[i], decorator.getTokens()[i]);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,377 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.DefaultJAXXContext;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Test du model de navigation.
+ *
+ * @author chemit
+ */
+public class NavigationTreeModelTest {
+
+ private static final String ROOT_CONTEXT = "$root";
+ private static final String FAKE = "-fake";
+ private static final String separator = "/";
+
+ @Test
+ public void testFindNode() throws Exception {
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, new DefaultJAXXContext(), null, null);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
+ for (int i = 0; i < 4; i++) {
+ NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null);
+ for (int j = 0; j < 4; j++) {
+ NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null);
+ for (int k = 0; k < 4; k++) {
+ builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null);
+ }
+ }
+ }
+
+ NavigationTreeModel model = builder.getModel();
+
+ NavigationTreeNode node;
+ String contextPath;
+ String currentNode;
+
+ contextPath = ROOT_CONTEXT;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, ROOT_CONTEXT, 0, node, true);
+
+ node = model.findNode(ROOT_CONTEXT + FAKE);
+ Assert.assertNull(node);
+
+ for (int i = 0; i < 4; i++) {
+ currentNode = getNodeContext(i);
+ contextPath = ROOT_CONTEXT + separator + currentNode;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, currentNode, 1, node, false);
+
+ for (int j = 0; j < 4; j++) {
+ currentNode = getNodeContext(i, j);
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, currentNode, 2, node, false);
+
+ for (int k = 0; k < 4; k++) {
+ currentNode = getNodeContext(i, j, k);
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, currentNode, 3, node, false);
+ }
+
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE);
+ Assert.assertNull(node);
+ }
+
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE);
+ Assert.assertNull(node);
+
+ }
+
+ }
+
+ /**
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * as a bean.
+ * <p/>
+ * Tree is like this
+ * <pre>
+ * $root +
+ * - name <-- attached to context entry : java.lang.String.class,"name"
+ * - name2 <-- attached to context entry : java.lang.String.class,"name2"
+ * - model + <-- attached to context entry : Model.class,null
+ * - name
+ * -integerValue
+ * - sons +
+ * - 0 +
+ * - name
+ * - integerValue
+ * - sons
+ * - 1 +
+ * - name
+ * - integerValue
+ * - sons
+ * - 2 +
+ * - name
+ * - integerValue
+ * - sons
+ * </pre>
+ * <p/>
+ * With this tree, we will have to results :
+ * <pre>
+ * $root.name => context.get(String.class,"name")
+ * $root.name2 => context.get(String.class,"name2")
+ * $root.model => context.get(Model.class)
+ * $root.model.name => context.get(Model.class).getName()
+ * $root.model.integerValue => context.get(Model.class).getIntegerValue()
+ * $root.model.sons => context.get(Model.class).getSons()
+ * $root.model.sons.0 => context.get(Model.class).getSons().get(0)
+ * </pre>
+ *
+ * @throws Exception if any pb
+ */
+ @Test
+ public void testGetJAXXContextValue() throws Exception {
+
+ JAXXContext context = new DefaultJAXXContext();
+ context.setContextValue("the name", "name");
+ context.setContextValue("the name2", "name2");
+
+
+ context.setContextValue(
+ new Model("modelName", 10,
+ Arrays.asList(
+ new Model("one", 1, Collections.<Model>emptyList()),
+ new Model("two", 2, Collections.<Model>emptyList()),
+ new Model("three", 3, Collections.<Model>emptyList()))));
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
+ NavigationTreeNode sonNode;
+ NavigationTreeNode sonSonNode;
+ NavigationTreeNode sonSonSonNode;
+
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
+
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
+
+ builder.build(sonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null);
+
+ sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null);
+
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null);
+
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null);
+ //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
+ sonSonNode.insert(sonSonSonNode, 2);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null);
+
+ NavigationTreeModel model = builder.getModel();
+
+ Assert.assertNull(model.getBean("$root.name" + FAKE));
+
+ testBinding(model, context, "$root/name", context.getContextValue(String.class, "name"));
+ testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2"));
+
+ Model bean = context.getContextValue(Model.class);
+
+ testBinding(model, context, "$root/model", bean);
+ testBinding(model, context, "$root/model/name", bean.getName());
+ testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/model/sons", bean.getSons());
+
+ testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName());
+ testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons());
+
+
+ testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName());
+ testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons());
+
+ testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName());
+ testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons());
+ }
+
+ /**
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * as a list.
+ * <p/>
+ * Tree is like this
+ * <pre>
+ * $root +
+ * - models + <-- attached to context entry : java.util.List.class,"models"
+ * - 0 +
+ * - name
+ * -integerValue
+ * - sons +
+ * - 0 +
+ * - name
+ * - 1 +
+ * - name
+ * - integerValue
+ * - sons
+ * - 2 +
+ * - name
+ * - integerValue
+ * - sons
+ * </pre>
+ * <p/>
+ * With this tree, we will have to results :
+ * <pre>
+ * $root.models => context.get(List.class,"models")
+ * $root.models.0 => context.get(List.class,"models").get(0)
+ * $root.models.0.name => context.get(List.class,"models").get(0).getName()
+ * </pre>
+ *
+ * @throws Exception if any pb
+ */
+ @Test
+ public void testGetBeanFromList() throws Exception {
+
+ List<Model> list = Arrays.asList(
+ new Model("entryOne", 10,
+ Arrays.asList(
+ new Model("one", 1, Collections.<Model>emptyList()),
+ new Model("two", 2, Collections.<Model>emptyList()),
+ new Model("three", 3, Collections.<Model>emptyList()))),
+ new Model("entryTwo", 20,
+ Arrays.asList(
+ new Model("2one", 1, Collections.<Model>emptyList()),
+ new Model("2two", 2, Collections.<Model>emptyList()),
+ new Model("2three", 3, Collections.<Model>emptyList()))),
+ new Model("entryThree", 30,
+ Arrays.asList(
+ new Model("3one", 1, Collections.<Model>emptyList()),
+ new Model("3two", 2, Collections.<Model>emptyList()),
+ new Model("3three", 3, Collections.<Model>emptyList()))));
+ JAXXContext context = new DefaultJAXXContext();
+ context.setContextValue(list, "models");
+
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
+ NavigationTreeNode sonNode;
+ NavigationTreeNode sonSonNode;
+ NavigationTreeNode sonSonSonNode;
+
+ // first son is a list of models
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
+
+ // first son son is a model
+ sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null);
+
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+
+ // second son son is a model
+ sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null);
+
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
+ // third son son is a model
+ sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null);
+
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
+ NavigationTreeModel model = builder.getModel();
+
+ Model bean;
+
+ testBinding(model, context, "$root/models", list);
+
+ bean = list.get(0);
+ testBinding(model, context, "$root/models/0", bean);
+ testBinding(model, context, "$root/models/0/name", bean.getName());
+ testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/0/sons", bean.getSons());
+ testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0));
+ testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName());
+
+ bean = list.get(1);
+ testBinding(model, context, "$root/models/1", bean);
+ testBinding(model, context, "$root/models/1/name", bean.getName());
+ testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/1/sons", bean.getSons());
+
+ bean = list.get(2);
+ testBinding(model, context, "$root/models/2", bean);
+ testBinding(model, context, "$root/models/2/name", bean.getName());
+ testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/2/sons", bean.getSons());
+
+ }
+
+ protected void testBinding(NavigationTreeModel model, JAXXContext context, String contextPath, Object expected) throws Exception {
+
+ Object value;
+ value = model.getBean(contextPath);
+ Assert.assertNotNull(value);
+ Assert.assertEquals(expected, value);
+ }
+
+ protected String getNodeContext(int... context) {
+ String result = "";
+ for (int i : context) {
+ result += i;
+ }
+ return result;
+ }
+
+ protected void assertNodeEquals(String contextPath, String nodeContext, int level, NavigationTreeNode node, boolean root) {
+ //System.out.println(contextPath + " : " + (node == null ? null : node.getContextPath()));
+ Assert.assertNotNull(node);
+ Assert.assertEquals(root, node.isRoot());
+ Assert.assertEquals(level, node.getLevel());
+ Assert.assertEquals(nodeContext, node.getNodePath());
+ Assert.assertEquals(contextPath, node.getFullPath());
+ }
+
+ public static class Model {
+
+ protected String name;
+ protected int integerValue;
+ protected List<Model> sons;
+
+ public Model(String name, int integerValue, List<Model> sons) {
+ this.name = name;
+ this.integerValue = integerValue;
+ this.sons = sons;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getIntegerValue() {
+ return integerValue;
+ }
+
+ public List<Model> getSons() {
+ return sons;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name:" + name + ",integerValue:" + integerValue + ",sons: " + sons + ">";
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,70 @@
+aboutframe.about=
+aboutframe.license=
+aboutframe.ok=
+aboutframe.thirdparty=
+columnselector.action.tip=
+config.action.quit=
+config.action.quit.tip=
+config.action.reset=
+config.action.reset.tip=
+config.action.save=
+config.action.save.tip=
+config.category.saved=
+config.choice.cancel=
+config.choice.continue=
+config.choice.doNotSave=
+config.choice.ok=
+config.choice.save=
+config.defaultValue=
+config.defaultValue.tip=
+config.descrition=
+config.error.category.already.exists=
+config.error.category.not.found=
+config.key=
+config.key.tip=
+config.message.quit.invalid.category=
+config.message.quit.valid.and.modified.category=
+config.modified=
+config.no.option.selected=
+config.option.final=
+config.option.label=
+config.option.modified=
+config.title=
+config.title.need.confirm=
+config.title.will.reload.application=
+config.unmodifiable=
+config.unvalid=
+config.value=
+config.value.tip=
+entitycombobox.action.reset.tip=
+entitycombobox.action.sort.tip=
+entitycombobox.popup.label=
+entitycombobox.popup.title=
+entitycombobox.sort.off=
+entitycombobox.sort.on=
+entitycombobox.unknown.type=
+errorUI.action.close=
+errorUI.message=
+errorUI.title=
+i18neditor.empty.locales=
+i18neditor.popup.title=
+i18neditor.selected=
+i18neditor.unselected=
+memorywidget.memory=
+numbereditor..=
+numbereditor.0=
+numbereditor.1=
+numbereditor.2=
+numbereditor.3=
+numbereditor.4=
+numbereditor.5=
+numbereditor.6=
+numbereditor.7=
+numbereditor.8=
+numbereditor.9=
+numbereditor.action.reset.tip=
+numbereditor.action.show.tip=
+numbereditor.clearAll=
+numbereditor.clearOne=
+numbereditor.toggleSign=
+timeeditor.H=
Added: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,70 @@
+aboutframe.about=
+aboutframe.license=
+aboutframe.ok=
+aboutframe.thirdparty=
+columnselector.action.tip=
+config.action.quit=
+config.action.quit.tip=
+config.action.reset=
+config.action.reset.tip=
+config.action.save=
+config.action.save.tip=
+config.category.saved=
+config.choice.cancel=
+config.choice.continue=
+config.choice.doNotSave=
+config.choice.ok=
+config.choice.save=
+config.defaultValue=
+config.defaultValue.tip=
+config.descrition=
+config.error.category.already.exists=
+config.error.category.not.found=
+config.key=
+config.key.tip=
+config.message.quit.invalid.category=
+config.message.quit.valid.and.modified.category=
+config.modified=
+config.no.option.selected=
+config.option.final=
+config.option.label=
+config.option.modified=
+config.title=
+config.title.need.confirm=
+config.title.will.reload.application=
+config.unmodifiable=
+config.unvalid=
+config.value=
+config.value.tip=
+entitycombobox.action.reset.tip=
+entitycombobox.action.sort.tip=
+entitycombobox.popup.label=
+entitycombobox.popup.title=
+entitycombobox.sort.off=
+entitycombobox.sort.on=
+entitycombobox.unknown.type=
+errorUI.action.close=
+errorUI.message=
+errorUI.title=
+i18neditor.empty.locales=
+i18neditor.popup.title=
+i18neditor.selected=
+i18neditor.unselected=
+memorywidget.memory=
+numbereditor..=
+numbereditor.0=
+numbereditor.1=
+numbereditor.2=
+numbereditor.3=
+numbereditor.4=
+numbereditor.5=
+numbereditor.6=
+numbereditor.7=
+numbereditor.8=
+numbereditor.9=
+numbereditor.action.reset.tip=
+numbereditor.action.show.tip=
+numbereditor.clearAll=
+numbereditor.clearOne=
+numbereditor.toggleSign=
+timeeditor.H=
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,84 @@
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ComboBoxTest extends JaxxBaseTest {
+
+ @Test
+ public void ok() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ mojo.execute();
+ checkPattern(mojo, "swingComboBox", true, "org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.java");
+ assertNumberJaxxFiles(2);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Test
+ public void error() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ // init mojo to get alls files to treate
+ mojo.init();
+
+ assertNumberJaxxFiles(1);
+
+ mojo.setLog(new SystemStreamLog() {
+
+ @Override
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ @Override
+ public void error(Throwable error) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ //do nothing
+ }
+ });
+ Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers");
+ Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount");
+
+ fieldCompilers.setAccessible(true);
+ fieldErrorCount.setAccessible(true);
+
+
+ // execute mjo on each jaxx file to produce the error
+ for (String file : mojo.files) {
+ log.info("test bad file " + file);
+ mojo.files = new String[]{file};
+ try {
+ mojo.doAction();
+ // should never pass
+ fail();
+ } catch (MojoExecutionException e) {
+ // ok jaxx compiler failed
+ assertTrue(true);
+
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get();
+ Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor);
+ assertEquals(1, compilers.size());
+ //JAXXCompiler compiler;
+ //compiler = compilers.values().iterator().next();
+ Integer nberrors = (Integer) fieldErrorCount.get(launchor);
+ assertTrue(nberrors != null && nberrors > 0);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,4 @@
+
+<JComboBox id='comboBox'>
+ <item value='{_("OK")}' selected='true'/>
+</JComboBox>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.nuiton.jaxx.test</groupId>
+ <artifactId>test</artifactId>
+ <version>0</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/target/test-classes</src>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <force>true</force>
+ <verbose>true</verbose>
+ <includes>
+ <value>**/ComboBoxTest/error/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,4 @@
+
+<JAXXComboBox id='comboBox'>
+ <item value='OK' selected='true'/>
+</JAXXComboBox>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,2 @@
+
+<JComboBox id='swingComboBox'/>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.nuiton.jaxx.test</groupId>
+ <artifactId>test</artifactId>
+ <version>0</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/target/test-classes</src>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <force>true</force>
+ <includes>
+ <value>**/ComboBoxTest/ok/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
1
0
Author: tchemit
Date: 2009-10-05 21:15:44 +0200 (Mon, 05 Oct 2009)
New Revision: 1559
Added:
branches/jaxx-2.X/jaxx-runtime/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.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/swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.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/CardLayout2.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.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/GBC.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.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/Item.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.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/LocaleListCellRenderer.java
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/OneClicListSelectionModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.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/WizardOperationModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
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/WizardUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/
branches/jaxx-2.X/jaxx-widgets/
Removed:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/
branches/jaxx-2.X/jaxx-example/
branches/jaxx-2.X/jaxx-runtime-api/
branches/jaxx-2.X/jaxx-runtime-swing-widget/
branches/jaxx-2.X/jaxx-runtime-swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java
Modified:
branches/jaxx-2.X/jaxx-compiler/pom.xml
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java
branches/jaxx-2.X/jaxx-demo/pom.xml
branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
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/BoxedDecoratorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
branches/jaxx-2.X/jaxx-runtime/pom.xml
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.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/Util.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/BeanValidatorEvent.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
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/XWorkBeanValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java
branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties
branches/jaxx-2.X/jaxx-swing-action/pom.xml
branches/jaxx-2.X/jaxx-widgets/pom.xml
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
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/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx
branches/jaxx-2.X/pom.xml
Log:
simplify modules + refactor NavigationTree and Decorator api + add real JComboBox tag handler (incompatible with JAXX 1.X)
Modified: branches/jaxx-2.X/jaxx-compiler/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -22,17 +22,11 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
-
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
@@ -43,8 +37,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx compiler api</description>
+ <name>JAXX Compiler</name>
+ <description>JAXX Compiler api</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -4,64 +4,29 @@
*/
package jaxx;
-import jaxx.tags.swing.JTextComponentHandler;
-import jaxx.tags.swing.JTabbedPaneHandler;
-import jaxx.tags.swing.TabHandler;
-import jaxx.tags.swing.CellHandler;
-import jaxx.tags.swing.JComboBoxHandler;
-import jaxx.tags.swing.JSliderHandler;
-import jaxx.tags.swing.RowHandler;
-import jaxx.tags.swing.JSpinnerHandler;
-import jaxx.tags.swing.TableHandler;
-import jaxx.tags.swing.JScrollPaneHandler;
-import jaxx.tags.swing.JProgressBarHandler;
-import jaxx.tags.swing.JInternalFrameHandler;
-import jaxx.tags.swing.JToolBarHandler;
-import jaxx.tags.swing.JRadioButtonHandler;
-import jaxx.tags.swing.JSplitPaneHandler;
-import jaxx.tags.swing.LocaleEditorHandler;
-import jaxx.tags.swing.JCheckBoxHandler;
-import jaxx.tags.swing.EnumEditorHandler;
-import jaxx.tags.swing.JWindowHandler;
-import jaxx.tags.swing.JAXXTabHandler;
-import jaxx.tags.swing.JPasswordFieldHandler;
-import jaxx.tags.swing.ApplicationHandler;
-import jaxx.tags.swing.JMenuHandler;
-import jaxx.tags.swing.ItemHandler;
-import jaxx.tags.swing.JListHandler;
-import jaxx.tags.swing.JPopupMenuHandler;
-import jaxx.tags.swing.JTreeHandler;
-import jaxx.tags.swing.*;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Application;
-import jaxx.runtime.swing.JAXXButtonGroup;
-import jaxx.runtime.swing.JAXXComboBox;
-import jaxx.runtime.swing.JAXXList;
-import jaxx.runtime.swing.JAXXTab;
-import jaxx.runtime.swing.JAXXTree;
-import jaxx.runtime.swing.Table;
-import jaxx.spi.Initializer;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.ColorConverter;
-import jaxx.types.GridBagConstraintsConverter;
-import jaxx.types.InsetsConverter;
-import jaxx.types.KeyStrokeConverter;
-import jaxx.types.TypeManager;
import jaxx.beaninfos.BeanInfoUtil;
-import javax.swing.*;
-import javax.swing.text.JTextComponent;
-import java.awt.Color;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
+import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.BoxedCompiledObjectDecorator;
import jaxx.compiler.CompiledObjectDecorator;
import jaxx.compiler.HelpRootCompiledObjectDecorator;
+
+import jaxx.reflect.ClassDescriptorLoader;
+
import jaxx.runtime.swing.editor.EnumEditor;
import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.spi.Initializer;
+
+import jaxx.runtime.swing.*;
+import jaxx.tags.*;
+import jaxx.tags.swing.*;
+import jaxx.types.*;
+
+import java.awt.*;
+import javax.swing.text.JTextComponent;
+import javax.swing.*;
+
public class SwingInitializer implements Initializer {
@Override
@@ -69,15 +34,21 @@
BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos");
- TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+ //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing
+ TagManager.registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), EnumEditorHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), LocaleEditorHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
- TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+ //TC-20091005 : JAXXComboBox and JComboBox are not the same
+// TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
+// TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class);
+
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
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-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -371,6 +371,7 @@
final String finalClassName = fullClassName;
registerInitializer(new Runnable() { // register an initializer which will create the CompiledObject after pass 1
+ @Override
public void run() {
DefaultObjectHandler handler = (DefaultObjectHandler) TagManager.getTagHandler(null, finalClassName, JAXXCompiler.this);
if (handler == null) {
@@ -725,15 +726,15 @@
lineNumber = lineAttr;
}
}
- File src = sourceFiles.peek();
+ File srcFile = sourceFiles.peek();
try {
- src = src.getCanonicalFile();
+ srcFile = srcFile.getCanonicalFile();
}
catch (IOException e) {
// ignore ?
}
- System.err.print(src);
+ System.err.print(srcFile);
if (lineNumber != null) {
System.err.print(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1));
}
@@ -789,17 +790,17 @@
}
public void reportError(int lineNumber, String error) {
- File src = sourceFiles.isEmpty() ? null : sourceFiles.peek();
+ File errorFile = sourceFiles.isEmpty() ? null : sourceFiles.peek();
try {
- if (src != null) {
- src = src.getCanonicalFile();
+ if (errorFile != null) {
+ errorFile = errorFile.getCanonicalFile();
}
}
catch (IOException e) {
// ignore ?
}
- System.err.print(src != null ? src.getPath() : "<unknown source>");
+ System.err.print(errorFile != null ? errorFile.getPath() : "<unknown source>");
if (lineNumber > 0) {
System.err.print(":" + lineNumber);
}
@@ -970,12 +971,12 @@
components[i].getStyleClass(), parentIndex != -1 ? descriptors[parentIndex] : null);
}
- Stylesheet stylesheet = getStylesheet();
- if (stylesheet == null) {
- stylesheet = new Stylesheet();
+ Stylesheet css = getStylesheet();
+ if (css == null) {
+ css = new Stylesheet();
}
- return new JAXXObjectDescriptor(descriptors, stylesheet);
+ return new JAXXObjectDescriptor(descriptors, css);
}
/*---------------------------------------------------------------------------------*/
@@ -1227,6 +1228,7 @@
break;
} else {
reportError("error parsing parameter list: " + parameters);
+ break;
}
default:
current.append(c);
@@ -1381,7 +1383,7 @@
}
// 1.5 adds getCanonicalName; unfortunately we can't depend on 1.5 features yet
- public static String getCanonicalName(Class clazz) {
+ public static String getCanonicalName(Class<?> clazz) {
if (clazz.isArray()) {
String canonicalName = getCanonicalName(clazz.getComponentType());
if (canonicalName != null) {
@@ -1496,14 +1498,17 @@
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setErrorListener(new ErrorListener() {
+ @Override
public void warning(TransformerException ex) throws TransformerException {
throw ex;
}
+ @Override
public void error(TransformerException ex) throws TransformerException {
throw ex;
}
+ @Override
public void fatalError(TransformerException ex) throws TransformerException {
throw ex;
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -183,9 +183,9 @@
return "";
}
if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame)
- String containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
- if (containerDelegate != null) {
- return id + '.' + containerDelegate + "().setLayout(" + valueCode + ");";
+ String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
+ if (cDelegate != null) {
+ return id + '.' + cDelegate + "().setLayout(" + valueCode + ");";
}
}
// ajout du support i18n
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -57,21 +57,17 @@
* name of a property (e.g. <code>"document"</code>).
*/
public class DefaultObjectHandler implements TagHandler {
+
/** The class that this handler provides support for. */
private ClassDescriptor beanClass;
-
/** The JAXXBeanInfo for the beanClass. */
protected JAXXBeanInfo jaxxBeanInfo;
-
/** Maps property names to their respective JAXXPropertyDescriptors. */
private Map<String, JAXXPropertyDescriptor> properties;
-
/** Maps event names to their respective JAXXEventSetDescriptors. */
private Map<String, JAXXEventSetDescriptor> events;
-
/** Maps property names to their respective ProxyEventInfos. */
private Map<String, ProxyEventInfo> eventInfos;
-
/** Maps XML tags to the CompiledObjects created from them. */
protected static Map<Element, CompiledObject> objectMap = new WeakHashMap<Element, CompiledObject>();
@@ -82,12 +78,11 @@
* normally throw something else, like <code>DocumentEvent</code>.
*/
private class ProxyEventInfo {
+
/** The name of the method or field being proxied, e.g. "getText". */
String memberName;
-
/** The "actual" event listener for the property in question, e.g. DocumentListener. */
ClassDescriptor listenerClass;
-
/**
* In cases where a different object (such as a model) is more directly responsible for
* managing the property, this is the name of the property where that object can be
@@ -97,15 +92,12 @@
* attached to the new value, and the data binding to be processed.
*/
String modelName;
-
/** The name of the method used to add the "native" event listener, e.g. "addDocumentListener". */
String addMethod;
-
/** The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". */
String removeMethod;
}
-
/**
* Creates a new <code>DefaultObjectHandler</code> which provides support for the specified class. The
* class is not actually introspected until the {@link #compileFirstPass} method is invoked.
@@ -116,7 +108,6 @@
this.beanClass = beanClass;
}
-
/**
* Performs introspection on the beanClass and stores the results.
*
@@ -147,7 +138,6 @@
}
}
-
/**
* Returns
*
@@ -157,7 +147,6 @@
return beanClass;
}
-
/**
* @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code>
* supports.
@@ -171,7 +160,6 @@
return jaxxBeanInfo;
}
-
/**
* Returns the <code>JAXXBeanInfo</code> for the specified class.
*
@@ -184,7 +172,6 @@
return JAXXIntrospector.getJAXXBeanInfo(beanClass);
}
-
/**
* Returns the type of the named property. This is the return type of the property's <code>get</code> method;
* for instance <code>JLabel</code>'s <code>text</code> property is a <code>String</code>.
@@ -209,7 +196,6 @@
throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object);
}
-
/**
* @param name ?
* @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code>
@@ -253,12 +239,10 @@
}
}
-
private static ClassDescriptor getEventClass(ClassDescriptor listenerClass) {
return listenerClass.getMethodDescriptors()[0].getParameterTypes()[0];
}
-
/**
* @param memberName name of the member
* @return an array of members on which the given property depends. For
@@ -270,7 +254,6 @@
return eventInfo == null ? null : new String[]{eventInfo.modelName};
}
-
/**
* Returns a snippet of Java code which will cause a <code>PropertyChangeListener</code> to be notified
* when the member's value changes. The <code>PropertyChangeListener</code> is provided in the form
@@ -342,7 +325,6 @@
}
}
-
public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) {
if ("getClass".equals(memberName)) {
return null;
@@ -370,8 +352,7 @@
compiler));
}
return result.toString();
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
throw new CompilerException("Internal error: " + e);
}
} else {
@@ -403,7 +384,6 @@
}
}
-
/**
* Configures the event handling for members which do not fire <code>PropertyChangeEvent</code> when
* modified. The default implementation does nothing. Subclasses should override this method to call
@@ -412,7 +392,6 @@
protected void configureProxyEventInfo() {
}
-
/**
* Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
* member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
@@ -427,11 +406,10 @@
* @param memberName the name of the field or method being proxied
* @param listenerClass the type of listener which receives events when the field or method is updated
*/
- public void addProxyEventInfo(String memberName, Class listenerClass) {
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass) {
addProxyEventInfo(memberName, listenerClass, null);
}
-
/**
* Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
* member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
@@ -453,16 +431,15 @@
* @param listenerClass the type of listener which receives events when the field or method is updated
* @param modelName the JavaBeans-style name of the model property
*/
- public void addProxyEventInfo(String memberName, Class listenerClass, String modelName) {
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass, String modelName) {
String listenerName = listenerClass.getName();
listenerName = listenerName.substring(listenerName.lastIndexOf(".") + 1);
addProxyEventInfo(memberName, listenerClass, modelName, "add" + listenerName, "remove" + listenerName);
}
-
// TODO: remove this temporary method, complete switchover to ClassDescriptors
- public void addProxyEventInfo(String memberName, Class listenerClass,
- String modelName, String addMethod, String removeMethod) {
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass,
+ String modelName, String addMethod, String removeMethod) {
try {
addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod);
} catch (ClassNotFoundException e) {
@@ -470,7 +447,6 @@
}
}
-
/**
* Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
* member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
@@ -499,7 +475,7 @@
* @param removeMethod remove method name
*/
public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass,
- String modelName, String addMethod, String removeMethod) {
+ String modelName, String addMethod, String removeMethod) {
ProxyEventInfo info = new ProxyEventInfo();
info.memberName = memberName;
info.listenerClass = listenerClass;
@@ -512,14 +488,12 @@
eventInfos.put(memberName, info);
}
-
@Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
scanAttributesForDependencies(tag, compiler);
compileChildrenFirstPass(tag, compiler);
}
-
@Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
try {
@@ -548,7 +522,6 @@
compileChildrenSecondPass(tag, compiler);
}
-
public void registerCompiledObject(Element tag, JAXXCompiler compiler) {
String id = tag.getAttribute("id");
if (id == null || id.length() == 0) {
@@ -563,7 +536,6 @@
compiler.registerCompiledObject(object);
}
-
/**
* Creates the <code>CompiledObject</code> which will represent the object created by this <code>TagHandler</code>.
*
@@ -575,7 +547,6 @@
return new CompiledObject(id, getBeanClass(), compiler);
}
-
/**
* Initializes the default settings of the object, prior to setting its attribute values. The default
* implementation does nothing.
@@ -587,7 +558,6 @@
protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) {
}
-
/**
* @param property property name to test
* @return <code>true</code> if the specified property should be inherited by child components when specified
@@ -599,7 +569,6 @@
return false;
}
-
/**
* @param name name of event
* @return <code>true</code> if the specified name has the form of an event handler attribute
@@ -609,7 +578,6 @@
return name.length() > 2 && name.startsWith("on") && Character.isUpperCase(name.charAt(2));
}
-
/**
* Scans all attributes for any dependency classes and adds them to the current compilation
* set. Called by <code>compileFirstPass()</code> (it is an error to add dependencies after
@@ -632,7 +600,7 @@
if (name.equals("javaBean")) {
//compiler.preprocessScript(value);
continue;
- }
+ }
if (name.equals("constraints") || isEventHandlerName(name)) {
compiler.preprocessScript(value); // adds dependencies as a side effect
} else if (name.equals("constructorParams")) {
@@ -645,7 +613,6 @@
}
}
-
/**
* Processes the attributes of an XML tag. Four kinds of attributes are supported: simple property values (of any
* datatype supported by {@link #convertFromString}), data binding expressions (attributes containing curly-brace
@@ -663,7 +630,7 @@
attributes.add((Attr) children.item(i));
}
Collections.sort(attributes, getAttributeComparator());
-
+
for (Attr attribute : attributes) {
String name = attribute.getName();
String value = attribute.getValue().trim();
@@ -702,7 +669,7 @@
if (name.equals("genericType")) {
//TC-20090313 check after all atributes been processed
- if (object == compiler.getRootObject() ) {
+ if (object == compiler.getRootObject()) {
compiler.setGenericType(value);
} else {
object.setGenericTypes(value.split(","));
@@ -741,7 +708,6 @@
}
}
-
/**
* Returns a <code>Comparator</code> which defines the ordering in which the tag's attributes should be processed. The
* default implementation sorts the attributes according to the order defined by the {@link #getAttributeOrdering} method.
@@ -750,6 +716,7 @@
*/
protected Comparator<Attr> getAttributeComparator() {
return new Comparator<Attr>() {
+
@Override
public int compare(Attr a, Attr b) {
int aOrder = getAttributeOrdering(a);
@@ -760,7 +727,6 @@
};
}
-
/**
* Returns the priority with which a particular attribute should be processed. Lower numbers should be processed before
* higher numbers. This value is used by the {@link #getAttributeComparator} method to define the sort ordering.
@@ -775,7 +741,6 @@
return 0;
}
-
public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) {
ClassDescriptor type = getPropertyType(object, propertyName, compiler);
String binding = compiler.processDataBindings(stringValue, type);
@@ -783,7 +748,7 @@
return "";
}
try {
- Class typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
Object value = convertFromString(propertyName, stringValue, typeClass);
return getSetPropertyCode(object.getJavaCode(), propertyName, TypeManager.getJavaCode(value), compiler);
} catch (NumberFormatException e) {
@@ -796,7 +761,6 @@
return "";
}
-
/**
* Set a single property on an object. The value may be either a simple value or contain data binding expressions.
* Simple values are first converted to the property's type using {@link #convertFromString}.
@@ -843,7 +807,7 @@
compiler.addInlineStyle(object, propertyName, false);
}
try {
- Class typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
Object value = convertFromString(propertyName, stringValue, typeClass);
setProperty(object, propertyName, value, compiler);
} catch (NumberFormatException e) {
@@ -859,17 +823,14 @@
}
}
-
public void applyStylesheets(CompiledObject object, JAXXCompiler compiler) {
applyStylesheets(object, compiler, null);
}
-
private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) {
applyStylesheets(object, compiler, overrides, true);
}
-
private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) {
try {
Stylesheet stylesheet = compiler.getStylesheet();
@@ -883,7 +844,7 @@
String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId();
CompiledObject child = new CompiledObject(id,
"((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " +
- object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))",
+ object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))",
classDescriptor,
compiler,
true);
@@ -916,15 +877,13 @@
} else if (stylesheet != null) {
StylesheetHelper.applyTo(object, compiler, stylesheet, overrides);
}
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new CompilerException(e);
} catch (IllegalArgumentException e) {
compiler.reportError(e.getMessage());
}
}
-
/**
* Adds the necessary Java code to a <code>CompiledObject</code> to add an event listener at runtime.
*
@@ -958,7 +917,6 @@
}
}
-
/**
* Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is
* just a call to the property's <code>get</code> method, but it can be arbitrarily complex.
@@ -986,7 +944,6 @@
throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
}
-
/**
* Returns a snippet of Java code which will set an object property at runtime. Typically the code is
* just a call to the property's <code>set</code> method, but it can be arbitrarily complex.
@@ -1009,7 +966,6 @@
throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
}
-
/**
* Appends Java code to a <code>CompiledObject</code> in order to implement a property assignment.
* <code>setProperty</code> is invoked in response to most XML attributes (those which are not more
@@ -1029,7 +985,6 @@
object.appendInitializationCode(getSetPropertyCode(object.getJavaCodeForProperty(name), name, TypeManager.getJavaCode(value), compiler));
}
-
/**
* Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
* example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
@@ -1074,7 +1029,6 @@
throw new NumberFormatException(value);
}
-
/**
* As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names
* for <code>int</code>-valued types.
@@ -1085,7 +1039,7 @@
* @return the converted object
* @see #constantValue
*/
- protected Object convertFromString(String key, String value, Class type) {
+ protected Object convertFromString(String key, String value, Class<?> type) {
if (type == null || type == Object.class) {
return value;
}
@@ -1100,7 +1054,6 @@
}
}
-
/**
* Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
* for each child tag.
@@ -1122,7 +1075,6 @@
}
}
-
/**
* Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
* for each child tag.
@@ -1149,7 +1101,6 @@
}
}
-
/**
* Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
* JAXXCompiler.compileFirstPass}.
@@ -1163,7 +1114,6 @@
compiler.compileFirstPass(tag);
}
-
/**
* Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
* JAXXCompiler.compileSecondPass}.
@@ -1181,4 +1131,4 @@
public String toString() {
return getClass().getName() + "[" + getBeanClass().getName() + "]";
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -53,8 +53,9 @@
private String localPart;
public QName(String namespaceURI, String localPart) {
- if (localPart == null)
+ if (localPart == null) {
throw new NullPointerException();
+ }
this.namespaceURI = namespaceURI;
this.localPart = localPart;
}
@@ -71,8 +72,9 @@
@Override
public boolean equals(Object o) {
- if (o == null || !(o instanceof QName))
+ if (o == null || !(o instanceof QName)) {
return false;
+ }
QName qname = (QName) o;
return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart());
}
@@ -101,6 +103,7 @@
* encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified
* <code>TagHandler</code> will be invoked to compile it.
*
+ * @param <T>
* @param beanClass the class to associate with a <code>TagHandler</code>
* @param handler the <code>TagHandler</code> class, which must descend from <code>DefaultObjectHandler</code>
* @throws IllegalArgumentException if the handler class does not descend from <code>DefaultObjectHandler</code>
@@ -152,6 +155,7 @@
* It is not an error to register an already-registered tag and namespace combination. The new mapping
* will replace the old mapping.
*
+ * @param <T>
* @param namespace the tag's namespace
* @param tag the simple name of the tag
* @param handler the <code>TagHandler</code> which should process the tag
@@ -385,15 +389,18 @@
* @return the resolved fqn class name
*/
public static String resolveClassName(String name, JAXXCompiler compiler) {
- if (name.endsWith("[]"))
+ if (name.endsWith("[]")) {
return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]";
- if (name.indexOf("<") != -1)
+ }
+ if (name.indexOf("<") != -1) {
name = name.substring(0, name.indexOf("<")); // strip off generic types
+ }
name = name.intern();
if (name.equals("boolean") || name.equals("byte") || name.equals("short") || name.equals("int") ||
- name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char"))
+ name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char")) {
return name;
+ }
String result = null;
String originalName = name;
@@ -452,14 +459,16 @@
// else we found a class by the same name, but in the wrong package
}
- if (dotPos <= 0)
+ if (dotPos <= 0) {
break;
+ }
dotPos = originalName.lastIndexOf('.', dotPos - 1);
}
}
- if (result != null && !result.equals(originalName))
+ if (result != null && !result.equals(originalName)) {
result = resolveClassName(result, compiler); // check for aliases against the new name as well
+ }
return result;
}
@@ -468,8 +477,9 @@
public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) {
try {
className = resolveClassName(className, compiler);
- if (className == null)
+ if (className == null) {
return null;
+ }
return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader());
}
catch (ClassNotFoundException e) {
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.tags.swing;
-
-import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultComponentHandler;
-
-import java.awt.event.ItemListener;
-import jaxx.runtime.swing.editor.EnumEditor;
-
-public class EnumEditorHandler extends DefaultComponentHandler {
-
- public EnumEditorHandler(ClassDescriptor beanClass) {
- super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, EnumEditor.class);
- }
-
- @Override
- protected void configureProxyEventInfo() {
- super.configureProxyEventInfo();
- addProxyEventInfo("getSelectedIndex", ItemListener.class);
- addProxyEventInfo("getSelectedItem", ItemListener.class);
- }
-
- @Override
- protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-// @Override
-// public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
-// super.compileChildrenSecondPass(tag, compiler);
-// CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
-// List<Item> items = list.getItems();
-// if (items != null && !items.isEmpty()) {
-// String listName = list.getId() + "$items";
-// list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
-// for (Item item : items) {
-// String id = item.getId();
-// CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
-// compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
-// compiler.registerCompiledObject(compiledItem);
-// list.appendAdditionCode(listName + ".add(" + id + ");");
-// }
-// list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
-// }
-// }
-}
-
-
-
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -24,14 +24,17 @@
public class ItemHandler implements TagHandler {
private String DATA_BINDING = "<data binding has not been processed yet>";
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
String id = tag.getAttribute("id");
- if (id == null || id.length() == 0)
+ if (id == null || id.length() == 0) {
id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class));
+ }
String label = null;
String value = null;
boolean selected = false;
@@ -47,10 +50,12 @@
}
if (name.equals(Item.LABEL_PROPERTY)) {
String labelBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(String.class));
- if (labelBinding != null)
+ if (labelBinding != null) {
compiler.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");");
- else
+ }
+ else {
label = attrValue;
+ }
continue;
}
if (name.equals(Item.VALUE_PROPERTY)) {
@@ -58,16 +63,19 @@
if (valueBinding != null) {
value = DATA_BINDING;
compiler.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");");
- } else
+ } else {
value = attrValue;
+ }
continue;
}
if (name.equals(Item.SELECTED_PROPERTY)) {
String selectedBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Boolean.class));
- if (selectedBinding != null)
+ if (selectedBinding != null) {
compiler.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");");
- else
+ }
+ else {
selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class);
+ }
continue;
}
@@ -78,8 +86,9 @@
Item item = new Item(id, label, value, selected);
CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
- if (value == null)
+ if (value == null) {
compiler.reportError("<item> tag is missing required 'value' attribute");
+ }
else {
if (!value.equals(DATA_BINDING)) {
List<Item> items = list.getItems();
@@ -108,8 +117,9 @@
} else
if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
String text = ((Text) node).getData().trim();
- if (text.length() > 0)
+ if (text.length() > 0) {
compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
}
}
}
@@ -126,8 +136,9 @@
} else
if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
String text = ((Text) node).getData().trim();
- if (text.length() > 0)
+ if (text.length() > 0) {
compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -4,26 +4,23 @@
*/
package jaxx.tags.swing;
+import java.io.IOException;
import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Item;
-import jaxx.runtime.swing.JAXXComboBox;
import jaxx.tags.DefaultComponentHandler;
-import jaxx.types.TypeManager;
-import org.w3c.dom.Element;
import java.awt.event.ItemListener;
-import java.io.IOException;
-import java.util.List;
+import javax.swing.JComboBox;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
public class JComboBoxHandler extends DefaultComponentHandler {
public JComboBoxHandler(ClassDescriptor beanClass) {
super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class);
}
@Override
@@ -34,26 +31,10 @@
}
@Override
- protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-
- @Override
public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
- super.compileChildrenSecondPass(tag, compiler);
- CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
- List<Item> items = list.getItems();
- if (items != null && !items.isEmpty()) {
- String listName = list.getId() + "$items";
- list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
- for (Item item : items) {
- String id = item.getId();
- CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
- compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
- compiler.registerCompiledObject(compiledItem);
- list.appendAdditionCode(listName + ".add(" + id + ");");
- }
- list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JComboBox does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -17,29 +17,32 @@
import javax.swing.event.ChangeListener;
public class JSliderHandler extends DefaultComponentHandler {
+
public JSliderHandler(ClassDescriptor beanClass) {
super(beanClass);
- if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass))
+ if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass)) {
throw new IllegalArgumentException(getClass().getName() + " does not support the class " + beanClass.getName());
+ }
}
-
+ @Override
protected int getAttributeOrdering(Attr attr) {
- if (attr.getName().equals("value"))
+ if (attr.getName().equals("value")) {
return 1;
- else
+ } else {
return super.getAttributeOrdering(attr);
+ }
}
-
- protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
super.setDefaults(object, tag, compiler);
setAttribute(object, "value", "0", false, compiler);
}
-
+ @Override
protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
addProxyEventInfo("getValue", ChangeListener.class, "model");
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -53,7 +53,7 @@
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
super.compileSecondPass(tag, compiler);
CompiledObject object = objectMap.get(tag);
- Map properties = object.getProperties();
+ Map<?,?> properties = object.getProperties();
if (!properties.containsKey("width") && !properties.containsKey("height")) {
compiler.appendLateInitializer(object.getId() + ".pack();\n");
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.tags.swing;
-
-import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultComponentHandler;
-
-import java.awt.event.ItemListener;
-import jaxx.runtime.swing.editor.LocaleEditor;
-
-public class LocaleEditorHandler extends DefaultComponentHandler {
-
- public LocaleEditorHandler(ClassDescriptor beanClass) {
- super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, LocaleEditor.class);
- }
-
- @Override
- protected void configureProxyEventInfo() {
- super.configureProxyEventInfo();
- addProxyEventInfo("getSelectedIndex", ItemListener.class);
- addProxyEventInfo("getSelectedItem", ItemListener.class);
- }
-
- @Override
- protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-// @Override
-// public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
-// super.compileChildrenSecondPass(tag, compiler);
-// CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
-// List<Item> items = list.getItems();
-// if (items != null && !items.isEmpty()) {
-// String listName = list.getId() + "$items";
-// list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
-// for (Item item : items) {
-// String id = item.getId();
-// CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
-// compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
-// compiler.registerCompiledObject(compiledItem);
-// list.appendAdditionCode(listName + ".add(" + id + ");");
-// }
-// list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
-// }
-// }
-}
-
-
-
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -18,10 +18,13 @@
import java.io.IOException;
public class RowHandler implements TagHandler {
+
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (!ClassDescriptorLoader.getClassDescriptor(Table.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
compiler.reportError("row tag may only appear within Table tag");
@@ -82,4 +85,4 @@
protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compiler.compileSecondPass(tag);
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -26,11 +26,13 @@
public class TabHandler implements TagHandler {
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (!ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
compiler.reportError("tab tag may only appear within JTabbedPane tag");
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -11,7 +11,7 @@
import jaxx.introspection.JAXXPropertyDescriptor;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.tags.DefaultObjectHandler;
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -25,6 +25,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(ExcludeFieldValidatorHandler.class);
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.info(tag);
@@ -32,6 +33,7 @@
//todo check there is no child
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.debug(tag);
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -25,6 +25,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(FieldValidatorHandler.class);
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.info(tag);
@@ -32,6 +33,7 @@
//todo check there is no child
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.info(tag);
Modified: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -21,7 +21,7 @@
BeanInfoUtil.reset();
Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length);
- String packageName = getClass().getPackage().getName()+".dummy";
+ String packageName = getClass().getPackage().getName() + ".dummy";
BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName);
searchPath = Introspector.getBeanInfoSearchPath();
Modified: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -135,8 +135,10 @@
@Test
public void testAliasing() {
- Assert.assertEquals("JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("JComboBox", compiler));
- Assert.assertEquals("javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("javax.swing.JComboBox", compiler));
+ Assert.assertEquals("ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("ButtonGroup", compiler));
+ Assert.assertEquals("javax.swing.ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("javax.swing.ButtonGroup", compiler));
+// Assert.assertEquals("JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("JComboBox", compiler));
+// Assert.assertEquals("javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("javax.swing.JComboBox", compiler));
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,394 +0,0 @@
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.swing.navigation.*;
-import jaxx.runtime.DefaultJAXXContext;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXContextEntryDef;
-import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Test du model de navigation.
- *
- * @author chemit
- */
-public class NavigationTreeModelTest {
-
- private static final String ROOT_CONTEXT = "$root";
- private static final String FAKE = "-fake";
-
- private static final String separator = "/";
-
- @Test
- public void testFindNode() throws Exception {
-
- NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
-
- NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
-
- for (int i = 0; i < 4; i++) {
- NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null);
- for (int j = 0; j < 4; j++) {
- NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null);
- for (int k = 0; k < 4; k++) {
- builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null);
- }
- }
- }
-
- NavigationTreeModel model = builder.getModel();
-
- NavigationTreeNode node;
- String contextPath;
- String currentNode;
-
- contextPath = ROOT_CONTEXT;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, ROOT_CONTEXT, 0, node, true);
-
- node = model.findNode(ROOT_CONTEXT + FAKE);
- Assert.assertNull(node);
-
- for (int i = 0; i < 4; i++) {
- currentNode = getNodeContext(i);
- contextPath = ROOT_CONTEXT + separator + currentNode;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, currentNode, 1, node, false);
-
- for (int j = 0; j < 4; j++) {
- currentNode = getNodeContext(i, j);
- contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, currentNode, 2, node, false);
-
- for (int k = 0; k < 4; k++) {
- currentNode = getNodeContext(i, j, k);
- contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, currentNode, 3, node, false);
- }
-
- node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE);
- Assert.assertNull(node);
- }
-
- node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE);
- Assert.assertNull(node);
-
- }
-
- }
-
- /**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
- * as a bean.
- * <p/>
- * Tree is like this
- * <pre>
- * $root +
- * - name <-- attached to context entry : java.lang.String.class,"name"
- * - name2 <-- attached to context entry : java.lang.String.class,"name2"
- * - model + <-- attached to context entry : Model.class,null
- * - name
- * -integerValue
- * - sons +
- * - 0 +
- * - name
- * - integerValue
- * - sons
- * - 1 +
- * - name
- * - integerValue
- * - sons
- * - 2 +
- * - name
- * - integerValue
- * - sons
- * </pre>
- * <p/>
- * With this tree, we will have to results :
- * <pre>
- * $root.name => context.get(String.class,"name")
- * $root.name2 => context.get(String.class,"name2")
- * $root.model => context.get(Model.class)
- * $root.model.name => context.get(Model.class).getName()
- * $root.model.integerValue => context.get(Model.class).getIntegerValue()
- * $root.model.sons => context.get(Model.class).getSons()
- * $root.model.sons.0 => context.get(Model.class).getSons().get(0)
- * </pre>
- *
- * @throws Exception if any pb
- */
- @Test
- public void testGetJAXXContextValue() throws Exception {
-
- NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
-
- NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
-
- NavigationTreeNode sonNode;
- NavigationTreeNode sonSonNode;
- NavigationTreeNode sonSonSonNode;
-
- builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
- builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
-
- sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
-
- builder.build(sonNode, (String) null, "../name", "name", null, null);
- builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null);
-
- sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null);
-
- builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null);
-
- builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null);
- //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
- sonSonNode.insert(sonSonSonNode, 2);
- builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null);
- builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null);
- builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null);
-
- NavigationTreeModel model = builder.getModel();
-
- JAXXContext context = new DefaultJAXXContext();
- context.setContextValue("the name", "name");
- context.setContextValue("the name2", "name2");
-
-
- context.setContextValue(
- new Model("modelName", 10,
- Arrays.asList(
- new Model("one", 1, Collections.<Model>emptyList()),
- new Model("two", 2, Collections.<Model>emptyList()),
- new Model("three", 3, Collections.<Model>emptyList())
- )
- )
- );
-
- Assert.assertNull(model.getJAXXContextValue(context, "$root.name" + FAKE));
-
- testBinding(model, context, "$root/name", context.getContextValue(String.class, "name"));
- testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2"));
-
- Model bean = context.getContextValue(Model.class);
-
- testBinding(model, context, "$root/model", bean);
- testBinding(model, context, "$root/model/name", bean.getName());
- testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/model/sons", bean.getSons());
-
- testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName());
- testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue());
- testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons());
-
-
- testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName());
- testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue());
- testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons());
-
- testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName());
- testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue());
- testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons());
- }
-
- /**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
- * as a list.
- * <p/>
- * Tree is like this
- * <pre>
- * $root +
- * - models + <-- attached to context entry : java.util.List.class,"models"
- * - 0 +
- * - name
- * -integerValue
- * - sons +
- * - 0 +
- * - name
- * - 1 +
- * - name
- * - integerValue
- * - sons
- * - 2 +
- * - name
- * - integerValue
- * - sons
- * </pre>
- * <p/>
- * With this tree, we will have to results :
- * <pre>
- * $root.models => context.get(List.class,"models")
- * $root.models.0 => context.get(List.class,"models").get(0)
- * $root.models.0.name => context.get(List.class,"models").get(0).getName()
- * </pre>
- *
- * @throws Exception if any pb
- */
- @Test
- public void testGetJAXXContextValueFromList() throws Exception {
-
- NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
-
- NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
-
- NavigationTreeNode sonNode;
- NavigationTreeNode sonSonNode;
- NavigationTreeNode sonSonSonNode;
-
- // first son is a list of models
- sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
-
- // first son son is a model
- sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null);
-
- builder.build(sonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null);
- builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
-
- // second son son is a model
- sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null);
-
- builder.build(sonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
-
- // third son son is a model
- sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null);
-
- builder.build(sonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
-
- NavigationTreeModel model = builder.getModel();
-
-
- List<Model> list = Arrays.asList(
- new Model("entryOne", 10,
- Arrays.asList(
- new Model("one", 1, Collections.<Model>emptyList()),
- new Model("two", 2, Collections.<Model>emptyList()),
- new Model("three", 3, Collections.<Model>emptyList())
- )
- ),
- new Model("entryTwo", 20,
- Arrays.asList(
- new Model("2one", 1, Collections.<Model>emptyList()),
- new Model("2two", 2, Collections.<Model>emptyList()),
- new Model("2three", 3, Collections.<Model>emptyList())
- )
- ),
- new Model("entryThree", 30,
- Arrays.asList(
- new Model("3one", 1, Collections.<Model>emptyList()),
- new Model("3two", 2, Collections.<Model>emptyList()),
- new Model("3three", 3, Collections.<Model>emptyList())
- )
- )
- );
- JAXXContext context = new DefaultJAXXContext();
- context.setContextValue(list, "models");
-
- Model bean;
-
- testBinding(model, context, "$root/models", list);
-
- bean = list.get(0);
- testBinding(model, context, "$root/models/0", bean);
- testBinding(model, context, "$root/models/0/name", bean.getName());
- testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/models/0/sons", bean.getSons());
- testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0));
- testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName());
-
- bean = list.get(1);
- testBinding(model, context, "$root/models/1", bean);
- testBinding(model, context, "$root/models/1/name", bean.getName());
- testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/models/1/sons", bean.getSons());
-
- bean = list.get(2);
- testBinding(model, context, "$root/models/2", bean);
- testBinding(model, context, "$root/models/2/name", bean.getName());
- testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/models/2/sons", bean.getSons());
-
- }
-
- protected void testBinding(NavigationTreeModel model, JAXXContext context, String contextPath, Object expected) throws Exception {
-
- Object value;
- value = model.getJAXXContextValue(context, contextPath);
- Assert.assertNotNull(value);
- Assert.assertEquals(expected, value);
- }
-
- protected String getNodeContext(int... context) {
- String result = "";
- for (int i : context) {
- result += i;
- }
- return result;
- }
-
- protected void assertNodeEquals(String contextPath, String nodeContext, int level, NavigationTreeNode node, boolean root) {
- //System.out.println(contextPath + " : " + (node == null ? null : node.getContextPath()));
- Assert.assertNotNull(node);
- Assert.assertEquals(root, node.isRoot());
- Assert.assertEquals(level, node.getLevel());
- Assert.assertEquals(nodeContext, node.getNavigationPath());
- Assert.assertEquals(contextPath, node.getContextPath());
- }
-
- public static class Model {
-
- protected String name;
-
- protected int integerValue;
-
- protected List<Model> sons;
-
- public Model(String name, int integerValue, List<Model> sons) {
- this.name = name;
- this.integerValue = integerValue;
- this.sons = sons;
- }
-
- public String getName() {
- return name;
- }
-
- public int getIntegerValue() {
- return integerValue;
- }
-
- public List<Model> getSons() {
- return sons;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<name:" + name + ",integerValue:" + integerValue + ",sons: " + sons + ">";
- }
- }
-
-}
Modified: branches/jaxx-2.X/jaxx-demo/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -22,12 +22,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing-widget</artifactId>
+ <artifactId>jaxx-widgets</artifactId>
<version>${project.version}</version>
</dependency>
@@ -35,7 +35,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<classifier>tests</classifier>
@@ -52,8 +52,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx Demo module</description>
+ <name>JAXX Demo</name>
+ <description>JAXX Demo</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
Modified: branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,6 +1,9 @@
application.name=${project.name}
application.version=${project.version}
application.site.url=http://maven-site.nuiton.org/jaxx/jaxx-example
+application.icon.path=/icons/jaxx.png
+application.license.path=META-INF/${project.artifactId}-LICENSE.txt
+application.third-party.path=META-INF/${project.artifactId}-THIRD-PARTY.txt
#licence.name=${project.licenses[0].license.name}
#licence.url=${project.licenses.0.url}
application.organisation.name=${project.organization.name}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,87 +1,110 @@
-
-<JTabbedPane id='top'>
-
- <script><![CDATA[
-import org.apache.commons.io.IOUtils;
-
-protected String[] getSources() {
- if (getClass() == DemoPanel.class) {
- return new String[0];
- }
- return new String[]{ getDefaultSource() };
-}
-
-protected String getDefaultSource() {
- return getClass().getSimpleName() + ".jaxx";
-}
-
-public String getLabel() {
- String name = getClass().getSimpleName();
- if (name.endsWith("Demo")) {
- name = name.substring(0, name.length() - "Demo".length());
- }
- return name;
-}
-
-public String getDemoTabTitle() {
- return getLabel() + " Demo";
-}
-
-public String loadSource(String filename) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(filename + " from " + getClass());
- }
- String result = IOUtils.toString(getClass().getResourceAsStream(filename));
-
- return result;
- } catch (Exception e) {
- log.error("could not load file " + filename, e);
- return "could not load file " + filename;
- }
-}
-
-private void $afterCompleteSetup() {
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- if (getSources().length == 0) {
- top.remove(sourceTabs);
- return;
- }
- for (String extra : getSources()) {
- JScrollPane pane = new JScrollPane(
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- pane.setBorder(null);
- // creation du contenu du fichier
- JTextArea content = new JTextArea();
- content.setFont(content.getFont().deriveFont((float) 11));
- content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
- content.setEditable(false);
- content.setWrapStyleWord(false);
- content.setText(loadSource(extra));
- content.setColumns(80);
- pane.getViewport().add(content);
- // ajout de l'onglet
- sourceTabs.addTab(extra, pane);
- int index = sourceTabs.indexOfComponent(pane);
- JLabel l = new JLabel(extra);
- l.setFont(l.getFont().deriveFont((float) 10));
- sourceTabs.setTabComponentAt(index,l);
- }
- }
- });
-}
- ]]>
- </script>
-
- <tab title='{getDemoTabTitle()}'>
- <JPanel id='demoPanel'/>
- </tab>
-
- <tab title='Sources'>
- <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
- </tab>
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<JTabbedPane id='top'>
+
+ <script><![CDATA[
+import org.apache.commons.io.IOUtils;
+
+protected String[] getSources() {
+ if (getClass() == DemoPanel.class) {
+ return new String[0];
+ }
+ return new String[]{ getDefaultSource() };
+}
+
+protected String getDefaultSource() {
+ return getClass().getSimpleName() + ".jaxx";
+}
+
+public String getLabel() {
+ String name = getClass().getSimpleName();
+ if (name.endsWith("Demo")) {
+ name = name.substring(0, name.length() - "Demo".length());
+ }
+ return name;
+}
+
+public String getDemoTabTitle() {
+ return getLabel() + " Demo";
+}
+
+public String loadSource(String filename) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(filename + " from " + getClass());
+ }
+ String result = IOUtils.toString(getClass().getResourceAsStream(filename));
+
+ return result;
+ } catch (Exception e) {
+ log.error("could not load file " + filename, e);
+ return "could not load file " + filename;
+ }
+}
+
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (getSources().length == 0) {
+ top.remove(sourceTabs);
+ return;
+ }
+ for (String extra : getSources()) {
+ JScrollPane pane = new JScrollPane(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ pane.setBorder(null);
+ //pane.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
+ // creation du contenu du fichier
+ JTextArea content = new JTextArea();
+ content.setFont(content.getFont().deriveFont((float) 11));
+ content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
+ content.setEditable(false);
+ content.setWrapStyleWord(false);
+ content.setText(loadSource(extra));
+ content.setColumns(80);
+ content.setLineWrap(true);
+ pane.getViewport().add(content);
+ content.setCaretPosition(0);
+ // ajout de l'onglet
+ sourceTabs.addTab(extra, pane);
+ int index = sourceTabs.indexOfComponent(pane);
+ JLabel l = new JLabel(extra);
+ l.setFont(l.getFont().deriveFont((float) 10));
+ sourceTabs.setTabComponentAt(index,l);
+ }
+ }
+ });
+}
+ ]]>
+ </script>
+
+ <tab title='{getDemoTabTitle()}'>
+ <JPanel id='demoPanel'/>
+ </tab>
+
+ <tab title='Sources'>
+ <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
+ </tab>
</JTabbedPane>
\ No newline at end of file
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-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -25,8 +25,8 @@
import jaxx.demo.component.swing.*;
import jaxx.demo.component.jaxx.*;
import jaxx.demo.component.jaxx.editor.*;
-import jaxx.demo.component.jaxx.navigation.full.FullNavigationTreeDemo;
import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
+import jaxx.demo.component.jaxx.tree.FullNavigationTreeDemo;
import jaxx.demo.feature.databinding.BeanDataBindingDemo;
import jaxx.demo.feature.validation.*;
import jaxx.demo.fun.*;
@@ -38,13 +38,8 @@
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.navigation.NavigationTreeModel;
-import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
-import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
-import jaxx.runtime.swing.navigation.NavigationTreeHandler;
-import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
-import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
-import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.tree.*;
+import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -67,7 +62,7 @@
log.debug("start creating demo model");
}
- TreeModelBuilder builder = new TreeModelBuilder();
+ TreeModelBuilder builder = new TreeModelBuilder(context);
builder.addText(n_("jaxxdemo.tree.component.swing")).
addText(n_("jaxxdemo.tree.component.swing.buttons")).
@@ -121,6 +116,7 @@
addDemo(ValidationListDemo.class).
addDemo(ValidationTableDemo.class).
goUp().
+ goUp().
addText(n_("jaxxdemo.tree.fun")).
addDemo(LabelStyleDemo.class).
addDemo(CounterDemo.class).
@@ -129,7 +125,7 @@
NavigationTreeModel model = builder.getModel();
if (log.isDebugEnabled()) {
- builder.printModel(context, model.getRoot());
+ builder.printModel(model.getRoot());
}
// save tree model in context
setTreeModel(context, model);
@@ -139,10 +135,10 @@
@Override
public NavigationTreeHandler createTreeHandler(JAXXObject context) {
- NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout(
+ NavigationTreeHandler handler;
+
+ handler = new NavigationTreeHandlerWithCardLayout(
getPrefix(),
- DemoPanel.class,
- null,
context,
Strategy.PER_UI_TYPE) {
@@ -168,7 +164,8 @@
ErrorDialogUI.showError(e);
}
- protected DemoUI getContext() {
+ @Override
+ public DemoUI getContext() {
return (DemoUI) context;
}
};
@@ -189,34 +186,34 @@
/**
* la pile des noeuds parent
*/
- protected Stack<NavigationTreeNode> parentNodes;
+ protected Stack<NavigationTreeNode> nodes;
- protected TreeModelBuilder() {
- super("/");
- parentNodes = new Stack<NavigationTreeNode>();
- parentNodes.add(buildEmptyRoot(def, "$root"));
+ protected TreeModelBuilder(JAXXContext context) {
+ super("/", context, DemoPanel.class, null);
+ nodes = new Stack<NavigationTreeNode>();
+ nodes.add(buildEmptyRoot(def, "$root"));
}
protected TreeModelBuilder goUp() {
- parentNodes.pop();
+ nodes.pop();
return this;
}
protected TreeModelBuilder addText(String label) {
- NavigationTreeNode parentNode = parentNodes.peek();
+ NavigationTreeNode parentNode = nodes.peek();
parentNode = build(parentNode, label, def, label, null, null);
if (log.isDebugEnabled()) {
- log.debug(label + " [" + parentNode.getContextPath() + "]");
+ log.debug(label + " [" + parentNode.getFullPath() + "]");
}
- parentNodes.push(parentNode);
+ nodes.push(parentNode);
return this;
}
protected TreeModelBuilder addDemo(Class<? extends DemoPanel> demoClass) {
- NavigationTreeNode parentNode = parentNodes.peek();
+ NavigationTreeNode parentNode = nodes.peek();
String label = demoClass.getSimpleName();
if (log.isDebugEnabled()) {
- log.debug(label + " [" + parentNode.getContextPath() + "]");
+ log.debug(label + " [" + parentNode.getFullPath() + "]");
}
build(parentNode, label, def, label, demoClass, null);
return this;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-05 19:15:44 UTC (rev 1559)
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
- */
+*/
JToolBar {
borderPainted:false;
floatable:false;
@@ -28,6 +28,12 @@
dividerSize:6;
}
+#mainFrame {
+ title:"JAXX Demo";
+ iconImage:{jaxx.runtime.SwingUtil.createIcon(getConfig().getOption("application.icon.path")).getImage()};
+ undecorated:{getConfig().isFullScreen()};
+}
+
#menu {
_help:{"ui.main.menu"};
}
@@ -61,8 +67,8 @@
toolTipText:"jaxxdemo.action.locale.fr.tip";
actionIcon:"i18n-fr";
enabled:{!acceptLocale(getConfig().getLocale(), "fr_FR")};
- mnemonic:F;
- _help:{"ui.main.menu.file.locale.fr"};
+mnemonic:F;
+_help:{"ui.main.menu.file.locale.fr"};
}
#menuFileLanguageUK {
@@ -70,8 +76,8 @@
toolTipText:"jaxxdemo.action.locale.uk.tip";
actionIcon:"i18n-uk";
enabled:{!acceptLocale(getConfig().getLocale(), "en_GB")};
- mnemonic:U;
- _help:{"ui.main.menu.file.locale.uk"};
+mnemonic:U;
+_help:{"ui.main.menu.file.locale.uk"};
}
#menuFileFullscreen {
@@ -80,7 +86,7 @@
actionIcon:"fullscreen";
mnemonic:P;
visible:{!isUndecorated()};
- _help:{"ui.main.menu.file.fullscreen"};
+_help:{"ui.main.menu.file.fullscreen"};
}
#menuFileNormalscreen {
@@ -89,7 +95,7 @@
actionIcon:"leave-fullscreen";
mnemonic:N;
visible:{isUndecorated()};
- _help:{"ui.main.menu.file.leave-fullscreen"};
+_help:{"ui.main.menu.file.leave-fullscreen"};
}
#menuFileExit{
@@ -137,17 +143,24 @@
visible:true;
}
+#navigationPane{
+ border:{null};
+minimumSize:{new Dimension(230,0)};
+horizontalScrollBarPolicy:{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER};
+}
+
#navigation{
rootVisible:false;
+ showsRootHandles:false;
largeModel:true;
font-size:11;
}
-/*
+
#splitpane{
orientation:{JSplitPane.HORIZONTAL_SPLIT};
_help:{"ui.main.body.db"};
resizeWeight:1.0;
-}*/
+}
#contentLayout{
useOnlyVisibleComponentDimension:true;
@@ -155,7 +168,7 @@
#content{
layout:{contentLayout};
- _help:{"ui.main.body.db.view.content"};
+_help:{"ui.main.body.db.view.content"};
}
/*
#toolbar {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,81 +1,113 @@
-
-<JFrame id='mainFrame'
- title="JAXX Demo"
- width='1024'
- height='800'
- decorator='help'
- undecorated='{getConfig().isFullScreen()}'
- onWindowClosing='getHandler().close(mainFrame)'>
-
- <style source='DemoUI.css'/>
-
- <jaxx.runtime.swing.CardLayout2 id='contentLayout'/>
-
- <script><![CDATA[
-import jaxx.runtime.swing.navigation.*;
-import java.util.Locale;
-
-public DemoConfig getConfig() {
- return getContextValue(DemoConfig.class);
-}
-
-protected DemoUIHandler getHandler() {
- return getContextValue(DemoUIHandler.class);
-}
-
-protected DemoTreeHelper getTreeHelper() {
- return getContextValue(DemoTreeHelper.class);
-}
-
-public boolean acceptLocale(Locale l, String expected) {
- return l !=null && l.toString().equals(expected);
-}
-
-]]>
- </script>
-
- <JMenuBar id='menu'>
-
- <JMenu id='menuFile'>
- <JMenuItem id='menuFileConfiguration'
- onActionPerformed="getHandler().showConfig(this)"/>
- <JMenu id='menuFileLanguage'>
- <JMenuItem id='menuFileLanguageFR'
- onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/>
- <JMenuItem id='menuFileLanguageUK'
- onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/>
- </JMenu>
- <JSeparator/>
- <JMenuItem id='menuFileFullscreen'
- onActionPerformed="getHandler().changeScreen(this, true)"/>
- <JMenuItem id='menuFileNormalscreen'
- onActionPerformed="getHandler().changeScreen(this, false)"/>
- <JSeparator/>
- <JMenuItem id='menuFileExit'
- onActionPerformed="getHandler().close(this)"/>
- </JMenu>
-
- <JMenu id='menuHelp'>
- <JMenuItem id='menuHelpHelp'
- onActionPerformed="getHandler().showHelp(this, null)"/>
- <JMenuItem id='menuHelpSite'
- onActionPerformed="getHandler().gotoSite(this)"/>
- <JMenuItem id='menuHelpAbout'
- onActionPerformed="getHandler().showAbout(this)"/>
- </JMenu>
-
- </JMenuBar>
-
- <JSplitPane id='splitPane'>
- <JScrollPane border='{null}'>
- <JTree id='navigation'
- model='{getTreeHelper().createTreeModel(this)}'
- selectionModel="{getTreeHelper().createTreeHandler(this)}"
- cellRenderer='{new NavigationTreeCellRenderer(this, 200)}'>
- </JTree>
- </JScrollPane>
-
- <JPanel id='content'/>
-
- </JSplitPane>
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<JFrame id='mainFrame' width='1024' height='800'
+ decorator='help'
+ onWindowClosing='getHandler().close(mainFrame)'>
+
+ <style source='DemoUI.css'/>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.tree.*;
+import java.util.Locale;
+
+public DemoConfig getConfig() {
+ return getContextValue(DemoConfig.class);
+}
+
+protected DemoUIHandler getHandler() {
+ return getContextValue(DemoUIHandler.class);
+}
+
+protected DemoTreeHelper getTreeHelper() {
+ return getContextValue(DemoTreeHelper.class);
+}
+
+public boolean acceptLocale(Locale l, String expected) {
+ return l !=null && l.toString().equals(expected);
+}
+
+private void $afterCompleteSetup() {
+ // share the tree
+ getTreeHelper().setTree(this, navigation);
+ // auto-expand node when selected
+ SwingUtil.addExpandOnClickListener(navigation);
+
+}
+
+]]>
+ </script>
+
+ <JMenuBar id='menu'>
+
+ <JMenu id='menuFile'>
+ <JMenuItem id='menuFileConfiguration'
+ onActionPerformed="getHandler().showConfig(this)"/>
+ <JMenu id='menuFileLanguage'>
+ <JMenuItem id='menuFileLanguageFR'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/>
+ <JMenuItem id='menuFileLanguageUK'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/>
+ </JMenu>
+ <JSeparator/>
+ <JMenuItem id='menuFileFullscreen'
+ onActionPerformed="getHandler().changeScreen(this, true)"/>
+ <JMenuItem id='menuFileNormalscreen'
+ onActionPerformed="getHandler().changeScreen(this, false)"/>
+ <JSeparator/>
+ <JMenuItem id='menuFileExit'
+ onActionPerformed="getHandler().close(this)"/>
+ </JMenu>
+
+ <JMenu id='menuHelp'>
+ <JMenuItem id='menuHelpHelp'
+ onActionPerformed="getHandler().showHelp(this, null)"/>
+ <JMenuItem id='menuHelpSite'
+ onActionPerformed="getHandler().gotoSite(this)"/>
+ <JMenuItem id='menuHelpAbout'
+ onActionPerformed="getHandler().showAbout(this)"/>
+ </JMenu>
+
+ </JMenuBar>
+
+ <JPanel id='mainPane' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+ <JScrollPane id='navigationPane'>
+ <JTree id='navigation'
+ model='{getTreeHelper().createTreeModel(this)}'
+ selectionModel="{getTreeHelper().createTreeHandler(this)}">
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this)}'>-->
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this,185)}'>-->
+ </JTree>
+ </JScrollPane>
+
+ <JPanel id='content'/>
+
+ </JSplitPane>
+
+ <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/>
+
+ </JPanel>
</JFrame>
\ No newline at end of file
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-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -23,7 +23,7 @@
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXInitialContext;
-import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import jaxx.runtime.swing.tree.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
@@ -102,8 +102,6 @@
@Override
public void run() {
-// // use best dimensions
-// ui.getSplitPane().resetToPreferredSizes();
String path;
if (node == null) {
@@ -111,23 +109,25 @@
path = "$root/jaxxdemo.tree.component.swing";
} else {
// take selected node
- path = node.getContextPath();
+ path = node.getFullPath();
}
+ log.info("node to re select " + path);
// select node
- ui.getTreeHelper().selectNode(ui, ui.getNavigation(), path);
-//
-// // show ui
-// ui.setVisible(true);
+ ui.getTreeHelper().selectNode(ui, path);
+
+ // use best dimensions
+ ui.getSplitPane().resetToPreferredSizes();
}
});
+
+ // show ui after all (in another invocation, tu avoid layout adjustement
+ // to be seen).
+
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- // use best dimensions
- ui.getSplitPane().resetToPreferredSizes();
-
// show ui
ui.setVisible(true);
}
@@ -154,7 +154,7 @@
node = ui.getTreeHelper().getSelectedNode(ui);
if (node != null) {
- log.info("selected node " + node.getContextPath());
+ log.info("selected node " + node.getFullPath());
}
ErrorDialogUI.init(null);
@@ -284,14 +284,20 @@
public void showAbout(DemoUI ui) {
+ DemoConfig config = ui.getConfig();
+
+ String iconPath = config.getOption("application.icon.path");
+ String licensePath = config.getOption("application.license.path");
+ String thirdPartyPath = config.getOption("application.third-party.path");
+
AboutPanel about = new AboutPanel();
-
about.setTitle(_("jaxxdemo.title.about"));
- about.setIconPath("/icons/jaxx.png");
about.setAboutText(_("jaxxdemo.about.message"));
about.setBottomText(ui.getConfig().getCopyrightText());
- about.setLicenseFile("META-INF/jaxx-example-LICENSE.txt");
- about.setThirdpartyFile("META-INF/jaxx-example-THIRD-PARTY.txt");
+ about.setIconPath(iconPath);
+ about.setLicenseFile(licensePath);
+ about.setThirdpartyFile(thirdPartyPath);
+ about.buildTopPanel();
about.init();
about.showInDialog(ui, true);
}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<jaxx.runtime.swing.BlockingLayerUI id='layerUI'
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<JPanel id='demoPanel' layout='{new BorderLayout()}'>
<JPanel layout='{new GridLayout(0,1)}' constraints='BorderLayout.CENTER'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<Table id='demoPanel' fill='both'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<String id='string' javaBean='null'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style>
JButton.fancy {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
public String getText(boolean bold, boolean italic, boolean underline) {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<JMenuItemDemo>
<style>
.form {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,22 +1,65 @@
-
-<jaxx.demo.DemoPanel>
- <Table id='demoPanel'>
- <row>
- <cell>
- <JLabel text='Button label:'/>
- </cell>
-
- <cell>
- <JComboBox id='comboBox' editable='true'>
- <item value='OK' selected='true'/>
- <item value='Cancel'/>
- <item value='Help'/>
- </JComboBox>
- </cell>
-
- <cell>
- <JButton text='{comboBox.getSelectedItem()}'/>
- </cell>
- </row>
- </Table>
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+
+private void $afterCompleteSetup() {
+ jaxxComboBox.setSelectedIndex(0);
+}
+]]>
+ </script>
+ <Table id='demoPanel'>
+ <row>
+ <cell>
+ <JLabel text='Button label:'/>
+ </cell>
+
+ <cell>
+ <JAXXComboBox id='jaxxComboBox' editable='true'>
+ <item value='{_("OK")}' selected='true'/>
+ <item value='{_("Cancel")}'/>
+ <item value='{_("Help")}'/>
+ </JAXXComboBox>
+ </cell>
+
+ <cell>
+ <JButton text='{jaxxComboBox.getSelectedItem()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Button label:'/>
+ </cell>
+
+ <cell>
+ <JComboBox id='comboBox'
+ editable='true'
+ model='{new DefaultComboBoxModel(new Object[]{n_("OK"),n_("Cancel"),n_("Help")})}'/>
+ </cell>
+
+ <cell>
+ <JButton text='{comboBox.getSelectedItem()}'/>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script>
String username;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<Table id='demoPanel'>
<row>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script>
void $afterCompleteSetup(){}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<HBox>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
import javax.swing.Timer;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<VBox>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<JMenuItemDemo>
<JMenuBar id='menuBar'>
<JMenu text='Font size'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<VBox>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<JLabel text='Spacing:' displayedMnemonic='S' labelFor='{spinner}'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<JPanel id='demoPanel' layout='{new BorderLayout()}'>
<JSplitPane>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<Table id='demoPanel' anchor='northwest'>
<row>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<JPanel id='demoPanel'>
<Table>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<JToggleButton text='1' id='one'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<!-- a full java bean property of the class -->
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<BaseBeanDataBinding>
<Boolean id='editing3' javaBean='true'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source="Validation.css"/>
@@ -3,4 +23,6 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer;
+
void $afterCompleteSetup() {
}
@@ -310,7 +332,7 @@
width='500'>
<JScrollPane>
<JList id='errorList' model='{errors}'
- cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
+ cellRenderer='{new SwingValidatorMessageListRenderer()}'/>
</JScrollPane>
</JPanel>
</cell>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source="Validation.css"/>
@@ -31,9 +51,11 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
void $afterCompleteSetup() {
- jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
+ SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
}
@Override
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source='Calculator.css'/>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script>int count;</script>
<JPanel id='demoPanel'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source="LabelStyle.css"/>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -47,6 +47,7 @@
Green=
Green\:=
Greet=
+Help=
I18n\ editor\ with\ no\ icon\ \:=
I18n\ editor\ with\ no\ text\ \:=
I18n\ editor\:=
@@ -111,7 +112,7 @@
form2.ratio=Form 2 Ratio
form2.text=Form 2 Text
form2.text2=Form 2 Text 2
-jaxxdemo.about.message=<h3>JAXX Demo</h3>Demo du framework JAXX <hr/><p>Ce projet a \u00E9t\u00E9 r\u00E9alis\u00E9 par la soci\u00E9t\u00E9 <a href\="http\://codelutin.com">Codelutin</a> en 2009.</p><br/><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-example">site du projet</a>.
+jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>.
jaxxdemo.action.about=About...
jaxxdemo.action.about.tip=About JAXXDemo...
jaxxdemo.action.configuration=Preferences
@@ -120,7 +121,7 @@
jaxxdemo.action.exit.tip=Quit JAXXDemo
jaxxdemo.action.fullscreen=Full screen
jaxxdemo.action.fullscreen.tip=Change to full screen mode
-jaxxdemo.action.help=Help
+jaxxdemo.action.help=
jaxxdemo.action.help.tip=Display help
jaxxdemo.action.locale.fr=French
jaxxdemo.action.locale.fr.tip=Change to french language
@@ -142,7 +143,7 @@
jaxxdemo.init.ui.done=UI initialized.
jaxxdemo.menu.file=File
jaxxdemo.menu.file.locale=Languages
-jaxxdemo.menu.help=Help
+jaxxdemo.menu.help=
jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded.
jaxxdemo.message.goto.site=Go to JAXXDemo Web site
jaxxdemo.title.about=About JAXXDemo...
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -20,7 +20,7 @@
Blue=Bleu
Blue\:=bleu \:
Bold=En gras
-Button\ label\:=Libell\u00E9 du label
+Button\ label\:=Libell\u00E9 de l'action
C=C
CE=CE
Cancel=Annuler
@@ -47,6 +47,7 @@
Green=Vert
Green\:=Vert \:
Greet=
+Help=
I18n\ editor\ with\ no\ icon\ \:=Editeur I18n sans icone \:
I18n\ editor\ with\ no\ text\ \:=Editeur I18n sans texte \:
I18n\ editor\:=Editeur I18n
@@ -111,7 +112,7 @@
form2.ratio=Form2 \: ratio
form2.text=Form2 \: text
form2.text2=Form2 \: text2
-jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/kaxx/jaxx-demo">site du projet</a>.
+jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>.
jaxxdemo.action.about=A propos
jaxxdemo.action.about.tip=A propos de JAXX Demo...
jaxxdemo.action.configuration=Configuration
@@ -159,7 +160,7 @@
jaxxdemo.tree.feature=Fonctionnalit\u00E9s
jaxxdemo.tree.features.databinding=Data binding
jaxxdemo.tree.features.validation=Validation
-jaxxdemo.tree.fun=Contestes
+jaxxdemo.tree.fun=Fun
jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
movies=Films
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -6,5 +6,7 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
log4j.logger.jaxx.demo=INFO
-#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeHandler=DEBUG
+#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeCellRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeNodeRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeModel=DEBUG
log4j.logger.org.nuiton=WARN
Property changes on: branches/jaxx-2.X/jaxx-runtime
___________________________________________________________________
Added: svn:ignore
+ target
*.log
*.iml
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,11 +10,11 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<dependencies>
@@ -62,8 +62,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx runtime api</description>
+ <name>JAXX Runtime</name>
+ <description>JAXX Runtime api</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -81,6 +81,14 @@
<goal>parserJava</goal>
<goal>gen</goal>
</goals>
+ <configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <basedir>src/main/java/jaxx/runtime/validator</basedir>
+ </entry>
+ </entries>
+ </configuration>
</execution>
</executions>
</plugin>
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.beaninfos;
+
+import jaxx.runtime.swing.HBox;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class HBoxBeanInfo extends SimpleBeanInfo {
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", HBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", HBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", HBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", HBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.beaninfos;
+
+import jaxx.runtime.swing.VBox;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class VBoxBeanInfo extends SimpleBeanInfo {
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", VBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", VBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", VBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", VBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,176 +0,0 @@
-package jaxx.runtime;
-
-import jaxx.runtime.*;
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import jaxx.runtime.validator.*;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The helper class for validation module.
- *
- * @author chemit
- */
-public class BeanValidatorUtil {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
- /**
- * a shared value stack to allow external operations on it (for example
- * add some datas in stack to be usedby validators
- */
- static private ValueStack sharedValueStack;
-
- public static synchronized ValueStack getSharedValueStack() {
- if (sharedValueStack == null) {
-
- // init context
- ConfigurationManager confManager = new ConfigurationManager();
- Configuration conf = confManager.getConfiguration();
-
- sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
- if (log.isDebugEnabled()) {
- log.debug("init shared value stack " + sharedValueStack);
- }
- }
- return sharedValueStack;
- }
-
- protected BeanValidatorUtil() {
- // no instance
- }
-
- /**
- * Convinient method to attach a bean to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param bean the bean to attach in validators (can be null)
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
- if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
- // touch validator, only if fits the bean type (or bean is null)
- beanValidator.setBean(bean);
- }
- }
- }
-
- /**
- * Convinient method to set the changed property to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param newValue the new value to set in changed validator property
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
- beanValidator.setChanged(newValue);
- }
- }
-
- /**
- * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
- *
- * @param validator validator to be involved
- * @param fieldName the name of the bean property
- * @param value the actual value to convert
- * @param valueClass the type of the conversion
- */
- public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
-
- Object result = validator.convert(fieldName, value, valueClass);
- if (result != null) {
- try {
- BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
-
- for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
- if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
-
- descriptor.getWriteMethod().invoke(validator.getBean(), result);
- break;
- }
- }
- } catch (IntrospectionException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (InvocationTargetException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (IllegalAccessException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- }
- } else {
- //fixme : conversion failed, we should be able to notify ui that values has changed ?
- // otherwise, bean value has not changed,...
- }
- }
-
- public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
- try {
- // check that the bean is listenable, otherwise, can't use
- // the validator on it
- BeanInfo infos = Introspector.getBeanInfo(beanClass);
- EventSetDescriptor[] events = infos.getEventSetDescriptors();
- for (EventSetDescriptor event : events) {
- if ("propertyChange".equals(event.getName())) {
-
- if (event.getAddListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
- }
- if (event.getRemoveListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
- }
- return event;
- }
- }
-
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
- } catch (IntrospectionException ex) {
- throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
- }
- }
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DataContext.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -150,12 +150,12 @@
return result;
}
- public void setContextValue(DataContextEntry entry, Object value, String key) {
+ public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
String contextKey = getKey(entry, key);
delegate.setContextValue(value, contextKey);
}
- public void removeContextValue(DataContextEntry entry, Object value, String key) {
+ public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
String contextKey = getKey(entry, key);
delegate.removeContextValue(value.getClass(), contextKey);
}
@@ -246,7 +246,7 @@
pcs.firePropertyChange(name, oldValue, newValue);
}
- protected String getKey(DataContextEntry entry, String key) {
+ protected String getKey(DataContextEntry<?> entry, String key) {
String result = null;
if (key != null) {
result = entry.hashCode() + "#" + key;
@@ -259,7 +259,7 @@
// suppression des ecouteurs
- for (PropertyChangeListener l : getPropertyChangeListeners()) {
+ for (PropertyChangeListener l : getPropertyChangeListeners()) {
removePropertyChangeListener(l);
}
}
@@ -272,14 +272,14 @@
private final int level;
private final DataContextEntry<?> previous;
- private final DataContextEntry[] parents;
+ private final DataContextEntry<?>[] parents;
private Class<E> klass;
public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
this.previous = previous;
this.level = previous.level + 1;
this.klass = klass;
- this.parents = new DataContextEntry[level];
+ this.parents = new DataContextEntry<?>[level];
int i = level;
while (i > 0) {
parents[--i] = previous;
@@ -291,7 +291,7 @@
this.level = 0;
this.klass = klass;
this.previous = null;
- this.parents = new DataContextEntry[0];
+ this.parents = new DataContextEntry<?>[0];
}
public Class<E> getKlass() {
@@ -302,7 +302,7 @@
return level;
}
- public DataContextEntry[] getParents() {
+ public DataContextEntry<?>[] getParents() {
return parents;
}
@@ -321,7 +321,7 @@
@Override
public Iterator<DataContextEntry<?>> iterator() {
int length = parents.length;
- DataContextEntry[] t = new DataContextEntry[length + 1];
+ DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1];
System.arraycopy(parents, 0, t, 0, length);
t[length] = this;
return new DataContextEntryIterator(t, true);
@@ -335,31 +335,31 @@
public static interface UpdateDataContext<D extends DataContext> {
- void onRemovingData(D context, DataContextEntry<?> entry);
+ void onRemovingData(D context, DataContextEntry<D> entry);
- void onAddingData(D context, DataContextEntry entry, String path);
+ void onAddingData(D context, DataContextEntry<D> entry, String path);
}
public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> {
- protected final DataContextEntry[] datas;
+ protected final DataContextEntry<?>[] datas;
protected final boolean reverse;
protected final int level;
protected int index;
- public DataContextEntryIterator(DataContextEntry[] datas) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas) {
this(datas, false, -1);
}
- public DataContextEntryIterator(DataContextEntry[] datas, int level) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
this(datas, false, level);
}
- public DataContextEntryIterator(DataContextEntry[] datas, boolean reverse) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
this(datas, reverse, -1);
}
- DataContextEntryIterator(DataContextEntry[] datas, boolean reverse, int level) {
+ DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
this.datas = datas;
this.reverse = reverse;
if (reverse) {
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/Decorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,36 +0,0 @@
-package jaxx.runtime;
-
-/**
- * A simple contract to define a String decorator on any java objet.
- *
- * @param <O> the type of decorated object
- * @author chemit
- */
-public abstract class Decorator<O> implements java.io.Serializable {
-
- protected final Class<O> internalClass;
- private static final long serialVersionUID = -1L;
-
- /**
- * @param internalClass the class of objects to be decorated.
- * @throws NullPointerException if internalClass parameter is null
- */
- public Decorator(Class<O> internalClass) throws NullPointerException {
- if (internalClass == null) {
- throw new NullPointerException("internalClass can not be null.");
- }
- this.internalClass = internalClass;
- }
-
- /**
- * @param bean the bean to decorate
- * @return the string value of the given bean
- */
- public abstract String toString(Object bean);
-
-
- public final Class<O> getInternalClass() {
- return internalClass;
- }
-
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DecoratorUtils.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,111 +0,0 @@
-package jaxx.runtime;
-
-import java.util.List;
-
-/**
- *
- * Some usefull methods on {@link Decorator} to store and obtain decorators.
- *
- * Use the method {@link #registerDecorator(String, Decorator)} to register a new
- * decorator.
- *
- * Use the method {@link #getDecorator(String)} to obtain a registred
- * decorator based on his registred name.
- *
- * Use the method {@link #getDecorator(Class, tring)} to obtain a registred
- * decorator based on the type of decorator and the registred name.
- *
- * @author tony
- * @since 1.3
- */
-public class DecoratorUtils {
-
- protected static List<DecoratorContext<?>> cache;
-
- public static <T> void registerDecorator(String context, Decorator<T> decorator) {
- DecoratorContext<T> result = getDecoratorContext(decorator.getInternalClass(), context);
-
- if (result != null) {
- throw new IllegalArgumentException("there is an already register decorator " + result);
- }
-
- if (cache == null) {
- cache = new java.util.ArrayList<DecoratorContext<?>>();
- }
- cache.add(new DecoratorContext<T>(context, decorator));
- }
-
- public static <T> Decorator<T> getDecorator(String context) {
- Decorator<T> result = getDecorator(null, context);
- return result;
- }
-
- public static <T> Decorator<T> getDecorator(Class<T> type, String context) {
- DecoratorContext<T> decoratorContext = getDecoratorContext(type, context);
- Decorator<T> result = decoratorContext == null ? null : decoratorContext.getDecorator();
- return result;
- }
-
- public static void clear() {
- if (cache != null) {
- cache.clear();
- }
- }
-
- @SuppressWarnings({"unchecked"})
- protected static <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) {
- DecoratorContext<T> result = null;
- if (cache != null) {
- for (DecoratorContext<?> d : cache) {
- if (type == null) {
- if (d.accept(context)) {
- result = (DecoratorContext<T>) d;
- break;
- }
- continue;
- }
- if (d.accept(type, context)) {
- result = (DecoratorContext<T>) d;
- break;
- }
- }
- }
- return result;
- }
-
- public static class DecoratorContext<T> {
-
- final String context;
- final Decorator<T> decorator;
-
- public DecoratorContext(String context, Decorator<T> decorator) {
- this.context = context;
- this.decorator = decorator;
- }
-
- public String getContext() {
- return context;
- }
-
- public Decorator<T> getDecorator() {
- return decorator;
- }
-
- public Class<T> getType() {
- return decorator.getInternalClass();
- }
-
- public boolean accept(Class<?> type, String context) {
- return getType().isAssignableFrom(type) && accept(context);
- }
-
- public boolean accept(String context) {
- return ((this.context == null && context == null) || (this.context != null && this.context.equals(context)));
- }
-
- @Override
- public String toString() {
- return super.toString() + "<type: " + getType().getName() + ", context :" + context + ">";
- }
- }
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -78,11 +78,11 @@
/**
* Map of forwarded classes (key) to classes (values).
*/
- protected Map<Class, Class> forwards;
+ protected Map<Class<?>, Class<?>> forwards;
public DefaultApplicationContext() {
super();
- forwards = new HashMap<Class, Class>();
+ forwards = new HashMap<Class<?>, Class<?>>();
pcs = new PropertyChangeSupport(this);
}
@@ -165,10 +165,10 @@
@Override
public <T> void removeContextValue(Class<T> klazz, String name) {
- Entry<Class, Class> entry;
+ Entry<Class<?>, Class<?>> entry;
if (name == null && forwards.containsValue(klazz)) {
// remove forward
- Iterator<Entry<Class, Class>> itr = forwards.entrySet().iterator();
+ Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
while (itr.hasNext()) {
entry = itr.next();
if (entry.getValue().equals(klazz)) {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -29,6 +29,7 @@
* <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);
@@ -38,6 +39,7 @@
* <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
*/
@@ -46,6 +48,7 @@
/**
* 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);
@@ -53,6 +56,7 @@
/**
* 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
*/
@@ -66,6 +70,7 @@
* <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.
*/
@@ -74,6 +79,7 @@
/**
* 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.
@@ -83,6 +89,7 @@
/**
* 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
*/
@@ -91,6 +98,7 @@
/**
* 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
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,278 +0,0 @@
-package jaxx.runtime;
-
-import org.apache.commons.jxpath.JXPathContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * JXPath decorator based on {@link String#format(String, Object[])} method.
- * <p/>
- * To use it, give to him a expression where all jxpath to apply on bean are boxed in <code>${}</code>.
- * <p/>
- * After the jxpath token you must specifiy the formatter to apply of the jxpath token.
- * <p/>
- * For example :
- * <pre>
- * Decorator<Object> d = JXPathDecorator.newDecorator(JXPathDecorator.class,"expr = ${expressions}$s");
- * assert "expr = %1$s" == d.getExpression();
- * assert 1 == d.getNbToken();
- * assert java.util.Arrays.asList("expression") == d.getTokens();
- * assert "expr = %1$s" == d.toString(d);
- * </pre>
- *
- * @param <O> type of data
- * @author chemit
- * @see Decorator
- */
-public class JXPathDecorator<O> extends Decorator<O> {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(JXPathDecorator.class);
- private static final long serialVersionUID = 1L;
-
- /**
- * Factory method to instanciate a new {@link JXPathDecorator} for the given class {@link O} and expression.
- *
- * @param internalClass the class of the objects decorated by the new decorator
- * @param expression the expression to use to decorated objects
- * @param <O> the generic type of class to be decorated by the new decorator
- * @return the new instanciated decorator
- * @throws IllegalArgumentException if the expression is not valid, says:
- * <p/>
- * - a missing right brace was detected.
- * <p/>
- * - a ${ was found in a jxpath token.
- * @throws NullPointerException if internalClass parameter is null.
- */
- public static <O> JXPathDecorator<O> newDecorator(Class<O> internalClass, String expression)
- throws IllegalArgumentException, NullPointerException {
- return new JXPathDecorator<O>(internalClass, expression, true);
- }
-
- /**
- * Sort a list of data based on the first token property of a given context
- * in a given decorator.
- *
- * @param <O> type of data to sort
- * @param decorator the decorator to use to sort
- * @param datas the list of data to sort
- * @param pos the index of context to used in decorator to obtain sorted property.
- */
- public static <O> void sort(JXPathDecorator<O> decorator, List<O> datas, int pos) {
- Comparator<O> c = null;
- boolean cachedComparator = false;
- try {
- c = decorator.getComparator(pos);
- cachedComparator = c instanceof JXPathComparator<?>;
-
- if (cachedComparator) {
- ((JXPathComparator<O>) c).init(decorator, datas);
- }
- Collections.sort(datas, c);
- } finally {
- if (cachedComparator) {
- ((JXPathComparator<?>) c).clear();
- }
- }
- }
-
- public static class JXPathComparator<O> implements Comparator<O> {
-
- protected Map<O, Comparable<Comparable<?>>> valueCache;
- private final String expression;
-
- public JXPathComparator(String expression) {
- this.expression = expression;
- this.valueCache = new HashMap<O, Comparable<Comparable<?>>>();
- }
-
- @Override
- public int compare(O o1, O o2) {
- Comparable<Comparable<?>> c1 = valueCache.get(o1);
- Comparable<Comparable<?>> c2 = valueCache.get(o2);
- return c1.compareTo(c2);
- }
-
- public void clear() {
- valueCache.clear();
- }
-
- public void init(JXPathDecorator<O> decorator, List<O> datas) {
- clear();
- for (O data : datas) {
- JXPathContext jxcontext = JXPathContext.newContext(data);
- Comparable<Comparable<?>> key = decorator.getTokenValue(jxcontext, expression);
- valueCache.put(data, key);
- }
- }
- }
-
- public static class Context<O> implements java.io.Serializable {
-
- /**
- * expression to format using {@link String#format(String, Object[])}, all variables are compute
- * using using the jxpath tokens.
- */
- protected String expression;
- /** list of jxpath tokens to apply on expression */
- protected String[] tokens;
- protected transient Comparator<O> comparator;
- private static final long serialVersionUID = 1L;
-
- public Context(String expression, String[] tokens) {
- this.expression = expression;
- this.tokens = tokens;
- }
-
- public String getFirstProperty() {
- return tokens[0];
- }
-
- public Comparator<O> getComparator(int pos) {
- if (comparator == null) {
- comparator = new JXPathComparator<O>(tokens[pos]);
- }
- return comparator;
- }
-
- public void setComparator(Comparator<O> comparator) {
- this.comparator = comparator;
- }
-
- @Override
- public String toString() {
- return "<expression:" + expression + ", tokens:" + Arrays.toString(tokens) + ">";
- }
- }
- /** the computed context of the decorator */
- protected Context<O> context;
- /** nb jxpath tokens to compute */
- protected int nbToken;
- /** the initial expression used to compute the decorator context. */
- protected String initialExpression;
-
- @Override
- public String toString(Object bean) {
- if (bean == null) {
- return null;
- }
- JXPathContext jxcontext = JXPathContext.newContext(bean);
- Object[] args = new Object[nbToken];
-
- for (int i = 0; i < nbToken; i++) {
- try {
- args[i] = getTokenValue(jxcontext, context.tokens[i]);
- } catch (Exception e) {
- log.error("can not obtain token " + context.tokens[i] + "on object " + bean + " for reason " + e.getMessage(), e);
-
- }
- }
-
- return String.format(context.expression, args);
- }
-
- @SuppressWarnings({"unchecked"})
- protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
- // assume all values are comparable
- return (Comparable<Comparable<?>>) jxcontext.getValue(token);
- }
-
- public String getProperty(int pos) {
- return getTokens()[pos];
- }
-
- public String getExpression() {
- return context.expression;
- }
-
- public String[] getTokens() {
- return context.tokens;
- }
-
- public int getNbToken() {
- return nbToken;
- }
-
- public String getInitialExpression() {
- return initialExpression;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<" + context + ">";
- }
-
- public void setContext(Context<O> context) {
- this.context = context;
- this.nbToken = context.tokens.length;
- // always reset comparator
- //this.context.comparator = null;
- if (log.isDebugEnabled()) {
- log.debug(context);
- }
- }
-
- public JXPathDecorator(Class<O> internalClass, String expression, boolean creatContext) throws IllegalArgumentException, NullPointerException {
- super(internalClass);
- this.initialExpression = expression;
- if (creatContext) {
- setContext(JXPathDecorator.<O>createInitialContext(expression));
- if (log.isDebugEnabled()) {
- log.debug(expression + " --> " + this.context);
- }
- }
- }
-
- @SuppressWarnings({"unchecked"})
- protected Comparator<O> getComparator(int pos) {
- ensureTokenIndex(this, pos);
- return context.getComparator(pos);
- }
-
- public static <O> Context<O> createInitialContext(String expression) {
- List<String> lTokens = new ArrayList<String>();
- StringBuilder buffer = new StringBuilder();
- int size = expression.length();
- int end = -1;
- int start;
- while ((start = expression.indexOf("${", end + 1)) > -1) {
- if (start > end + 1) {
- // prefix of next jxpath token
- buffer.append(expression.substring(end + 1, start));
- }
- // seek end of jxpath
- end = expression.indexOf("}", start + 1);
- if (end == -1) {
- throw new IllegalArgumentException("could not find the rigth brace starting at car " + start + " : " + expression.substring(start + 2));
- }
- String jxpath = expression.substring(start + 2, end);
- // not allowed ${ inside a jxpath token
- if (jxpath.indexOf("${") > -1) {
- throw new IllegalArgumentException("could not find a ${ inside a jxpath expression at car " + (start + 2) + " : " + jxpath);
- }
- // save the jxpath token
- lTokens.add(jxpath);
- // replace jxpath token in expresion with a string format variable
- buffer.append("%").append(lTokens.size());
- }
- if (size > (end + 1)) {
- // suffix after end jxpath (or all expression if no jxpath)
- buffer.append(expression.substring(end + 1));
- }
- return new Context<O>(buffer.toString(), lTokens.toArray(new String[lTokens.size()]));
- }
-
- protected static void ensureTokenIndex(JXPathDecorator<?> decorator, int pos) {
- if (pos < -1 || pos > decorator.getNbToken()) {
- throw new ArrayIndexOutOfBoundsException("token index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.nbToken + "]");
- }
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,23 @@
+package jaxx.runtime;
+
+import java.awt.Component;
+import jaxx.runtime.swing.JaxxHelpBroker;
+
+/**
+ *
+ * Contract to be added on JAXXObject wihch wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JaxxHelpBroker
+ */
+public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/MultiJXPathDecorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,129 +0,0 @@
-package jaxx.runtime;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * TODO
- *
- * @param <O> type of decorated objects
- * @author chemit
- * @see jaxx.runtime.Decorator
- */
-public class MultiJXPathDecorator<O> extends JXPathDecorator<O> {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class);
-
- private static final long serialVersionUID = 1L;
-
- public static <O> MultiJXPathDecorator<O> newDecorator(Class<O> internalClass,
- String expression,
- String separator)
- throws IllegalArgumentException, NullPointerException {
-
- return newDecorator(internalClass, expression, separator, separator);
- }
-
- public static <O> MultiJXPathDecorator<O> newDecorator(Class<O> internalClass,
- String expression,
- String separator,
- String separatorReplacement)
- throws IllegalArgumentException, NullPointerException {
-
- Context<O>[] contexts = createInitialContexts(expression, separator, separatorReplacement);
-
- return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts);
- }
-
- protected Context<O>[] contexts;
- protected String separator;
- protected String separatorReplacement;
-
-
- public MultiJXPathDecorator(Class<O> internalClass, String expression,
- String separator, String separatorReplacement,
- Context<O>[] contexts) throws IllegalArgumentException, NullPointerException {
- super(internalClass, expression, false);
- this.separator = separator;
- this.separatorReplacement = separatorReplacement;
- this.contexts = contexts;
-
- setContextIndex(0);
-
- if (log.isDebugEnabled()) {
- log.debug(expression + " --> " + this.context);
- }
- }
-
- public void setContextIndex(int index) {
- ensureContextIndex(this, index);
- setContext(contexts[index]);
- }
-
- public int getNbContext() {
- return contexts.length;
- }
-
- public String getSeparator() {
- return separator;
- }
-
- public String getSeparatorReplacement() {
- return separatorReplacement;
- }
-
- @Override
- protected Comparator<O> getComparator(int pos) {
- ensureContextIndex(this, pos);
- Context<O> context1 = contexts[pos];
- return context1.getComparator(0);
- }
-
- public static <O> Context<O>[] createInitialContexts(String expression, String separator, String separatorReplacement) {
- int sep = expression.indexOf(separator);
- if (sep == -1) {
- Context<O>[] result = MultiJXPathDecorator.newInstance(1);
- result[0] = createInitialContext(expression);
- return result;
- }
-
- List<String> tokens = new ArrayList<String>();
- StringTokenizer stk = new StringTokenizer(expression, separator);
- while (stk.hasMoreTokens()) {
- tokens.add(stk.nextToken());
- }
-
- int nbTokens = tokens.size();
- Context<O>[] contexts = newInstance(nbTokens);
- for (int i = 0; i < nbTokens; i++) {
- StringBuilder buffer = new StringBuilder(expression.length());
- for (int j = 0; j < nbTokens; j++) {
- int index = (i + j) % nbTokens;
- String str = tokens.get(index);
- //todo replace %index with %j
- buffer.append(separatorReplacement).append(str);
- }
- contexts[i] = createInitialContext(buffer.substring(separatorReplacement.length()));
- }
- return contexts;
- }
-
- protected static void ensureContextIndex(MultiJXPathDecorator<?> decorator, int pos) {
- if (pos < -1 || pos > decorator.contexts.length) {
- throw new ArrayIndexOutOfBoundsException("context index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.contexts.length + "]");
- }
- }
-
- @SuppressWarnings("unchecked")
- protected static <O> Context<O>[] newInstance(int size) {
- // fixme how to instanciate a typed array with no checking warning ?
- return new Context[size];
- }
-
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/PropertyDecorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,94 +0,0 @@
-package jaxx.runtime;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-
-/**
- * Simple property decorator based on {@link String#format(String, Object[])} method.
- * <p/>
- * To use it, give him a class and the property name to render.
- * <p/>
- * For example :
- * <pre>
- * Decorator<Object> d = PropertyDecorator.newDecorator(PropertyDecorator.class,"expressions");
- * </pre>
- *
- * @param <O> type of decorated objects
- * @author chemit
- * @see Decorator
- */
-public class PropertyDecorator<O> extends Decorator<O> {
-
- private static final long serialVersionUID = 1L;
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(PropertyDecorator.class);
-
- /**
- * Factory method to instanciate a new {@link jaxx.runtime.PropertyDecorator} for the given class {@link O} and a
- * readable property name.
- *
- * @param internalClass the class of the objects decorated by the new decorator
- * @param property the property
- * @param <O> the generic type of class to be decorated by the new decorator
- * @return the new instanciated decorator
- * @throws IllegalArgumentException if the expression is not valid, says:
- * <p/>
- * - a missing right brace was detected.
- * <p/>
- * - a ${ was found in a jxpath token.
- * @throws NullPointerException if internalClass parameter is null.
- */
- public static <O> PropertyDecorator<O> newDecorator(Class<O> internalClass, String property)
- throws IllegalArgumentException, NullPointerException {
- return new PropertyDecorator<O>(internalClass, property);
- }
-
- protected String property;
-
- protected transient Method m;
-
- @Override
- public String toString(Object bean) {
- try {
- return getM().invoke(bean) + "";
- } catch (Exception e) {
- log.error("could not convert for reason : " + e, e);
- return "";
- }
- }
-
- public String getProperty() {
- return property;
- }
-
- protected PropertyDecorator(Class<O> internalClass, String property) throws NullPointerException {
- super(internalClass);
- if (property == null) {
- throw new NullPointerException("property can not be null.");
- }
- this.property = property;
- // init method
- getM();
- }
-
-
- protected Method getM() {
- if (m == null) {
- for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(internalClass)) {
- if (propertyDescriptor.getName().equals(property)) {
- this.m = propertyDescriptor.getReadMethod();
- break;
- }
- }
- if (m == null) {
- throw new IllegalArgumentException("could not find the property " + property + " in " + internalClass);
- }
- }
- return m;
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,762 @@
+package jaxx.runtime;
+
+import jaxx.runtime.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Desktop;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Rectangle;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.JTextComponent;
+import java.lang.reflect.Field;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JRootPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTree;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.TreeSelectionListener;
+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.Item;
+import jaxx.runtime.swing.JAXXComboBox;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ * The runtime swing util class with some nice stuff.
+ *
+ * Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class SwingUtil extends Util {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingUtil.class);
+ private static Field numReaders;
+ private static Field notifyingListeners;
+ public static final String ICON_PREFIX = "icon.";
+ public static final String COLOR_PREFIX = "color.";
+
+ public static Dimension newMinDimension() {
+ return new Dimension(0, 0);
+ }
+
+ public static Dimension newMaxXDimension() {
+ return new Dimension(Short.MAX_VALUE, 0);
+ }
+
+ public static Dimension newMaxYDimension() {
+ return new Dimension(0, Short.MAX_VALUE);
+ }
+
+ public static Dimension newMaxXYDimension() {
+ return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+ }
+
+ public static void setText(final JTextComponent c, final String text) {
+ try {
+ // AbstractDocument deadlocks if we try to acquire a write lock while a read lock is held by the current thread
+ // If there are any readers, dispatch an invokeLater. This should only happen in the event of circular bindings.
+ // Similarly, circular bindings can result in an "Attempt to mutate in notification" error, which we deal with
+ // by checking for the 'notifyingListeners' property.
+ AbstractDocument document = (AbstractDocument) c.getDocument();
+ if (numReaders == null) {
+ numReaders = AbstractDocument.class.getDeclaredField("numReaders");
+ numReaders.setAccessible(true);
+ }
+ if (notifyingListeners == null) {
+ notifyingListeners = AbstractDocument.class.getDeclaredField("notifyingListeners");
+ notifyingListeners.setAccessible(true);
+ }
+
+ if (notifyingListeners.get(document).equals(Boolean.TRUE)) {
+ return;
+ }
+
+ if ((Integer) numReaders.get(document) > 0) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (!c.getText().equals(text)) {
+ c.setText(text);
+ }
+ }
+ });
+ return;
+ }
+
+ String oldText = c.getText();
+ if (oldText == null || !oldText.equals(text)) {
+ c.setText(text);
+ }
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ c.setText(text);
+ }
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param combo the combo to fill
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ */
+ public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) {
+ if (!(combo.getModel() instanceof DefaultComboBoxModel)) {
+ throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass());
+ }
+ DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
+ // evince the model
+ model.removeListDataListener(combo);
+ model.removeAllElements();
+ if (data != null) {
+ for (Object o : data) {
+ model.addElement(o);
+ }
+ }
+ // attach the model
+ model.addListDataListener(combo);
+ model.setSelectedItem(select);
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param combo the combo to fill
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ * @param firstNull add a first null element
+ */
+ public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) {
+ List<Item> items = new ArrayList<Item>();
+ if (firstNull) {
+ items.add(new Item("null", " ", null, false));
+ }
+ if (data != null) {
+ for (Object d : data) {
+ items.add(new Item(d.toString(), d.toString(), d, d.equals(select)));
+ }
+ }
+ combo.setItems(items);
+ }
+
+ public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) {
+ int width = 0;
+ if (font == null) {
+ font = table.getFont();
+ }
+// if (font == null) {
+// TableColumn column = table.getColumnModel().getColumn(columnIndex);
+// font = ((JComponent) column.getCellRenderer()).getFont();
+// }
+ FontMetrics fontMetrics = table.getFontMetrics(font);
+ for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) {
+ String key = (String) table.getModel().getValueAt(i, 0);
+ int w = fontMetrics.stringWidth(key + suffix);
+ if (w > width) {
+ width = w;
+ }
+ }
+ return width;
+ }
+
+ public static void fixTableColumnWidth(JTable table, int columnIndex, int width) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setMaxWidth(width);
+ column.setMinWidth(width);
+ column.setWidth(width);
+ column.setPreferredWidth(width);
+ }
+
+ public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setCellEditor(editor);
+ }
+
+ public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setCellRenderer(editor);
+ }
+
+ public static void setI18nTableHeaderRenderer(JTable table, String... libelles) {
+ table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles));
+ }
+
+ public static TableCellRenderer newStringTableCellRenderer(final DefaultTableCellRenderer renderer, final int length, final boolean tooltip) {
+
+ return new DefaultTableCellRenderer() {
+
+ private static final long serialVersionUID = 1l;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ String val = renderer.getText();
+ String val2 = val;
+ if (val.length() > length) {
+ val2 = val.substring(0, length - 3) + "...";
+ }
+
+ JComponent comp = (JComponent) super.getTableCellRendererComponent(table, val2, isSelected, hasFocus, row, column);
+ if (tooltip) {
+ comp.setToolTipText(val);
+ }
+ return comp;
+ }
+ };
+ }
+
+ /**
+ * Box a component in a {@link org.jdesktop.jxlayer.JXLayer}.
+ *
+ * @param component the component to box
+ * @return the {@link org.jdesktop.jxlayer.JXLayer} boxing the component
+ */
+ public static JXLayer<?> boxComponentWithJxLayer(JComponent component) {
+ JXLayer<?> layer = getLayer(component);
+ if (layer != null) {
+ return layer;
+ }
+ layer = new org.jdesktop.jxlayer.JXLayer<JComponent>();
+ layer.add(component);
+ return layer;
+ }
+
+ public static List<JComponent> getLayeredComponents(JAXXObject object) {
+ List<JComponent> result = new ArrayList<JComponent>();
+ for (Entry<String, Object> child : object.get$objectMap().entrySet()) {
+ if (child.getValue() == null) {
+ log.warn("find a null object in $objectMap " + child.getKey());
+ continue;
+ }
+ if (JComponent.class.isAssignableFrom(child.getValue().getClass())) {
+ JComponent comp = (JComponent) child.getValue();
+ if (isLayered(comp)) {
+ result.add(comp);
+ }
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static JXLayer<JComponent> getLayer(JComponent comp) {
+ if (!isLayered(comp)) {
+ return null;
+ }
+ return (JXLayer<JComponent>) comp.getParent();
+ }
+
+ public static boolean isLayered(JComponent comp) {
+ Container parent = comp.getParent();
+ return parent != null && parent instanceof JXLayer<?>;
+ }
+
+ /**
+ * recherche les composants portant le meme nom que les champs de la classe
+ * clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser
+ * dans un autre context (je pense par exemple a la generation jaxx).
+ * <p/>
+ * <p/>
+ * Si la recherche echoue pour quelque raison que se soit, aucune exception
+ * n'est leve, et la map retournee est tout simplement vide ou incomplete
+ *
+ * @param clazz la classe ou recherche les champs
+ * @param container le container ou rechercher les composants d'edition
+ * @return le dictionnaire des composants recherches.
+ */
+ public static Map<String, JComponent> lookingForEditor(Class<?> clazz, Container container) {
+ Map<String, JComponent> result = new HashMap<String, JComponent>();
+ try {
+ // looking for all component with name set
+ Map<String, JComponent> allNamedComponent = new HashMap<String, JComponent>();
+ List<Container> todo = new LinkedList<Container>();
+ todo.add(container);
+ while (todo.size() > 0) {
+ for (ListIterator<Container> i = todo.listIterator(); i.hasNext();) {
+ Container parent = i.next();
+ i.remove();
+ for (Component c : parent.getComponents()) {
+ if (c instanceof Container) {
+ i.add((Container) c);
+ String name = c.getName();
+ if (c instanceof JComponent &&
+ name != null && !"".equals(name)) {
+ allNamedComponent.put(name, (JComponent) c);
+ }
+ }
+ }
+ }
+ }
+
+ // looking for all properties on class
+ BeanInfo info = Introspector.getBeanInfo(clazz);
+ PropertyDescriptor[] props = info.getPropertyDescriptors();
+
+ // find if one properties have same name that component
+ for (PropertyDescriptor prop : props) {
+ String name = prop.getName();
+ if (allNamedComponent.containsKey(name)) {
+ result.put(name, allNamedComponent.get(name));
+ }
+ }
+
+ } catch (IntrospectionException eee) {
+ log.warn("Can't introspect bean", eee);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Result: " + result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Centrer un component graphique au center d'un autre component.
+ *
+ * <b>Note:</b> si le parent est null, alors on ne fait rien.
+ *
+ * @param parent le component parent
+ * @param component le component à centrer
+ */
+ public static void center(Component parent, Component component) {
+ if (parent == null) {
+ return;
+ }
+ Rectangle r = parent.getBounds();
+ int x = r.x + (r.width - component.getSize().width) / 2;
+ int y = r.y + (r.height - component.getSize().height) / 2;
+ component.setLocation(x, y);
+ }
+
+ /**
+ * Try to load the Nimbus look and feel.
+ * <p/>
+ * @throws UnsupportedLookAndFeelException
+ * if nimbus is not applicable
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static void initNimbusLoookAndFeel() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+ for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(laf.getName())) {
+ UIManager.setLookAndFeel(laf.getClassName());
+ }
+ }
+ }
+
+ /**
+ * Load the ui.properties file and set in {@link UIManager} colors and icons found.
+ *
+ * @param defaultUIConfig le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path)
+ * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path)
+ *
+ * @throws IOException if could not load the ui.properties file
+ */
+ public static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException {
+
+ Properties p = new Properties();
+ log.info("loading default UI config " + defaultUIConfig);
+ p.load(SwingUtil.class.getResourceAsStream(defaultUIConfig));
+ if (log.isDebugEnabled()) {
+ log.debug(p.toString());
+ }
+ if (extraUIConfig != null) {
+ InputStream extraStream = SwingUtil.class.getResourceAsStream(extraUIConfig);
+ if (extraStream == null) {
+ log.warn("could not find extraUIConfig : " + extraUIConfig);
+ } else {
+ log.info("loading extra UI config " + extraUIConfig);
+ Properties p2 = new Properties(p);
+ p2.load(extraStream);
+ if (log.isDebugEnabled()) {
+ log.debug(p2.toString());
+ }
+ p.putAll(p2);
+ }
+ }
+ for (Entry<Object, Object> entry : p.entrySet()) {
+ String key = (String) entry.getKey();
+ if (key.startsWith(ICON_PREFIX)) {
+ ImageIcon icon;
+ try {
+ icon = createImageIcon((String) entry.getValue());
+ UIManager.put(key.substring(ICON_PREFIX.length()), icon);
+ } catch (Exception e) {
+ log.warn("could not load icon " + entry.getValue());
+ }
+ continue;
+ }
+ if (key.startsWith(COLOR_PREFIX)) {
+ String value = (String) entry.getValue();
+ String[] rgb = value.split(",");
+ UIManager.put(key.substring(COLOR_PREFIX.length()), new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2])));
+ }
+ }
+ }
+
+ /**
+ * Iterate the components of a {@link JTabbedPane} in natural order.
+ *
+ * Says using method {@link JTabbedPane#getComponent(int)}
+ * @param tabs the
+ * @return
+ * @since 1.4
+ */
+ public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) {
+ return new TabbedPaneIterator<Component>(false, tabs) {
+
+ @Override
+ protected Component get(int index, Component comp) {
+ return comp;
+ }
+ };
+ }
+
+ /**
+ * A simple iterator on a {@link JTabbedPane}.
+ *
+ * Implements the method {@link #get(int, java.awt.Component)} to obtain
+ * the data required given the component (or index).
+ *
+ * You can also inverse the order by usin the method {@link #reverse()}.
+ *
+ * Note: After the use of the method {@link #reverse()} the iterator returns
+ * to the first element.
+ *
+ * @param <O> the type of return elements.
+ * @since 1.4
+ */
+ public static abstract class TabbedPaneIterator<O> implements Iterator<O> {
+
+ final JTabbedPane tabs;
+ boolean reverse;
+ int index;
+ int increment;
+
+ protected abstract O get(int index, Component comp);
+
+ public TabbedPaneIterator(boolean reverse, JTabbedPane tabs) {
+ this.tabs = tabs;
+ setReverse(reverse);
+ }
+
+ public void reset() {
+ setReverse(reverse);
+ }
+
+ public int size() {
+ return tabs.getTabCount();
+ }
+
+ public TabbedPaneIterator<O> reverse() {
+ setReverse(!reverse);
+ return this;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return reverse ? index > 0 : index < tabs.getTabCount();
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public O next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ Component next = tabs.getComponentAt(index);
+ O result = get(index, next);
+ index += increment;
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ throw new IllegalStateException("not implemented for " + this);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "< reverse:" + reverse + ", index:" + index + ", size:" + tabs.getTabCount() + " >";
+ }
+
+ protected void setReverse(boolean reverse) {
+ if (reverse) {
+ index = tabs.getTabCount() - 1;
+ increment = -1;
+ } else {
+ index = 0;
+ increment = 1;
+ }
+ this.reverse = reverse;
+ }
+ }
+
+ public static JLabel newLabel(String text, Object iconKey, int aligment) {
+ Icon icon = null;
+ if (iconKey instanceof Icon) {
+ icon = (Icon) iconKey;
+ } else if (iconKey instanceof String) {
+ icon = jaxx.runtime.Util.getUIManagerActionIcon((String) iconKey);
+ }
+ JLabel result;
+ if (icon == null) {
+ result = new JLabel(text, aligment);
+ } else {
+ result = new JLabel(text, icon, aligment);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the higest visible component in a ancestor hierarchy at
+ * specific x,y coordinates
+ * @param parent
+ * @param x
+ * @param y
+ * @return
+ */
+ public static Component getDeepestObjectAt(Component parent, int x, int y) {
+
+ if (parent instanceof Container) {
+ Container cont = (Container) parent;
+ // use a copy of 1.3 Container.findComponentAt
+ Component child = findComponentAt(cont, cont.getWidth(), cont.getHeight(), x, y);
+ if (child != null && child != cont) {
+ //log.info("child find : " + child.getName());
+ if (child instanceof JRootPane) {
+ JLayeredPane lp = ((JRootPane) child).getLayeredPane();
+ Rectangle b = lp.getBounds();
+ child = getDeepestObjectAt(lp, x - b.x, y - b.y);
+ }
+ if (child != null) {
+ return child;
+ }
+ }
+ }
+ // if the parent is not a Container then it might be a MenuItem.
+ // But even if it isn't a MenuItem just return the parent because
+ // that's a close as we can come.
+ return parent;
+ }
+
+ public static Component findComponentAt(Container cont, int width, int height, int x, int y) {
+ //log.info("container : " + cont.getName());
+ synchronized (cont.getTreeLock()) {
+
+ if (!((x >= 0) && (x < width) && (y >= 0) && (y < height) && cont.isVisible() && cont.isEnabled())) {
+ return null;
+ }
+
+ Component[] component = cont.getComponents();
+ int ncomponents = cont.getComponentCount();
+
+ // Two passes: see comment in sun.awt.SunGraphicsCallback
+ for (int i = 0; i < ncomponents; i++) {
+ Component comp = component[i];
+ Rectangle rect = null;
+
+ if (comp != null && !comp.isLightweight()) {
+ if (rect == null || rect.width == 0 || rect.height == 0) {
+ rect = comp.getBounds();
+ }
+ if (comp instanceof JXLayer<?>) {
+ JXLayer<?> layer = (JXLayer<?>) comp;
+ comp = layer.getView();
+ }
+ if (comp instanceof Container) {
+ comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y);
+ } else {
+ comp = comp.getComponentAt(x - rect.x, y - rect.y);
+ }
+ if (comp != null && comp.isVisible() && comp.isEnabled()) {
+ return comp;
+ }
+ }
+ }
+
+ for (int i = 0; i < ncomponents; i++) {
+ Component comp = component[i];
+ Rectangle rect = null;
+
+ if (comp != null && comp.isLightweight()) {
+ if (rect == null || rect.width == 0 || rect.height == 0) {
+ rect = comp.getBounds();
+ }
+ if (comp instanceof JXLayer<?>) {
+ JXLayer<?> layer = (JXLayer<?>) comp;
+ comp = layer.getView();
+ }
+ if (comp instanceof Container) {
+ comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y);
+ } else {
+ comp = comp.getComponentAt(x - rect.x, y - rect.y);
+ }
+ if (comp != null && comp.isVisible() && comp.isEnabled()) {
+ return comp;
+ }
+ }
+ }
+ return cont;
+ }
+ }
+
+ public static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer) {
+ Icon icon = UIManager.getIcon("Table.removeIcon");
+ if (icon == null) {
+ // try with default icon
+ icon = createActionIcon("delete");
+ }
+ return new BooleanCellRenderer(renderer, icon);
+ }
+
+ public static TableCellRenderer newBooleanTableCellRenderer(DefaultTableCellRenderer renderer) {
+ return new BooleanCellRenderer(renderer);
+ }
+
+ public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer) {
+ return new EmptyNumberTableCellRenderer(renderer);
+ }
+
+ public static <E extends Enum<E>> EnumTableCellRenderer<E> newEnumTableCellRenderer(TableCellRenderer renderer, Class<E> enumClass) {
+ return new EnumTableCellRenderer<E>(renderer, enumClass);
+ }
+
+ /**
+ * Open a link coming from a {@link HyperlinkEvent}.
+ *
+ * And try to open the link if an url in a browser.
+ *
+ * @param he the event to treate
+ * @since 1.6.0
+ */
+ public static void openLink(HyperlinkEvent he) {
+ if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+
+ if (Desktop.isDesktopSupported()) {
+ try {
+ URL u = he.getURL();
+ if (u.getProtocol().equalsIgnoreCase("mailto") || u.getProtocol().equalsIgnoreCase("http") || u.getProtocol().equalsIgnoreCase("ftp")) {
+ Desktop.getDesktop().browse(u.toURI());
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error while opening link", e);
+ }
+ } catch (URISyntaxException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error while opening link", e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Expand all childs of a tree.
+ *
+ * @param tree the tree to expand
+ */
+ public static void expandTree(final JTree tree) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ int i = 0;
+ while (i < tree.getRowCount()) {
+ tree.expandRow(i++);
+ }
+ }
+ });
+ }
+
+ /**
+ * Add a listener of tree selection model to expand a new selected node
+ * when it is selected.
+ *
+ * @param tree the tree to treate
+ */
+ public static void addExpandOnClickListener(final JTree tree) {
+
+ tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(final TreeSelectionEvent e) {
+ TreeNode node = (TreeNode) e.getPath().getLastPathComponent();
+ if (node != null && !node.isLeaf()) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ for (TreePath path : e.getPaths()) {
+ if (e.isAddedPath(path) && !tree.isExpanded(path)) {
+ log.info("expand node [" + path + "]");
+ // will expand the node
+ tree.expandPath(path);
+ }
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -4,11 +4,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
-import javax.swing.JList;
import javax.swing.UIManager;
import java.awt.Component;
import java.awt.Dimension;
@@ -31,24 +29,20 @@
public static final String DEFAULT_ICON_PATH = "/icons/";
public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path";
-
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(Util.class);
-
-
// Maps root objects to lists of event listeners
private static Map<Object, WeakReference<List<EventListenerDescriptor>>> eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>();
private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>();
-
private static class EventListenerDescriptor {
- Class listenerClass;
+
+ Class<?> listenerClass;
String listenerMethodName;
String methodName;
Object eventListener;
}
-
/**
* Decodes the serialized representation of a JAXXObjectDescriptor. The string must be a byte-to-character mapping
* of the binary serialization data for a JAXXObjectDescriptor. See the comments in JAXXCompiler.createJAXXObjectDescriptorField
@@ -66,16 +60,13 @@
//descriptor.getBytes(0, descriptor.length(), data, 0);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
return (JAXXObjectDescriptor) in.readObject();*/
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
}
}
-
public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor(String descriptor) {
try {
return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, true);
@@ -86,16 +77,13 @@
//descriptor.getBytes(0, descriptor.length(), data, 0);
ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
return (JAXXObjectDescriptor) in.readObject();*/
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
}
}
-
public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) {
WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer);
List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null;
@@ -131,22 +119,22 @@
if (listenerMethodName != null && listenerMethod == null) {
throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName());
}
- Class[] parameterTypes = listenerMethods.get(0).getParameterTypes();
+ Class<?>[] parameterTypes = listenerMethods.get(0).getParameterTypes();
Class<?> methodContainerClass = methodContainer.getClass();
final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes);
descriptor.eventListener = Proxy.newProxyInstance(listenerClass.getClassLoader(),
- new Class[]{listenerClass},
+ new Class<?>[]{listenerClass},
new InvocationHandler() {
+
+ @Override
public Object invoke(Object proxy, Method method, Object[] args) {
String methodName = method.getName();
if ((listenerMethodName == null && listenerMethods.contains(method)) || methodName.equals(listenerMethodName)) {
try {
return targetMethod.invoke(methodContainer, args);
- }
- catch (IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
throw new RuntimeException(e);
- }
- catch (InvocationTargetException e) {
+ } catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
@@ -164,18 +152,15 @@
});
descriptors.add(descriptor);
return descriptor.eventListener;
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
-
public static Object getEventListener(Class<? extends EventListener> listenerClass, final Object methodContainer, final String methodName) {
return getEventListener(listenerClass, null, methodContainer, methodName);
}
-
public static DataBindingUpdateListener getDataBindingUpdateListener(JAXXObject object, String bindingName) {
WeakReference<List<DataBindingUpdateListener>> ref = dataBindingUpdateListeners.get(object);
List<DataBindingUpdateListener> listeners = ref == null ? null : ref.get();
@@ -194,7 +179,6 @@
return listener;
}
-
public static void setComponentWidth(Component component, int width) {
component.setSize(width, component.getHeight());
if (component instanceof JComponent) {
@@ -207,7 +191,6 @@
}
}
-
public static void setComponentHeight(Component component, int height) {
component.setSize(component.getWidth(), height);
if (component instanceof JComponent) {
@@ -220,55 +203,46 @@
}
}
-
public static boolean assignment(boolean value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static byte assignment(byte value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static short assignment(short value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static int assignment(int value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static long assignment(long value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static float assignment(float value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static double assignment(double value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static char assignment(char value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static java.lang.Object assignment(java.lang.Object value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
@@ -346,24 +320,6 @@
}
}
- public static <O> DefaultListCellRenderer newDecoratedListCellRenderer(final Decorator<O> decorator) {
- return new DefaultListCellRenderer() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- String decorated;
- if (value instanceof String) {
- decorated = (String) value;
- } else {
- decorated = decorator.toString(value);
- }
- return super.getListCellRendererComponent(list, decorated, index, isSelected, cellHasFocus);
- }
- };
- }
-
public static ImageIcon createIcon(String path) {
java.net.URL imgURL = Util.class.getResource(path);
if (imgURL != null) {
@@ -400,7 +356,6 @@
return getUIManagerIcon("action." + key);
}
-
public static ImageIcon createActionIcon(String name) {
String iconPath = getIconPath();
return createIcon(iconPath + "action-" + name + ".png");
@@ -461,5 +416,4 @@
}
return iconPath;
}
-
}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Application.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,56 @@
+package jaxx.runtime.swing;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import java.awt.GraphicsConfiguration;
+
+public class Application extends JFrame {
+ // Special: jaxxc will automatically add a main() method to any components which
+ // extend <Application>
+
+
+ public Application() {
+ }
+
+
+ public Application(GraphicsConfiguration gc) {
+ super(gc);
+ }
+
+
+ public Application(String title) {
+ super(title);
+ }
+
+
+ public Application(String title, GraphicsConfiguration gc) {
+ super(title, gc);
+ }
+
+
+ public void setLookAndFeel(String lookAndFeel) {
+ if (lookAndFeel.equals("system"))
+ lookAndFeel = UIManager.getSystemLookAndFeelClassName();
+ else if (lookAndFeel.equals("cross_platform"))
+ lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
+ try {
+ UIManager.setLookAndFeel(lookAndFeel);
+ if (isDisplayable())
+ SwingUtilities.updateComponentTreeUI(this);
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ catch (UnsupportedLookAndFeelException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,259 @@
+package jaxx.runtime.swing;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ *
+ * A JXLayer ui implementation that permits to block a component but still
+ * allow an action when clicking on the right-top icon painted on the layer.
+ *
+ * You can change the blocking and accepting icon.
+ *
+ * To hook an click on the layer's icon, you can :
+ *
+ * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li>
+ * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
+ * </ul>
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class BlockingLayerUI extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
+
+ public static final String CAN_CLICK_PROPERTY = "canClick";
+ public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
+ public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ public static final String BLOCK_PROPERTY = "block";
+ private static final long serialVersionUID = 1L;
+ /**
+ * Action to be treated when click on icon
+ */
+ protected Action acceptAction;
+ /**
+ * Icon when you can not click
+ */
+ protected BufferedImage blockIcon;
+ /**
+ * Icon when you can click
+ */
+ protected BufferedImage acceptIcon;
+ /**
+ * Optinal color to put fill background when blocking
+ */
+ protected Color blockingColor;
+ /**
+ * Internal state to known when we can accept click
+ */
+ protected boolean canClick;
+ /**
+ * A flag to enable or disable the use of the icon.
+ *
+ * If set to false, no icon will be displayed and no action
+ * will be possible.
+ *
+ * By default, this is active.
+ */
+ protected boolean useIcon = true;
+ /**
+ * Internal state when should block event and paint layer
+ */
+ protected boolean block;
+
+ public void setAcceptAction(Action acceptAction) {
+ this.acceptAction = acceptAction;
+ }
+
+ public void setAcceptIcon(ImageIcon acceptIcon) {
+ this.acceptIcon = prepareIcon(acceptIcon);
+ firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon);
+ setDirty(true);
+ }
+
+ public void setBlockIcon(ImageIcon blockIcon) {
+ this.blockIcon = prepareIcon(blockIcon);
+ firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon);
+ setDirty(true);
+ }
+
+ public void setCanClick(boolean canClick) {
+ boolean oldvalue = this.canClick;
+ this.canClick = canClick;
+ firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick);
+ if (oldvalue != canClick) {
+ setDirty(true);
+ }
+ }
+
+ public void setBlock(boolean block) {
+ boolean oldvalue = this.block;
+ this.block = block;
+ firePropertyChange(BLOCK_PROPERTY, oldvalue, block);
+ if (oldvalue != block) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean isDirty) {
+ super.setDirty(isDirty);
+ }
+
+ public void setBlockIcon(BufferedImage blockIcon) {
+ this.blockIcon = blockIcon;
+ }
+
+ public void setBlockingColor(Color blockingColor) {
+ this.blockingColor = blockingColor;
+ }
+
+ public BufferedImage getBlockIcon() {
+ return blockIcon;
+ }
+
+ protected BufferedImage getAcceptIcon() {
+ return acceptIcon;
+ }
+
+ public boolean isCanClick() {
+ return canClick;
+ }
+
+ public void setUseIcon(boolean useIcon) {
+ boolean oldvalue = this.useIcon;
+ this.useIcon = useIcon;
+ if (oldvalue != useIcon) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public BlockingLayerUI clone() {
+ BlockingLayerUI clone = new BlockingLayerUI();
+ clone.acceptAction = acceptAction;
+ clone.acceptIcon = acceptIcon;
+ clone.blockIcon = blockIcon;
+ clone.useIcon = useIcon;
+ clone.block = block;
+ clone.blockingColor = blockingColor;
+ clone.setCanClick(false);
+ return clone;
+ }
+
+ @Override
+ protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
+ if (useIcon || block) {
+ e.consume();
+ }
+ }
+
+ @Override
+ protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (useIcon) {
+ updateCanClickState(l, e);
+ }
+ if (useIcon || block) {
+ e.consume();
+ }
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (useIcon) {
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ updateCanClickState(l, e);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
+ }
+ if (useIcon || block) {
+ e.consume();
+ }
+
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ if (block && blockingColor != null) {
+ // to be in sync with the view if the layer has a border
+ /*Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+
+ g2.setColor(blockingColor);
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
+ if (useIcon && getCurrentIcon() != null) {
+ g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
+ }
+ }
+
+ protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (acceptAction != null) {
+ acceptAction.putValue("layer", l);
+ Component source = l.getView();
+ acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
+ }
+ }
+
+ protected BufferedImage getCurrentIcon() {
+ return canClick ? acceptIcon : blockIcon;
+ }
+
+ protected BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) {
+ // udpate toolTipText
+ Point layerLocation = l.getView().getLocation();
+ Point mousePoint = e.getPoint();
+ BufferedImage currentIcon = getCurrentIcon();
+ if (currentIcon == null) {
+ setCanClick(false);
+ return;
+ }
+ int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth();
+ int maxX = (int) layerLocation.getX() + l.getWidth();
+ int minY = 0;
+ int maxY = currentIcon.getHeight();
+ boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX;
+ accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY;
+ setCanClick(accept);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,217 @@
+package jaxx.runtime.swing;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ *
+ * A JXLayer ui implementation that permits to block a component but still
+ * allow an action when clicking everywhere on the layer.
+ *
+ * Moreover, an icon can be added on the right-top icon painted and changed
+ * when the mouse is over the layer.
+ *
+ * You can change the blocking and accepting icon.
+ *
+ * To hook an click on the layer's icon, you can :
+ *
+ * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li>
+ * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
+ * </ul>
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class BlockingLayerUI2 extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
+
+ public static final String CAN_CLICK_PROPERTY = "canClick";
+ public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
+ public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ private static final long serialVersionUID = 1L;
+ /**
+ * Action to be treated when click on icon
+ */
+ protected Action acceptAction;
+ /**
+ * Icon when you can not click
+ */
+ protected BufferedImage blockIcon;
+ /**
+ * Icon when you can click
+ */
+ protected BufferedImage acceptIcon;
+ /**
+ * Optinal color to put fill background when blocking
+ */
+ protected Color blockingColor;
+ /**
+ * Internal state to known when we can accept click
+ */
+ protected boolean canClick;
+
+ public void setAcceptAction(Action acceptAction) {
+ this.acceptAction = acceptAction;
+ }
+
+ public void setAcceptIcon(ImageIcon acceptIcon) {
+ this.acceptIcon = prepareIcon(acceptIcon);
+ firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon);
+ setDirty(true);
+ }
+
+ public void setBlockIcon(ImageIcon blockIcon) {
+ this.blockIcon = prepareIcon(blockIcon);
+ firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon);
+ setDirty(true);
+ }
+
+ public void setCanClick(boolean canClick) {
+ boolean oldvalue = this.canClick;
+ this.canClick = canClick;
+ firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick);
+ if (oldvalue != canClick) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean isDirty) {
+ super.setDirty(isDirty);
+ }
+
+ public void setBlockingColor(Color blockingColor) {
+ this.blockingColor = blockingColor;
+ }
+
+ public void setBlockIcon(BufferedImage blockIcon) {
+ this.blockIcon = blockIcon;
+ }
+
+ public BufferedImage getBlockIcon() {
+ return blockIcon;
+ }
+
+ protected BufferedImage getAcceptIcon() {
+ return acceptIcon;
+ }
+
+ public boolean isCanClick() {
+ return canClick;
+ }
+
+ @Override
+ public BlockingLayerUI2 clone() {
+ BlockingLayerUI2 clone = new BlockingLayerUI2();
+ clone.acceptAction = acceptAction;
+ clone.acceptIcon = acceptIcon;
+ clone.blockIcon = blockIcon;
+ clone.blockingColor = blockingColor;
+ clone.setCanClick(false);
+ return clone;
+ }
+
+ @Override
+ protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
+ e.consume();
+ }
+
+ @Override
+ protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
+ e.consume();
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ setCanClick(true);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
+ e.consume();
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ if (blockingColor != null) {
+ // to be in sync with the view if the layer has a border
+ /*Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+
+ g2.setColor(blockingColor);
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
+ if (getCurrentIcon() != null) {
+ g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
+ }
+ }
+
+ protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (acceptAction != null) {
+ acceptAction.putValue("layer", l);
+ Component source = l.getView();
+ acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
+ }
+ }
+
+ protected BufferedImage getCurrentIcon() {
+ return canClick ? acceptIcon : blockIcon;
+ }
+
+ protected BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) {
+ // udpate toolTipText
+ Point layerLocation = l.getView().getLocation();
+ Point mousePoint = e.getPoint();
+ BufferedImage currentIcon = getCurrentIcon();
+ if (currentIcon == null) {
+ setCanClick(false);
+ return;
+ }
+ int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth();
+ int maxX = (int) layerLocation.getX() + l.getWidth();
+ int minY = 0;
+ int maxY = currentIcon.getHeight();
+ boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX;
+ accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY;
+ setCanClick(accept);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,61 @@
+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;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,221 @@
+package jaxx.runtime.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * An override of the awt {@link java.awt.CardLayout}.
+ * <p/>
+ * Because in the original layout is not overridable : everything is package level accessible.
+ * <p/>
+ * This new class offers to test if a constrains (as a Serializable) is actually dealed by the layout,
+ * via the method {@link #contains(java.io.Serializable)}.
+ * <p/>
+ * We had also another method to obtain the current visible component in a container layouted by the class,
+ * via the method {@link #getVisibleComponent(java.awt.Container)}.
+ *
+ * @author chemit
+ * @version 1.0
+ */
+public class CardLayout2 extends CardLayout {
+
+ /** log */
+ static private Log log = LogFactory.getLog(CardLayout2.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /** list of already loaded context (since the {@link #vector} attribute is package visible... */
+ protected List<Serializable> contexts = new LinkedList<Serializable>();
+
+ /**
+ * A flag to compute dimension only on visible component.
+ * <p/>
+ * This is usefull when we only care of the visible component.
+ */
+ protected boolean useOnlyVisibleComponentDimension;
+
+ @Override
+ public void addLayoutComponent(Component comp, Object constraints) {
+ super.addLayoutComponent(comp, constraints);
+ contexts.add((Serializable) constraints);
+ if (log.isDebugEnabled()) {
+ log.debug(this + " new constraints : " + constraints);
+ }
+ }
+
+ /**
+ * Test if a constrains is contained in the layout.
+ *
+ * @param constraints l'identifiant a tester
+ * @return <code>true</code> si l'identifiant est deja present dans le layout, <code>false</code> autrement.
+ */
+ public boolean contains(Serializable constraints) {
+ return contexts.contains(constraints);
+ }
+
+ /**
+ * Obtain the visible component in the container.
+ *
+ * @param container the container using this layout
+ * @return the component visible in the container.
+ */
+ public Component getVisibleComponent(Container container) {
+ if (container.getLayout() != this) {
+ throw new IllegalArgumentException("the container is not managed by the current layout");
+ }
+ for (Component component : container.getComponents()) {
+ if (component.isVisible()) {
+ return component;
+ }
+ }
+ // no component actually visible
+ return null;
+ }
+
+ public Component getComponent(Container container, String constraints) {
+ if (container.getLayout() != this) {
+ throw new IllegalArgumentException("the container is not manage by the current layout");
+ }
+ if (!contexts.contains(constraints)) {
+ throw new IllegalArgumentException("the constraints '" + constraints + "' is not supported by this layout : " + contexts);
+ }
+ int index = contexts.indexOf(constraints);
+ return container.getComponents()[index];
+ }
+
+ /**
+ * Determines the preferred size of the container argument using
+ * this card layout.
+ *
+ * @param parent the parent container in which to do the layout
+ * @return the preferred dimensions to lay out the subcomponents
+ * of the specified container
+ * @see java.awt.Container#getPreferredSize
+ * @see java.awt.CardLayout#minimumLayoutSize
+ */
+ @Override
+ public Dimension preferredLayoutSize(Container parent) {
+ Dimension dimension = null;
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(parent);
+ if (comp != null) {
+ dimension = comp.getPreferredSize();
+ }
+ }
+ if (dimension == null) {
+ dimension = super.preferredLayoutSize(parent);
+ }
+ return dimension;
+ }
+
+ /**
+ * Calculates the minimum size for the specified panel.
+ *
+ * @param parent the parent container in which to do the layout
+ * @return the minimum dimensions required to lay out the
+ * subcomponents of the specified container
+ * @see java.awt.Container#doLayout
+ * @see java.awt.CardLayout#preferredLayoutSize
+ */
+ @Override
+ public Dimension minimumLayoutSize(Container parent) {
+ Dimension dimension = null;
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(parent);
+ if (comp != null) {
+ dimension = comp.getMinimumSize();
+ }
+ }
+ if (dimension == null) {
+ dimension = super.minimumLayoutSize(parent);
+ }
+ return dimension;
+ }
+
+ /**
+ * Returns the maximum dimensions for this layout given the components
+ * in the specified target container.
+ *
+ * @param target the component which needs to be laid out
+ * @see java.awt.Container
+ * @see #minimumLayoutSize
+ * @see #preferredLayoutSize
+ */
+ @Override
+ public Dimension maximumLayoutSize(Container target) {
+ Dimension dimension = null;
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(target);
+ if (comp != null) {
+ dimension = comp.getMaximumSize();
+ }
+ }
+ if (dimension == null) {
+ dimension = super.maximumLayoutSize(target);
+ }
+ return dimension;
+ }
+
+ /**
+ * Lays out the specified container using this card layout.
+ * <p/>
+ * Each component in the <code>parent</code> container is reshaped
+ * to be the size of the container, minus space for surrounding
+ * insets, horizontal gaps, and vertical gaps.
+ *
+ * @param parent the parent container in which to do the layout
+ * @see java.awt.Container#doLayout
+ */
+ @Override
+ public void layoutContainer(Container parent) {
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(parent);
+ if (comp != null) {
+ //dimension = comp.getMinimumSize();
+ Insets insets = parent.getInsets();
+ comp.setBounds(getHgap() + insets.left, getVgap() + insets.top,
+ parent.getWidth() - (getHgap() * 2 + insets.left + insets.right),
+ parent.getHeight() - (getVgap() * 2 + insets.top + insets.bottom));
+ } else {
+ super.layoutContainer(parent);
+ }
+ } else {
+ super.layoutContainer(parent);
+ }
+ }
+
+ public boolean isUseOnlyVisibleComponentDimension() {
+ return useOnlyVisibleComponentDimension;
+ }
+
+ public void setUseOnlyVisibleComponentDimension(boolean useOnlyVisibleComponentDimension) {
+ this.useOnlyVisibleComponentDimension = useOnlyVisibleComponentDimension;
+ }
+
+ /**
+ * remove from cardlayout and linked container all his components.
+ *
+ * @param parent the parent container linked with the layout
+ */
+ public void reset(Container parent) {
+ if (parent.getLayout() != this) {
+ throw new IllegalArgumentException("wrong parent for CardLayout");
+ }
+ for (Component component : parent.getComponents()) {
+ removeLayoutComponent(component);
+ parent.remove(component);
+ }
+ contexts.clear();
+
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,99 @@
+package jaxx.runtime.swing;
+
+import java.awt.Container;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Une extension de {@link CardLayout2} pour pouvoir automatiquement afficher un
+ * contenu à partir de la propriété {@link #selected}.
+ *
+ * Ainsi, en changeant cette propriété via la méthode {@link #setSelected(String)},
+ * le contenu sera changé automatiquement, ce qui permet une utilisation direct
+ * dans jaxx sans à avoir à écrire d'écouteur.
+ *
+ * @author tony
+ * @since 1.3
+ * @see CardLayout2
+ */
+public class CardLayout2Ext extends CardLayout2 {
+
+ /** log */
+ static private Log log = LogFactory.getLog(CardLayout2.class);
+ private static final long serialVersionUID = 1L;
+ public static final String SELECTED_PROPERTY_NAME = "selected";
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+ /**
+ * le contenu sélectionné
+ */
+ protected String selected;
+ private String containerName;
+ private JAXXObject ui;
+ private Container container;
+
+ public CardLayout2Ext(JAXXObject ui, String containerName) {
+ pcs = new PropertyChangeSupport(this);
+ this.ui = ui;
+ this.containerName = containerName;
+ }
+
+ public String getSelected() {
+ return selected;
+ }
+
+ public String getPreviousSelected() {
+ int index = contexts.indexOf(selected);
+ if (index < 1) {
+ return null;
+ }
+ return contexts.get(index - 1) + "";
+ }
+
+ public String getNextSelected() {
+ int index = contexts.indexOf(selected);
+ if (index >= contexts.size()) {
+ return null;
+ }
+ return contexts.get(index + 1) + "";
+ }
+
+ public void setSelected(String selected) {
+ this.selected = selected;
+ show(getContainer(), selected);
+ }
+
+ public Container getContainer() {
+ if (container == null) {
+ container = (Container) ui.getObjectById(containerName);
+ }
+ return container;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,37 @@
+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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,47 @@
+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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/GBC.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,151 @@
+/**
+ * *##% Lutin I18n Editor
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+/*
+GBC - A convenience class to tame the GridBagLayout
+
+Copyright (C) 2002 Cay S. Horstmann (http://horstmann.com)
+
+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 jaxx.runtime.swing;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+
+/**
+ * This class simplifies the use of the GridBagConstraints
+ * class.
+ */
+public class GBC extends GridBagConstraints {
+ private static final long serialVersionUID = -3626882543530638704L;
+
+ /**
+ * Constructs a GBC with a given gridx and gridy position and
+ * all other grid bag constraint values set to the default.
+ *
+ * @param gridx the gridx position
+ * @param gridy the gridy position
+ */
+ public GBC(int gridx, int gridy) {
+ this.gridx = gridx;
+ this.gridy = gridy;
+ }
+
+ /**
+ * Constructs a GBC with given gridx, gridy, gridwidth, gridheight
+ * and all other grid bag constraint values set to the default.
+ *
+ * @param gridx the gridx position
+ * @param gridy the gridy position
+ * @param gridwidth the cell span in x-direction
+ * @param gridheight the cell span in y-direction
+ */
+ public GBC(int gridx, int gridy, int gridwidth, int gridheight) {
+ this.gridx = gridx;
+ this.gridy = gridy;
+ this.gridwidth = gridwidth;
+ this.gridheight = gridheight;
+ }
+
+ /**
+ * Sets the anchor.
+ *
+ * @param anchor the anchor value
+ * @return this object for further modification
+ */
+ public GBC setAnchor(int anchor) {
+ this.anchor = anchor;
+ return this;
+ }
+
+ /**
+ * Sets the fill direction.
+ *
+ * @param fill the fill direction
+ * @return this object for further modification
+ */
+ public GBC setFill(int fill) {
+ this.fill = fill;
+ return this;
+ }
+
+ /**
+ * Sets the cell weights.
+ *
+ * @param weightx the cell weight in x-direction
+ * @param weighty the cell weight in y-direction
+ * @return this object for further modification
+ */
+ public GBC setWeight(double weightx, double weighty) {
+ this.weightx = weightx;
+ this.weighty = weighty;
+ return this;
+ }
+
+ /**
+ * Sets the insets of this cell.
+ *
+ * @param distance the spacing to use in all directions
+ * @return this object for further modification
+ */
+ public GBC setInsets(int distance) {
+ this.insets = new Insets(distance, distance, distance, distance);
+ return this;
+ }
+
+ /**
+ * Sets the insets of this cell.
+ *
+ * @param top the spacing to use on top
+ * @param left the spacing to use to the left
+ * @param bottom the spacing to use on the bottom
+ * @param right the spacing to use to the right
+ * @return this object for further modification
+ */
+ public GBC setInsets(int top, int left, int bottom, int right) {
+ this.insets = new Insets(top, left, bottom, right);
+ return this;
+ }
+
+ /**
+ * Sets the internal padding
+ *
+ * @param ipadx the internal padding in x-direction
+ * @param ipady the internal padding in y-direction
+ * @return this object for further modification
+ */
+ public GBC setIpad(int ipadx, int ipady) {
+ this.ipadx = ipadx;
+ this.ipady = ipady;
+ return this;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/HBox.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import java.awt.Insets;
+
+/**
+ * Panel which uses an {@link HBoxLayout} by default.
+ *
+ * @author Ethan Nicholas
+ */
+public class HBox extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ public static final String SPACING_PROPERTY = "spacing";
+ public static final String MARGIN_PROPERTY = "margin";
+ public static final String HORIZONTAL_ALIGNMENT_PROPERTY = "horizontalAlignment";
+ public static final String VERTICAL_ALIGNMENT_PROPERTY = "verticalAlignment";
+ private Insets margin;
+
+ public HBox() {
+ super(new HBoxLayout());
+ }
+
+ /**
+ * Returns the spacing between components, in pixels. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @return spacing between components
+ */
+ public int getSpacing() {
+ return ((HBoxLayout) getLayout()).getSpacing();
+ }
+
+ /**
+ * Sets the spacing between components. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @param spacing new spacing value
+ */
+ public void setSpacing(int spacing) {
+ int oldValue = getSpacing();
+ ((HBoxLayout) getLayout()).setSpacing(spacing);
+ firePropertyChange(SPACING_PROPERTY, oldValue, spacing);
+ revalidate();
+ }
+
+ public int getHorizontalAlignment() {
+ return ((HBoxLayout) getLayout()).getHorizontalAlignment();
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ int oldValue = getHorizontalAlignment();
+ ((HBoxLayout) getLayout()).setHorizontalAlignment(horizontalAlignment);
+ firePropertyChange(HORIZONTAL_ALIGNMENT_PROPERTY, oldValue, horizontalAlignment);
+ revalidate();
+ }
+
+ public int getVerticalAlignment() {
+ return ((HBoxLayout) getLayout()).getVerticalAlignment();
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ int oldValue = getVerticalAlignment();
+ ((HBoxLayout) getLayout()).setVerticalAlignment(verticalAlignment);
+ firePropertyChange(VERTICAL_ALIGNMENT_PROPERTY, oldValue, verticalAlignment);
+ revalidate();
+ }
+
+ public Insets getMargin() {
+ return margin;
+ }
+
+ public void setMargin(Insets margin) {
+ Insets oldValue = this.margin;
+ this.margin = (Insets) margin.clone();
+ firePropertyChange(MARGIN_PROPERTY, oldValue, margin);
+ }
+
+ @Override
+ public Insets getInsets() {
+ Insets result = super.getInsets();
+ if (margin != null) {
+ result.top += margin.top;
+ result.left += margin.left;
+ result.right += margin.right;
+ result.bottom += margin.bottom;
+ }
+ return result;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/HBoxLayout.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.SwingConstants;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Horizontal box layout. The layout rules followed by this class are quite different than the core BoxLayout class,
+ * and in general represent a more useful algorithm.
+ *
+ * @author Ethan Nicholas
+ */
+public class HBoxLayout implements LayoutManager {
+
+ private int spacing = 6;
+ private int horizontalAlignment = SwingConstants.LEFT;
+ private int verticalAlignment = SwingConstants.TOP;
+
+ public int getSpacing() {
+ return spacing;
+ }
+
+ public void setSpacing(int spacing) {
+ this.spacing = spacing;
+ }
+
+ public int getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public int getVerticalAlignment() {
+ return verticalAlignment;
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ this.verticalAlignment = verticalAlignment;
+ }
+
+ @Override
+ public void addLayoutComponent(String name, Component comp) {
+ }
+
+ @Override
+ public void layoutContainer(Container parent) {
+ Insets insets = parent.getInsets();
+ int parentHeight = parent.getSize().height - insets.top - insets.bottom;
+ int count = parent.getComponentCount();
+ Dimension preferredSize = parent.getPreferredSize();
+ int x;
+ switch (horizontalAlignment) {
+ case SwingConstants.LEFT:
+ x = insets.left;
+ break;
+ case SwingConstants.CENTER:
+ x = insets.left + (parent.getWidth() - preferredSize.width) / 2;
+ break;
+ case SwingConstants.RIGHT:
+ x = insets.left + (parent.getWidth() - preferredSize.width);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid horizontal alignment: " + horizontalAlignment);
+ }
+
+ for (int i = 0; i < count; i++) {
+ Component component = parent.getComponent(i);
+ Dimension childPreferredSize = component.getPreferredSize();
+ int height = Math.min(childPreferredSize.height, parentHeight);
+ int y;
+ switch (verticalAlignment) {
+ case SwingConstants.TOP:
+ y = insets.top;
+ break;
+ case SwingConstants.CENTER:
+ y = insets.top + (parentHeight - childPreferredSize.height) / 2;
+ break;
+ case SwingConstants.BOTTOM:
+ y = insets.top + (parentHeight - childPreferredSize.height);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid vertical alignment: " + verticalAlignment);
+ }
+ component.setBounds(x, y, childPreferredSize.width, height);
+ x += childPreferredSize.width + spacing;
+ }
+ }
+
+ @Override
+ public Dimension minimumLayoutSize(Container parent) {
+ int width = (parent.getComponentCount() - 1) * spacing;
+ int height = 0;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension minimumSize = parent.getComponent(i).getMinimumSize();
+ width += minimumSize.width;
+ height = Math.max(height, minimumSize.height);
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public Dimension preferredLayoutSize(Container parent) {
+ int width = (parent.getComponentCount() - 1) * spacing;
+ int height = 0;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension preferredSize = parent.getComponent(i).getPreferredSize();
+ width += preferredSize.width;
+ height = Math.max(height, preferredSize.height);
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public void removeLayoutComponent(Component comp) {
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,66 @@
+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;
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Item.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.event.SwingPropertyChangeSupport;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.List;
+
+// This needs to be split into two classes, Item and TreeItem
+/**
+ * An item in a component such as <code>JComboBox</code> or <code>JTree</code>. The <code>Item</code>
+ * class corresponds to the <code><item></code> tag in JAXX source files.
+ */
+public class Item {
+
+ public static final String LABEL_PROPERTY = "label";
+ public static final String VALUE_PROPERTY = "value";
+ public static final String SELECTED_PROPERTY = "selected";
+ private String id;
+ private String label;
+ private Object value;
+ private boolean selected;
+ private List<Item> children;
+ private Item parent;
+ private PropertyChangeSupport propertyChangeSupport;
+
+ /**
+ * Creates a new Item. This should only be called from compiled JAXX files.
+ *
+ * @param id the item's ID
+ * @param label the string that should be used to represent the item visually
+ * @param value the item's actual value
+ * @param selected <code>true</code> if the item should be selected by default
+ */
+ public Item(String id, String label, Object value, boolean selected) {
+ this.id = id;
+ this.label = label;
+ this.value = value;
+ this.selected = selected;
+ }
+
+ /**
+ * Returns this item's ID.
+ *
+ * @return the JAXX ID attribute
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the string that should be used to represent the item at display time. If <code>null</code>,
+ * <code>String.valueOf(getValue())</code> will be used instead.
+ *
+ * @return this item's display string
+ * @see #setLabel
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * Sets the item's display string. If <code>null, String.valueOf(getValue())</code> will be used instead.
+ *
+ * @param label the new display string
+ * @see #getLabel
+ */
+ public void setLabel(String label) {
+ String oldLabel = this.label;
+ this.label = label;
+ firePropertyChange(LABEL_PROPERTY, oldLabel, label);
+ }
+
+ /**
+ * Returns the item's actual value as it appears in the component's model. The <code>Item</code> itself is not
+ * visible from the model, only the value.
+ *
+ * @return the item's value
+ * @see #setValue
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the item's value as it appears in the component's model. The <code>Item</code> itself is not
+ * visible from the model, only the value.
+ *
+ * @param value the new value
+ * @see #getValue
+ */
+ public void setValue(Object value) {
+ Object oldValue = this.value;
+ this.value = value;
+ firePropertyChange(VALUE_PROPERTY, oldValue, value);
+ }
+
+ /**
+ * Returns <code>true</code> if this item is currently selected. This is a bound property.
+ *
+ * @return <code>true</code> if item is selected
+ * @see #setSelected
+ */
+ public boolean isSelected() {
+ return selected;
+ }
+
+ /**
+ * Sets the item's selection state. This is a bound property.
+ *
+ * @param selected the new selection state
+ * @see #isSelected
+ */
+ public void setSelected(boolean selected) {
+ boolean oldSelected = this.selected;
+ this.selected = selected;
+ firePropertyChange(SELECTED_PROPERTY, oldSelected, selected);
+ }
+
+ /**
+ * Adds a new child node (Items can be nested in trees).
+ *
+ * @param item the new child item
+ */
+ public void addChild(Item item) {
+ if (children == null) {
+ children = new ArrayList<Item>();
+ }
+ children.add(item);
+ item.parent = this;
+ }
+
+ /**
+ * Remove child node a new child node
+ *
+ * @param item to remove
+ */
+ public void removeChild(Item item) {
+ if (children != null) {
+ children.remove(item);
+ }
+ }
+
+ /**
+ * Remove all childs nodes
+ *
+ * @param list of items to remove
+ */
+ public void removeChilds(List<Item> items) {
+ if (children != null) {
+ children.removeAll(items);
+ }
+ }
+
+ /**
+ * Returns a list of this item's children.
+ *
+ * @return a list of all nested child nodes
+ */
+ public List<Item> getChildren() {
+ if (children == null) {
+ children = new ArrayList<Item>();
+ }
+ return children;
+ }
+
+ /**
+ * Returns the <code>Item</code> containing this <code>Item</code>, or <code>null</code> for a top-level
+ * <code>Item</code>.
+ *
+ * @return the item parent (or null)
+ */
+ public Item getParent() {
+ return parent;
+ }
+
+ /**
+ * Set the parent of this item
+ *
+ * @return the item parent (or null)
+ */
+ public void setParent(Item parent) {
+ this.parent = parent;
+ }
+
+ private PropertyChangeSupport getPropertyChangeSupport() {
+ if (propertyChangeSupport == null) {
+ propertyChangeSupport = new SwingPropertyChangeSupport(this);
+ }
+ return propertyChangeSupport;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(property, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(property, listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (propertyChangeSupport != null) {
+ getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + value + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.AbstractButton;
+import javax.swing.ButtonGroup;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.EventListenerList;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Enumeration;
+
+public class JAXXButtonGroup extends ButtonGroup {
+
+ public static final String SELECTED_VALUE_PROPERTY = "selectedValue";
+ public static final String BUTTON8GROUP_CLIENT_PROPERTY = "$buttonGroup";
+ public static final String VALUE_CLIENT_PROPERTY = "$value";
+ public static final String SELECTED_TIP_CLIENT_PROPERTY = "$selected.toolTipText";
+ public static final String NOT_SELECTED_TIP_CLIENT_PROPERTY = "$not.selected.toolTipText";
+ protected EventListenerList listenerList = new EventListenerList();
+ private PropertyChangeSupport propertyChangeSupport;
+ private transient Object selectedValue;
+ protected boolean useToolTipText;
+ protected transient ChangeEvent changeEvent = new ChangeEvent(this);
+ private transient ChangeListener changeListener = new ChangeListener() {
+
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ updateSelectedValue();
+ if (useToolTipText) {
+ updateToolTipText();
+ }
+ }
+ };
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void add(AbstractButton button) {
+ super.add(button);
+ button.addChangeListener(changeListener);
+ updateSelectedValue();
+ }
+
+ @Override
+ public void remove(AbstractButton button) {
+ super.remove(button);
+ button.removeChangeListener(changeListener);
+ updateSelectedValue();
+ }
+
+ public void updateSelectedValue() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ if (button.isSelected()) {
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY);
+ if (buttonValue != getSelectedValue()) {
+ setSelectedValue(buttonValue);
+ }
+ }
+ }
+ }
+
+ public void updateToolTipText() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ String key = button.isSelected() ? SELECTED_TIP_CLIENT_PROPERTY : NOT_SELECTED_TIP_CLIENT_PROPERTY;
+ button.setToolTipText((String) button.getClientProperty(key));
+ }
+ }
+
+ public boolean isUseToolTipText() {
+ return useToolTipText;
+ }
+
+ public Object getSelectedValue() {
+ return selectedValue;
+ }
+
+ public AbstractButton getSelectedButton() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ if (button.isSelected()) {
+ return button;
+ }
+ }
+ return null;
+ }
+
+ public AbstractButton getButton(Object value) {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY);
+ if (value.equals(buttonValue)) {
+ return button;
+ }
+ }
+ return null;
+ }
+
+ public void setSelectedValue(Object value) {
+ Object oldValue = getSelectedValue();
+ this.selectedValue = value;
+ firePropertyChange(oldValue);
+ }
+
+ public void setUseToolTipText(boolean useToolTipText) {
+ this.useToolTipText = useToolTipText;
+ }
+
+ public void setSelectedButton(Object value) {
+ setSelectedValue(value);
+ if (value == null) {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ setSelected(button.getModel(), false);
+ }
+ return;
+ }
+
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY);
+ if (value.equals(buttonValue)) {
+ button.setSelected(true);
+ break;
+ }
+ }
+ }
+
+ protected PropertyChangeSupport getPropertyChangeSupport() {
+ if (propertyChangeSupport == null) {
+ propertyChangeSupport = new PropertyChangeSupport(this);
+ }
+ return propertyChangeSupport;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(property, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(property, listener);
+ }
+
+ private void firePropertyChange(Object oldValue) {
+ if (propertyChangeSupport != null) {
+ getPropertyChangeSupport().firePropertyChange(SELECTED_VALUE_PROPERTY,
+ oldValue, getSelectedValue());
+ }
+ fireStateChanged();
+ }
+
+ /**
+ * Adds a <code>ChangeListener</code> to the button.
+ *
+ * @param l the listener to be added
+ */
+ public void addChangeListener(ChangeListener l) {
+ listenerList.add(ChangeListener.class, l);
+ }
+
+ /**
+ * Removes a ChangeListener from the button.
+ *
+ * @param l the listener to be removed
+ */
+ public void removeChangeListener(ChangeListener l) {
+ listenerList.remove(ChangeListener.class, l);
+ }
+
+ /**
+ * Returns an array of all the <code>ChangeListener</code>s added
+ * to this AbstractButton with addChangeListener().
+ *
+ * @return all of the <code>ChangeListener</code>s added or an empty
+ * array if no listeners have been added
+ * @since 1.4
+ */
+ public ChangeListener[] getChangeListeners() {
+ return listenerList.getListeners(ChangeListener.class);
+ }
+
+ /**
+ * Notifies all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created.
+ *
+ * @see EventListenerList
+ */
+ protected void fireStateChanged() {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == ChangeListener.class) {
+ // Lazily create the event:
+ if (changeEvent == null) {
+ changeEvent = new ChangeEvent(this);
+ }
+ ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.ListModel;
+import java.awt.Component;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class JAXXComboBox extends JComboBox {
+
+ private static final long serialVersionUID = 1L;
+
+ public class JAXXComboBoxModel extends AbstractListModel implements ComboBoxModel {
+
+ private List<Item> items;
+ private Object selectedItem;
+ private static final long serialVersionUID = -8940733376638766414L;
+
+ public JAXXComboBoxModel(List<Item> items) {
+ this.items = items;
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) {
+ Item item = (Item) e.getSource();
+ int itemIndex = JAXXComboBoxModel.this.items.indexOf(item);
+ // TODO: fix cut-and-pasting badness
+ int[] oldSelection = new int[]{getSelectedIndex()};
+ int[] newSelection;
+ int index = -1;
+ for (int i = 0; i < oldSelection.length; i++) {
+ if (oldSelection[i] == itemIndex) {
+ index = i;
+ break;
+ }
+ }
+ if (item.isSelected()) {
+ if (index != -1) // it was already selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length + 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, oldSelection.length);
+ newSelection[newSelection.length - 1] = itemIndex;
+ } else {
+ if (index == -1) // it already wasn't selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length - 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, index);
+ System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index);
+ }
+ if (newSelection.length > 0) {
+ setSelectedIndex(newSelection[0]);
+ }
+ } else {
+ // TODO: more cut-and-pasting badness
+ for (int i = 0; i < getSize(); i++) {
+ if (getElementAt(i) == ((Item) e.getSource()).getValue()) {
+ fireContentsChanged(JAXXComboBoxModel.this, i, i);
+ if (getSelectedIndex() == i) {
+ fireItemStateChanged(new ItemEvent(JAXXComboBox.this, ItemEvent.ITEM_STATE_CHANGED, getElementAt(i), ItemEvent.DESELECTED));
+ }
+ return;
+ }
+ }
+ }
+ }
+ };
+ for (Item item : items) {
+ item.addPropertyChangeListener(listener);
+ }
+ }
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ @Override
+ public Object getElementAt(int i) {
+ return items.get(i).getValue();
+ }
+
+ @Override
+ public int getSize() {
+ return items.size();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedItem;
+ }
+
+ @Override
+ public void setSelectedItem(Object selectedItem) {
+ if ((this.selectedItem != null && !this.selectedItem.equals(selectedItem)) ||
+ this.selectedItem == null && selectedItem != null) {
+ this.selectedItem = selectedItem;
+ fireContentsChanged(this, -1, -1);
+ }
+ }
+ }
+
+ public JAXXComboBox() {
+ setRenderer(new DefaultListCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ ListModel model = list.getModel();
+ if (model instanceof JAXXComboBoxModel) {
+ List/*<Item>*/ items = ((JAXXComboBoxModel) model).items;
+ Item item = null;
+ if (index == -1) {
+ for (Object item1 : items) {
+ Item testItem = (Item) item1;
+ if (testItem.getValue() == value) {
+ item = testItem;
+ break;
+ }
+ }
+ } else {
+ item = (Item) items.get(index);
+ }
+
+ if (item != null) {
+ String label = item.getLabel();
+ if (label != null) {
+ value = label;
+ }
+ }
+ }
+ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+ });
+
+ addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ ListModel model = getModel();
+ if (model instanceof JAXXComboBoxModel) {
+ List<Item> items = ((JAXXComboBoxModel) model).items;
+ for (int i = items.size() - 1; i >= 0; i--) {
+ boolean selected = getSelectedIndex() == i;
+ Item item = items.get(i);
+ if (selected != item.isSelected()) {
+ item.setSelected(selected);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ * @param methodName method to invoke to display data's name
+ */
+ public void fillComboBox(Collection<?> data, Object select, String methodName) {
+ // prepare method to use
+ Method m;
+ try {
+ m = select.getClass().getMethod(methodName);
+ m.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("could not find method " + methodName + " on " + select.getClass());
+ }
+
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = o.equals(select);
+ try {
+ items.add(new Item(o.toString(), (String) m.invoke(o), o, selected));
+ } catch (IllegalAccessException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ }
+ }
+ setItems(items);
+ }
+
+ // this way we can keep it marked protected and still allow code in this file to call it
+ @Override
+ protected void fireItemStateChanged(ItemEvent e) {
+ super.fireItemStateChanged(e);
+ }
+
+ public void setItems(List<Item> items) {
+ setModel(new JAXXComboBoxModel(items));
+ List<Integer> selectedIndexList = new ArrayList<Integer>();
+ for (int i = 0; i < items.size(); i++) {
+ if (items.get(i).isSelected()) {
+ selectedIndexList.add(i);
+ }
+ }
+ int[] selectedIndices = new int[selectedIndexList.size()];
+ for (int i = 0; i < selectedIndexList.size(); i++) {
+ selectedIndices[i] = selectedIndexList.get(i);
+ }
+ if (selectedIndices.length > 0) {
+ setSelectedIndex(selectedIndices[0]);
+ }
+ }
+
+ public List<Item> getItems() {
+ if (getModel() instanceof JAXXComboBoxModel) {
+ return ((JAXXComboBoxModel) getModel()).getItems();
+ }
+ return null;
+ }
+
+ public void setSelectedItem(Item item) {
+ //TC-20092004 Anomalie #73 fix npe when want to call with a null
+ // value
+ super.setSelectedItem(item == null ? null : item.getValue());
+ }
+
+ public Item getSelectedJaxxItem() {
+ Object selected = super.getSelectedItem();
+ return findItem(selected);
+ }
+
+ public Item findItem(Object value) {
+ List<Item> items = getItems();
+ if (items != null) {
+ for (Item i : items) {
+ if (i.getValue().equals(value)) {
+ return i;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void addItem(Item item) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.add(item);
+ setItems(items);
+ }
+ }
+
+ public void addAllItems(Collection<Item> itemsToAdd) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.addAll(itemsToAdd);
+ setItems(items);
+ }
+ }
+
+ public void removeItem(Item item) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.remove(item);
+ setItems(items);
+ }
+ }
+
+ public void removeAllItems(Collection<Item> itemsToRemove) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.removeAll(itemsToRemove);
+ setItems(items);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXList.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,396 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.AbstractListModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JList;
+import javax.swing.ListModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class JAXXList extends JList {
+
+ private static final long serialVersionUID = 1L;
+
+ public class JAXXListModel extends AbstractListModel {
+
+ private List<Item> items;
+ private static final long serialVersionUID = -1598924187490122036L;
+
+ public JAXXListModel(List<Item> items) {
+ this.items = items;
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) {
+ Item item = (Item) e.getSource();
+ int itemIndex = JAXXListModel.this.items.indexOf(item);
+ int[] oldSelection = getSelectedIndices();
+ int[] newSelection;
+ int index = -1;
+ for (int i = 0; i < oldSelection.length; i++) {
+ if (oldSelection[i] == itemIndex) {
+ index = i;
+ break;
+ }
+ }
+ if (item.isSelected()) {
+ if (index != -1) // it was already selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length + 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, oldSelection.length);
+ newSelection[newSelection.length - 1] = itemIndex;
+ } else {
+ if (index == -1) // it already wasn't selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length - 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, index);
+ System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index);
+ }
+ setSelectedIndices(newSelection);
+ } else {
+ for (int i = 0; i < getSize(); i++) {
+ if (getElementAt(i) == ((Item) e.getSource()).getValue()) {
+ fireContentsChanged(JAXXListModel.this, i, i);
+ if (isSelectedIndex(i)) {
+ fireSelectionValueChanged(i, i, false);
+ }
+ return;
+ }
+ }
+ }
+ }
+ };
+ for (Item item : items) {
+ item.addPropertyChangeListener(listener);
+ }
+ }
+
+ public List<Item> getItems(){
+ return items;
+ }
+
+ @Override
+ public Object getElementAt(int i) {
+ return items.get(i).getValue();
+ }
+
+ @Override
+ public int getSize() {
+ return items.size();
+ }
+ }
+
+ public JAXXList() {
+ setCellRenderer(new DefaultListCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ ListModel model = list.getModel();
+ if (model instanceof JAXXListModel) {
+ Item item = ((JAXXListModel) model).items.get(index);
+ String label = item.getLabel();
+ if (label != null) {
+ value = label;
+ }
+ }
+ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+ });
+
+ addListSelectionListener(new ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ ListModel model = getModel();
+ if (model instanceof JAXXListModel) {
+ List<Item> items = ((JAXXListModel) model).items;
+ for (int i = items.size() - 1; i >= 0; i--) {
+ boolean selected = isSelectedIndex(i);
+ Item item = items.get(i);
+ if (selected != item.isSelected()) {
+ item.setSelected(selected);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ // this way we can keep it marked protected and still allow code in this file to call it
+ @Override
+ protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) {
+ super.fireSelectionValueChanged(firstIndex, lastIndex, isAdjusting);
+ }
+
+ public void setItems(List<Item> items) {
+ setModel(new JAXXListModel(items));
+ List<Integer> selectedIndexList = new ArrayList<Integer>();
+ for (int i = 0; i < items.size(); i++) {
+ if (items.get(i).isSelected()) {
+ selectedIndexList.add(i);
+ }
+ }
+ int[] selectedIndices = new int[selectedIndexList.size()];
+ for (int i = 0; i < selectedIndexList.size(); i++) {
+ selectedIndices[i] = selectedIndexList.get(i);
+ }
+ setSelectedIndices(selectedIndices);
+ }
+
+ public List<Item> getItems(){
+ if (getModel() instanceof JAXXListModel){
+ return ((JAXXListModel)getModel()).getItems();
+ }
+ return null;
+ }
+
+ public void setSelectedValue(Object value) {
+ super.setSelectedValue(value, true);
+ }
+
+ /**
+ * Set the selected Objects
+ *
+ * @param values Objects must be selected in the list
+ */
+ public void setSelectedValues(Object[] values) {
+ if (values != null){
+ List<Integer> selectedIndices = new ArrayList<Integer>();
+ ListModel model = getModel();
+ for (int i = 0; i < model.getSize(); i++) {
+ Object o = model.getElementAt(i);
+ for (Object value : values) {
+ if (o.equals(value)) {
+ selectedIndices.add(i);
+ break;
+ }
+ }
+ }
+ int[] ints = new int[selectedIndices.size()];
+ for (int i = 0; i < ints.length; i++) {
+ ints[i] = selectedIndices.get(i).intValue();
+ }
+ setSelectedIndices(ints);
+ }
+ else{
+ // No selection if values is null
+ setSelectedIndex(-1);
+ }
+ }
+
+ public void setSelectedItem(Item item) {
+ super.setSelectedValue(item.getValue(), true);
+ }
+
+ public void setSelectedItems(List<Item> itemsToSelect) {
+ if (itemsToSelect != null){
+ List<Item> items = getItems();
+ int[] indices = new int[itemsToSelect.size()];
+ int i = 0;
+ for (Item item : itemsToSelect){
+ indices[i] = items.indexOf(item);
+ i++;
+ }
+ super.setSelectedIndices(indices);
+ }
+ }
+
+ public Item getSelectedItem(){
+ Object selected = super.getSelectedValue();
+ return findItem(selected);
+ }
+
+ public List<Item> getSelectedItems(){
+ Object[] selected = super.getSelectedValues();
+ java.util.List<Item> itemsSelected = new ArrayList<Item>();
+ for (Object s : selected){
+ itemsSelected.add(findItem(s));
+ }
+ return itemsSelected;
+ }
+
+ public Item findItem(Object value){
+ List<Item> items = getItems();
+ if (items != null){
+ for (Item i : items){
+ if (i.getValue().equals(value)){
+ return i;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void addItem(Item item){
+ List<Item> items = getItems();
+ if (items != null){
+ items.add(item);
+ setItems(items);
+ }
+ }
+
+ public void addAllItems(Collection<Item> itemsToAdd){
+ List<Item> items = getItems();
+ if (items != null){
+ items.addAll(itemsToAdd);
+ setItems(items);
+ }
+ }
+
+ public void removeItem(Item item){
+ List<Item> items = getItems();
+ if (items != null){
+ items.remove(item);
+ setItems(items);
+ }
+ }
+
+ public void removeAllItems(Collection<Item> itemsToRemove){
+ List<Item> items = getItems();
+ if (items != null){
+ items.removeAll(itemsToRemove);
+ setItems(items);
+ }
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param selects the objects to select in list after reflling his model
+ */
+ public void fillList(Collection<?> data, Collection<?> selects) {
+ if (selects == null) {
+ selects = java.util.Collections.EMPTY_LIST;
+ }
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = false;
+ for (Object select : selects) {
+ if (selected = o.equals(select)) {
+ break;
+ }
+ }
+ items.add(new Item(o.toString(), o.toString(), o, selected));
+ }
+ setItems(items);
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param select object to select in list after reflling his model
+ */
+ public void fillList(Collection<?> data, Object select) {
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = o.equals(select);
+ items.add(new Item(o.toString(), o.toString(), o, selected));
+ }
+ setItems(items);
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param select object to select in list after reflling his model
+ * @param methodName method to invoke to display data's name
+ */
+ public void fillList(Collection<?> data, Object select, String methodName) {
+ // prepare method to use
+ Method m = null;
+
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = o.equals(select);
+ if (m == null) {
+ try {
+ m = o.getClass().getMethod(methodName);
+ m.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("could not find method " + methodName + " on " + o.getClass());
+ }
+ }
+ try {
+ items.add(new Item(o.toString(), (String) m.invoke(o), o, selected));
+ } catch (SecurityException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ }
+ }
+ setItems(items);
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param selects the objects to select in list after reflling his model
+ * @param methodName method to invoke to display data's name
+ */
+ public void fillList(Collection<?> data, Collection<?> selects, String methodName) {
+ // prepare method to use
+ Method m = null;
+
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = selects.contains(o);
+ if (m == null) {
+ try {
+ m = o.getClass().getMethod(methodName);
+ m.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("could not find method " + methodName + " on " + o.getClass());
+ }
+ }
+ try {
+ items.add(new Item(o.toString(), (String) m.invoke(o), o, selected));
+ } catch (SecurityException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ }
+ }
+ setItems(items);
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXTab.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,25 @@
+/*
+ * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+ * Tony Chemit
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##% */
+package jaxx.runtime.swing;
+
+/** @author chemit */
+public class JAXXTab extends Table {
+
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,92 @@
+package jaxx.runtime.swing;
+
+public class JAXXToggleButton extends javax.swing.JToggleButton {
+
+ private static final long serialVersionUID = 1L;
+ protected String glueText;
+ protected String normalText;
+ protected String glueTooltipText;
+ protected String normalTooltipText;
+ protected int normalMnemonic;
+ protected int glueMnemonic;
+ protected boolean _init;
+
+ public String getGlueText() {
+ return glueText;
+ }
+
+ public String getNormalText() {
+ return normalText;
+ }
+
+ public String getGlueTooltipText() {
+ return glueTooltipText;
+ }
+
+ public String getNormalTooltipText() {
+ return normalTooltipText;
+ }
+
+ public void setGlueText(String glueText) {
+ this.glueText = glueText;
+
+ }
+
+ public void setNormalText(String normalText) {
+ this.normalText = normalText;
+
+ }
+
+ public void setGlueTooltipText(String glueTooltipText) {
+ this.glueTooltipText = glueTooltipText;
+ }
+
+ public int getNormalMnemonic() {
+ return normalMnemonic;
+ }
+
+ public void setNormalMnemonic(int normalMnemonic) {
+ this.normalMnemonic = normalMnemonic;
+ }
+
+ public int getGlueMnemonic() {
+ return glueMnemonic;
+ }
+
+ public void setGlueMnemonic(int glueMnemonic) {
+ this.glueMnemonic = glueMnemonic;
+ }
+
+ public void setNormalTooltipText(String normalTooltipText) {
+ this.normalTooltipText = normalTooltipText;
+ if (!_init) {
+ init();
+ _init = true;
+ }
+ }
+
+ @Override
+ public void setSelected(boolean b) {
+ super.setSelected(b);
+ if (isSelected()) {
+ setText(getGlueText());
+ setToolTipText(getGlueTooltipText());
+ setMnemonic(getGlueMnemonic());
+ } else {
+ setText(getNormalText());
+ setToolTipText(getNormalTooltipText());
+ setMnemonic(getNormalMnemonic());
+ }
+ revalidate();
+ }
+
+ public void init() {
+ setSelected(false);
+ }
+
+ /* end raw body code */
+ public JAXXToggleButton() {
+ super();
+ _init = false;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXTree.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JTree;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JAXXTree extends JTree {
+
+ private static final long serialVersionUID = 1L;
+ private static final String SYNTHETIC = "<synthetic root node>";
+
+ public class JAXXTreeModel implements TreeModel {
+
+ private Item root;
+ private List<TreeModelListener> listeners = new ArrayList<TreeModelListener>();
+
+ public JAXXTreeModel(List<Item> items) {
+ if (items.size() == 1) {
+ this.root = items.get(0);
+ } else {
+ this.root = new Item(null, null, SYNTHETIC, false);
+ for (Item item : items) {
+ root.addChild(item);
+ }
+ }
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) {
+ Item item = (Item) e.getSource();
+ if (item.isSelected()) {
+ addSelectionPath(getTreePath(item));
+ } else {
+ removeSelectionPath(getTreePath(item));
+ }
+ } else {
+ Item item = (Item) e.getSource();
+ boolean root = item.getParent() == null;
+ TreePath path = !root ? getTreePath(item.getParent()) : null;
+ fireTreeNodesChanged(new TreeModelEvent(JAXXTreeModel.this, path,
+ !root ? new int[]{item.getParent().getChildren().indexOf(item)} : null,
+ new Object[]{item.getValue()}));
+ }
+ }
+ };
+ addPropertyChangeListener(root, listener);
+ }
+
+ private void addPropertyChangeListener(Item item, PropertyChangeListener listener) {
+ item.addPropertyChangeListener(listener);
+ List<Item> children = item.getChildren();
+ for (Item aChildren : children) {
+ addPropertyChangeListener(aChildren, listener);
+ }
+ }
+
+ @Override
+ public void addTreeModelListener(TreeModelListener listener) {
+ listeners.add(listener);
+ }
+
+
+ /* This is an inefficient implementation, but hand-coded tree structures are unlikely to contain
+ enough nodes for that to really matter. This could be sped up with caching. */
+ public Item findItem(Object value) {
+ return findItem(root, value);
+ }
+
+ private Item findItem(Item node, Object value) {
+ if (node.getValue() == value) {
+ return node;
+ } else {
+ List<Item> children = node.getChildren();
+ for (Item aChildren : children) {
+ Item result = findItem(aChildren, value);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+ }
+
+ private TreePath getTreePath(Item node) {
+ List<Object> path = new ArrayList<Object>();
+ while (node != null) {
+ path.add(0, node.getValue());
+ node = node.getParent();
+ }
+ return new TreePath(path.toArray());
+ }
+
+ @Override
+ public Object getChild(Object parent, int index) {
+ Item node = findItem(parent);
+ return node.getChildren().get(index).getValue();
+ }
+
+ @Override
+ public int getChildCount(Object parent) {
+ Item node = findItem(parent);
+ if (node == null){
+ return 0;
+ }
+ return node.getChildren().size();
+ }
+
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ Item node = findItem(parent);
+ List<Item> children = node.getChildren();
+ for (int i = 0, j = children.size(); i < j; i++) {
+ if (children.get(i).getValue() == child) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public Object getRoot() {
+ return root.getValue();
+ }
+
+ public Item getRootItem() {
+ return root;
+ }
+
+ @Override
+ public boolean isLeaf(Object node) {
+ Item item = findItem(node);
+ return item != null && item.getChildren().size() == 0;
+ }
+
+ @Override
+ public void removeTreeModelListener(TreeModelListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void fireTreeNodesChanged(TreeModelEvent e) {
+ for (TreeModelListener listener : listeners) {
+ listener.treeNodesChanged(e);
+ }
+ }
+
+ @Override
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ }
+ }
+
+ public JAXXTree(TreeModel model) {
+ super(model);
+ }
+
+ public JAXXTree() {
+ setCellRenderer(new DefaultTreeCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+ TreeModel model = tree.getModel();
+ if (model instanceof JAXXTreeModel) {
+ Item item = ((JAXXTreeModel) model).findItem(value);
+ if (item != null) {
+ String label = item.getLabel();
+ if (label != null) {
+ value = label;
+ }
+ }
+ }
+ return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+ });
+
+ addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ TreeModel model = getModel();
+ if (model instanceof JAXXTreeModel) {
+ scan((JAXXTreeModel) model, ((JAXXTreeModel) model).root);
+ }
+ }
+
+ private void scan(JAXXTreeModel model, Item item) {
+ TreePath path = model.getTreePath(item);
+ if (item.isSelected() != isPathSelected(path)) {
+ item.setSelected(!item.isSelected());
+ }
+ List<Item> children = item.getChildren();
+ for (Item aChildren : children) {
+ scan(model, aChildren);
+ }
+ }
+ });
+ }
+
+ public void setItem(Item items) {
+ List<Item> newItems = new ArrayList<Item>();
+ newItems.add(items);
+ setItems(newItems);
+ }
+
+ public void setItems(List<Item> items) {
+ // Create model
+ JAXXTreeModel model = new JAXXTreeModel(items);
+ if (model.getRoot() != null) {
+ setRootVisible(model.getRoot() != SYNTHETIC);
+ }
+ // Atach model
+ setModel(model);
+
+ // Appli selected items
+ if (items != null){
+ List<TreePath> treePathSelected = new ArrayList<TreePath>();
+ for (Item i : items){
+ if (i.isSelected()){
+ treePathSelected.add(model.getTreePath(i));
+ }
+ }
+ this.setSelectionPaths(convertToTreePathArray(treePathSelected.toArray()));
+ }
+ }
+
+ public Object getSelectionValue() {
+ TreePath selectionPath = getSelectionPath();
+ return selectionPath != null ? selectionPath.getLastPathComponent() : null;
+ }
+
+ public Item getRootItem(){
+ if (getModel() instanceof JAXXTreeModel){
+ return ((JAXXTreeModel)getModel()).getRootItem();
+ }
+ return null;
+ }
+
+ protected TreePath[] convertToTreePathArray(Object[] datas){
+ TreePath[] params = new TreePath[datas.length];
+ System.arraycopy(datas, 0, params, 0, datas.length);
+ return params;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,500 @@
+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.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";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
+ protected final String helpsetName;
+ protected final String defaultID;
+ protected final String helpKey;
+ // Main HelpSet & Broker
+ protected final HelpSet helpset;
+ protected final HelpBroker helpBroker;
+ protected Hashtable<Component, Cursor> cursors;
+ protected Cursor onItemCursor;
+ protected final Map<Component, String> cache;
+
+ protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
+ if (helpsetName == null) {
+ throw new NullPointerException("parameter helpsetName can not be null!");
+ }
+ this.helpsetName = helpsetName;
+ this.helpKey = helpKey;
+ this.defaultID = defaultID;
+ 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);
+ }
+ }
+
+ 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() {
+ return helpBroker;
+ }
+
+ public String getHelpKey() {
+ return helpKey;
+ }
+
+ public HelpSet getHelpset() {
+ return helpset;
+ }
+
+ public String getHelpsetName() {
+ return helpsetName;
+ }
+
+ public String getDefaultID() {
+ return defaultID;
+ }
+
+ public void showHelpSet() {
+ 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);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,114 @@
+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 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 = locale.getDisplayName(Locale.getDefault());
+ }
+ return text;
+ }
+
+ 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 synchronized Icon getIcon(Locale locale) {
+ if (!showIcon) {
+ return null;
+ }
+ 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;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,104 @@
+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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,181 @@
+package jaxx.runtime.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.ListModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionListener;
+import java.util.Arrays;
+
+/**
+ * @author chemit
+ * @since 1.5
+ */
+public class OneClicListSelectionModel implements ListSelectionModel {
+
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(OneClicListSelectionModel.class);
+ protected ListSelectionModel delegate;
+ protected final ListModel model;
+ private boolean[] _states;
+
+ public OneClicListSelectionModel(ListSelectionModel delegate, ListModel model) {
+ this.delegate = delegate;
+ this.model = model;
+ delegate.clearSelection();
+ }
+
+ protected boolean[] getStates(int selectedIndex) {
+ int max = model.getSize();
+ if (_states == null || _states.length != max) {
+ _states = new boolean[max];
+ } else {
+ Arrays.fill(_states, false);
+ }
+ for (int i = 0; i < max; i++) {
+ _states[i] = i != selectedIndex && delegate.isSelectedIndex(i);
+ }
+ return _states;
+ }
+
+ @Override
+ public void setSelectionInterval(int index0, int index1) {
+ if (index0 != index1) {
+ // not a single selection (come from a click)
+ // use default behaviour
+ delegate.setSelectionInterval(index0, index1);
+ return;
+ }
+ delegate.setValueIsAdjusting(true);
+
+ try {
+ int max = model.getSize();
+
+ if (log.isDebugEnabled()) {
+ log.debug("single [index:" + index0 + "] [selected:" + isSelectedIndex(index0) + "] [size:" + max + "] [anchor:" + delegate.getAnchorSelectionIndex() + "] [lead:" + delegate.getLeadSelectionIndex() + "]");
+ }
+
+ if (!isSelectedIndex(index0)) {
+ // select it
+ delegate.addSelectionInterval(index0, index1);
+ return;
+ }
+ if (max == index0) {
+ // last selected index, so can directly remove it
+ delegate.removeIndexInterval(index0, index0);
+ return;
+ }
+
+ // must recompute the selection removing only the index0 item
+ boolean[] state = getStates(index0);
+
+ if (log.isDebugEnabled()) {
+ log.debug("state : " + Arrays.toString(state));
+ }
+ delegate.clearSelection();
+ for (int i = 0; i < max; i++) {
+ if (state[i]) {
+ delegate.addSelectionInterval(i, i);
+ }
+ }
+ } finally {
+ delegate.setValueIsAdjusting(false);
+ }
+ }
+
+ @Override
+ public void addSelectionInterval(int index0, int index1) {
+ delegate.addSelectionInterval(index0, index1);
+ }
+
+ @Override
+ public void removeSelectionInterval(int index0, int index1) {
+ delegate.removeSelectionInterval(index0, index1);
+ }
+
+ @Override
+ public int getMinSelectionIndex() {
+ return delegate.getMinSelectionIndex();
+ }
+
+ @Override
+ public int getMaxSelectionIndex() {
+ return delegate.getMaxSelectionIndex();
+ }
+
+ @Override
+ public boolean isSelectedIndex(int index) {
+ return delegate.isSelectedIndex(index);
+ }
+
+ @Override
+ public int getAnchorSelectionIndex() {
+ return delegate.getAnchorSelectionIndex();
+ }
+
+ @Override
+ public void setAnchorSelectionIndex(int index) {
+ delegate.setAnchorSelectionIndex(index);
+ }
+
+ @Override
+ public int getLeadSelectionIndex() {
+ return delegate.getLeadSelectionIndex();
+ }
+
+ @Override
+ public void setLeadSelectionIndex(int index) {
+ delegate.setLeadSelectionIndex(index);
+ }
+
+ @Override
+ public void clearSelection() {
+ delegate.clearSelection();
+ }
+
+ @Override
+ public boolean isSelectionEmpty() {
+ return delegate.isSelectionEmpty();
+ }
+
+ @Override
+ public void insertIndexInterval(int index, int length, boolean before) {
+ delegate.insertIndexInterval(index, length, before);
+ }
+
+ @Override
+ public void removeIndexInterval(int index0, int index1) {
+ delegate.removeIndexInterval(index0, index1);
+ }
+
+ @Override
+ public void setValueIsAdjusting(boolean valueIsAdjusting) {
+ delegate.setValueIsAdjusting(valueIsAdjusting);
+ }
+
+ @Override
+ public boolean getValueIsAdjusting() {
+ return delegate.getValueIsAdjusting();
+ }
+
+ @Override
+ public void setSelectionMode(int selectionMode) {
+ delegate.setSelectionMode(selectionMode);
+ }
+
+ @Override
+ public int getSelectionMode() {
+ return delegate.getSelectionMode();
+ }
+
+ @Override
+ public void addListSelectionListener(ListSelectionListener x) {
+ delegate.addListSelectionListener(x);
+ }
+
+ @Override
+ public void removeListSelectionListener(ListSelectionListener x) {
+ delegate.removeListSelectionListener(x);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Spacer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JComponent;
+
+public class Spacer extends JComponent {
+
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/TabInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.Icon;
+import javax.swing.event.SwingPropertyChangeSupport;
+import java.awt.Color;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+public class TabInfo {
+
+ public static String BACKGROUND_PROPERTY = "background";
+ public static String DISABLED_ICON_PROPERTY = "disabledIcon";
+ public static String DISPLAYED_MNEMONIC_INDEX_PROPERTY = "displayedMnemonicIndex";
+ public static String ENABLED_PROPERTY = "enabled";
+ public static String FOREGROUND_PROPERTY = "foreground";
+ public static String ICON_PROPERTY = "icon";
+ public static String MNEMONIC_PROPERTY = "mnemonic";
+ public static String TITLE_PROPERTY = "title";
+ public static String TOOL_TIP_TEXT_PROPERTY = "toolTipText";
+ private String id;
+ private Color background;
+ private Icon disabledIcon;
+ private int displayedMnemonicIndex = -1;
+ private boolean enabled = true;
+ private Color foreground;
+ private Icon icon;
+ private int mnemonic = -1;
+ private String title;
+ private String toolTipText;
+ private PropertyChangeSupport propertyChangeSupport;
+
+ public TabInfo() {
+ }
+
+ public TabInfo(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Color getBackground() {
+ return background;
+ }
+
+ public void setBackground(Color background) {
+ Color oldValue = this.background;
+ this.background = background;
+ firePropertyChange(BACKGROUND_PROPERTY, oldValue, background);
+ }
+
+ public Icon getDisabledIcon() {
+ return disabledIcon;
+ }
+
+ public void setDisabledIcon(Icon disabledIcon) {
+ Icon oldValue = this.disabledIcon;
+ this.disabledIcon = disabledIcon;
+ firePropertyChange(DISABLED_ICON_PROPERTY, oldValue, disabledIcon);
+ }
+
+ public int getDisplayedMnemonicIndex() {
+ return displayedMnemonicIndex;
+ }
+
+ public void setDisplayedMnemonicIndex(int displayedMnemonicIndex) {
+ int oldValue = this.displayedMnemonicIndex;
+ this.displayedMnemonicIndex = displayedMnemonicIndex;
+ firePropertyChange(DISPLAYED_MNEMONIC_INDEX_PROPERTY, oldValue, displayedMnemonicIndex);
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ boolean oldValue = this.enabled;
+ this.enabled = enabled;
+ firePropertyChange(ENABLED_PROPERTY, oldValue, enabled);
+ }
+
+ public Color getForeground() {
+ return foreground;
+ }
+
+ public void setForeground(Color foreground) {
+ Color oldValue = this.foreground;
+ this.foreground = foreground;
+ firePropertyChange(FOREGROUND_PROPERTY, oldValue, foreground);
+ }
+
+ public Icon getIcon() {
+ return icon;
+ }
+
+ public void setIcon(Icon icon) {
+ Icon oldValue = this.icon;
+ this.icon = icon;
+ firePropertyChange(ICON_PROPERTY, oldValue, icon);
+ }
+
+ public int getMnemonic() {
+ return mnemonic;
+ }
+
+ public void setMnemonic(int mnemonic) {
+ int oldValue = this.mnemonic;
+ this.mnemonic = mnemonic;
+ firePropertyChange(MNEMONIC_PROPERTY, oldValue, mnemonic);
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ String oldValue = this.title;
+ this.title = title;
+ firePropertyChange(TITLE_PROPERTY, oldValue, title);
+ }
+
+ public String getToolTipText() {
+ return toolTipText;
+ }
+
+ public void setToolTipText(String toolTipText) {
+ String oldValue = this.toolTipText;
+ this.toolTipText = toolTipText;
+ firePropertyChange(TOOL_TIP_TEXT_PROPERTY, oldValue, toolTipText);
+ }
+
+ private PropertyChangeSupport getPropertyChangeSupport() {
+ if (propertyChangeSupport == null) {
+ propertyChangeSupport = new SwingPropertyChangeSupport(this);
+ }
+ return propertyChangeSupport;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(property, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(property, listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (propertyChangeSupport != null) {
+ getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+import java.awt.Color;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+public class TabInfoPropertyChangeListener implements PropertyChangeListener {
+
+ private JTabbedPane tabs;
+ private int tabIndex;
+
+ public TabInfoPropertyChangeListener(JTabbedPane tabs, int tabIndex) {
+ this.tabs = tabs;
+ this.tabIndex = tabIndex;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ String name = e.getPropertyName();
+ if (name.equals(TabInfo.TITLE_PROPERTY)) {
+ tabs.setTitleAt(tabIndex, (String) e.getNewValue());
+ } else if (name.equals(TabInfo.TOOL_TIP_TEXT_PROPERTY)) {
+ tabs.setToolTipTextAt(tabIndex, (String) e.getNewValue());
+ } else if (name.equals(TabInfo.FOREGROUND_PROPERTY)) {
+ tabs.setForegroundAt(tabIndex, (Color) e.getNewValue());
+ } else if (name.equals(TabInfo.BACKGROUND_PROPERTY)) {
+ tabs.setBackgroundAt(tabIndex, (Color) e.getNewValue());
+ } else if (name.equals(TabInfo.MNEMONIC_PROPERTY)) {
+ tabs.setMnemonicAt(tabIndex, (Integer) e.getNewValue());
+ } else if (name.equals(TabInfo.DISPLAYED_MNEMONIC_INDEX_PROPERTY)) {
+ tabs.setDisplayedMnemonicIndexAt(tabIndex, (Integer) e.getNewValue());
+ } else if (name.equals(TabInfo.ICON_PROPERTY)) {
+ tabs.setIconAt(tabIndex, (Icon) e.getNewValue());
+ } else if (name.equals(TabInfo.DISABLED_ICON_PROPERTY)) {
+ tabs.setDisabledIconAt(tabIndex, (Icon) e.getNewValue());
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Table.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Panel which uses a {@link GridBagLayout} by default.
+ *
+ * @author Ethan Nicholas
+ */
+public class Table extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3);
+ private GridBagConstraints tableConstraints = new GridBagConstraints();
+ private GridBagConstraints rowConstraints = null;
+ private GridBagConstraints cellConstraints = null;
+
+ public Table() {
+ super.setLayout(new GridBagLayout());
+
+ tableConstraints.insets = DEFAULT_INSETS;
+ }
+
+ @Override
+ public void setLayout(LayoutManager layout) {
+ // do nothing
+ }
+
+ public GridBagConstraints getTableConstraints() {
+ return tableConstraints;
+ }
+
+ public GridBagConstraints getRowConstraints() {
+ return rowConstraints;
+ }
+
+ public GridBagConstraints getCellConstraints() {
+ return cellConstraints;
+ }
+
+ public void newRow() {
+ tableConstraints.gridy++;
+ rowConstraints = (GridBagConstraints) tableConstraints.clone();
+ }
+
+ public void newCell() {
+ rowConstraints.gridx++;
+ cellConstraints = (GridBagConstraints) rowConstraints.clone();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/VBox.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import java.awt.Insets;
+
+/**
+ * Panel which uses a {@link VBoxLayout} by default.
+ *
+ * @author Ethan Nicholas
+ */
+public class VBox extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ public static final String SPACING_PROPERTY = "spacing";
+ public static final String MARGIN_PROPERTY = "margin";
+ public static final String HORIZONTAL_ALIGNMENT_PROPERTY = "horizontalAlignment";
+ public static final String VERTICAL_ALIGNMENT_PROPERTY = "verticalAlignment";
+ private Insets margin;
+
+ public VBox() {
+ super(new VBoxLayout());
+ }
+
+ /**
+ * Returns the spacing between components, in pixels. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @return spacing between components
+ */
+ public int getSpacing() {
+ return ((VBoxLayout) getLayout()).getSpacing();
+ }
+
+ /**
+ * Sets the spacing between components. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @param spacing new spacing value
+ */
+ public void setSpacing(int spacing) {
+ int oldValue = getSpacing();
+ ((VBoxLayout) getLayout()).setSpacing(spacing);
+ firePropertyChange(SPACING_PROPERTY, oldValue, spacing);
+ revalidate();
+ }
+
+ public int getHorizontalAlignment() {
+ return ((VBoxLayout) getLayout()).getHorizontalAlignment();
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ int oldValue = getHorizontalAlignment();
+ ((VBoxLayout) getLayout()).setHorizontalAlignment(horizontalAlignment);
+ firePropertyChange(HORIZONTAL_ALIGNMENT_PROPERTY, oldValue, horizontalAlignment);
+ revalidate();
+ }
+
+ public int getVerticalAlignment() {
+ return ((VBoxLayout) getLayout()).getVerticalAlignment();
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ int oldValue = getVerticalAlignment();
+ ((VBoxLayout) getLayout()).setVerticalAlignment(verticalAlignment);
+ firePropertyChange(VERTICAL_ALIGNMENT_PROPERTY, oldValue, verticalAlignment);
+ revalidate();
+ }
+
+ public Insets getMargin() {
+ return margin;
+ }
+
+ public void setMargin(Insets margin) {
+ Insets oldValue = this.margin;
+ this.margin = (Insets) margin.clone();
+ firePropertyChange(MARGIN_PROPERTY, oldValue, margin);
+ }
+
+ @Override
+ public Insets getInsets() {
+ Insets result = super.getInsets();
+ if (margin != null) {
+ result.top += margin.top;
+ result.left += margin.left;
+ result.right += margin.right;
+ result.bottom += margin.bottom;
+ }
+ return result;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/VBoxLayout.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.SwingConstants;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Vertical box layout. The layout rules followed by this class are quite different than the core BoxLayout class,
+ * and in general represent a more useful algorithm.
+ *
+ * @author Ethan Nicholas
+ */
+public class VBoxLayout implements LayoutManager {
+
+ private int spacing = 6;
+ private int horizontalAlignment = SwingConstants.LEFT;
+ private int verticalAlignment = SwingConstants.TOP;
+
+ public int getSpacing() {
+ return spacing;
+ }
+
+ public void setSpacing(int spacing) {
+ this.spacing = spacing;
+ }
+
+ public int getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public int getVerticalAlignment() {
+ return verticalAlignment;
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ this.verticalAlignment = verticalAlignment;
+ }
+
+ @Override
+ public void addLayoutComponent(String name, Component comp) {
+ }
+
+ @Override
+ public void layoutContainer(Container parent) {
+ Insets insets = parent.getInsets();
+ int parentWidth = parent.getSize().width - insets.left - insets.right;
+ int count = parent.getComponentCount();
+ Dimension preferredSize = parent.getPreferredSize();
+ int y;
+ switch (verticalAlignment) {
+ case SwingConstants.TOP:
+ y = insets.top;
+ break;
+ case SwingConstants.CENTER:
+ y = insets.top + (parent.getHeight() - preferredSize.height) / 2;
+ break;
+ case SwingConstants.BOTTOM:
+ y = insets.top + (parent.getHeight() - preferredSize.height);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid vertical alignment: " + verticalAlignment);
+ }
+
+ for (int i = 0; i < count; i++) {
+ Component component = parent.getComponent(i);
+ Dimension childPreferredSize = component.getPreferredSize();
+ int width = Math.min(childPreferredSize.width, parentWidth);
+ int x;
+ switch (horizontalAlignment) {
+ case SwingConstants.LEFT:
+ x = insets.left;
+ break;
+ case SwingConstants.CENTER:
+ x = insets.left + (parentWidth - childPreferredSize.width) / 2;
+ break;
+ case SwingConstants.RIGHT:
+ x = insets.left + (parentWidth - childPreferredSize.width);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid horizontal alignment: " + horizontalAlignment);
+ }
+ component.setBounds(x, y, width, childPreferredSize.height);
+ y += childPreferredSize.height + spacing;
+ }
+ }
+
+ @Override
+ public Dimension minimumLayoutSize(Container parent) {
+ int width = 0;
+ int height = (parent.getComponentCount() - 1) * spacing;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension minimumSize = parent.getComponent(i).getMinimumSize();
+ width = Math.max(width, minimumSize.width);
+ height += minimumSize.height;
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public Dimension preferredLayoutSize(Container parent) {
+ int width = 0;
+ int height = (parent.getComponentCount() - 1) * spacing;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension preferredSize = parent.getComponent(i).getPreferredSize();
+ width = Math.max(width, preferredSize.width);
+ height += preferredSize.height;
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public void removeLayoutComponent(Component comp) {
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,119 @@
+/*
+* *##% ui
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor;
+
+import org.apache.commons.beanutils.Converter;
+import org.nuiton.util.ConverterUtil;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+
+/**
+ * A class cell editor (fork from comandline project).
+ *
+ * @author chemit
+ */
+public class ClassCellEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+
+ String valStr = (value + "").trim();
+ if (valStr.equals("null")) {
+ valStr = "";
+ } else if (valStr.startsWith("class ")) {
+ valStr = valStr.substring(6);
+ }
+ Component comp;
+ comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column);
+ return comp;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ Object o = !hasDelegate() ? null : delegate.getCellEditorValue();
+ if (o == null) {
+ return null;
+ }
+ Converter converter = ConverterUtil.getConverter(Class.class);
+
+ try {
+ if (converter != null) {
+ return converter.convert(Class.class, o);
+ }
+ o = Class.forName(o + "");
+ } catch (Exception e) {
+ o = null;
+ }
+ return o;
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ @Override
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ @Override
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ @Override
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor getDelegate() {
+ if (delegate == null) {
+ delegate = new DefaultCellEditor(new JTextField());
+ }
+ return delegate;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,57 @@
+/*
+ * *##% Lutin utilities library
+ * Copyright (C) 2004 - 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor;
+
+import javax.swing.JComboBox;
+import java.util.EnumSet;
+import org.nuiton.util.ReflectUtil;
+
+/**
+ * Une éditeur d'enum.
+ *
+ * @param <E> le type d'enumeration a editer.
+ *
+ * @author chemit
+ *
+ * @since 1.6.0
+ */
+public class EnumEditor<E extends Enum<E>> extends JComboBox {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = 2693771553067104538L;
+ protected Class<E> type;
+
+ public static <E extends Enum<E>> EnumEditor<E> newEditor(Class<E> type) {
+ return new EnumEditor<E>(type);
+ }
+
+ public EnumEditor(Class<E> type) {
+ super(buildModel(type));
+ }
+
+ @Override
+ public E getSelectedItem() {
+ return (E) super.getSelectedItem();
+ }
+
+ protected static <E extends Enum<E>> Object[] buildModel(Class<E> type) {
+ Class<E> enumClass = ReflectUtil.getEnumClass(type);
+ EnumSet<E> result = EnumSet.allOf(enumClass);
+ return result.toArray(new Object[result.size()]);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,64 @@
+/*
+* *##% Lutin utilities library
+ * Copyright (C) 2004 - 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor;
+
+import javax.swing.JComboBox;
+import java.util.Locale;
+import org.nuiton.i18n.I18n;
+
+/**
+ * A {@link Locale} editor.
+ * <p/>
+ * use the static method to have an instance of editor {@link #newEditor(java.util.Locale[])}
+ * <p/>
+ * If no locale is given to this method, it will go and seek via
+ * {@link org.nuiton.i18n.I18nLoader#getLocales()} all loaded locales in i18n system
+ *
+ * @author chemit
+ * @since 1.6.0
+ */
+public class LocaleEditor extends JComboBox {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -6777873426011538807L;
+
+ protected Locale[] type;
+
+ public static LocaleEditor newEditor(Locale... type) {
+ return new LocaleEditor(type);
+ }
+
+ public LocaleEditor(Locale... type) {
+ super(buildModel(type));
+ }
+
+ @Override
+ public Locale getSelectedItem() {
+ return (Locale) super.getSelectedItem();
+ }
+
+ protected static Locale[] buildModel(Locale... type) {
+ if (type.length > 0) {
+ return type;
+ }
+ // get availables locales registred in I18n system
+ type = I18n.getLoader().getLocales();
+ return type;
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,59 @@
+package jaxx.runtime.swing.navigation;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import javax.swing.JPanel;
+import jaxx.runtime.swing.Item;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author letellier
+ * @since 1.7.2
+ */
+public class ItemNavigationCardPanel extends JPanel {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(ItemNavigationCardPanel.class);
+ private static final long serialVersionUID = 1L;
+ CardLayout layout;
+
+ public ItemNavigationCardPanel() {
+ super();
+
+ layout = new CardLayout();
+ setLayout(layout);
+ }
+
+ public void showItem(Item i) {
+ if (i != null && i.getValue() != null) {
+ if (i.getValue() instanceof Class<?>) {
+ layout.show(this, i.getValue().getClass().getName());
+ } else {
+ layout.show(this, i.getValue().getClass().getName());
+ }
+ }
+ }
+
+ public Component getShowedComponent() {
+ Component[] components = getComponents();
+ if (components != null) {
+ for (Component c : components) {
+ if (c.isVisible()) {
+ return c;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Component add(Component comp) {
+ if (!(comp instanceof ItemNavigationPanel)) {
+ throw new IllegalArgumentException("ItemNavigationCardPanel must be have only ItemNavigationPanel children");
+ }
+ super.add(comp, ((ItemNavigationPanel) comp).getAssociatedClass().getName());
+ return comp;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,28 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author letellier
+ */
+public class ItemNavigationPanel extends JPanel{
+
+ private static final long serialVersionUID = 1L;
+
+ protected Class associatedClass = null;
+
+ public ItemNavigationPanel(Class associatedClass) {
+ this.associatedClass = associatedClass;
+ }
+
+ public Class getAssociatedClass() {
+ return associatedClass;
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,64 @@
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.runtime.swing.JAXXTree.JAXXTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** A {@link javax.swing.event.TreeSelectionListener} implementation@@author letellier */
+public abstract class ItemTreeNavigationAdapter implements TreeSelectionListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(ItemTreeNavigationAdapter.class);
+
+ /** l'ui contenant l'arbre de navigation */
+ protected JAXXObject context;
+
+ protected JAXXTree tree;
+ protected ItemNavigationCardPanel cardPanel;
+
+ public ItemTreeNavigationAdapter(JAXXObject context, JAXXTree tree, ItemNavigationCardPanel cardPanel) {
+ super();
+ this.context = context;
+ this.tree = tree;
+ this.cardPanel = cardPanel;
+
+ // Attache ce listener a l'arbre de navigation
+ tree.addTreeSelectionListener(this);
+ }
+
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ log.debug("Selection in JAXXTree changed" + e.getPath());
+
+ // Recuperation du path selectionne
+ TreePath path = e.getNewLeadSelectionPath();
+ TreeModel model = tree.getModel();
+
+ if (!(model instanceof JAXXTreeModel)){
+ log.error("Its not an JAXXTreeModel");
+ return;
+ }
+ // Find item coresponding
+ Item itemSelected = ((JAXXTreeModel) model).findItem(path.getLastPathComponent());
+
+ // Show corresponding panel
+ cardPanel.showItem(itemSelected);
+
+ // Notifie change
+ valueChanged(itemSelected.getValue());
+ }
+
+ /**
+ * Method abstraite pour pouvoir propager la donnee selectionner
+ *
+ * @param data value of the node selected
+ */
+ protected abstract void valueChanged(Object data);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,244 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.List;
+
+/**
+ * Un modèle de wizard.
+ *
+ *
+ * <b>Note:</b> le type des étapes doit être uné énumération qui implante
+ * {@link WizardStep}.
+ *
+ * @param <E> le type des étapes.
+ *
+ * @author tony
+ * @since 1.3
+ * @see WizardStep
+ */
+public class WizardModel<E extends WizardStep> {
+
+ public static final String STEPS_PROPERTY_NAME = "steps";
+ public static final String STEP_PROPERTY_NAME = "step";
+ public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
+ public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
+ public static final String VALID_STEP_PROPERTY_NAME = "validStep";
+ /**
+ * le type d'une etape du model (doit etre une enumeration)
+ */
+ protected final Class<E> stepClass;
+ /**
+ * Toutes les étapes à passer
+ */
+ protected List<E> steps;
+ /** les etapes a exclure */
+ protected List<E> excludeSteps;
+ /**
+ * L'étape courante
+ */
+ protected E step;
+ /**
+ * drapeau pour valider l'état de l'étape courante
+ */
+ protected boolean validStep;
+ /**
+ * drapeau lorsque le modele effectue des operations
+ * de transformation de modele mais que les écouteurs
+ * ne devraient pas tenir compte des modifications
+ */
+ protected boolean valueAdjusting;
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+
+ public WizardModel(Class<E> stepClass, E... steps) {
+ if (!Enum.class.isAssignableFrom(stepClass)) {
+ throw new IllegalArgumentException("stepClass must be an Enumeration but was " + stepClass.getName());
+ }
+ this.stepClass = stepClass;
+ this.pcs = new PropertyChangeSupport(this);
+ this.steps = new java.util.ArrayList<E>();
+ if (steps.length > 0) {
+ setSteps(steps);
+ }
+ }
+
+ public void start() {
+ if (steps.isEmpty()) {
+ throw new IllegalStateException("can not start, no step found");
+ }
+ step = null;
+ E startStep = steps.get(0);
+ setStep(startStep);
+ }
+
+ public void gotoNextStep() {
+ E nextStep = getNextStep();
+ if (nextStep == null) {
+ throw new IllegalStateException("no next step to go");
+ }
+ setStep(nextStep);
+ }
+
+ public void gotoPreviousStep() {
+ E previousStep = getPreviousStep();
+ if (previousStep == null) {
+ throw new IllegalStateException("no previous step to go");
+ }
+ setStep(previousStep);
+ }
+
+ public void gotoStep(E e) {
+ if (e == null) {
+ throw new NullPointerException("step can not be null");
+ }
+ if (!steps.contains(e)) {
+ throw new IllegalStateException("step " + e.toString() + " is not in universe of steps (" + steps + ")");
+ }
+ setStep(e);
+ }
+
+ public E getStep() {
+ return step;
+ }
+
+ public int getStepIndex(E s) {
+ int index = steps.indexOf(s);
+ return index;
+ }
+
+ public boolean isValidStep() {
+ return validStep;
+ }
+
+ public E getPreviousStep() {
+ E e = getPreviousStep(step);
+ return e;
+ }
+
+ public E getPreviousStep(E step) {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
+ public E getNextStep(E step) {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
+ public E getNextStep() {
+ int index = getStepIndex(step);
+ if (index == -1 || index == steps.size() - 1) {
+ // si pas de step positionne ou dernier etape
+ return null;
+ }
+ return steps.get(index + 1);
+ }
+
+ public java.util.List<E> getSteps() {
+ return steps;
+ }
+
+ public boolean isValueAdjusting() {
+ return valueAdjusting;
+ }
+
+ /**
+ * Change l'univers des etapes.
+ *
+ * Note: on presume ici que l'étape courante est toujours la meme.
+ *
+ * @param steps le nouvel univers des etapes
+ */
+ public void setSteps(E... steps) {
+ java.util.List<E> oldValue = this.steps;
+ this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
+ firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ }
+
+ public void setValueAdjusting(boolean valueAdjusting) {
+ this.valueAdjusting = valueAdjusting;
+ }
+
+ public void setExcludeSteps(List<E> excludeSteps) {
+ this.excludeSteps = excludeSteps;
+ }
+ public boolean validate(E s) {
+ return step != null;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+
+ public void validate() {
+ if (step == null) {
+ // pas de validation quand aucune etape n'est sélectionnée
+ return;
+ }
+ boolean validate = validate(step);
+ this.validStep = validate;
+ // toujours forcer la propagation
+ firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
+ }
+
+ protected Class<E> getStepClass() {
+ return stepClass;
+ }
+
+ protected void setStep(E step) {
+ E oldValue = this.step;
+ this.step = step;
+ firePropertyChange(STEP_PROPERTY_NAME, oldValue, step);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ // la propriete previousStep peut avoir changee
+ firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null, getPreviousStep());
+ validate();
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) {
+ pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
+ }
+
+ protected E[] updateStepUniverse() {
+ return null;
+ }
+
+ protected void updateUniverse() {
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,108 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.SwingWorker;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * La classe de base a implanter pour definir l'action d'une operation
+ * dans un wizard.
+ *
+ * @author tony
+ * @param <E> le type d'étapes
+ * @param <M> le type de modèle
+ * @since 1.3
+ */
+public abstract class WizardOperationAction<E extends WizardOperationStep, M extends WizardOperationModel<E>> extends SwingWorker<WizardOperationState, String> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardOperationAction.class);
+ E operation;
+ WizardOperationState operationState;
+ Exception error;
+
+ public WizardOperationAction(E operation) {
+ super();
+ if (!operation.isOperation()) {
+ throw new IllegalArgumentException("the step " + operation + " has no operation defined");
+ }
+ this.operation = operation;
+ }
+
+ public E getOperation() {
+ return operation;
+ }
+
+ public Exception getError() {
+ return error;
+ }
+
+ public void setError(Exception e) {
+ error = e;
+ }
+
+ public void sendMessage(String msg) {
+ firePropertyChange("message", null, msg);
+ }
+
+ public abstract void start(JAXXContext context);
+
+ public abstract void beforeAction(JAXXContext context, M model) throws Exception;
+
+ public abstract WizardOperationState doAction(M model) throws Exception;
+
+ public abstract WizardOperationState onError(M model, Exception e);
+
+ public abstract WizardOperationState onCancel(M model, Exception e);
+
+ protected abstract M getModel();
+
+ public WizardOperationState getOperationState() {
+ return operationState;
+ }
+
+ protected abstract JAXXContext getContext();
+
+ @Override
+ public String toString() {
+ return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
+ }
+
+ @Override
+ protected WizardOperationState doInBackground() throws Exception {
+ log.trace(this);
+ WizardOperationState result;
+ M model = getModel();
+ try {
+ beforeAction(getContext(), model);
+ result = doAction(model);
+ } catch (Exception e) {
+ error = e;
+ result = onError(model, e);
+ }
+ return result;
+ }
+
+ @Override
+ protected void done() {
+ log.trace(this);
+ WizardOperationState result = null;
+ try {
+ if (isCancelled()) {
+
+ result = onCancel(getModel(), error);
+ } else {
+ result = get();
+ }
+ } catch (Exception e) {
+ result = WizardOperationState.FAILED;
+ error = e;
+ // ne devrait jamais arrivé ?
+ log.error(e.getMessage(), e);
+ } finally {
+ // on enregistre le resultat de l'opération
+ this.operationState = result;
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,204 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import javax.swing.SwingWorker.StateValue;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Thread qui réalise les opérations.
+ *
+ * Pour exécuter une nouvelle opération, on utilise la méthode
+ * {@link #launchOperation(SynchroActionWorker)}.
+ *
+ * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
+ *
+ * @param <E> le type des etapes
+ * @param <M> le type de modele
+ * @param <A> le type d'action d'operation
+ *
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardOperationActionThread<E extends WizardOperationStep, M extends WizardOperationModel<E>, A extends WizardOperationAction<E, M>> extends Thread implements PropertyChangeListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardOperationActionThread.class);
+ /**
+ * l'état du thread si annulé
+ */
+ private boolean canceled;
+ protected Class<M> modelClass;
+ protected A currentAction;
+ /**
+ * un lock pour permettre la suspension et la reprise du thread
+ * lors du mode interactif.
+ */
+ private final Object LOCK = new Object();
+
+ protected abstract M getModel();
+
+ protected abstract JAXXContext getContext();
+
+ public WizardOperationActionThread(Class<M> modelClass) throws IllegalArgumentException {
+ super(WizardOperationActionThread.class.getSimpleName() + " " + new Date());
+ this.modelClass = modelClass;
+ }
+
+ public void cancel() {
+ log.info("cancel " + this);
+ this.canceled = true;
+
+ // on annule le modele
+ getModel().cancel();
+
+ // on rend la main au thread
+ setWaiting(false);
+ }
+
+ @SuppressWarnings("unchecked")
+ public A launchOperation(E operation) {
+
+ if (currentAction != null && (!currentAction.isDone() || currentAction.operationState == WizardOperationState.RUNNING)) {
+ // on ne peut traiter qu'une seule opération à la fois
+ throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
+ }
+ currentAction = (A) getModel().getOperationAction(operation);
+
+ // on libere le thread pour qu'il execute l'opération
+ setWaiting(false);
+
+ return currentAction;
+ }
+
+ public A getCurrentAction() {
+ return currentAction;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ if ("state".equals(evt.getPropertyName())) {
+ StateValue state = (StateValue) evt.getNewValue();
+ if (state == StateValue.DONE) {
+ // on rend la main au thread pour qu'il attende une prochaine operation
+ setWaiting(false);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ // on vérifie que le context contient bien le modèle
+ if (getModel() == null) {
+ throw new NullPointerException("could not find model " + modelClass + " for " + this);
+ }
+
+ while (!canceled) {
+
+ if (canceled) {
+ // une annulation a été demandé
+ // donc même si une opération est demandée, on ne la traite
+ // pas
+ break;
+ }
+
+ // en attente qu'une opération
+ // le block est bloqué jusqu'à arrivée d'une opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread a repris la main, donc plus en attente
+ log.trace("no more waiting " + this);
+
+ if (!canceled) {
+ // une opération a été demandée
+
+ // le thread écoute les modifications de l'action
+ currentAction.addPropertyChangeListener(this);
+
+ // l'opération passe en etant en cours
+ getModel().setOperationState(WizardOperationState.RUNNING);
+
+ // démarrage de l'opération dans un worker
+ currentAction.start(getContext());
+ // le thread est bloqué jusqu'à la fin de l'opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread reprend la main des que l'operation
+ // est terminée ou a été annulée, on passera alors
+ // dans la méthode onPropertyChanged
+
+ if (canceled) {
+ getModel().setOperationState(WizardOperationState.CANCELED);
+ } else {
+ getModel().setOperationState(currentAction.getOperationState());
+ }
+
+ // le thread n'écoute plus l'action car elle est terminée
+ // ou annulée
+ currentAction.removePropertyChangeListener(this);
+ // suppression de l'action
+ //currentAction = null;
+ }
+
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ unlockThread();
+ log.trace(this + " will close...");
+ close();
+ }
+ }
+
+ /**
+ * La méthode pour nettoyer le thread, a la fermeture.
+ *
+ */
+ protected void close() {
+ // par defaut, on ne fait rien
+ log.trace(this);
+ }
+
+ protected void setWaiting(boolean waiting) {
+
+ if (waiting && !canceled) {
+ // locking thread
+ try {
+ lockThread();
+ } catch (InterruptedException ex) {
+ log.error(ex.getMessage(), ex);
+ canceled = true;
+ }
+ }
+
+ if (!waiting) {
+ // release lock
+ unlockThread();
+ }
+ }
+
+ protected void lockThread() throws InterruptedException {
+ synchronized (LOCK) {
+ log.trace(this);
+ // lock
+ LOCK.wait();
+ }
+ }
+
+ protected void unlockThread() {
+ synchronized (LOCK) {
+ log.trace(this);
+ // unlock
+ LOCK.notify();
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,269 @@
+package jaxx.runtime.swing.wizard;
+
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.swing.SwingWorker.StateValue;
+
+/**
+ * Un modèle de wizard avec des opérations.
+ *
+ * @param <E> le type des étapes.
+ * @author tony
+ * @since 1.3
+ */
+public class WizardOperationModel<E extends WizardOperationStep> extends WizardModel<E> {
+
+ public static final String OPERATIONS_PROPERTY_NAME = "operations";
+ public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
+ public static final String MODEL_STATE_PROPERTY_NAME = "modelState";
+ public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted";
+
+ /**
+ * La liste des opérations à effectuer
+ */
+ protected Set<E> operations;
+ /**
+ * Pour conserver les états des opérations
+ */
+ protected Map<E, WizardOperationState> operationStates;
+ protected Map<E, WizardOperationAction> operationActions;
+ /**
+ * L'état générale du modèle
+ */
+ protected WizardOperationState modelState;
+ /**
+ * un drapeau pour savoir siune opération a été lancée
+ */
+ protected boolean wasStarted;
+
+ @SuppressWarnings("unchecked")
+ public <T extends Enum<T>> WizardOperationModel(Class<E> stepClass, E... steps) {
+ super(stepClass, steps);
+ Class<T> k = (Class) stepClass;
+ this.operationStates = (Map) new EnumMap(k);
+ this.operations = (Set<E>) EnumSet.noneOf(k);
+ this.operationActions = (Map) new EnumMap(k);
+ }
+
+ public Set<E> getOperations() {
+ return operations;
+ }
+
+ public WizardOperationState getModelState() {
+ return modelState;
+ }
+
+ public boolean isWasStarted() {
+ return wasStarted;
+ }
+
+ @SuppressWarnings("unchecked")
+ public E getOperation() {
+ return getStep() != null && getStep().isOperation() ? getStep() : null;
+ }
+
+ public WizardOperationState getOperationState() {
+ E operation = getOperation();
+ return getOperationState(operation);
+ }
+
+ public WizardOperationState getOperationState(E operation) {
+ return operationStates.get(operation);
+ }
+
+ public WizardOperationAction getOperationAction(E operation) {
+ WizardOperationAction action = operationActions.get(operation);
+ if (action == null) {
+ try {
+ action = operation.getActionClass().newInstance();
+ operationActions.put(operation, action);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ return action;
+ }
+
+ public void setOperationState(WizardOperationState operationState) {
+ E operation = getOperation();
+ setOperationState(operation, operationState);
+ }
+
+ public void setOperationState(E operation, WizardOperationState operationState) {
+ WizardOperationState oldValue = getOperationState(operation);
+ this.operationStates.put(operation, operationState);
+ fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getSteps().indexOf(operation), oldValue, operationState);
+ updateModelState(operation, operationState);
+ validate();
+ }
+
+ public boolean[] getAccessibleSteps() {
+ boolean[] result = new boolean[getSteps().size()];
+ int index = getSteps().indexOf(getStep());
+ if (index != -1) {
+
+ for (int i = 0, j = steps.size(); i < j; i++) {
+ if (i <= index) {
+ // tous les onglets inferieur ou egal au courant sont accessibles
+ result[i] = true;
+ continue;
+ }
+ // les onglets au dela de l'onglet sélectionné sont accessibles
+ // uniquement si l'onglet precedent est accessible, valide et son etat est a SUCCESSED
+ E previousStep = steps.get(i - 1);
+ result[i] = modelState == WizardOperationState.SUCCESSED ||
+ (result[i - 1] &&
+ validate(previousStep) &&
+ (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED));
+ }
+ }
+ //System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
+ return result;
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ updateUniverse();
+ //setSteps(steps.toArray((E[]) Array.newInstance(stepClass, steps.size())));
+
+ // le modèle n'est pas démarré
+ setModelState(WizardOperationState.PENDING);
+ }
+
+ public void cancel() {
+
+ for (E op : operations) {
+ if (getOperationState(op) == WizardOperationState.PENDING) {
+ // on annule l'opération à venir
+ setOperationState(op, WizardOperationState.CANCELED);
+ }
+ }
+ setModelState(WizardOperationState.CANCELED);
+ if (getStep() != null && getStep().isOperation()) {
+ WizardOperationAction action = getOperationAction(getStep());
+ if (action != null) {
+ if (!action.isCancelled() && !action.isDone() && action.getState() == StateValue.STARTED) {
+ System.out.println("cancel action " + action);
+ // on annule l'action
+ action.cancel(true);
+ }
+ }
+ }
+ }
+
+ public WizardOperationModel<E> addOperation(E operation) {
+ operations.add(operation);
+ // mis a jour de l'univers des etapes et operations
+ updateUniverse();
+ // validation
+ validate();
+ return this;
+ }
+
+ public void removeOperation(E operation) {
+ operations.remove(operation);
+
+ // mis a jour de l'univers des etapes et operations
+ updateUniverse();
+ // validation
+ validate();
+ }
+
+ @Override
+ public void setSteps(E... steps) {
+ super.setSteps(steps);
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ updateOperationStates(Arrays.asList(steps));
+ }
+
+ public void updateOperationStates(List<E> steps) {
+ int index = 0;
+ for (E e : steps) {
+ fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, index++, null, getOperationState(e));
+ }
+ firePropertyChange(MODEL_STATE_PROPERTY_NAME, null, modelState);
+ }
+
+ public WizardOperationAction reloadOperation(E operation) {
+ operationActions.remove(operation);
+ WizardOperationAction newOp = getOperationAction(operation);
+ return newOp;
+ }
+
+ protected void setModelState(WizardOperationState modelState) {
+ WizardOperationState oldValue = this.modelState;
+ this.modelState = modelState;
+ firePropertyChange(MODEL_STATE_PROPERTY_NAME, oldValue, modelState);
+ if (!wasStarted) {
+ if ((oldValue == null || oldValue == WizardOperationState.PENDING) && modelState == WizardOperationState.RUNNING) {
+ this.wasStarted = true;
+ firePropertyChange(WAS_STARTED_PROPERTY_NAME, false, true);
+ }
+ }
+ }
+
+ protected void updateModelState(E operation, WizardOperationState operationState) {
+
+ switch (operationState) {
+ case RUNNING:
+ //le modele est occupé
+ setModelState(WizardOperationState.RUNNING);
+ break;
+ case FAILED:
+ //le modele est en erreur
+ setModelState(WizardOperationState.FAILED);
+ break;
+ case CANCELED:
+ //le modele devient annulé
+ setModelState(WizardOperationState.CANCELED);
+ return;
+ case PENDING:
+ //le modele est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case NEED_FIX:
+ //le modele est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case SUCCESSED:
+ // on regarde si on peut passer le model a l'état success
+ boolean valid = true;
+ for (E o : operations) {
+ if (getOperationState(o) != WizardOperationState.SUCCESSED) {
+ valid = false;
+ break;
+ }
+ }
+ if (valid) {
+ setModelState(WizardOperationState.SUCCESSED);
+ } else {
+ setModelState(WizardOperationState.PENDING);
+ }
+ break;
+ }
+ updateOperationStates(steps);
+ }
+
+ @Override
+ protected void updateUniverse() {
+ E[] newSteps = updateStepUniverse();
+ setSteps(newSteps);
+ }
+
+ protected int getOperationIndex(E operation) {
+ int index = 0;
+ for (E o : operations) {
+ if (operation == o) {
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,32 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ * Pour caractériser l'état d'une opération.
+ */
+public enum WizardOperationState {
+
+ /**
+ * quand l'opération n'a pas encore été réalisée
+ */
+ PENDING,
+ /**
+ * quand l'opération est en cours
+ */
+ RUNNING,
+ /**
+ * quand l'opération est annulé en cours d'exécution
+ */
+ CANCELED,
+ /**
+ * quand une erreur s'est produite pendant l'exécution
+ */
+ FAILED,
+ /**
+ * quand l'exécution s'est terminée mais requière des corrections
+ */
+ NEED_FIX,
+ /**
+ * quand l'exécution s'est terminée et ne requière pas de correction
+ */
+ SUCCESSED
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,34 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ *
+ * Le contrat a implanter pour une etapes dans le modèle de wizard avec
+ * opérations.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardOperationStep extends WizardStep {
+
+ /**
+ * @return le label de l'opération
+ */
+ String getOperationLabel();
+
+ /**
+ * @return la description de l'opération
+ */
+ String getOperationDescription();
+
+ /**
+ * @return le type de l'action associée à l'étape ou <code>null</code> si
+ * l'étape n'a pas d'opération associée.
+ */
+ Class<? extends WizardOperationAction> getActionClass();
+
+ /**
+ * @return <code>true</code> si l'étape a une opération associée,
+ * <code>false</code> sinon.
+ */
+ boolean isOperation();
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,20 @@
+package jaxx.runtime.swing.wizard;
+
+import java.io.Serializable;
+
+/**
+ * le contrat d'une étape d'un wizard.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardStep extends Serializable {
+
+ String name();
+
+ int ordinal();
+
+ String getLabel();
+
+ String getDescription();
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,14 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ * Le contrat d'une ui d'étape.
+ *
+ * @param <E> le type d'étape
+ * @param <M> le type de modèle
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardStepUI<E extends WizardStep, M extends WizardModel<E>> {
+
+ E getStep();
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.JTabbedPane;
+
+/**
+ *
+ * Contrat a respecter pour une ui de wizard.
+ *
+ * @param <E> le type d'etape
+ * @param <M> le type de model
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> {
+
+ /**
+ * @return le modèle de wizard
+ */
+ M getModel();
+
+ /**
+ *
+ * @return l'étape courante
+ */
+ E getSelectedStep();
+
+ /**
+ *
+ * @return l'ui de l'étape courante
+ */
+ WizardStepUI<E, M> getSelectedStepUI();
+
+ /**
+ *
+ * @param step l'étape donnée
+ * @return l'ui de l'étape donnée
+ */
+ WizardStepUI<E, M> getStepUI(E step);
+
+ /**
+ *
+ * @param stepIndex la position de l'étape
+ * @return l'ui de l'étape donée
+ */
+ WizardStepUI<E, M> getStepUI(int stepIndex);
+
+ /**
+ * démarre le wizard
+ */
+ void start();
+
+ /**
+ * //TODO il faudrait supprimer cette méthode
+ * @return le conteneur d'ui d'étapes
+ */
+ JTabbedPane getTabs();
+
+ /**
+ * Méthode invoqué lorsque la première opération du modèlé a été démarrée.
+ */
+ void onWasStarted();
+
+ /**
+ * Méthode invoquée lorsque l'univers des étapes a été modifié dans le
+ * modèle.
+ *
+ * @param steps les nouvelles étapes
+ */
+ void onStepsChanged(E[] steps);
+
+ /**
+ * Méthode invoquée lorsque l'étape courante a changé dans le modèle.
+ *
+ * @param newStep la nouvelle étape courante
+ */
+ void onStepChanged(E newStep);
+
+ /**
+ * Méthode invoquée lorsque l'état interne du modèle a changé.
+ *
+ * @param newState le nouvelle état du modèle de wizard
+ */
+ void onModelStateChanged(WizardOperationState newState);
+
+ /**
+ * Méthode invoqué lorsque l'état d'une opération a changé.
+ *
+ * @param step l'étape dont l'état a changé
+ * @param newState le nouvel état pour l'étape donné
+ */
+ void onOperationStateChanged(E step,WizardOperationState newState) ;
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,162 @@
+package jaxx.runtime.swing.wizard;
+
+import java.awt.Window;
+import javax.swing.ImageIcon;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.beanutils.ConstructorUtils;
+
+/**
+ *
+ * Une classe pour lancer une ui de wizard.
+ *
+ * @param <E> le type des etapes
+ * @param <M> le type de modele
+ * @param <UI> le type d'ui
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardUILancher<E extends WizardStep, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
+
+ protected UI ui;
+
+ public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, String title, String tip, ImageIcon icon) {
+ this(context, uiClass, modelClass, null, title, tip, icon);
+ }
+
+ public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) {
+ try {
+ ui = createUI(context, uiClass, modelClass, model, title, tip, icon);
+ } catch (Exception ex) {
+ throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) {
+ try {
+ ui = createUI(context, mainUI, uiClass, modelClass, model);
+ } catch (Exception ex) {
+ throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass) {
+ this(context, mainUI, uiClass, modelClass, null);
+ }
+
+ public void start() {
+ init(ui);
+ start(ui);
+ }
+
+ protected void start(UI ui) {
+ ui.start();
+ }
+
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ if (ui == null) {
+ throw new NullPointerException("ui can not be null");
+ }
+ if (!(ui instanceof JAXXObject)) {
+ throw new ClassCastException("ui can not be casted to JAXXObject ");
+ }
+
+ return ((JAXXObject) ui).getContextValue(clazz, name);
+ }
+
+ public <T> T getContextValue(Class<T> clazz) {
+ return getContextValue(clazz, null);
+ }
+
+ protected void init(UI ui) {
+ }
+
+ protected void doAction(UI ui) {
+ }
+
+ protected void doCancel(UI ui) {
+ }
+
+ protected void doClose(UI ui, boolean wasCanceld) {
+ }
+
+ @SuppressWarnings("unchecked")
+ protected UI createUI(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) throws Exception {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(mainUI == null ? context : mainUI);
+ // parent context model
+ uiContext.add(modelClass.newInstance());
+ if (model != null) {
+ uiContext.add("incoming", model);
+ }
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doAction(ui);
+ } finally {
+ doClose(ui, false);
+ }
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doCancel(ui);
+ } finally {
+ doClose(ui, true);
+ }
+ }
+ });
+
+ // instanciate ui
+
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{Window.class, JAXXContext.class});
+ return newUI;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected UI createUI(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) throws Exception {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(context);
+ // parent context model
+ uiContext.add(modelClass.newInstance());
+ if (model != null) {
+ uiContext.add("incoming", model);
+ }
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doAction(ui);
+ } finally {
+ doClose(ui, false);
+ }
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doCancel(ui);
+ } finally {
+ doClose(ui, true);
+ }
+ }
+ });
+
+ // instanciate ui
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{uiContext, title, tip, icon}, new Class[]{JAXXContext.class, String.class, String.class, ImageIcon.class});
+ return newUI;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,157 @@
+package jaxx.runtime.swing.wizard;
+
+import java.awt.Component;
+import java.beans.IndexedPropertyChangeEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.Array;
+import javax.swing.JTabbedPane;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Classe de méthodes utiles sur les wizard.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class WizardUtil {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(WizardUI.class);
+
+ protected WizardUtil() {
+ }
+
+ public static boolean acceptStates(WizardOperationState state, WizardOperationState... accepted) {
+ for (WizardOperationState s : accepted) {
+ if (s == state) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean rejectStates(WizardOperationState state, WizardOperationState... rejected) {
+ for (WizardOperationState s : rejected) {
+ if (s == state) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static void addDebugLogListener(final Log log, WizardModel<?> model) {
+ if (log.isDebugEnabled()) {
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.debug(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ }
+ });
+ }
+ }
+
+ public static void addTraceLogListener(final Log log, WizardModel<?> model) {
+ if (log.isTraceEnabled()) {
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ }
+ });
+ }
+ }
+
+ public static <E extends WizardStep, M extends WizardModel<E>> void installWizardUIListeners(final WizardUI<E, M> ui) {
+ ui.getModel().addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void propertyChange(PropertyChangeEvent evt) {
+ String propertyName = evt.getPropertyName();
+ if (WizardOperationModel.WAS_STARTED_PROPERTY_NAME.equals(propertyName)) {
+ ui.onWasStarted();
+ return;
+ }
+ if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) {
+ java.util.List<E> steps = (java.util.List<E>) evt.getNewValue();
+ ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size())));
+ return;
+ }
+ if (WizardModel.STEP_PROPERTY_NAME.equals(propertyName)) {
+ ui.onStepChanged((E) evt.getNewValue());
+ return;
+ }
+ if (WizardOperationModel.MODEL_STATE_PROPERTY_NAME.equals(propertyName)) {
+ //TODO should be unicast : only for good stepUI ?
+ ui.onModelStateChanged((WizardOperationState) evt.getNewValue());
+ return;
+ }
+ if (WizardOperationModel.OPERATION_STATE_PROPERTY_NAME.equals(propertyName)) {
+ IndexedPropertyChangeEvent e = (IndexedPropertyChangeEvent) evt;
+ int stepIndex = e.getIndex();
+ E step = ui.getModel().getSteps().get(stepIndex);
+ ui.onOperationStateChanged(step, (WizardOperationState) evt.getNewValue());
+ return;
+ }
+ }
+ });
+ }
+
+ /**
+ * Ajoute un listener sur le modele pour gere la politique d'affichage des
+ * onglets.
+ *
+ * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape courante.
+ * Lorsque l'on revient en arrière, les onglets d'etapes superieurs sont
+ * fermes.
+ *
+ * @param <E> le type d'un etape de l'assistant
+ * @param <M> le type du modele de l'assistant
+ * @param ui l'ui de l'assitant
+ * @since 1.7.1
+ */
+ public static <E extends WizardStep, M extends WizardModel<E>> void addTabsDisplayUntilStepListener(final WizardUI<E, M> ui) {
+ // on écoute les changements d'étapes
+ ui.getModel().addPropertyChangeListener(WizardModel.STEP_PROPERTY_NAME, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ M model = (M) evt.getSource();
+ E oldStep = (E) evt.getOldValue();
+ E newStep = (E) evt.getNewValue();
+ log.debug("step has changed <old:" + oldStep + ", new:" + newStep + ">");
+ int oldStepIndex = oldStep == null ? -1 : model.getStepIndex(oldStep);
+ int newStepIndex = model.getStepIndex(newStep);
+ JTabbedPane tabs = ui.getTabs();
+ if (oldStepIndex + 1 == newStepIndex) {
+ // creation d'un nouvel onglet
+ WizardStepUI<E, M> c = ui.getStepUI(newStep);
+ String title = _(newStep.getLabel());
+ String tip = _(newStep.getDescription());
+ tabs.addTab(title, null, (Component) c, tip);
+ // selection du nouvel onglet
+ int index = tabs.indexOfComponent((Component) c);
+ if (index > -1) {
+ tabs.setSelectedIndex(index);
+ }
+ } else if (oldStepIndex > newStepIndex) {
+ // il s'agit d'un retour en arrière
+ // on supprime tous les onglets obsoletes
+ int index = newStepIndex + 1;
+ while (tabs.getTabCount() > index) {
+ log.trace("remove tab : " + index);
+ tabs.remove(index);
+ }
+ } else {
+ throw new IllegalStateException("can not go from " + oldStep + " to " + newStep);
+ }
+ }
+ });
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <h1>JAXX - Wizard framework</h1>
+
+ This package contains all the classes of the wizard framework.
+
+ TODO
+ </body>
+</html>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,6 +1,5 @@
package jaxx.runtime.validator;
-import jaxx.runtime.BeanValidatorUtil;
import java.beans.EventSetDescriptor;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -17,7 +17,7 @@
String[] messagestoAdd;
String[] messagestoDelete;
- public BeanValidatorEvent(BeanValidator source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+ public BeanValidatorEvent(BeanValidator<?> source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
super(source);
this.field = field;
this.scope = scope;
@@ -26,8 +26,8 @@
}
@Override
- public BeanValidator getSource() {
- return (BeanValidator) super.getSource();
+ public BeanValidator<?> getSource() {
+ return (BeanValidator<?>) super.getSource();
}
public String getFieldName() {
@@ -46,7 +46,7 @@
return scope;
}
- public BeanValidatorField getField() {
+ public BeanValidatorField<?> getField() {
return field;
}
}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -192,11 +192,11 @@
if (this == o) {
return true;
}
- if (!(o instanceof BeanValidatorField)) {
+ if (!(o instanceof BeanValidatorField<?>)) {
return false;
}
- BeanValidatorField that = (BeanValidatorField) o;
+ BeanValidatorField<?> that = (BeanValidatorField<?>) o;
return beanClass.equals(that.beanClass) && name.equals(that.name);
}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -8,16 +8,16 @@
* @author chemit
* @since 1.3
*/
-public class BeanValidatorMessage<E extends BeanValidatorMessage> implements Comparable<E> {
+public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> {
/**
* the validator that produce the message
*/
- protected BeanValidator validator;
+ protected BeanValidator<?> validator;
/**
* the field thatproduce the message
*/
- protected BeanValidatorField field;
+ protected BeanValidatorField<?> field;
/**
* the label of the message (to be displayed somewhere)
*/
@@ -27,18 +27,18 @@
*/
protected BeanValidatorScope scope;
- public BeanValidatorMessage(BeanValidator validator, BeanValidatorField field, String message, BeanValidatorScope scope) {
+ public BeanValidatorMessage(BeanValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope) {
this.field = field;
this.validator = validator;
this.message = message;
this.scope = scope;
}
- public BeanValidator getValidator() {
+ public BeanValidator<?> getValidator() {
return validator;
}
- public BeanValidatorField getField() {
+ public BeanValidatorField<?> getField() {
return field;
}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/BeanValidatorUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,176 @@
+package jaxx.runtime.validator;
+
+import jaxx.runtime.*;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import jaxx.runtime.validator.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author chemit
+ */
+public class BeanValidatorUtil {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
+ /**
+ * a shared value stack to allow external operations on it (for example
+ * add some datas in stack to be usedby validators
+ */
+ static private ValueStack sharedValueStack;
+
+ public static synchronized ValueStack getSharedValueStack() {
+ if (sharedValueStack == null) {
+
+ // init context
+ ConfigurationManager confManager = new ConfigurationManager();
+ Configuration conf = confManager.getConfiguration();
+
+ sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+ if (log.isDebugEnabled()) {
+ log.debug("init shared value stack " + sharedValueStack);
+ }
+ }
+ return sharedValueStack;
+ }
+
+ protected BeanValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Convinient method to attach a bean to all validators of an JAXXObject.
+ * <p/>
+ * It is possible to exclude some validator to be treated.
+ *
+ * @param ui the ui containing the validatros to treate
+ * @param bean the bean to attach in validators (can be null)
+ * @param excludeIds the list of validator id to exclude
+ */
+ @SuppressWarnings({"unchecked"})
+ public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
+ if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
+ return;
+ }
+ JAXXValidator jaxxValidator = (JAXXValidator) ui;
+ List<String> validatorIds = jaxxValidator.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
+ // touch validator, only if fits the bean type (or bean is null)
+ beanValidator.setBean(bean);
+ }
+ }
+ }
+
+ /**
+ * Convinient method to set the changed property to all validators of an JAXXObject.
+ * <p/>
+ * It is possible to exclude some validator to be treated.
+ *
+ * @param ui the ui containing the validatros to treate
+ * @param newValue the new value to set in changed validator property
+ * @param excludeIds the list of validator id to exclude
+ */
+ @SuppressWarnings({"unchecked"})
+ public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
+ if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
+ return;
+ }
+ JAXXValidator jaxxValidator = (JAXXValidator) ui;
+ List<String> validatorIds = jaxxValidator.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ beanValidator.setChanged(newValue);
+ }
+ }
+
+ /**
+ * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
+ *
+ * @param validator validator to be involved
+ * @param fieldName the name of the bean property
+ * @param value the actual value to convert
+ * @param valueClass the type of the conversion
+ */
+ public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
+
+ Object result = validator.convert(fieldName, value, valueClass);
+ if (result != null) {
+ try {
+ BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
+
+ for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
+ if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
+
+ descriptor.getWriteMethod().invoke(validator.getBean(), result);
+ break;
+ }
+ }
+ } catch (IntrospectionException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ }
+ } else {
+ //fixme : conversion failed, we should be able to notify ui that values has changed ?
+ // otherwise, bean value has not changed,...
+ }
+ }
+
+ public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
+ try {
+ // check that the bean is listenable, otherwise, can't use
+ // the validator on it
+ BeanInfo infos = Introspector.getBeanInfo(beanClass);
+ EventSetDescriptor[] events = infos.getEventSetDescriptors();
+ for (EventSetDescriptor event : events) {
+ if ("propertyChange".equals(event.getName())) {
+
+ if (event.getAddListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
+ }
+ if (event.getRemoveListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
+ }
+ return event;
+ }
+ }
+
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
+ } catch (IntrospectionException ex) {
+ throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -20,7 +20,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import jaxx.runtime.BeanValidatorUtil;
/**
*
@@ -182,10 +181,10 @@
}
if (validationContext.hasFieldErrors()) {
- Map messages = validationContext.getFieldErrors();
+ Map<?,?> messages = validationContext.getFieldErrors();
result = new HashMap<String, List<String>>(messages.size());
for (Object fieldName : messages.keySet()) {
- Collection c = (Collection) messages.get(fieldName);
+ Collection<?> c = (Collection<?>) messages.get(fieldName);
List<String> mm = new java.util.ArrayList<String>(c.size());
for (Object message : c) {
mm.add(message + "");
@@ -225,7 +224,7 @@
int skip = 0;
if (contextName != null && !includeDefaultContext) {
// count the number of validator to skip
- for (Validator v : validator.getValidators(beanClass, null)) {
+ for (Validator<?> v : validator.getValidators(beanClass, null)) {
// we only work on FieldValidator at the moment
if (v instanceof FieldValidator) {
skip++;
@@ -233,7 +232,7 @@
}
}
- for (Validator v : validator.getValidators(beanClass, contextName)) {
+ for (Validator<?> v : validator.getValidators(beanClass, contextName)) {
// we only work on FieldValidator at the moment
if (v instanceof FieldValidator) {
if (skip > 0) {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -41,6 +41,7 @@
*/
public class ExistingDirectoryFieldValidator extends FieldValidatorSupport {
+ @Override
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -41,6 +41,7 @@
*/
public class ExistingFileFieldValidator extends FieldValidatorSupport {
+ @Override
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -41,6 +41,7 @@
*/
public class RequiredFileFieldValidator extends FieldValidatorSupport {
+ @Override
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,279 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
+import jaxx.runtime.validator.swing.ui.IconValidationUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import java.awt.Container;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import jaxx.runtime.validator.BeanValidator;
+import jaxx.runtime.validator.BeanValidatorField;
+
+/**
+ * La surcharge de {@link jaxx.runtime.validator.BeanValidator} pour les ui swing
+ * <p/>
+ * /**
+ * <p/>
+ * Permet d'ajouter facilement le support de la validation des champs d'un
+ * bean et de le relier a une interface graphique.
+ * Utilise xwork pour la validation et JXLayer pour la visualisation.
+ * <p/>
+ * <p/>
+ * Le mieux pour son integration dans Jaxx est de faire de la generation pour
+ * force la compilation du code suivant:
+ * <p/>
+ * <pre>
+ * myValidor.getBean().get<field>();
+ * </pre>
+ * <p/>
+ * et ceci pour chaque field ajoute a la map fieldRepresentation. De cette
+ * facon meme si le champs field est en texte on a une verification de son
+ * existance a la compilation.
+ * <p/>
+ * <p/>
+ * La representation en tag pourrait etre
+ * <pre>
+ * <validator id="myValidator" beanClass="{Personne.class}" errorList="$list">
+ * <field name="name" component="$name"/>
+ * <field name="firstName" component="$firstName"/>
+ * <field name="birthDate" component="$birthDate"/>
+ * </validator>
+ * <validator beanClass="{Personne.class}" autoField="true" errorList="$list">
+ * <fieldRepresentation name="name" component="$lastName"/>
+ * </validator>
+ * </pre>
+ * <p/>
+ * dans le premier exemple on fait un mapping explicite des champs, mais on voit
+ * que le nom du composant graphique est le meme que celui du champs. Pour eviter
+ * de longue saisie, il est possible d'utiliser le flag <b>autoField</b>
+ * qui pour chaque champs du ayant une methode get du bean recherche un composant
+ * avec cet Id. Il est aussi possible de surcharge un champs explicitement
+ * comme ici name, dans le cas ou le composant qui porterait ce nom serait
+ * utilise pour autre chose.
+ * <p/>
+ * <p/>
+ * Il faut un handler particulier pour ce composant car les attributs
+ * <b>beanClass</b> et <b>autoField</b> ne sont present que dans le XML jaxx et
+ * servent a la generation. Il faut aussi prendre en compte les elements
+ * fieldRepresentation fils du tag validator.
+ * <p/>
+ * <p/>
+ * Voici ce que pourrait etre le code genere par jaxx
+ * <pre>
+ * // declaration du bean
+ * BeanValidator<beanClass> $myValidator;
+ * // init du bean
+ * protected void createMyValidator() {
+ * $myValidator = new BeanValidator<beanClass>();
+ * // genere seulement si autoField = true
+ * for (Method m : beanClass.getMethod()) {
+ * if (m.getName().startsWith("get")) {
+ * String fieldName = m.getName().substring(3).toLowerCase();
+ * $myValidator.setFieldRepresentation(fieldName, $objectMap.get(fieldName));
+ * }
+ * }
+ * // pour chaque tag fieldRepresentation
+ * myValidator.setFieldRepresentation("name", $lastName);
+ * // si beanClass est specifie et n'est pas Object, on force l'acces au champs
+ * // pour validation a la compilation
+ * $myValidator.getBean().getName();
+ * $objectMap.put("myValidator", $myValidator);
+ * }
+ * </pre>
+ *
+ * @param <B> le type de bean a valider
+ * @author poussin
+ * @author chemit
+ * @version 1.0
+ */
+public class SwingValidator<B> extends BeanValidator<B> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingValidator.class);
+ static private final Class<? extends AbstractBeanValidatorUI> DEFAULT_UI_CLASS = IconValidationUI.class;
+ /** permet de faire le lien en un champs du bean et l'objet qui permet de l'editer */
+ protected Map<String, JComponent> fieldRepresentation;
+ /** Object servant a contenir la liste des erreurs */
+ protected SwingValidatorMessageListModel errorListModel;
+ /** Object servant a contenir la liste des erreurs */
+ protected SwingValidatorMessageTableModel errorTableModel;
+ /** ui renderer class */
+ protected Class<? extends AbstractBeanValidatorUI> uiClass;
+
+ public SwingValidator(Class<B> beanClass, String contextName) {
+ super(beanClass, contextName);
+ fieldRepresentation = new HashMap<String, JComponent>();
+ }
+
+ /**
+ * To reload a bean in the validator.
+ *
+ * This method is used to reload ui, since some editors
+ * could not exist when validator is init, so some messages
+ * should not be attached to an editor.
+ */
+ public void reloadBean() {
+ B b = getBean();
+ if (b != null) {
+ setBean(null);
+ setBean(b);
+ }
+ }
+
+ public JComponent getFieldRepresentation(String fieldname) {
+ return fieldRepresentation.get(fieldname);
+ }
+
+ public Class<? extends AbstractBeanValidatorUI> getUiClass() {
+ return uiClass;
+ }
+
+ public void setErrorListModel(SwingValidatorMessageListModel errorListModel) {
+ this.errorListModel = errorListModel;
+ if (errorListModel != null) {
+ // register the validator in the model list
+ errorListModel.registerValidator(this);
+ }
+ }
+
+ public void setErrorTableModel(SwingValidatorMessageTableModel errorTableModel) {
+ this.errorTableModel = errorTableModel;
+ if (errorTableModel != null) {
+ // register the validator in the model table
+ errorTableModel.registerValidator(this);
+ }
+ }
+
+ public void setUiClass(Class<? extends AbstractBeanValidatorUI> uiClass) {
+ this.uiClass = uiClass;
+ }
+
+ @Override
+ public void setContextName(String contextName) {
+ /*Map<ValidatorField<B>, List<ValidatorErrorListener>> oldListeners = new HashMap<ValidatorField<B>, List<ValidatorErrorListener>>();
+
+ for (ValidatorField<B> field : fields) {
+ ValidatorErrorListener[] listeners = field.getValidatorErrorListeners();
+ List<ValidatorErrorListener> toReinject = new ArrayList<ValidatorErrorListener>();
+ for (ValidatorErrorListener listener : listeners) {
+ if (listener instanceof AbstractBeanValidatorUI) {
+ // this listener will be reinject via installUIs method
+ continue;
+ }
+ toReinject.add(listener);
+ }
+ oldListeners.put(field, toReinject);
+ }*/
+ super.setContextName(contextName);
+ // must reinstall ui
+ installUIs();
+ // reinject none ui listeners
+ /*for (Entry<ValidatorField<B>, List<ValidatorErrorListener>> entry : oldListeners.entrySet()) {
+ ValidatorField<B> field = getField(entry.getKey().getName());
+ for (ValidatorErrorListener listener : entry.getValue()) {
+ field.addValidatorErrorListener(listener);
+ }
+ }
+ oldListeners.clear();*/
+ }
+
+ /**
+ * Permet d'indiquer le composant graphique responsable de l'affichage
+ * d'un attribut du bean
+ *
+ * @param fieldname the field name in the bean
+ * @param c the editor component for the field
+ */
+ public void setFieldRepresentation(String fieldname, JComponent c) {
+ BeanValidatorField<B> field = getField(fieldname);
+ if (field == null) {
+ // no field registred in the validator
+ log.warn("the field '" + fieldname + "' is not defined in validator (no rules on it)");
+ return;
+ }
+ fieldRepresentation.put(fieldname, c);
+ }
+
+ public void setFieldRepresentation(Map<String, JComponent> fieldRepresentation) {
+ for (Map.Entry<String, JComponent> e : fieldRepresentation.entrySet()) {
+ setFieldRepresentation(e.getKey(), e.getValue());
+ }
+ }
+
+ @Override
+ public SwingValidator<?> getParentValidator() {
+ return (SwingValidator<?>) super.getParentValidator();
+ }
+
+ public void setParentValidator(SwingValidator<?> parentValidator) {
+ super.setParentValidator(parentValidator);
+ }
+
+ /** install ui on required components */
+ public void installUIs() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (uiClass == null) {
+ // use the default one
+ uiClass = DEFAULT_UI_CLASS;
+ }
+ for (Entry<String, JComponent> entry : fieldRepresentation.entrySet()) {
+ try {
+ setMessageRepresentation(entry.getKey(), null, entry.getValue(), uiClass);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ });
+ }
+
+ protected void setMessageRepresentation(String fieldname, JComponent old, JComponent c, Class<? extends AbstractBeanValidatorUI> uiClass)
+ throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
+ if (old == c) {
+ // same component, nothing to do
+ return;
+ }
+ BeanValidatorField<B> field = getField(fieldname);
+
+ if (field == null) {
+ // this case should not appear since fieldName has already been check in method addFieldRepresentation
+ return;
+ }
+ if (old != null) {
+ // suppression du jxlayer sous l'ancien composant
+ Container container = old.getParent();
+ if (container instanceof JXLayer<?>) {
+ JXLayer<?> jx = (JXLayer<?>) container;
+ Object ui = jx.getUI();
+ if (ui != null && ui instanceof AbstractBeanValidatorUI) {
+ removeBeanValidatorListener((AbstractBeanValidatorUI) ui);
+ }
+
+ jx.setUI(null);
+ }
+ }
+ if (c != null) {
+ // ajout du jxlayer sous ce composant
+ Container container = c.getParent();
+ if (container instanceof JXLayer<?>) {
+ Constructor<? extends AbstractBeanValidatorUI> cons = uiClass.getConstructor(BeanValidatorField.class);
+ AbstractBeanValidatorUI ui = cons.newInstance(field);
+ ui.setEnabled(true);
+ JXLayer<JComponent> jx = (JXLayer<JComponent>) container;
+ addBeanValidatorListener(ui);
+ jx.setUI(ui);
+ }
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,66 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.JComponent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorMessage;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/**
+ * The object to box a validation message within an u.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see BeanValidatorMessage
+ */
+public class SwingValidatorMessage extends BeanValidatorMessage<SwingValidatorMessage> {
+
+ /**
+ * the optional field's editor
+ */
+ protected JComponent editor;
+ protected String fieldName;
+
+ public SwingValidatorMessage(SwingValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope, JComponent editor) {
+ super(validator, field, message, scope);
+ this.fieldName = field.getName();
+ this.editor = editor;
+ }
+
+ public SwingValidatorMessage(SwingValidator<?> validator, String fieldName, String message, BeanValidatorScope scope, JComponent editor) {
+ super(validator, null, message, scope);
+ this.fieldName = fieldName;
+ this.editor = editor;
+ }
+
+ public JComponent getEditor() {
+ return editor;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ @Override
+ public int compareTo(SwingValidatorMessage o) {
+ // sort on scope
+ int result = getScope().compareTo(o.getScope());
+ if (result == 0) {
+ // sort on field name
+ result = fieldName.compareTo(o.getFieldName());
+ if (result == 0) {
+ // sort on message
+ result = message.compareTo(o.getMessage());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ String s = scope + " - " + (field == null ? message : field.getI18nError(message));
+ if (editor == null) {
+ return s;
+ }
+ return editor.getName() + " : " + s;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,142 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+
+import javax.swing.JComponent;
+import java.util.ArrayList;
+import java.util.List;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The model of the list of validation's messages
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageListModel
+ extends javax.swing.AbstractListModel
+ implements jaxx.runtime.validator.BeanValidatorListener {
+
+ private static final long serialVersionUID = 1L;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageListModel.class);
+ /** list of registred validators */
+ protected transient List<SwingValidator<?>> validators;
+ /** list of messages actual displayed */
+ protected List<SwingValidatorMessage> data;
+
+ public SwingValidatorMessageListModel() {
+ validators = new ArrayList<SwingValidator<?>>();
+ data = new java.util.ArrayList<SwingValidatorMessage>();
+ }
+
+ public boolean isEmpty() {
+ return getSize() == 0;
+ }
+
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
+ }
+
+ public void clear() {
+ int i = data.size();
+ if (i > 0) {
+ data.clear();
+ fireIntervalRemoved(this, 0, i - 1);
+ }
+ }
+
+ @Override
+ public int getSize() {
+ return data.size();
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ ensureRowIndex(index);
+ return data.get(index);
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorField<?> field = event.getField();
+ BeanValidatorScope scope = event.getScope();
+ boolean mustAdd = toAdd != null && toAdd.length > 0;
+ boolean mustDel = toDelete != null && toDelete.length > 0;
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getSize() + ") toAdd " + mustAdd);
+ log.trace(field + " - (" + getSize() + ") toDelete " + mustDel);
+ }
+
+ SwingValidator<?> validator = (SwingValidator<?>) event.getSource();
+
+ if (mustDel) {
+
+ // removes datas and notify if no messages to add
+ removeMessages(validator, field, scope, !mustAdd, toDelete);
+ }
+
+ if (mustAdd) {
+
+ // add new messages, sort datas and notify
+ addMessages(validator, field, scope, true, toAdd);
+ }
+ }
+
+ protected void ensureRowIndex(int index) throws ArrayIndexOutOfBoundsException {
+ if (index < -1 || index >= getSize()) {
+ throw new ArrayIndexOutOfBoundsException("the rowIndex was " + index + ", but should be int [0," + (getSize() - 1) + "]");
+ }
+ }
+
+ protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireIntervalAdded(this, data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireContentsChanged(this, 0, getSize() - 1);
+ }
+ }
+
+ protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getSize() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getField() == field && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireIntervalRemoved(this, i, i);
+ }
+ }
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,60 @@
+package jaxx.runtime.validator.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JComponent;
+import javax.swing.JList;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/**
+ * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageListModel} as a model.
+ * <p/>
+ * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageListMouseListener extends MouseAdapter {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(SwingValidatorMessageListMouseListener.class);
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ super.mouseClicked(e);
+ if (e.getClickCount() == 2) {
+
+ SwingValidatorMessage entry = getSelectedMessage(e);
+ if (entry == null) {
+ // no entry found
+ return;
+ }
+ JComponent component = entry.getEditor();
+ if (component != null) {
+ component.requestFocus();
+ }
+ }
+ }
+
+ protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
+ JList list = (JList) e.getSource();
+ if (!(list.getModel() instanceof SwingValidatorMessageListModel)) {
+ log.warn("model must be a " + SwingValidatorMessageListModel.class + ", but was " + list.getModel());
+ return null;
+ }
+
+ SwingValidatorMessageListModel model = (SwingValidatorMessageListModel) list.getModel();
+ int index = list.getSelectionModel().getMinSelectionIndex();
+ if (index == -1) {
+ // nothing is selected
+ return null;
+ }
+ SwingValidatorMessage entry = (SwingValidatorMessage) model.getElementAt(index);
+ if (log.isDebugEnabled()) {
+ log.debug("selected index: " + index + " : error: " + entry);
+ }
+ return entry;
+ }
+
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,89 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import jaxx.runtime.validator.BeanValidatorScope;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * A simple render of a table of validator's messages, says a table that use
+ * a {@link SwingValidatorMessageTableModel} model.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see SwingValidatorMessageTableModel
+ */
+public class SwingValidatorMessageListRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected String format = "%1$-20s - %2$s";
+ protected String formatTip = "%1$-20s - %2$-20s : %3$s";
+
+ public SwingValidatorMessageListRenderer() {
+ }
+
+ public SwingValidatorMessageListRenderer(String format) {
+ this.format = format;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+
+ JLabel rendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+
+ SwingValidatorMessage model = (SwingValidatorMessage) value;
+
+ // scope
+ ImageIcon icon = SwingValidatorUtil.getIcon(model.getScope());
+
+ // field name
+ String fieldName = getFieldName(list, model.getField().getName(), index);
+
+ // message
+ String message = getMessage(model);
+
+ // text to display
+ String text = String.format(format, fieldName, message);
+
+ String label = _(model.getScope().getLabel());
+ String tmp = _("validator.scope.tip", label);
+ String tmp2 = _("validator.field.tip", fieldName);
+
+ String tooltTipText = String.format(formatTip, tmp, tmp2, message);
+
+
+ rendererComponent.setText(text);
+ rendererComponent.setToolTipText(tooltTipText);
+ rendererComponent.setIcon(icon);
+
+ return rendererComponent;
+ }
+
+ public ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = SwingValidatorUtil.getIcon(scope);
+ return icon;
+ }
+
+ public String getMessage(SwingValidatorMessage model) {
+ String text = SwingValidatorUtil.getMessage(model);
+ return text;
+ }
+
+ public String getFieldName(JList list, String value, int row) {
+ SwingValidatorMessageListModel tableModel = (SwingValidatorMessageListModel) list.getModel();
+ SwingValidatorMessage model = (SwingValidatorMessage) tableModel.getElementAt(row);
+ String fieldName = SwingValidatorUtil.getFieldName(model, value);
+ return fieldName;
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,327 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+
+import javax.swing.JComponent;
+import java.util.ArrayList;
+import java.util.List;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The model of the table of errors.
+ *
+ * The model listens validators messages and update his internal model from it.
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public class SwingValidatorMessageTableModel
+ extends javax.swing.table.AbstractTableModel
+ implements jaxx.runtime.validator.BeanValidatorListener {
+
+ private static final long serialVersionUID = 1L;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+ public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
+ public static final Class<?>[] columnClasses = {BeanValidatorScope.class, String.class, String.class};
+ /** list of registred validators */
+ protected transient List<SwingValidator<?>> validators;
+ /** list of messages actual displayed */
+ protected List<SwingValidatorMessage> data;
+
+ public SwingValidatorMessageTableModel() {
+ super();
+ validators = new ArrayList<SwingValidator<?>>();
+ data = new java.util.ArrayList<SwingValidatorMessage>();
+ }
+
+ /**
+ * Register a validator for this model.
+ *
+ *
+ * Note: a validator can not be register twice in the same model.
+ *
+ * @param validator the validator to register
+ */
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
+ }
+
+ public void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ addMessages(validator, fieldName, scope, true, messages);
+ }
+
+ public void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, String... messages) {
+ addMessages(editor, fieldName, scope, true, messages);
+ }
+
+ public void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) {
+ addMessages(validator, field, scope, true, messages);
+ }
+
+ public void removeMessages(JComponent editor, BeanValidatorScope scope) {
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getEditor() == editor && (scope == null || error.getScope() == scope)) {
+ // remove the message
+ data.remove(i);
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+
+ public void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ removeMessages(validator, fieldName, scope, true, messages);
+ }
+
+ public void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope) {
+ removeMessages(editor, fieldName, scope, true);
+ }
+
+ public void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) {
+ removeMessages(validator, field, scope, true, messages);
+ }
+
+ public void clear() {
+ int i = data.size();
+ if (i > 0) {
+ data.clear();
+ fireTableRowsDeleted(0, i - 1);
+ }
+ }
+
+ /**
+ * Obtain the message for a given row.
+ *
+ * @param rowIndex the row index
+ * @return the message for the given row index
+ */
+ public SwingValidatorMessage getRow(int rowIndex) {
+ ensureRowIndex(rowIndex);
+ return data.get(rowIndex);
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ // cells are never editable in this model
+ return false;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ ensureColumnIndex(columnIndex);
+ return columnClasses[columnIndex];
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ ensureColumnIndex(column);
+ return columnNames[column];
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorField<?> field = event.getField();
+ BeanValidatorScope scope = event.getScope();
+ boolean mustAdd = toAdd != null && toAdd.length > 0;
+ boolean mustDel = toDelete != null && toDelete.length > 0;
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getRowCount() + ") toAdd " + mustAdd);
+ log.trace(field + " - (" + getRowCount() + ") toDelete " + mustDel);
+ }
+
+ SwingValidator<?> validator = (SwingValidator<?>) event.getSource();
+
+ if (mustDel) {
+
+ // removes datas and notify if no messages to add
+ removeMessages(validator, field, scope, !mustAdd, toDelete);
+ }
+
+ if (mustAdd) {
+
+ // add new messages, sort datas and notify
+ addMessages(validator, field, scope, true, toAdd);
+ }
+ }
+
+ @Override
+ public int getRowCount() {
+ return data.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ ensureColumnIndex(columnIndex);
+ ensureRowIndex(rowIndex);
+
+ SwingValidatorMessage row = data.get(rowIndex);
+ if (columnIndex == 0) {
+ // the icon
+ return row.getScope();
+ }
+ if (columnIndex == 1) {
+ // the field
+ return row.getFieldName();
+ }
+ if (columnIndex == 2) {
+ // the message
+ return row.getMessage();
+ }
+
+ // should never come here
+ return null;
+ }
+
+ protected void ensureRowIndex(int rowIndex) throws ArrayIndexOutOfBoundsException {
+ if (rowIndex < -1 || rowIndex >= getRowCount()) {
+ throw new ArrayIndexOutOfBoundsException("the rowIndex was " + rowIndex + ", but should be int [0," + (getRowCount() - 1) + "]");
+ }
+ }
+
+ protected void ensureColumnIndex(int index) throws ArrayIndexOutOfBoundsException {
+ if (index < -1 || index >= getColumnCount()) {
+ throw new ArrayIndexOutOfBoundsException("the columnIndex was " + index + ", but should be int [0," + (getColumnCount() - 1) + "]");
+ }
+ }
+
+ protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator == null ? null : validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator == null ? null : validator.getFieldRepresentation(fieldName);
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, fieldName, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(null, fieldName, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(field.getName()) && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+ }
+
+ protected void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(fieldName) && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+ }
+
+ protected void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean notify) {
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getEditor() == editor && (scope == null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+package jaxx.runtime.validator.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageTableModel} as a model.
+ * <p/>
+ * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageTableMouseListener extends MouseAdapter {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+
+ public static final String HIGHLIGHT_ERROR_PROPERTY = "highlightError";
+
+ /** delgate property change support */
+ protected PropertyChangeSupport pcs;
+
+ public SwingValidatorMessageTableMouseListener() {
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ super.mouseClicked(e);
+ if (e.getClickCount() == 2) {
+
+ SwingValidatorMessage entry = getSelectedMessage(e);
+ if (entry == null) {
+ // no entry found
+ return;
+ }
+ JComponent component = entry.getEditor();
+ if (component != null) {
+ pcs.firePropertyChange(HIGHLIGHT_ERROR_PROPERTY, null, entry);
+ if (component.isVisible()) {
+ component.requestFocus();
+ }
+ }
+ }
+ }
+
+
+ protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
+ JTable table = (JTable) e.getSource();
+ if (!(table.getModel() instanceof SwingValidatorMessageTableModel)) {
+ log.warn("model must be a " + SwingValidatorMessageTableModel.class + ", but was " + table.getModel());
+ return null;
+ }
+
+ SwingValidatorMessageTableModel model = (SwingValidatorMessageTableModel) table.getModel();
+ int index = table.getSelectionModel().getMinSelectionIndex();
+ if (index == -1) {
+ // nothing is selected
+ return null;
+ }
+ if (table.getRowSorter() != null) {
+ index = table.getRowSorter().convertRowIndexToModel(index);
+ }
+ SwingValidatorMessage entry = model.getRow(index);
+ if (log.isDebugEnabled()) {
+ log.debug("selected index: " + index + " : error: " + entry);
+ }
+ return entry;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,83 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.Component;
+import jaxx.runtime.validator.BeanValidatorScope;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * A simple render of a table of validator's messages, says a table that use
+ * a {@link SwingValidatorMessageTableModel} model.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see SwingValidatorMessageTableModel
+ */
+public class SwingValidatorMessageTableRenderer extends DefaultTableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ ImageIcon icon = null;
+ String text = null;
+ String toolTipText = null;
+
+ column = table.convertColumnIndexToModel(column);
+ if (table.getRowSorter() != null) {
+ row = table.getRowSorter().convertRowIndexToModel(row);
+ }
+
+
+ switch (column) {
+ case 0:
+ // scope
+ BeanValidatorScope scope = (BeanValidatorScope) value;
+ icon = SwingValidatorUtil.getIcon(scope);
+ String label = _(scope.getLabel());
+ toolTipText = _("validator.scope.tip", label);
+ break;
+
+ case 1:
+ // field name
+ text = getFieldName(table, (String) value, row);
+ toolTipText = _("validator.field.tip", text);
+ break;
+
+ case 2:
+ // message
+ text = getMessage(table, (String) value, row);
+ toolTipText = _("validator.message.tip", text);
+ break;
+ }
+
+ rendererComponent.setText(text);
+ rendererComponent.setToolTipText(toolTipText);
+ rendererComponent.setIcon(icon);
+ return rendererComponent;
+ }
+
+ public ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = SwingValidatorUtil.getIcon(scope);
+ return icon;
+ }
+
+ public String getMessage(JTable table, String value, int row) {
+ SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessage model = tableModel.getRow(row);
+ String text = SwingValidatorUtil.getMessage(model);
+ return text;
+ }
+
+ public String getFieldName(JTable table, String value, int row) {
+ SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessage model = tableModel.getRow(row);
+ String fieldName = SwingValidatorUtil.getFieldName(model, value);
+ return fieldName;
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,201 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.*;
+import jaxx.runtime.validator.BeanValidatorUtil;
+import jaxx.runtime.validator.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JList;
+import javax.swing.JTable;
+import java.awt.event.MouseListener;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.RowSorter;
+import javax.swing.SortOrder;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessage;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author chemit
+ */
+public class SwingValidatorUtil extends BeanValidatorUtil {
+
+ static ImageIcon errorIcon;
+ static ImageIcon warningIcon;
+ static ImageIcon infoIcon;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingValidatorUtil.class);
+
+ public static ImageIcon getErrorIcon() {
+ if (errorIcon == null) {
+ errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
+ }
+ return errorIcon;
+ }
+
+ public static ImageIcon getInfoIcon() {
+ if (infoIcon == null) {
+ infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
+ }
+ return infoIcon;
+ }
+
+ public static ImageIcon getWarningIcon() {
+ if (warningIcon == null) {
+ warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
+ }
+ return warningIcon;
+ }
+
+ protected SwingValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Prepare the ui where to display the validators messages.
+ *
+ * @param errorTable the table where to display validators messages
+ * @param render renderer to use
+ */
+ public static void installUI(JTable errorTable, SwingValidatorMessageTableRenderer render) {
+ errorTable.setDefaultRenderer(Object.class, render);
+ errorTable.getRowSorter().setSortKeys(java.util.Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
+ SwingUtil.setI18nTableHeaderRenderer(errorTable,
+ n_("validator.scope.header"),
+ n_("validator.scope.header.tip"),
+ n_("validator.field.header"),
+ n_("validator.field.header.tip"),
+ n_("validator.message.header"),
+ n_("validator.message.header.tip"));
+ // register a single 'goto widget error' mouse listener on errorTable
+ registerErrorTableMouseListener(errorTable);
+ SwingUtil.fixTableColumnWidth(errorTable, 0, 25);
+ }
+
+ /**
+ * Register for a given validator list ui a validator mouse listener.
+ *
+ * Note: there is only one listener registred for a given list model, so
+ * invoking this method tiwce or more will have no effect.
+ *
+ * @param list the validation ui list
+ * @return the listener instanciate or found
+ * @see SwingValidatorMessageListMouseListener
+ */
+ public static SwingValidatorMessageListMouseListener registerErrorListMouseListener(JList list) {
+ SwingValidatorMessageListMouseListener listener = getErrorListMouseListener(list);
+
+ if (listener != null) {
+ return listener;
+ }
+ listener = new SwingValidatorMessageListMouseListener();
+ if (log.isDebugEnabled()) {
+ log.debug(listener.toString());
+ }
+ list.addMouseListener(listener);
+ return listener;
+ }
+
+ /**
+ * Register for a given validator table ui a validator mouse listener
+ *
+ * Note: there is onlt one listener registred for a givne table model, so
+ * invokin this method twice or more will have no effect.
+ *
+ * @param table the validator table ui
+ * @return the listener instanciate or found
+ * @see SwingValidatorMessageTableMouseListener
+ */
+ public static SwingValidatorMessageTableMouseListener registerErrorTableMouseListener(JTable table) {
+ SwingValidatorMessageTableMouseListener listener = getErrorTableMouseListener(table);
+
+ if (listener != null) {
+ return listener;
+ }
+ listener = new SwingValidatorMessageTableMouseListener();
+ if (log.isDebugEnabled()) {
+ log.debug(listener.toString());
+ }
+ table.addMouseListener(listener);
+ return listener;
+ }
+
+ /**
+ * @param list the validator list ui
+ * @return the validator list mouse listener, or <code>null</code> if not found
+ * @see SwingValidatorMessageListMouseListener
+ */
+ public static SwingValidatorMessageListMouseListener getErrorListMouseListener(JList list) {
+ if (list != null) {
+ for (MouseListener listener : list.getMouseListeners()) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageListMouseListener) listener;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param table the validator table ui
+ * @return the validator table mouse listener, or <code>null</code> if not found
+ * @see SwingValidatorMessageTableMouseListener
+ */
+ public static SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) {
+ if (table != null) {
+ for (MouseListener listener : table.getMouseListeners()) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageTableMouseListener) listener;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String getMessage(SwingValidatorMessage model) {
+ String text = model.getMessage();
+ if (model.getField() != null) {
+ text = model.getField().getI18nError(text);
+ }
+ return text;
+ }
+
+ public static String getFieldName(SwingValidatorMessage model, String value) {
+ String text = null;
+ JComponent editor = model.getEditor();
+ if (editor != null) {
+ text = (String) editor.getClientProperty("validatorLabel");
+ /*if (l != null) {
+ text = I18n._(l);
+ } else {
+ // TODO should try the text
+ }*/
+ }
+ if (text == null) {
+ text = value;
+ }
+ return text;
+ }
+
+ public static ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = getErrorIcon();
+ break;
+ case WARNING:
+ icon = getWarningIcon();
+ break;
+ case INFO:
+ icon = getInfoIcon();
+ break;
+ }
+ return icon;
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,37 @@
+package jaxx.runtime.validator.swing.ui;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.plaf.AbstractLayerUI;
+
+/**
+ * Abstract renderer
+ *
+ * @author chemit
+ */
+public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<javax.swing.JComponent> implements BeanValidatorListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class);
+ /** the field to render */
+ protected BeanValidatorField<?> field;
+
+ public AbstractBeanValidatorUI(BeanValidatorField<?> field) {
+ this.field = field;
+ if (log.isDebugEnabled()) {
+ log.debug("install " + this + "<field:" + field + ">");
+ }
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ if (field.equals(event.getField())) {
+ // ask to repaint the layer
+ setDirty(true);
+ }
+ }
+
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,86 @@
+package jaxx.runtime.validator.swing.ui;
+
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/** @author chemit */
+public class IconValidationUI extends AbstractBeanValidatorUI {
+
+ // The icon to be shown at the layer's corner
+ protected static BufferedImage errorIcon;
+ protected static BufferedImage warningIcon;
+ protected static BufferedImage infoIcon;
+
+ public IconValidationUI(BeanValidatorField<?> field) {
+ super(field);
+ if (errorIcon == null) {
+ errorIcon = prepareIcon(Color.RED);
+ }
+ if (warningIcon == null) {
+ warningIcon = prepareIcon(Color.ORANGE);
+ }
+ if (infoIcon == null) {
+ infoIcon = prepareIcon(Color.GREEN);
+ }
+ }
+
+ @Override
+ public void installUI(JComponent c) {
+ super.installUI(c);
+ c.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 3));
+ }
+
+ @Override
+ public void uninstallUI(JComponent c) {
+ super.uninstallUI(c);
+ c.setBorder(null);
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ // There is no need to take insets into account for this painter
+ BeanValidatorScope scope = field.getScope();
+ if (scope != null) {
+ BufferedImage icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ if (icon != null) {
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+ }
+ }
+ }
+
+ protected static BufferedImage prepareIcon(Color color) {
+ int width = 7;
+ int height = 8;
+ BufferedImage icon = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.setColor(color);
+ g2.fillRect(0, 0, width, height);
+ g2.setColor(Color.WHITE);
+ g2.drawLine(0, 0, width, height);
+ g2.drawLine(0, height, width, 0);
+ g2.dispose();
+ return icon;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,78 @@
+package jaxx.runtime.validator.swing.ui;
+
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/** @author chemit */
+public class ImageValidationUI extends AbstractBeanValidatorUI {
+
+ protected static BufferedImage errorIcon;
+ protected static BufferedImage warningIcon;
+ protected static BufferedImage infoIcon;
+
+ public ImageValidationUI(BeanValidatorField<?> field) {
+ super(field);
+ if (errorIcon == null) {
+ errorIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("error.png"));
+ }
+ if (warningIcon == null) {
+ warningIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("warning.png"));
+ }
+ if (infoIcon == null) {
+ infoIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("info.png"));
+ }
+ }
+
+ protected static BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ @Override
+ public void installUI(JComponent c) {
+ super.installUI(c);
+ c.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 3));
+ }
+
+ @Override
+ public void uninstallUI(JComponent c) {
+ super.uninstallUI(c);
+ c.setBorder(null);
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ BeanValidatorScope scope = field.getScope();
+ if (scope != null) {
+ BufferedImage icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ if (icon != null) {
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,65 @@
+package jaxx.runtime.validator.swing.ui;
+
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.JComponent;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import jaxx.runtime.validator.BeanValidatorField;
+
+/** @author chemit */
+public class TranslucentValidationUI extends AbstractBeanValidatorUI {
+
+ protected Color errorHightlight;
+ protected Color warningHightlight;
+ protected Color infoHightlight;
+
+ public TranslucentValidationUI(BeanValidatorField<?> field) {
+ super(field);
+ errorHightlight = Color.RED;
+ warningHightlight = Color.YELLOW;
+ infoHightlight = Color.GREEN;
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ // paints the layer as is
+ super.paintLayer(g2, l);
+
+ // to be in sync with the view if the layer has a border
+ Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+
+ BeanValidatorScope scope = field.getScope();
+
+ if (scope == null) {
+ g2.setColor(Color.WHITE);
+ } else {
+ switch (scope) {
+ case ERROR:
+ g2.setColor(errorHightlight);
+ break;
+ case WARNING:
+ g2.setColor(warningHightlight);
+ break;
+ case INFO:
+ g2.setColor(infoHightlight);
+ break;
+ }
+ }
+
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
+}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +0,0 @@
-validator.scope.error.label=Error
-validator.scope.info.label=Information
-validator.scope.warning.label=Warning
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +0,0 @@
-validator.scope.error.label=Erreur
-validator.scope.info.label=Information
-validator.scope.warning.label=Avertissement
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,12 @@
+validator.field.header=Field
+validator.field.header.tip=The field involved
+validator.field.tip=Property '%1$s'
+validator.message.header=Message
+validator.message.header.tip=Message
+validator.message.tip=Message \: %1$s
+validator.scope.error.label=Error
+validator.scope.header=...
+validator.scope.header.tip=Severity of the message
+validator.scope.info.label=Information
+validator.scope.tip=Message scope \: '%1$s'
+validator.scope.warning.label=Warning
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,12 @@
+validator.field.header=Champ
+validator.field.header.tip=Le champ surquel intervient le message
+validator.field.tip=Propri\u00E9t\u00E9 '%1$s'
+validator.message.header=Message
+validator.message.header.tip=Le texte du message
+validator.message.tip=Message \: %1$s
+validator.scope.error.label=Erreur
+validator.scope.header=...
+validator.scope.header.tip=Le de type de message
+validator.scope.info.label=Information
+validator.scope.tip=Type de message \: '%1$s'
+validator.scope.warning.label=Avertissement
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-delete.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/error.png)
===================================================================
(Binary files differ)
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/info.png)
===================================================================
(Binary files differ)
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/warning.png)
===================================================================
(Binary files differ)
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,163 +0,0 @@
-package jaxx.runtime;
-
-import jaxx.runtime.JXPathDecorator.Context;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/** @author chemit */
-public class JXPathDecoratorTest {
-
-
- protected JXPathDecorator<?> decorator;
- protected String expected;
- protected String result;
-
- @After
- public void after() {
- decorator = null;
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullInternalClass() throws Exception {
- decorator = JXPathDecorator.newDecorator(null, "hello");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "${haha");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace2() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "${haha${hum}");
- }
-
- @Test
- public void testNullBean() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "hello");
- expected = "hello";
- assertEquals(expected, decorator.getExpression());
- assertEquals(0, decorator.nbToken);
- assertEquals(0, decorator.getTokens().length);
-
- result = decorator.toString(null);
- assertEquals(null, result);
- }
-
- @Test
- public void testNoJXPath() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "hello");
- expected = "hello";
- assertEquals(expected, decorator.getExpression());
- assertEquals(0, decorator.nbToken);
- assertEquals(0, decorator.getTokens().length);
-
- result = decorator.toString(this);
- assertEquals(expected, result);
- }
-
- @Test
- public void testDecorator() throws Exception {
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
- assertEquals("%1$s - %2$d", decorator.getExpression());
- assertDecoratorInternal();
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}${nbToken}");
- assertEquals("%1%2", decorator.getExpression());
- assertDecoratorInternal();
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after");
- assertEquals("before %1$s - %2$d after", decorator.getExpression());
- assertDecoratorInternal();
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter");
- assertEquals("before%1$s-%2$dafter", decorator.getExpression());
- assertDecoratorInternal();
- }
-
- public static class Data {
- int pos;
- String name;
-
- protected static List<Data> generate(int nb) {
- List<Data> datas = new ArrayList<Data>(nb);
- for (int i = 0; i < nb; i++) {
- datas.add(new Data(i, "name_" + (nb - i)));
- }
- return datas;
- }
-
- Data(int pos, String name) {
- this.pos = pos;
- this.name = name;
- }
-
- public int getPos() {
- return pos;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "Data{pos=" + pos + ", name='" + name + '\'' + '}';
- }
- }
-
- @Test
- public void testSort() throws Exception {
-
- List<Data> datas = Data.generate(10);
- JXPathDecorator<Data> decorator = JXPathDecorator.newDecorator(Data.class, "${pos}$d ${name}$s");
-
- List<Data> sortData = new ArrayList<Data>(datas);
- JXPathDecorator.sort(decorator, sortData, 0);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- Collections.sort(datas, new Comparator<Data>() {
- @Override
- public int compare(Data o1, Data o2) {
- return o1.name.compareTo(o2.name);
- }
- });
- Context<Data> context = decorator.context;
- context.setComparator(null);
- JXPathDecorator.sort(decorator, sortData, 1);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- }
-
-
- public void assertDecoratorInternal(String... tokens) {
- assertTokens(tokens);
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- private void assertTokens(String... tokens) {
- if (tokens.length == 0) {
- tokens = new String[]{"expression", "nbToken"};
- }
- assertEquals(2, decorator.nbToken);
- assertEquals(2, decorator.getTokens().length);
- assertEquals(tokens[0], decorator.getTokens()[0]);
- assertEquals(tokens[1], decorator.getTokens()[1]);
- }
-
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,184 +0,0 @@
-package jaxx.runtime;
-
-import jaxx.runtime.JXPathDecoratorTest.Data;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/** @author chemit */
-public class MultiJXPathDecoratorTest {
-
-
- protected MultiJXPathDecorator<?> decorator;
- protected String expected;
- protected String result;
-
- @After
- public void after() {
- decorator = null;
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullInternalClass() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(null, "hello", "#");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(Object.class, "${haha", "#");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace2() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(Object.class, "${haha${hum}", "#");
- }
-
- @Test
- public void testNullBean() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(Object.class, "hello", "");
- expected = "hello";
- assertEquals(expected, decorator.getExpression());
- assertEquals(0, decorator.nbToken);
- assertEquals(0, decorator.getTokens().length);
-
- result = decorator.toString(null);
- assertEquals(null, result);
- }
-
- @Test
- public void testMultiDecorator() throws Exception {
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - ");
- assertEquals("%1$s - %2$d", decorator.getExpression());
- assertDecoratorInternal();
- assertEquals(2, decorator.contexts.length);
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s", decorator.getExpression());
- assertTokens("nbToken", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - ");
- assertEquals("%1$s - %2$d", decorator.getExpression());
- assertDecoratorInternal();
- assertEquals(2, decorator.contexts.length);
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s", decorator.getExpression());
- assertTokens("nbToken", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- @Test
- public void testMultiDecorator2() throws Exception {
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - ");
-
- assertEquals("%1$s - %2$d - %3$s", decorator.getExpression());
- assertTokens("expression", "nbToken", "separator");
- assertEquals(3, decorator.contexts.length);
-
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s - %3$s", decorator.getExpression());
- assertTokens("nbToken", "separator", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(2);
- assertEquals("%1$s - %2$s - %3$d", decorator.getExpression());
- assertTokens("separator", "expression", "nbToken");
-
- expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- @Test
- public void testMultiDecoratorWithMultiRef() throws Exception {
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - ");
-
- assertEquals("%1$s - %2$d - %3$s %3$s", decorator.getExpression());
- assertTokens("expression", "nbToken", "separator");
- assertEquals(3, decorator.contexts.length);
-
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s %3$s - %3$s", decorator.getExpression());
- assertTokens("nbToken", "separator", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(2);
- assertEquals("%1$s %3$s - %2$s - %3$d", decorator.getExpression());
- assertTokens("separator", "expression", "nbToken");
-
- expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- @Test
- public void testSort() throws Exception {
-
- List<Data> datas = Data.generate(10);
-
- MultiJXPathDecorator<Data> decorator = MultiJXPathDecorator.newDecorator(Data.class, "${pos}$d-${name}$s", "-");
-
- List<Data> sortData = new ArrayList<Data>(datas);
- JXPathDecorator.sort(decorator, sortData, 0);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- Collections.sort(datas, new Comparator<Data>() {
- @Override
- public int compare(Data o1, Data o2) {
- return o1.name.compareTo(o2.name);
- }
- });
- decorator.setContextIndex(1);
- JXPathDecorator.sort(decorator, sortData, 1);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- }
-
- public void assertDecoratorInternal(String... tokens) {
- assertTokens(tokens);
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- private void assertTokens(String... tokens) {
- if (tokens.length == 0) {
- tokens = new String[]{"expression", "nbToken"};
- }
- assertEquals(tokens.length, decorator.nbToken);
- assertEquals(tokens.length, decorator.getTokens().length);
- for (int i = 0; i < tokens.length; i++) {
- assertEquals(tokens[i], decorator.getTokens()[i]);
- }
- }
-
-}
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/test/resources/log4j.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -5,4 +5,4 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-log4j.logger.jaxx=DEBUG
+log4j.logger.jaxx=INFO
Modified: branches/jaxx-2.X/jaxx-swing-action/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-swing-action/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-swing-action/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
@@ -42,8 +42,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx lutin library swing extension (tabs and actions)</description>
+ <name>JAXX Action</name>
+ <description>JAXX Action framework</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
Modified: branches/jaxx-2.X/jaxx-widgets/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,11 +10,11 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
- <artifactId>jaxx-runtime-swing-widget</artifactId>
+ <artifactId>jaxx-widgets</artifactId>
<dependencies>
@@ -22,7 +22,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
@@ -47,8 +47,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx runtime swing widgets</description>
+ <name>JAXX Widgets</name>
+ <description>Collection of swing widgets wrote with JAXX</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -97,13 +97,9 @@
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<configuration>
- <silent>true</silent>
<entries>
<entry>
- <basedir>${maven.gen.dir}/java/</basedir>
- <includes>
- <param>**\/**.java</param>
- </includes>
+ <basedir>${maven.gen.dir}/java</basedir>
</entry>
</entries>
</configuration>
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -76,6 +76,7 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.decorator.JXPathDecorator;
public static final String DEFAULT_POPUP_LABEL = n_("entitycombobox.popup.label");
@@ -83,7 +84,7 @@
public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("entitycombobox.sort.off");
-public <O> void init(jaxx.runtime.JXPathDecorator<O> decorator, java.util.List<O> data) {
+public <O> void init(JXPathDecorator<O> decorator, java.util.List<O> data) {
handler.init(decorator, data);
}
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -19,9 +19,6 @@
package jaxx.runtime.swing;
import java.awt.Component;
-import jaxx.runtime.JXPathDecorator;
-import jaxx.runtime.MultiJXPathDecorator;
-import jaxx.runtime.Util;
import jaxx.runtime.SwingUtil;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
@@ -46,7 +43,11 @@
import java.lang.reflect.Method;
import java.util.List;
import javax.swing.JComboBox;
-import jaxx.runtime.Decorator;
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.decorator.JXPathDecorator;
+import jaxx.runtime.decorator.MultiJXPathDecorator;
+import jaxx.runtime.decorator.swing.DecoratorListCellRenderer;
+import jaxx.runtime.decorator.DecoratorUtils;
import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener;
/**
@@ -119,12 +120,12 @@
// should clone decorator ?
d = (MultiJXPathDecorator<O>) decorator;
} else {
- d = MultiJXPathDecorator.newDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - ");
+ d = DecoratorUtils.newMultiJXPathDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - ");
}
this.decorator = d;
// init combobox renderer base on given decorator
- ui.getCombobox().setRenderer(Util.newDecoratedListCellRenderer(d));
+ ui.getCombobox().setRenderer(new DecoratorListCellRenderer(d));
this.convertor = newDecoratedObjectToStringConverter(d);
@@ -233,7 +234,7 @@
try {
// Sort data with the decorator jxpath tokens.
- JXPathDecorator.sort(decorator, ui.getData(), newValue);
+ DecoratorUtils.sort(decorator, ui.getData(), newValue);
} catch (Exception e) {
log.warn(e.getMessage(), e);
//System.out.println("newValue :: "+decorator+" : "+newValue);
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -2,8 +2,7 @@
aboutframe.license=License
aboutframe.ok=OK
aboutframe.thirdparty=Third party
-columnselection.action.tip=
-columnselector.action.tip=
+columnselector.action.tip=Select the columns
config.action.quit=Quit
config.action.quit.tip=Quit the configuration editor
config.action.reset=Cancel
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -2,8 +2,7 @@
aboutframe.license=Licence
aboutframe.ok=OK
aboutframe.thirdparty=Tierce partie
-columnselection.action.tip=
-columnselector.action.tip=
+columnselector.action.tip=S\u00E9lectionner les colonnes
config.action.quit=Quitter
config.action.quit.tip=Quitter l'\u00E9diteur de configuration
config.action.reset=Annuler
Modified: branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -22,6 +22,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>jaxx-compiler</artifactId>
<version>${project.version}</version>
</dependency>
@@ -108,10 +114,9 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
+ <name>JAXX Maven plugin</name>
<description>
- Maven 2 plugin to generate java source from ui interface definitions
- in jaxx format.
+ Maven 2 plugin to generate java sources from JAXX files.
</description>
<!-- ************************************************************* -->
@@ -135,6 +140,188 @@
</plugin>
</plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc.version}</version>
+ <configuration>
+ <taglets>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ </taglets>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<reporting>
@@ -142,6 +329,175 @@
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc.version}</version>
+ <configuration>
+ <taglets>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ </taglets>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
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-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -124,46 +124,6 @@
protected boolean checkPackaging() {
return project != null && !"pom".equals(project.getPackaging()) && !"site".equals(project.getPackaging());
}
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// try {
-// init();
-// } catch (Exception e) {
-// if (e instanceof MojoFailureException) {
-// throw (MojoFailureException) e;
-// }
-// if (e instanceof MojoExecutionException) {
-// throw (MojoExecutionException) e;
-// }
-// throw new MojoExecutionException("error in init : " + e.getMessage(), e);
-// }
-//
-// if (skip) {
-// if (verbose) {
-// getLog().info("jaxx - skip!");
-// }
-// return;
-// }
-//
-// try {
-//
-// doAction();
-//
-// } catch (Exception e) {
-// //getLog().error(e);
-// Throwable e2 = e;
-// while (e2.getCause() != null) {
-// e2 = e.getCause();
-// }
-// getLog().error(e2);
-//
-// throw new MojoExecutionException(e2.getMessage(), e2);
-// } finally {
-// System.gc();
-// }
-//
-// }
@Override
public MavenProject getProject() {
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-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -182,9 +182,9 @@
*/
protected String jaxxContextImplementorClass;
/**
- * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(String[])}.
+ * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
* <p/>
- * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(String[])}
+ * 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()}.
* <p/>
@@ -215,7 +215,8 @@
* If not given, will use the one defined in validator
*
* @parameter expression="${jaxx.defaultErrorUIFQN}"
- * @see jaxx.runtime.validator.swing.SwingValidator#DEFAULT_UI_CLASS
+ *
+ * @see jaxx.runtime.validator.swing.SwingValidator
*/
protected String defaultErrorUIFQN;
/**
@@ -284,13 +285,6 @@
if (skip) {
return true;
}
-//
-// if (project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) {
-// // nothing to be done for this type of packaging
-// skip = true;
-// getLog().info("skip generate goal for packaging " + project.getPackaging());
-// return true;
-// }
if (generateHelp) {
// check there is some bundle
@@ -475,14 +469,7 @@
return result;
}
- //TODO use the AbstractPublig method
protected void fixCompileSourceRoots() {
-// //fixme should remove this silly test when we will make real maven plugin tests :)
-// if (project != null) {
-// if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
-// project.addCompileSourceRoot(outJava.getPath());
-// }
-// }
if (project == null) {
// no project defined, can not fix anything
// this case could appears if we wanted to do some tests of the plugin
@@ -525,13 +512,6 @@
getLog().warn("??? : " + e.getMessage(), e);
}
}
-
- //fixme should remove this silly test when we will make real maven plugin tests :)
- if (getPluginContext() != null) {
- for (Object e : getPluginContext().keySet()) {
- getLog().info("pluginContext " + e + " : " + getPluginContext().get(e));
- }
- }
}
protected void checkJaxxContextImplementorClass() {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,3 @@
-<JComboBox>
+<JAXXComboBox>
<item value='Working' selected='true'/>
-</JComboBox>
\ No newline at end of file
+</JAXXComboBox>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,3 @@
-<JComboBox>
+<JAXXComboBox>
<item value='Failed!'/>
-</JComboBox>
\ No newline at end of file
+</JAXXComboBox>
\ No newline at end of file
Modified: branches/jaxx-2.X/pom.xml
===================================================================
--- branches/jaxx-2.X/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -14,18 +14,17 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<modules>
- <module>jaxx-runtime-api</module>
- <module>jaxx-runtime-swing</module>
+ <module>jaxx-runtime</module>
<module>jaxx-compiler</module>
<module>jaxx-swing-action</module>
<module>maven-jaxx-plugin</module>
- <module>jaxx-runtime-swing-widget</module>
+ <module>jaxx-widgets</module>
<!-- deprecated since 1.7.2, will be removed before 2.0.0
<module>jaxx-example</module-->
@@ -256,7 +255,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.9</version>
+ <version>1.2.14</version>
</dependency>
<dependency>
@@ -308,8 +307,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx library parent pom</description>
+ <name>JAXX Project</name>
+ <description>JAXX Project</description>
<inceptionYear>2008</inceptionYear>
<url>http://maven-site.nuiton.org/jaxx</url>
@@ -325,7 +324,7 @@
<projectId>jaxx</projectId>
<lutinutil.version>1.1.0</lutinutil.version>
- <i18n.version>1.0.1-SNAPSHOT</i18n.version>
+ <i18n.version>1.0.2-SNAPSHOT</i18n.version>
<jxlayer.version>3.0.3</jxlayer.version>
1
0
Author: tchemit
Date: 2009-10-05 15:18:45 +0200 (Mon, 05 Oct 2009)
New Revision: 1558
Added:
branches/jaxx-2.X/
Log:
create version 2.X of jaxx, with non compatible api with jaxx > 1.7.2
Property changes on: branches/jaxx-2.X
___________________________________________________________________
Added: svn:ignore
+ *.ipr
*.iws
*.iml
target
catalog.xml
*.log
Added: svn:mergeinfo
+
1
0
r1557 - trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by tchemit@users.nuiton.org 04 Oct '09
by tchemit@users.nuiton.org 04 Oct '09
04 Oct '09
Author: tchemit
Date: 2009-10-04 13:37:17 +0200 (Sun, 04 Oct 2009)
New Revision: 1557
Modified:
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
Log:
[Anomalie #73] fix NPE
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-04 10:12:06 UTC (rev 1556)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-04 11:37:17 UTC (rev 1557)
@@ -68,7 +68,7 @@
System.arraycopy(oldSelection, 0, newSelection, 0, index);
System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index);
}
- if (newSelection.length > 0){
+ if (newSelection.length > 0) {
setSelectedIndex(newSelection[0]);
}
} else {
@@ -90,10 +90,10 @@
}
}
- public List<Item> getItems(){
+ public List<Item> getItems() {
return items;
}
-
+
@Override
public Object getElementAt(int i) {
return items.get(i).getValue();
@@ -228,27 +228,29 @@
}
}
- public List<Item> getItems(){
- if (getModel() instanceof JAXXComboBoxModel){
- return ((JAXXComboBoxModel)getModel()).getItems();
+ public List<Item> getItems() {
+ if (getModel() instanceof JAXXComboBoxModel) {
+ return ((JAXXComboBoxModel) getModel()).getItems();
}
return null;
}
public void setSelectedItem(Item item) {
- super.setSelectedItem(item.getValue());
+ //TC-20092004 Anomalie #73 fix npe when want to call with a null
+ // value
+ super.setSelectedItem(item == null ? null : item.getValue());
}
- public Item getSelectedJaxxItem(){
+ public Item getSelectedJaxxItem() {
Object selected = super.getSelectedItem();
return findItem(selected);
}
- public Item findItem(Object value){
+ public Item findItem(Object value) {
List<Item> items = getItems();
- if (items != null){
- for (Item i : items){
- if (i.getValue().equals(value)){
+ if (items != null) {
+ for (Item i : items) {
+ if (i.getValue().equals(value)) {
return i;
}
}
@@ -256,33 +258,33 @@
return null;
}
- public void addItem(Item item){
+ public void addItem(Item item) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.add(item);
setItems(items);
}
}
- public void addAllItems(Collection<Item> itemsToAdd){
+ public void addAllItems(Collection<Item> itemsToAdd) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.addAll(itemsToAdd);
setItems(items);
}
}
- public void removeItem(Item item){
+ public void removeItem(Item item) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.remove(item);
setItems(items);
}
}
- public void removeAllItems(Collection<Item> itemsToRemove){
+ public void removeAllItems(Collection<Item> itemsToRemove) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.removeAll(itemsToRemove);
setItems(items);
}
1
0
04 Oct '09
Author: tchemit
Date: 2009-10-04 12:12:06 +0200 (Sun, 04 Oct 2009)
New Revision: 1556
Modified:
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
Log:
add usefull addExpandOnClickListener method
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-04 08:57:25 UTC (rev 1555)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-04 10:12:06 UTC (rev 1556)
@@ -19,6 +19,7 @@
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
+import javax.swing.event.TreeSelectionEvent;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
@@ -50,7 +51,10 @@
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.TreeSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
import jaxx.runtime.swing.BooleanCellRenderer;
import jaxx.runtime.swing.DecoratorTableCellRenderer;
import jaxx.runtime.swing.EmptyNumberTableCellRenderer;
@@ -755,4 +759,37 @@
}
});
}
+
+ /**
+ * Add a listener of tree selection model to expand a new selected node
+ * when it is selected.
+ *
+ * @param tree the tree to treate
+ */
+ public static void addExpandOnClickListener(final JTree tree) {
+
+ tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(final TreeSelectionEvent e) {
+ TreeNode node = (TreeNode) e.getPath().getLastPathComponent();
+ if (node != null && !node.isLeaf()) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ for (TreePath path : e.getPaths()) {
+ if (e.isAddedPath(path) && !tree.isExpanded(path)) {
+ log.info("expand node [" + path + "]");
+ // will expand the node
+ tree.expandPath(path);
+ }
+ }
+ }
+ });
+ }
+ }
+ });
+ }
}
1
0
r1555 - in trunk/jaxx-demo/src/main: java/jaxx/demo java/jaxx/demo/component/jaxx/editor java/jaxx/demo/component/jaxx/navigation/full java/jaxx/demo/component/jaxx/navigation/item java/jaxx/demo/component/swing java/jaxx/demo/feature/databinding java/jaxx/demo/feature/validation java/jaxx/demo/fun resources/i18n
by tchemit@users.nuiton.org 04 Oct '09
by tchemit@users.nuiton.org 04 Oct '09
04 Oct '09
Author: tchemit
Date: 2009-10-04 10:57:25 +0200 (Sun, 04 Oct 2009)
New Revision: 1555
Added:
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java
Removed:
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
Log:
- add multi-sources in demo
- update license header
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo;
import java.io.IOException;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,73 +1,87 @@
+
<JTabbedPane id='top'>
<script><![CDATA[
- import java.io.*;
+import org.apache.commons.io.IOUtils;
- public DemoPanel(String... extraSources) {
- super();
-
- for (String extra : extraSources) {
- // creation du contenu du fichier
- JTextArea content = new JTextArea();
- content.setEditable(false);
- content.setText(loadSource(extra));
- // ajout de l'onglet
- top.addTab(extra,null,content,null);
- }
+protected String[] getSources() {
+ if (getClass() == DemoPanel.class) {
+ return new String[0];
}
+ return new String[]{ getDefaultSource() };
+}
- public String getLabel() {
- String name = getClass().getName();
- name = name.substring(name.lastIndexOf(".") + 1);
- if (name.endsWith("Demo"))
- name = name.substring(0, name.length() - "Demo".length());
- return name;
- }
-
+protected String getDefaultSource() {
+ return getClass().getSimpleName() + ".jaxx";
+}
- public String getDemoTabTitle() {
- return getLabel() + " Demo";
+public String getLabel() {
+ String name = getClass().getSimpleName();
+ if (name.endsWith("Demo")) {
+ name = name.substring(0, name.length() - "Demo".length());
}
+ return name;
+}
- public String loadSource(String filename) {
- try {
- Reader in = new InputStreamReader(getClass().getResourceAsStream(filename));
- StringWriter out = new StringWriter();
- char[] buffer = new char[2048];
- int c;
- while ((c = in.read(buffer)) > 0)
- out.write(buffer, 0, c);
- return out.toString();
+public String getDemoTabTitle() {
+ return getLabel() + " Demo";
+}
+
+public String loadSource(String filename) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(filename + " from " + getClass());
}
- catch (IOException e) {
- throw new RuntimeException(e);
- }
+ String result = IOUtils.toString(getClass().getResourceAsStream(filename));
+
+ return result;
+ } catch (Exception e) {
+ log.error("could not load file " + filename, e);
+ return "could not load file " + filename;
}
+}
- public String loadSource() {
- try {
- String className = getClass().getName();
- Reader in = new InputStreamReader(getClass().getResourceAsStream(className.substring(className.lastIndexOf(".") + 1) + ".jaxx"));
- StringWriter out = new StringWriter();
- char[] buffer = new char[2048];
- int c;
- while ((c = in.read(buffer)) > 0)
- out.write(buffer, 0, c);
- return out.toString();
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (getSources().length == 0) {
+ top.remove(sourceTabs);
+ return;
+ }
+ for (String extra : getSources()) {
+ JScrollPane pane = new JScrollPane(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ pane.setBorder(null);
+ // creation du contenu du fichier
+ JTextArea content = new JTextArea();
+ content.setFont(content.getFont().deriveFont((float) 11));
+ content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
+ content.setEditable(false);
+ content.setWrapStyleWord(false);
+ content.setText(loadSource(extra));
+ content.setColumns(80);
+ pane.getViewport().add(content);
+ // ajout de l'onglet
+ sourceTabs.addTab(extra, pane);
+ int index = sourceTabs.indexOfComponent(pane);
+ JLabel l = new JLabel(extra);
+ l.setFont(l.getFont().deriveFont((float) 10));
+ sourceTabs.setTabComponentAt(index,l);
+ }
}
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- ]]></script>
+ });
+}
+ ]]>
+ </script>
<tab title='{getDemoTabTitle()}'>
<JPanel id='demoPanel'/>
</tab>
- <!--tab title='Source'>
- <JScrollPane height='100'>
- <JTextArea text='{loadSource()}' editable='false'/>
- </JScrollPane>
- </tab-->
+ <tab title='Sources'>
+ <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
+ </tab>
</JTabbedPane>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo;
import java.util.Stack;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -73,7 +73,6 @@
selectionModel="{getTreeHelper().createTreeHandler(this)}"
cellRenderer='{new NavigationTreeCellRenderer(this, 200)}'>
</JTree>
- <!--model='{DemoTreeHelper.TREE_MODEL.getContextValue(this)}'-->
</JScrollPane>
<JPanel id='content'/>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,9 +1,10 @@
/**
- * *##% observe-swing
- * Copyright (C) 2008 - 2009 IRD
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
+ * it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
@@ -12,9 +13,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package jaxx.demo;
@@ -100,8 +102,8 @@
@Override
public void run() {
- // use best dimensions
- ui.getSplitPane().resetToPreferredSizes();
+// // use best dimensions
+// ui.getSplitPane().resetToPreferredSizes();
String path;
if (node == null) {
@@ -113,7 +115,19 @@
}
// select node
ui.getTreeHelper().selectNode(ui, ui.getNavigation(), path);
+//
+// // show ui
+// ui.setVisible(true);
+ }
+ });
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+
+ // use best dimensions
+ ui.getSplitPane().resetToPreferredSizes();
+
// show ui
ui.setVisible(true);
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo;
import jaxx.runtime.DefaultApplicationContext;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.component.jaxx.editor;
import java.beans.PropertyChangeListener;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,11 +1,9 @@
-
<JPanel layout='{new BorderLayout()}'>
<Object id='data' javaBean='helper.getSelectedBean(this)'/>
<script><![CDATA[
import jaxx.runtime.SwingUtil;
-import jaxx.demo.component.jaxx.navigation.full.model.*;
private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
@@ -73,7 +71,7 @@
verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
minimumSize='{SwingUtil.newMinDimension()}'>
- <JLabel icon='{getImage(getData())}'/>
+ <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/>
</JScrollPane>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -9,9 +9,14 @@
private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
-setContextValue(helper.createMovies(this), " movies");
+helper.createModel(this);
-void $afterCompleteSetup() {
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" };
+}
+
+private void $afterCompleteSetup() {
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -41,7 +46,6 @@
model='{helper.createTreeModel(this)}'
selectionModel="{helper.createTreeHandler(this)}"
cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />
- <!--model='{helper.createTreeModel(this, helper.createMovies())}'-->
</JScrollPane>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,8 +1,26 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.component.jaxx.navigation.full;
-import java.util.ArrayList;
-import java.util.HashSet;
-import jaxx.demo.component.jaxx.navigation.full.model.Movie;
+import java.util.Arrays;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
@@ -10,14 +28,13 @@
import static org.nuiton.i18n.I18n._;
import java.util.List;
-import java.util.Set;
-import jaxx.demo.component.jaxx.navigation.full.model.People;
import jaxx.runtime.Decorator;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.MultiJXPathDecorator;
import javax.swing.JPanel;
+import jaxx.runtime.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
@@ -35,15 +52,29 @@
*/
public class FullNavigationTreeHelper extends NavigationTreeHelper {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * Logger
+ */
static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+ /**
+ * where the movies are hold in context
+ */
+ static public final JAXXContextEntryDef<List<Movie>> MOVIES = JAXXContextEntryDef.newListDef("movies");
+ /**
+ * where the actors are hold in context
+ */
+ static public final JAXXContextEntryDef<List<People>> ACTORS = JAXXContextEntryDef.newListDef("actors");
public FullNavigationTreeHelper() {
super("full");
}
- public java.util.List<Movie> createMovies(JAXXContext context) {
- java.util.List<Movie> result = new java.util.ArrayList<Movie>();
+ /**
+ * Create the model and store it in the given context.
+ *
+ * @param context the context where to hold the model
+ */
+ public void createModel(JAXXContext context) {
People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
@@ -52,43 +83,38 @@
m.addActor(a);
m.addActor(a2);
m.addActor(a3);
- result.add(m);
- m = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
- m.addActor(a);
- m.addActor(a2);
- result.add(m);
+ Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m2.addActor(a);
+ m2.addActor(a2);
- context.setContextValue(result, "movies");
-
- return result;
+ MOVIES.setContextValue(context, Arrays.asList(m, m2));
+ ACTORS.setContextValue(context, Arrays.asList(a, a2, a3));
}
@Override
public NavigationTreeModel createTreeModel(JAXXContext context) {
- List<Movie> movies = context.getContextValue(List.class, "movies");
+ List<Movie> movies = MOVIES.getContextValue(context);
+ List<People> actors = ACTORS.getContextValue(context);
- log.info("for " + movies.size() + " movie(s)");
+ if (log.isDebugEnabled()) {
+ log.debug("for " + movies.size() + " movie(s)");
+ }
- NavigationTreeNode rootNode, moviesNode, movieNode, actorsNode;
-
- log.info("start creating demo model");
-
NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/");
- Decorator<Movie> movieDecorator = MultiJXPathDecorator.newDecorator(Movie.class, "${title}$s##${year}$s", "##", " - ");
- Decorator<People> peopleDecorator = MultiJXPathDecorator.newDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " ");
+ Decorator<Movie> mDecorator = MultiJXPathDecorator.newDecorator(Movie.class, "${title}$s##${year}$s", "##", " - ");
+ Decorator<People> pDecorator = MultiJXPathDecorator.newDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " ");
- Set<People> actors = new HashSet<People>();
// construction du noeud root
// il ne contient pas de context et ne sera pas visible
- rootNode = builder.buildEmptyRoot(null, "$root");
+ NavigationTreeNode rootNode = builder.buildEmptyRoot(null, "$root");
// construction du noeud avec les films recupere la liste des films
// dans le context avec la clef movies
// navigation path = $root/movies
- moviesNode = builder.build(
+ NavigationTreeNode moviesNode = builder.build(
rootNode,
_("movies"),
newListDef("movies"),
@@ -99,16 +125,16 @@
for (Movie m : movies) {
// navigation path = $root/movies/m.id
- movieNode = builder.build(
+ NavigationTreeNode movieNode = builder.build(
moviesNode,
- movieDecorator,
+ mDecorator,
"..[@id=\"" + m.getId() + "\"]",
m.getId(),
null,
null);
// navigation path = $root/movies/m.id/actors
- actorsNode = builder.build(
+ NavigationTreeNode actorsNode = builder.build(
movieNode,
_("actors"),
"../actors",
@@ -118,29 +144,26 @@
for (People p : m.getActors()) {
// navigation path = $root/movies/m.id/actors/p.id
-
builder.build(
actorsNode,
- peopleDecorator,
+ pDecorator,
"..[@id=\"" + p.getId() + "\"]",
p.getId(),
null,
null);
- actors.add(p);
}
}
// construction du noeud avec les acteurs
- actorsNode = builder.build(rootNode, _("actors"),
+ NavigationTreeNode actorsNode = builder.build(rootNode, _("actors"),
newListDef("actors"),
"actors", null, null);
for (People p : actors) {
// navigation path = $root/actors/p.id
-
builder.build(
actorsNode,
- peopleDecorator,
+ pDecorator,
"..[@id=\"" + p.getId() + "\"]",
p.getId(),
null,
@@ -148,24 +171,22 @@
}
NavigationTreeModel model = builder.getModel();
- context.setContextValue(movies, "movies");
- context.setContextValue(new ArrayList<People>(actors), "actors");
-
if (log.isDebugEnabled()) {
builder.printModel(context, model.getRoot());
}
// save tree model in context
setTreeModel(context, model);
-
return model;
}
+ @Override
public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+ if (log.isDebugEnabled()) {
+ log.debug("create handler");
+ }
- log.info("create handler");
-
NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout(
getPrefix(),
BaseContent.class,
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java (from rev 1552, trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -0,0 +1,127 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation.full;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java (from rev 1552, trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -0,0 +1,117 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation.full;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.component.jaxx.navigation.item;
import java.beans.PropertyChangeEvent;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -7,6 +7,11 @@
import jaxx.runtime.swing.navigation.*;
import org.jdesktop.swingx.JXDatePicker;
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "ExempleItemTreeNavigationAdapter.java" };
+}
+
void $afterCompleteSetup() {
new ExempleItemTreeNavigationAdapter(this, nav, content);
}
@@ -26,7 +31,7 @@
</item>
</JTree>
</JScrollPane>
- <!-- Card panel, only ItemNavigationPanel children is alowed -->
+ <!-- Card panel, only ItemNavigationPanel children is allowed -->
<ItemNavigationCardPanel id="content">
<!-- The associated type is passed by the constructor -->
<ItemNavigationPanel id='stringPanel' constructorParams='String.class' layout='{new FlowLayout()}'>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,23 +1,24 @@
-<jaxx.demo.DemoPanel>
- <script>
- private void displayMessage() {
- JOptionPane.showMessageDialog(demoPanel, "Menu item clicked");
- }
- </script>
-
- <JPanel id='demoPanel'>
- <JDesktopPane width='350' height='400' background='{null}'>
- <JInternalFrame title='JMenu demo' width='300' height='250' resizable='true'>
- <JMenuBar id='menuBar'>
- <JMenu text='Demo'>
- <JMenuItem text='Message Box' onActionPerformed='displayMessage()'/>
- </JMenu>
- </JMenuBar>
-
- <JPanel id='framePanel'>
- <JLabel text='JMenu demo' id='demoMessage' horizontalAlignment='center'/>
- </JPanel>
- </JInternalFrame>
- </JDesktopPane>
- </JPanel>
+<jaxx.demo.DemoPanel>
+ <script>
+ void $afterCompleteSetup(){}
+ private void displayMessage() {
+ JOptionPane.showMessageDialog(demoPanel, "Menu item clicked");
+ }
+ </script>
+
+ <JPanel id='demoPanel'>
+ <JDesktopPane width='350' height='400' background='{null}'>
+ <JInternalFrame title='JMenu demo' width='300' height='250' resizable='true'>
+ <JMenuBar id='menuBar'>
+ <JMenu text='Demo'>
+ <JMenuItem text='Message Box' onActionPerformed='displayMessage()'/>
+ </JMenu>
+ </JMenuBar>
+
+ <JPanel id='framePanel'>
+ <JLabel text='JMenu demo' id='demoMessage' horizontalAlignment='center'/>
+ </JPanel>
+ </JInternalFrame>
+ </JDesktopPane>
+ </JPanel>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -9,6 +9,7 @@
<String id='contentMessage' javaBean='"message..."'/>
<script>
+ void $afterCompleteSetup(){}
public Boolean isEditing2() { return editing2; }
public void setEditing2(Boolean newValue) {
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,7 +1,13 @@
<BaseBeanDataBinding>
<Boolean id='editing3' javaBean='true'/>
-
+ <script><![CDATA[
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseBeanDataBinding.jaxx" };
+}
+]]>
+ </script>
<Table id='demoPanel'>
<row>
<cell columns='2'>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.feature.validation;
import java.beans.PropertyChangeListener;
@@ -100,4 +120,4 @@
this.dir = dir;
p.firePropertyChange("dir", oldDir, dir);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.feature.validation;
import java.beans.*;
@@ -63,4 +83,4 @@
this.ratio = ratio;
p.firePropertyChange("ratio", oldRatio, ratio);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,325 +1,330 @@
-<jaxx.demo.DemoPanel>
- <style source="Validation.css"/>
-
-<script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-void $afterCompleteSetup() {
-}]]>
-</script>
- <!-- models -->
- <Model id='model1'/>
- <Model id='model2'/>
- <Identity id='identity'/>
-
- <!-- errors model -->
- <!-- Not existing :) -->
- <!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
- onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
-
- <!-- validators -->
- <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
- <field name="text"/>
- <field name="text2"/>
- <field name="ratio"/>
- </BeanValidator>
- <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
- <field name="text" component="_text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
- <BeanValidator id='validator3' autoField='true' bean='identity'
- uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
- <field name="email" component="email2"/>
- </BeanValidator>
-
- <Table fill='both' id='demoPanel'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='{model1.getText()}'
- _validatorLabel='{n_("form.text")}'
- onKeyReleased='model1.setText(text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text2' text='{model1.getText2()}'
- _validatorLabel='{n_("form.text2")}'
- onKeyReleased='model1.setText2(text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='ratio' minimum='0' maximum='100'
- value='{model1.getRatio()}'
- _validatorLabel='{n_("form.ratio")}'
- onStateChanged='model1.setRatio(ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model1.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- _validatorLabel='{n_("form2.text")}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- _validatorLabel='{n_("form2.text2")}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100'
- value='{model2.getRatio()}'
- _validatorLabel='{n_("form2.ratio")}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='180'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file :'/>
- </cell>
- <cell>
- <JTextField id='config' text='{identity.getConfig()}'
- onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Working directory:'/>
- </cell>
- <cell>
- <JTextField id='dir' text='{identity.getDir()}'
- onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getConfig()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Directory file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getDir()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
- width='500'>
- <JScrollPane>
- <JList id='errorList' model='{errors}'
- cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton id='cancel' text='cancel'
- onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- <JButton id='ok' text='valid'
- onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-
-</jaxx.demo.DemoPanel>
+<jaxx.demo.DemoPanel>
+ <style source="Validation.css"/>
+
+<script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+void $afterCompleteSetup() {
+}
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
+}
+]]>
+</script>
+ <!-- models -->
+ <Model id='model1'/>
+ <Model id='model2'/>
+ <Identity id='identity'/>
+
+ <!-- errors model -->
+ <!-- Not existing :) -->
+ <!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
+ onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
+ <field name="text" component="_text"/>
+ <field name="text2" component="_text2"/>
+ <field name="ratio" component="_ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator3' autoField='true' bean='identity'
+ uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
+ <field name="email" component="email2"/>
+ </BeanValidator>
+
+ <Table fill='both' id='demoPanel'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model1.getText()}'
+ _validatorLabel='{n_("form.text")}'
+ onKeyReleased='model1.setText(text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model1.getText2()}'
+ _validatorLabel='{n_("form.text2")}'
+ onKeyReleased='model1.setText2(text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model1.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
+ onKeyReleased='model2.setText(_text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
+ onKeyReleased='model2.setText2(_text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
+ onStateChanged='model2.setRatio(_ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model2.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
+ layout='{new GridLayout()}' width='250' height='180'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='firstName' text='{identity.getFirstName()}'
+ onKeyReleased='identity.setFirstName(firstName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='lastName' text='{identity.getLastName()}'
+ onKeyReleased='identity.setLastName(lastName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='email2' text='{identity.getEmail()}'
+ onKeyReleased='identity.setEmail(email2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
+ onStateChanged='identity.setAge(age.getValue())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file :'/>
+ </cell>
+ <cell>
+ <JTextField id='config' text='{identity.getConfig()}'
+ onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Working directory:'/>
+ </cell>
+ <cell>
+ <JTextField id='dir' text='{identity.getDir()}'
+ onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getFirstName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getLastName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getEmail()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getAge()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getConfig()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Directory file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getDir()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane>
+ <JList id='errorList' model='{errors}'
+ cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,331 +1,336 @@
-<jaxx.demo.DemoPanel>
- <style source="Validation.css"/>
-
- <!-- models -->
- <Model id='model1'/>
- <Model id='model2'/>
- <Identity id='identity'/>
-
- <!-- errors model -->
- <!-- Not existing :) -->
- <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
- onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
-
- <!-- validators -->
- <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
- <field name="text"/>
- <field name="text2"/>
- <field name="ratio"/>
- </BeanValidator>
- <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
- <field name="text" component="_text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
- <BeanValidator id='validator3' autoField='true' bean='identity'
- uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
- <field name="email" component="email2"/>
- </BeanValidator>
-
- <script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-import jaxx.runtime.SwingUtil;
-
-void $afterCompleteSetup() {
- jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
-}
-]]></script>
-
- <Table fill='both' id='demoPanel'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='{model1.getText()}'
- onKeyReleased='model1.setText(text.getText())'
- _validatorLabel='{n_("form.text")}'
- />
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text2' text='{model1.getText2()}'
- onKeyReleased='model1.setText2(text2.getText())'
- _validatorLabel='{n_("form.text2")}'
- />
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='ratio' minimum='0' maximum='100'
- value='{model1.getRatio()}'
- _validatorLabel='{n_("form.ratio")}'
- onStateChanged='model1.setRatio(ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model1.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- _validatorLabel='{n_("form2.text")}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- _validatorLabel='{n_("form2.text2")}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100'
- value='{model2.getRatio()}'
- _validatorLabel='{n_("form2.ratio")}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='180'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file :'/>
- </cell>
- <cell>
- <JTextField id='config' text='{identity.getConfig()}'
- onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Working directory:'/>
- </cell>
- <cell>
- <JTextField id='dir' text='{identity.getDir()}'
- onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getConfig()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Directory file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getDir()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
- width='500'>
- <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true' autoCreateRowSorter='true'
- autoResizeMode='2' cellSelectionEnabled='false' selectionMode='0'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton id='cancel' text='cancel'
- onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- <JButton id='ok' text='valid'
- onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-
-</jaxx.demo.DemoPanel>
+<jaxx.demo.DemoPanel>
+ <style source="Validation.css"/>
+
+ <!-- models -->
+ <Model id='model1'/>
+ <Model id='model2'/>
+ <Identity id='identity'/>
+
+ <!-- errors model -->
+ <!-- Not existing :) -->
+ <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
+ <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
+ onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
+ <field name="text" component="_text"/>
+ <field name="text2" component="_text2"/>
+ <field name="ratio" component="_ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator3' autoField='true' bean='identity'
+ uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
+ <field name="email" component="email2"/>
+ </BeanValidator>
+
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.SwingUtil;
+
+void $afterCompleteSetup() {
+ jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
+}
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
+}
+]]></script>
+
+ <Table fill='both' id='demoPanel'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model1.getText()}'
+ onKeyReleased='model1.setText(text.getText())'
+ _validatorLabel='{n_("form.text")}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model1.getText2()}'
+ onKeyReleased='model1.setText2(text2.getText())'
+ _validatorLabel='{n_("form.text2")}'
+ />
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model1.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
+ onKeyReleased='model2.setText(_text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
+ onKeyReleased='model2.setText2(_text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
+ onStateChanged='model2.setRatio(_ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model2.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
+ layout='{new GridLayout()}' width='250' height='180'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='firstName' text='{identity.getFirstName()}'
+ onKeyReleased='identity.setFirstName(firstName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='lastName' text='{identity.getLastName()}'
+ onKeyReleased='identity.setLastName(lastName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='email2' text='{identity.getEmail()}'
+ onKeyReleased='identity.setEmail(email2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
+ onStateChanged='identity.setAge(age.getValue())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file :'/>
+ </cell>
+ <cell>
+ <JTextField id='config' text='{identity.getConfig()}'
+ onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Working directory:'/>
+ </cell>
+ <cell>
+ <JTextField id='dir' text='{identity.getDir()}'
+ onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getFirstName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getLastName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getEmail()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getAge()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getConfig()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Directory file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getDir()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true' autoCreateRowSorter='true'
+ autoResizeMode='2' cellSelectionEnabled='false' selectionMode='0'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,89 +1,95 @@
-<jaxx.demo.DemoPanel>
- <style source='Calculator.css'/>
- <script><![CDATA[
- plus.setText("+");
- sign.setText("+/-");
-]]></script>
- <!-- use fully-qualified name just in case this is compiled into a different package -->
- <CalculatorEngine id='engine'/>
-
- <Table id='demoPanel' fill='both'>
- <row>
- <cell columns='4'>
- <JLabel id='display' text='{engine.getDisplayText()}'/>
- </cell>
- </row>
-
- <row>
- <cell columns='2'>
- <JButton id='c' text='C' onActionPerformed='engine.clear()' styleClass='clear'/>
- </cell>
- <cell>
- <JButton id='ce' text='CE' onActionPerformed='engine.clearEntry()' styleClass='clear'/>
- </cell>
- <cell>
- <JButton id='equals' text='=' onActionPerformed='engine.equal()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d7' text='7' onActionPerformed='engine.digit(7)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d8' text='8' onActionPerformed='engine.digit(8)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d9' text='9' onActionPerformed='engine.digit(9)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='plus' onActionPerformed='engine.add()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d4' text='4' onActionPerformed='engine.digit(4)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d5' text='5' onActionPerformed='engine.digit(5)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d6' text='6' onActionPerformed='engine.digit(6)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='subtract' text='-' onActionPerformed='engine.subtract()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d1' text='1' onActionPerformed='engine.digit(1)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d2' text='2' onActionPerformed='engine.digit(2)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d3' text='3' onActionPerformed='engine.digit(3)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='multiply' text='x' onActionPerformed='engine.multiply()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d0' text='0' onActionPerformed='engine.digit(0)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='sign' onActionPerformed='engine.toggleSign()' styleClass='operator'/>
- </cell>
- <cell>
- <JButton id='dot' text='.' onActionPerformed='engine.dot()' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='divide' text='÷' onActionPerformed='engine.divide()' styleClass='operator'/>
- </cell>
- </row>
- </Table>
+<jaxx.demo.DemoPanel>
+ <style source='Calculator.css'/>
+ <script><![CDATA[
+ plus.setText("+");
+ sign.setText("+/-");
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Calculator.css", "CalculatorEngine.java" };
+}
+]]>
+ </script>
+ <!-- use fully-qualified name just in case this is compiled into a different package -->
+ <CalculatorEngine id='engine'/>
+
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell columns='4'>
+ <JLabel id='display' text='{engine.getDisplayText()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2'>
+ <JButton id='c' text='C' onActionPerformed='engine.clear()' styleClass='clear'/>
+ </cell>
+ <cell>
+ <JButton id='ce' text='CE' onActionPerformed='engine.clearEntry()' styleClass='clear'/>
+ </cell>
+ <cell>
+ <JButton id='equals' text='=' onActionPerformed='engine.equal()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d7' text='7' onActionPerformed='engine.digit(7)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d8' text='8' onActionPerformed='engine.digit(8)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d9' text='9' onActionPerformed='engine.digit(9)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='plus' onActionPerformed='engine.add()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d4' text='4' onActionPerformed='engine.digit(4)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d5' text='5' onActionPerformed='engine.digit(5)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d6' text='6' onActionPerformed='engine.digit(6)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='subtract' text='-' onActionPerformed='engine.subtract()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d1' text='1' onActionPerformed='engine.digit(1)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d2' text='2' onActionPerformed='engine.digit(2)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d3' text='3' onActionPerformed='engine.digit(3)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='multiply' text='x' onActionPerformed='engine.multiply()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d0' text='0' onActionPerformed='engine.digit(0)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='sign' onActionPerformed='engine.toggleSign()' styleClass='operator'/>
+ </cell>
+ <cell>
+ <JButton id='dot' text='.' onActionPerformed='engine.dot()' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='divide' text='÷' onActionPerformed='engine.divide()' styleClass='operator'/>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,177 +1,197 @@
-package jaxx.demo.fun;
-
-import java.beans.*;
-import java.math.*;
-
-public class CalculatorEngine {
- public static final String DISPLAY_TEXT_PROPERTY = "displayText";
-
- public static final int ADD = 0;
- public static final int SUBTRACT = 1;
- public static final int MULTIPLY = 2;
- public static final int DIVIDE = 3;
- public static final int RESULT = 4;
-
- private int operation = -1;
- private boolean clear = true; // true to clear on next key
- private String displayText = "0";
- private BigDecimal value;
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
-
-
- public String getDisplayText() {
- return displayText;
- }
-
-
- public void setDisplayText(String displayText) {
- String oldDisplayText = this.displayText;
- this.displayText = displayText;
- firePropertyChange(DISPLAY_TEXT_PROPERTY, oldDisplayText, displayText);
- }
-
-
- public void clear() {
- clearEntry();
- value = new BigDecimal(0);
- operation = -1;
- }
-
-
- public void clearEntry() {
- setDisplayText("0");
- clear = true;
- }
-
-
- private void checkClear() {
- if (clear) {
- setDisplayText("");
- clear = false;
- }
- }
-
-
- public void digit(int digit) {
- checkClear();
- setDisplayText(getDisplayText() + String.valueOf(digit));
- }
-
-
- public void dot() {
- checkClear();
- if (getDisplayText().indexOf('.') == -1) {
- if (getDisplayText().length() == 0) {
- setDisplayText("0.");
- } else {
- setDisplayText(getDisplayText() + '.');
- }
- }
- }
-
-
- public void toggleSign() {
- String text = getDisplayText();
- if (text.startsWith("-")) {
- text = text.substring(1);
- } else if (!text.equals("0")) {
- text = '-' + text;
- }
- setDisplayText(text);
- }
-
-
- public void equal() {
- BigDecimal displayValue = new BigDecimal(getDisplayText());
- BigDecimal newValue = displayValue;
- switch (operation) {
- case ADD:
- newValue = value.add(displayValue);
- break;
- case SUBTRACT:
- newValue = value.subtract(displayValue);
- break;
- case MULTIPLY:
- newValue = value.multiply(displayValue);
- break;
- case DIVIDE:
- newValue = value.divide(displayValue, 8, BigDecimal.ROUND_HALF_UP);
- break;
- }
- value = newValue;
- setDisplayText(toString(newValue));
- clear = true;
- operation = -1;
- }
-
-
- public static String toString(BigDecimal decimal) {
- // can't use stripTrailingZeros, as it wasn't introduced until 1.5
- String result = decimal.toString();
- if (result.indexOf(".") != -1) {
- while (result.endsWith("0")) {
- result = result.substring(0, result.length() - 1);
- }
- if (result.endsWith(".")) {
- result = result.substring(0, result.length() - 1);
- }
- }
- return result;
- }
-
-
- public void operation(int operation) {
- if (this.operation != -1) {
- equal();
- } else {
- value = new BigDecimal(getDisplayText());
- clear = true;
- }
- this.operation = operation;
- }
-
-
- public void add() {
- operation(ADD);
- }
-
-
- public void subtract() {
- operation(SUBTRACT);
- }
-
-
- public void multiply() {
- operation(MULTIPLY);
- }
-
-
- public void divide() {
- operation(DIVIDE);
- }
-
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
-
- public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(property, listener);
- }
-
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
-
- public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(property, listener);
- }
-
-
- protected void firePropertyChange(String property, Object oldValue, Object newValue) {
- propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
- }
-}
\ No newline at end of file
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.fun;
+
+import java.beans.*;
+import java.math.*;
+
+public class CalculatorEngine {
+ public static final String DISPLAY_TEXT_PROPERTY = "displayText";
+
+ public static final int ADD = 0;
+ public static final int SUBTRACT = 1;
+ public static final int MULTIPLY = 2;
+ public static final int DIVIDE = 3;
+ public static final int RESULT = 4;
+
+ private int operation = -1;
+ private boolean clear = true; // true to clear on next key
+ private String displayText = "0";
+ private BigDecimal value;
+ private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+
+ public void setDisplayText(String displayText) {
+ String oldDisplayText = this.displayText;
+ this.displayText = displayText;
+ firePropertyChange(DISPLAY_TEXT_PROPERTY, oldDisplayText, displayText);
+ }
+
+
+ public void clear() {
+ clearEntry();
+ value = new BigDecimal(0);
+ operation = -1;
+ }
+
+
+ public void clearEntry() {
+ setDisplayText("0");
+ clear = true;
+ }
+
+
+ private void checkClear() {
+ if (clear) {
+ setDisplayText("");
+ clear = false;
+ }
+ }
+
+
+ public void digit(int digit) {
+ checkClear();
+ setDisplayText(getDisplayText() + String.valueOf(digit));
+ }
+
+
+ public void dot() {
+ checkClear();
+ if (getDisplayText().indexOf('.') == -1) {
+ if (getDisplayText().length() == 0) {
+ setDisplayText("0.");
+ } else {
+ setDisplayText(getDisplayText() + '.');
+ }
+ }
+ }
+
+
+ public void toggleSign() {
+ String text = getDisplayText();
+ if (text.startsWith("-")) {
+ text = text.substring(1);
+ } else if (!text.equals("0")) {
+ text = '-' + text;
+ }
+ setDisplayText(text);
+ }
+
+
+ public void equal() {
+ BigDecimal displayValue = new BigDecimal(getDisplayText());
+ BigDecimal newValue = displayValue;
+ switch (operation) {
+ case ADD:
+ newValue = value.add(displayValue);
+ break;
+ case SUBTRACT:
+ newValue = value.subtract(displayValue);
+ break;
+ case MULTIPLY:
+ newValue = value.multiply(displayValue);
+ break;
+ case DIVIDE:
+ newValue = value.divide(displayValue, 8, BigDecimal.ROUND_HALF_UP);
+ break;
+ }
+ value = newValue;
+ setDisplayText(toString(newValue));
+ clear = true;
+ operation = -1;
+ }
+
+
+ public static String toString(BigDecimal decimal) {
+ // can't use stripTrailingZeros, as it wasn't introduced until 1.5
+ String result = decimal.toString();
+ if (result.indexOf(".") != -1) {
+ while (result.endsWith("0")) {
+ result = result.substring(0, result.length() - 1);
+ }
+ if (result.endsWith(".")) {
+ result = result.substring(0, result.length() - 1);
+ }
+ }
+ return result;
+ }
+
+
+ public void operation(int operation) {
+ if (this.operation != -1) {
+ equal();
+ } else {
+ value = new BigDecimal(getDisplayText());
+ clear = true;
+ }
+ this.operation = operation;
+ }
+
+
+ public void add() {
+ operation(ADD);
+ }
+
+
+ public void subtract() {
+ operation(SUBTRACT);
+ }
+
+
+ public void multiply() {
+ operation(MULTIPLY);
+ }
+
+
+ public void divide() {
+ operation(DIVIDE);
+ }
+
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(listener);
+ }
+
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(property, listener);
+ }
+
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(listener);
+ }
+
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(property, listener);
+ }
+
+
+ protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+ propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
+ }
+}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,85 +1,92 @@
-<jaxx.demo.DemoPanel>
- <style source="LabelStyle.css"/>
-
- <Table id='demoPanel' anchor='north' fill='both'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='Data Binding'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Red:'/>
- </cell>
- <cell>
- <JSlider id='red' value='128' maximum='255' styleClass='color'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Green:'/>
- </cell>
- <cell>
- <JSlider id='green' value='0' maximum='255' styleClass='color'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Blue:'/>
- </cell>
- <cell>
- <JSlider id='blue' value='255' maximum='255' styleClass='color'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Size:'/>
- </cell>
- <cell>
- <JSlider id='dummySize' value='36' minimum='6' maximum='60'/>
- </cell>
- </row>
-
- <row>
- <cell columns='2' fill='both' weighty='1'>
- <JPanel border='{BorderFactory.createTitledBorder("Preview")}'
- height='90'
- layout='{new BorderLayout()}'>
- <VBox background='{(Color)( backgroundCheckbox.isSelected() ? backgroundColor.getSelectedValue() : null)}'
- margin='0'
- horizontalAlignment='center'
- verticalAlignment='middle'>
- <JLabel text='{text.getText()}' font-size='{dummySize.getValue()}'
- foreground='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/>
- </VBox>
- </JPanel>
- </cell>
- </row>
- </Table>
- </cell>
-
- <cell>
- <VBox spacing='0' border='{BorderFactory.createTitledBorder("Background")}'>
- <JCheckBox id='backgroundCheckbox' text='Show Background'/>
- <JRadioButton text='Red' buttonGroup='backgroundColor' value='{Color.RED}' selected='true'/>
- <JRadioButton text='Orange' buttonGroup='backgroundColor' value='{Color.ORANGE}'/>
- <JRadioButton text='Yellow' buttonGroup='backgroundColor' value='{Color.YELLOW}'/>
- <JRadioButton text='Green' buttonGroup='backgroundColor' value='{Color.GREEN}'/>
- <JRadioButton text='Cyan' buttonGroup='backgroundColor' value='{Color.CYAN}'/>
- <JRadioButton text='Blue' buttonGroup='backgroundColor' value='{Color.BLUE}'/>
- <JRadioButton text='Purple' buttonGroup='backgroundColor' value='{new Color(160, 30, 255)}'/>
- </VBox>
- </cell>
- </row>
- </Table>
+<jaxx.demo.DemoPanel>
+ <style source="LabelStyle.css"/>
+ <script><![CDATA[
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "LabelStyle.css" };
+}
+
+]]>
+ </script>
+ <Table id='demoPanel' anchor='north' fill='both'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='Data Binding'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Red:'/>
+ </cell>
+ <cell>
+ <JSlider id='red' value='128' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Green:'/>
+ </cell>
+ <cell>
+ <JSlider id='green' value='0' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Blue:'/>
+ </cell>
+ <cell>
+ <JSlider id='blue' value='255' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Size:'/>
+ </cell>
+ <cell>
+ <JSlider id='dummySize' value='36' minimum='6' maximum='60'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2' fill='both' weighty='1'>
+ <JPanel border='{BorderFactory.createTitledBorder("Preview")}'
+ height='90'
+ layout='{new BorderLayout()}'>
+ <VBox background='{(Color)( backgroundCheckbox.isSelected() ? backgroundColor.getSelectedValue() : null)}'
+ margin='0'
+ horizontalAlignment='center'
+ verticalAlignment='middle'>
+ <JLabel text='{text.getText()}' font-size='{dummySize.getValue()}'
+ foreground='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/>
+ </VBox>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+
+ <cell>
+ <VBox spacing='0' border='{BorderFactory.createTitledBorder("Background")}'>
+ <JCheckBox id='backgroundCheckbox' text='Show Background'/>
+ <JRadioButton text='Red' buttonGroup='backgroundColor' value='{Color.RED}' selected='true'/>
+ <JRadioButton text='Orange' buttonGroup='backgroundColor' value='{Color.ORANGE}'/>
+ <JRadioButton text='Yellow' buttonGroup='backgroundColor' value='{Color.YELLOW}'/>
+ <JRadioButton text='Green' buttonGroup='backgroundColor' value='{Color.GREEN}'/>
+ <JRadioButton text='Cyan' buttonGroup='backgroundColor' value='{Color.CYAN}'/>
+ <JRadioButton text='Blue' buttonGroup='backgroundColor' value='{Color.BLUE}'/>
+ <JRadioButton text='Purple' buttonGroup='backgroundColor' value='{new Color(160, 30, 255)}'/>
+ </VBox>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-04 08:57:25 UTC (rev 1555)
@@ -73,6 +73,7 @@
Sign\ on=
Simple\ Button=
Size\:=
+Sources=
Spacing\:=
Start=
Stop=
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-04 08:57:25 UTC (rev 1555)
@@ -73,6 +73,7 @@
Sign\ on=Signer
Simple\ Button=Bouton simple
Size\:=Taille \:
+Sources=Sources
Spacing\:=Espacement \:
Start=D\u00E9marrer
Stop=Arr\u00EAter
1
0
Author: tchemit
Date: 2009-10-04 10:25:09 +0200 (Sun, 04 Oct 2009)
New Revision: 1554
Modified:
trunk/jaxx-demo/pom.xml
Log:
fix websatrt config + readd sources in class-path (demo shows them)
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2009-10-03 23:22:44 UTC (rev 1553)
+++ trunk/jaxx-demo/pom.xml 2009-10-04 08:25:09 UTC (rev 1554)
@@ -85,6 +85,12 @@
<include>**/*</include>
</includes>
</resource>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
</resources>
<pluginManagement>
@@ -247,27 +253,17 @@
<artifactId>maven-helper-plugin</artifactId>
<executions>
<execution>
- <id>get-jnlp-keystore</id>
+ <id>get-keystore</id>
<goals>
<goal>share-server-secret</goal>
</goals>
<phase>package</phase>
<configuration>
<serverId>codelutin-keystore</serverId>
- <usernameOut>keystorepath</usernameOut>
+ <privateKeyOut>keystorepath</privateKeyOut>
<passwordOut>keystorepass</passwordOut>
- </configuration>
- </execution>
- <execution>
- <id>get-jnlp-key</id>
- <goals>
- <goal>share-server-secret</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <serverId>codelutin-keystore-nuiton-key</serverId>
<usernameOut>keyalias</usernameOut>
- <passwordOut>keypass</passwordOut>
+ <passphraseOut>keypass</passphraseOut>
</configuration>
</execution>
</executions>
1
0