This is an automated email from the git hooks/post-receive script. New commit to annotated tag v2.0.0-beta-1 in repository jaxx. See https://gitlab.nuiton.org/nuiton/jaxx.git commit b5e93d99cf400e3e55cf53d4403f61acf85501fe Author: Tony Chemit <chemit@codelutin.com> Date: Thu Nov 5 20:44:42 2009 +0000 - review JAXXContext api (remove getParentContainer methods) - improve JAXXObject api (add getParentContainer + make it javaBeans compatible for PropertyChange events) - improve generation code (avoid use of FQN when possible) - fix bug of name collisions on event generated method from css - the maven-jaxx-plugin tests are all compiling, we should compile them on integration-test - add getSimpleName on class descriptor - clean code, add javadoc, reformat, ... - add ListSelectorUI widget --- .../main/java/jaxx/compiler/CompiledObject.java | 46 ++-- .../src/main/java/jaxx/compiler/JAXXCompiler.java | 231 +++++++++++---------- .../src/main/java/jaxx/compiler/JAXXEngine.java | 26 +-- .../java/jaxx/compiler/binding/DataBinding.java | 22 +- .../java/jaxx/compiler/binding/DataSource.java | 96 +-------- .../java/jaxx/compiler/css/StylesheetHelper.java | 8 +- .../jaxx/compiler/finalizers/DefaultFinalizer.java | 26 ++- .../compiler/tags/DefaultComponentHandler.java | 35 ++-- .../jaxx/compiler/tags/DefaultObjectHandler.java | 156 ++++++-------- .../main/java/jaxx/compiler/tags/TagManager.java | 14 +- .../java/jaxx/compiler/tags/swing/ItemHandler.java | 6 +- .../java/jaxx/compiler/tags/swing/TabHandler.java | 2 +- .../tags/validator/FieldValidatorHandler.java | 2 +- .../src/main/java/jaxx/runtime/JAXXContext.java | 70 +++---- .../src/main/java/jaxx/runtime/JAXXObject.java | 54 ++++- jaxx-runtime/src/main/java/jaxx/runtime/Util.java | 38 +++- .../java/jaxx/runtime/context/DataContext.java | 46 ++-- .../runtime/context/DefaultApplicationContext.java | 14 +- .../jaxx/runtime/context/DefaultJAXXContext.java | 88 ++++---- .../jaxx/runtime/context/JAXXInitialContext.java | 22 +- .../runtime/context/DefaultJAXXContextTest.java | 107 ++++++---- .../java/jaxx/runtime/swing/EntityComboBox.jaxx | 9 +- .../jaxx/runtime/swing/EntityComboBoxHandler.java | 4 +- .../main/java/jaxx/runtime/swing/HidorButton.jaxx | 51 ++--- .../java/jaxx/runtime/swing/ListSelectorUI.jaxx | 153 ++++++++++++++ .../src/main/resources/icons/action-add.png | Bin 0 -> 733 bytes .../src/main/resources/icons/action-remove.png | Bin 0 -> 715 bytes .../nuiton/jaxx/plugin/DataBinding/BeanImpl.java | 2 +- .../org/nuiton/jaxx/plugin/DataBindingTest.java | 6 +- .../compilerTest/classReferences}/JavaTaist.java | 2 +- .../validator/ok/Identity.java | 0 .../compilerValidatorTest/validator/ok/Model.java | 0 .../nuiton/jaxx/plugin/compilerTest/CSSTests.xml | 3 +- .../jaxx/plugin/compilerTest/ClassReferences.xml | 2 +- .../jaxx/plugin/compilerTest/Initializers.xml | 2 +- .../jaxx/plugin/compilerTest/InnerClasses.xml | 2 +- .../plugin/compilerTest/OverridingDataBindings.xml | 2 +- .../org/nuiton/jaxx/plugin/compilerTest/Script.xml | 2 +- .../plugin/compilerTest/SpecialSubclassing.xml | 2 +- .../{CSSTests => cSSTests}/CSSTests.jaxx | 2 +- .../compilerTest/{CSSTests => cSSTests}/Child.jaxx | 0 .../{CSSTests => cSSTests}/Child2.jaxx | 0 .../{CSSTests => cSSTests}/GrandChild.jaxx | 0 .../{CSSTests => cSSTests}/GrandChildButton.jaxx | 0 .../{CSSTests => cSSTests}/Pseudoclasses.jaxx | 0 .../{CSSTests => cSSTests}/SimpleCSS.jaxx | 0 .../ClassReferences.jaxx | 0 .../ConstructorReferenceTest.jaxx | 0 .../JAXXReferenceTest.jaxx | 0 .../JAXXTest.jaxx | 0 .../StaticMethodTest.jaxx | 0 .../TypeReference.jaxx | 0 .../Initializers.jaxx | 0 .../InnerClasses.jaxx | 0 .../CurrentTime.jaxx | 0 .../OverriddenCurrentTime.jaxx | 0 .../OverridingDataBindings.jaxx | 0 .../{Script => script}/JScriptInitializer.jaxx | 0 .../JComboBoxTest1.jaxx | 0 .../JComboBoxTest2.jaxx | 0 .../JListTest1.jaxx | 0 .../JListTest2.jaxx | 0 .../JTreeTest1.jaxx | 0 .../JTreeTest2.jaxx | 0 .../SpecialSubclassing.jaxx | 0 .../validator/ok/Validation.jaxx | 8 +- .../validator/ok/ValidationBeanClass.jaxx | 2 +- .../nuiton/jaxx/plugin/dataBindingTest/First.jaxx | 4 +- 68 files changed, 756 insertions(+), 611 deletions(-) diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java b/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java index a956e01..2cc5461 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java @@ -127,7 +127,7 @@ public class CompiledObject { CompiledObject child; String constraints; String childJavaCode; - String delegateCode; + private String delegateCode; public ChildRef(CompiledObject child, String constraints, String childJavaCode, String delegateCode) { this.child = child; @@ -140,17 +140,17 @@ public class CompiledObject { return child; } - public void setChild(CompiledObject child) { - this.child = child; - } - - public String getConstraints() { - return constraints; - } - - public void setConstraints(String constraints) { - this.constraints = constraints; - } +// public void setChild(CompiledObject child) { +// this.child = child; +// } +// +// public String getConstraints() { +// return constraints; +// } +// +// public void setConstraints(String constraints) { +// this.constraints = constraints; +// } public String getChildJavaCode() { return childJavaCode; @@ -160,13 +160,13 @@ public class CompiledObject { this.childJavaCode = childJavaCode; } - public String getDelegateCode() { - return delegateCode; - } - - public void setDelegateCode(String delegateCode) { - this.delegateCode = delegateCode; - } +// public String getDelegateCode() { +// return delegateCode; +// } +// +// public void setDelegateCode(String delegateCode) { +// this.delegateCode = delegateCode; +// } public void addToAdditionCode(StringBuffer buffer, boolean isRootObject) { //TC-20091026 do not prefix if on root object @@ -177,10 +177,8 @@ public class CompiledObject { prefix = javaCode + delegateCode + "."; } if (constraints != null) { -// buffer.append(javaCode).append(delegateCode).append(".add(").append(childJavaCode).append(", ").append(constraints).append(");"); buffer.append(prefix).append("add(").append(childJavaCode).append(", ").append(constraints).append(");"); } else { -// buffer.append(javaCode).append(delegateCode).append(".add(").append(childJavaCode).append(");"); buffer.append(prefix).append("add(").append(childJavaCode).append(");"); } buffer.append(JAXXCompiler.getLineSeparator()); @@ -460,10 +458,9 @@ public class CompiledObject { MethodDescriptor addMethod = handler.getAddMethod(); ClassDescriptor listenerClass = addMethod.getParameterTypes()[0]; //TC-20091026 use 'this' instead of root object javaCode - return getJavaCode() + '.' + addMethod.getName() + "((" + JAXXCompiler.getCanonicalName(listenerClass) + - ") jaxx.runtime.Util.getEventListener(" + JAXXCompiler.getCanonicalName(listenerClass) + ".class, " + + //TC-20091105 Util.getEventListener is generic, no more need cast and use simple name + return getJavaCode() + '.' + addMethod.getName() + "(Util.getEventListener(" + listenerClass.getSimpleName() + ".class, " + compiler.getJavaCode(handler.getListenerMethod().getName()) + ", this, " + - // compiler.getJavaCode(handler.getListenerMethod().getName()) + ", " + compiler.getRootObject().getJavaCode() + ", " + compiler.getJavaCode(compiler.getEventHandlerMethodName(handler)) + "));" + JAXXCompiler.getLineSeparator(); } @@ -708,7 +705,6 @@ public class CompiledObject { childRef.addToAdditionCode(buffer, compiler.getRootObject() == this); } additionCode = buffer.append(additionCode); - return; } } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java index bcde6ef..106d038 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java @@ -82,6 +82,7 @@ import java.util.Set; import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; + import jaxx.compiler.java.JavaFileGenerator; import jaxx.compiler.types.TypeManager; import org.apache.commons.lang.StringUtils; @@ -93,7 +94,7 @@ import org.apache.commons.lang.StringUtils; */ public class JAXXCompiler { - /** + /** * Logger */ protected static final Log log = LogFactory.getLog(JAXXCompiler.class); @@ -112,7 +113,7 @@ public class JAXXCompiler { * */ public static final String JAXX_INTERNAL_NAMESPACE = "http://www.jaxxframework.org/internal"; - /** + /** * Maximum length of an inlinable creation method. */ public static final int INLINE_THRESHOLD = 300; @@ -128,27 +129,27 @@ public class JAXXCompiler { /*------------------------------------------------------------------------*/ /*-- compiler fields -----------------------------------------------------*/ /*------------------------------------------------------------------------*/ - /** + /** * flag to detect if an error occurs while compiling jaxx file */ protected boolean failed; - /** + /** * Object corresponding to the root tag in the document. */ protected CompiledObject root; - /** + /** * Contains strings of the form "javax.swing." */ protected Set<String> importedPackages = new HashSet<String>(); - /** + /** * 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). */ protected Stack<CompiledObject> openComponents = new Stack<CompiledObject>(); - /** + /** * Sequence number used to create automatic variable names. */ protected int autogenID = 0; @@ -165,15 +166,15 @@ public class JAXXCompiler { * which the .jaxx file resides). */ protected File baseDir; - /** + /** * jaxx file being compiled. */ protected File src; - /** + /** * Parsed XML of src file. */ protected Document document; - /** + /** * Name of class being compiled. */ protected String outputClassName; @@ -186,7 +187,7 @@ public class JAXXCompiler { * {@link #registerStylesheet}. */ protected Stylesheet stylesheet; - /** + /** * Contains all attributes defined inline on class tags. */ protected List<Rule> inlineStyles = new ArrayList<Rule>(); @@ -195,11 +196,11 @@ public class JAXXCompiler { * 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 */ protected Map<Object, String> uniqueIds = new HashMap<Object, String>(); - /** + /** * Map of event handler method names used in compiler */ protected Map<EventHandler, String> eventHandlerMethodNames = new HashMap<EventHandler, String>(); @@ -213,43 +214,43 @@ public class JAXXCompiler { * created in document order. */ protected List<Runnable> initializers = new ArrayList<Runnable>(); - /** + /** * left brace matcher */ protected Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher(""); - /** + /** * right brace matcher */ protected Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher(""); - /** + /** * extra interfaces which can by passed to root object via the 'implements' attribute */ private String[] extraInterfaces; - /** + /** * a flag to generate a abstract class */ private boolean abstractClass; - /** + /** * the possible generic type of the class */ private String genericType; - /** + /** * the possible generic type of the super class */ private String superGenericType; - /** + /** * 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. */ protected StringBuffer lateInitializer = new StringBuffer(); - /** + /** * Extra code to be added to the class body. */ protected StringBuffer bodyCode = new StringBuffer(); - /** + /** * Code to initialize data bindings. */ protected StringBuffer initDataBindings = new StringBuffer(); @@ -305,12 +306,12 @@ public class JAXXCompiler { /** * Creates a new JAXXCompiler. * - * @param engine engine which use the compiler (could be null if not attach to any engine) - * @param baseDir classpath location - * @param src location of file to run - * @param outputClassName the out file name - * @param configuration configuration to pass to javac - * @param defaultImports list of default imports to add to java files + * @param engine engine which use the compiler (could be null if not attach to any engine) + * @param baseDir classpath location + * @param src location of file to run + * @param outputClassName the out file name + * @param configuration configuration to pass to javac + * @param defaultImports list of default imports to add to java files */ public JAXXCompiler(JAXXEngine engine, File baseDir, File src, String outputClassName, CompilerConfiguration configuration, List<String> defaultImports) { this.engine = engine; @@ -412,7 +413,7 @@ public class JAXXCompiler { symbolTable.getClassTagIds().put(id, fullClassName); if (tag.getAttributeNode(DefaultObjectHandler.JAVA_BEAN_ATTRIBUTE) != null) { // add java bean support for this property - String capitalizeName = org.apache.commons.lang.StringUtils.capitalize(id); + String capitalizeName = StringUtils.capitalize(id); // add method symbolTable.getScriptMethods().add(new MethodDescriptor("get" + capitalizeName, Modifier.PUBLIC, fullClassName, new String[0], classLoader)); if (Boolean.class.getName().equals(fullClassName)) { @@ -447,15 +448,15 @@ public class JAXXCompiler { } }); } - if (handler != null) { + if (handler == null) { + reportError("Could not find a Java class corresponding to: <" + tag.getTagName() + ">"); + failed = true; + } else { try { handler.compileFirstPass(tag, this); } catch (CompilerException e) { reportError(e); } - } else { - reportError("Could not find a Java class corresponding to: <" + tag.getTagName() + ">"); - failed = true; } Element finished = tagsBeingCompiled.pop(); @@ -468,12 +469,12 @@ public class JAXXCompiler { tagsBeingCompiled.push(tag); TagHandler handler = TagManager.getTagHandler(tag.getNamespaceURI(), tag.getLocalName(), tag.getPrefix() != null, this); - if (handler != null) { - handler.compileSecondPass(tag, this); - } else { + if (handler == null) { reportError("Could not find a Java class corresponding to: <" + tag.getTagName() + ">"); - assert false : "can't-happen error: error should have been reported during the fast pass and caused an abort"; +// assert false : "can't-happen error: error should have been reported during the fast pass and caused an abort"; failed = true; + } else { + handler.compileSecondPass(tag, this); } Element finished = tagsBeingCompiled.pop(); @@ -615,11 +616,10 @@ public class JAXXCompiler { * If the attribute value does not invoke data binding, this method returns <code>null</code> * * @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 CompilerException ? */ - public String processDataBindings(String stringValue, ClassDescriptor type) throws CompilerException { + public String processDataBindings(String stringValue) throws CompilerException { int pos = getNextLeftBrace(stringValue, 0); if (pos != -1) { StringBuffer expression = new StringBuffer(); @@ -714,6 +714,17 @@ public class JAXXCompiler { String id = handler.getEventId().substring(0, handler.getEventId().indexOf(".")); result = "do" + StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id; + //TC-20091105 : check the method name is available + // using css can have multi methods with result name (see priority) + if (eventHandlerMethodNames.containsValue(result)) { + int index = 0; + String result2; + do { + result2 = result + "_" + (index++); + + } while (eventHandlerMethodNames.containsValue(result2)); + result = result2; + } } eventHandlerMethodNames.put(handler, result); } @@ -810,7 +821,7 @@ public class JAXXCompiler { StringBuilder buffer = new StringBuilder(); buffer.append(srcFile); if (lineNumber != null) { - buffer.append(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1)); + buffer.append(":").append((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1); } buffer.append(getLineSeparator()).append(warning.trim()); if (engine != null) { @@ -878,9 +889,9 @@ public class JAXXCompiler { StringBuilder buffer = new StringBuilder(); buffer.append(errorFile != null ? errorFile.getPath() : "<unknown source>"); if (lineNumber > 0) { - buffer.append(":" + lineNumber); + buffer.append(":").append(lineNumber); } - buffer.append(getLineSeparator()).append(": " + error); + buffer.append(getLineSeparator()).append(": ").append(error); if (engine != null) { engine.addError(buffer.toString()); } else { @@ -1038,12 +1049,12 @@ public class JAXXCompiler { return new JAXXObjectDescriptor(descriptors, css); } - /*------------------------------------------------------------------------*/ - /*-- Setter methods ------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ - public void setFailed(boolean failed) { - this.failed = failed; - } +// /*------------------------------------------------------------------------*/ +// /*-- Setter methods ------------------------------------------------------*/ +// /*------------------------------------------------------------------------*/ +// public void setFailed(boolean failed) { +// this.failed = failed; +// } /*------------------------------------------------------------------------*/ /*-- Buffer --------------------------------------------------------------*/ @@ -1254,69 +1265,69 @@ public class JAXXCompiler { return pos; } - public String[] parseParameterList(String parameters) throws CompilerException { - List<String> result = new ArrayList<String>(); - StringBuffer current = new StringBuffer(); - int state = 0; // normal - for (int i = 0; i < parameters.length(); i++) { - char c = parameters.charAt(i); - switch (state) { - case 0: // normal - switch (c) { - case '"': - current.append(c); - state = 1; - break; // in quoted string - case '\\': - current.append(c); - state = 2; - break; // immediately after backslash - case ',': - if (current.length() > 0) { - result.add(current.toString()); - current.setLength(0); - break; - } else { - reportError("error parsing parameter list: " + parameters); - break; - } - default: - current.append(c); - } - break; - case 1: // in quoted string - switch (c) { - case '"': - current.append(c); - state = 0; - break; // normal - case '\\': - current.append(c); - state = 3; - break; // immediate after backslash in quoted string - default: - current.append(c); - } - break; - case 2: // immediately after backslash - current.append(c); - state = 0; // normal - break; - case 3: // immediately after backslash in quoted string - current.append(c); - state = 1; // in quoted string - break; - } - } - if (current.length() > 0) { - result.add(current.toString()); - } - return result.toArray(new String[result.size()]); - } +// public String[] parseParameterList(String parameters) throws CompilerException { +// List<String> result = new ArrayList<String>(); +// StringBuffer current = new StringBuffer(); +// int state = 0; // normal +// for (int i = 0; i < parameters.length(); i++) { +// char c = parameters.charAt(i); +// switch (state) { +// case 0: // normal +// switch (c) { +// case '"': +// current.append(c); +// state = 1; +// break; // in quoted string +// case '\\': +// current.append(c); +// state = 2; +// break; // immediately after backslash +// case ',': +// if (current.length() > 0) { +// result.add(current.toString()); +// current.setLength(0); +// break; +// } else { +// reportError("error parsing parameter list: " + parameters); +// break; +// } +// default: +// current.append(c); +// } +// break; +// case 1: // in quoted string +// switch (c) { +// case '"': +// current.append(c); +// state = 0; +// break; // normal +// case '\\': +// current.append(c); +// state = 3; +// break; // immediate after backslash in quoted string +// default: +// current.append(c); +// } +// break; +// case 2: // immediately after backslash +// current.append(c); +// state = 0; // normal +// break; +// case 3: // immediately after backslash in quoted string +// current.append(c); +// state = 1; // in quoted string +// break; +// } +// } +// if (current.length() > 0) { +// result.add(current.toString()); +// } +// return result.toArray(new String[result.size()]); +// } public String getAutoId(ClassDescriptor objectClass) { String name = objectClass.getName(); - name = name.substring(name.lastIndexOf(".") + 1); + name = name.substring(name.lastIndexOf(".") + 1); return getAutoId(name); // if (configuration.getOptimize()) { // return "$" + Integer.toString(autogenID++, 36); diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java index dc5c331..ca2e9ba 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java @@ -416,7 +416,7 @@ public class JAXXEngine { * Run the pass. * * @param engine the engine to use - * @return {@code true} if pass was ok, {@ocde false} otherwise + * @return {@code true} if pass was ok, {@code false} otherwise * @throws Exception if any pb */ public abstract boolean run(JAXXEngine engine) throws Exception; @@ -627,19 +627,19 @@ public class JAXXEngine { /** * Create a new compiler. * - * @param parentFile - * @param file - * @param className + * @param parentFile the directory where to generate the java file + * @param file the path of file to generate + * @param className name of the class to generate in the file * @return the new compiler - * @throws InvocationTargetException - * @throws IllegalAccessException - * @throws InstantiationException - * @throws NoSuchMethodException + * @throws InvocationTargetException introspection error + * @throws IllegalAccessException introspection error + * @throws InstantiationException introspection error + * @throws NoSuchMethodException introspection error */ protected JAXXCompiler newCompiler(File parentFile, File file, String className) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException { Constructor<? extends JAXXCompiler> cons = configuration.getCompilerClass().getConstructor(JAXXEngine.class, File.class, File.class, String.class, CompilerConfiguration.class, List.class); - return cons.newInstance(this, parentFile, file, className, configuration, Arrays.asList(new String[]{ - "java.awt.*", + return cons.newInstance(this, parentFile, file, className, configuration, + Arrays.asList("java.awt.*", "java.awt.event.*", "java.beans.*", "java.io.*", @@ -652,9 +652,11 @@ public class JAXXEngine { "jaxx.runtime.swing.HBox", "jaxx.runtime.swing.VBox", "jaxx.runtime.swing.Table", + "jaxx.runtime.Util", + "jaxx.runtime.SwingUtil", "static org.nuiton.i18n.I18n._", - "static jaxx.runtime.Util.createImageIcon" - })); + "static jaxx.runtime.Util.createImageIcon") + ); } /** diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java b/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java index 7d7f064..c177b8a 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java @@ -54,7 +54,7 @@ public class DataBinding { * Creates a new data binding. * * @param source the Java source code for the data binding expression - * @param id the data binding destination in the form <code><id>.<propertyName></code> + * @param id the data binding destination in the form <code>id.propertyName</code> * @param assignment Java snippet which will cause the destination property to be updated with the current value of the binding */ public DataBinding(String source, String id, String assignment) { @@ -87,7 +87,7 @@ public class DataBinding { // handles all of the listener additions //TC-20091026 use 'this' instead of root object javaCode // boolean result = dataSource.compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + compiler.getJavaCode(id) + ")"); - boolean result = dataSource.compile("new jaxx.runtime.DataBindingListener(this, " + compiler.getJavaCode(id) + ")"); + boolean result = dataSource.compile("new DataBindingListener(this, " + compiler.getJavaCode(id) + ")"); if (log.isDebugEnabled()) { log.debug(id + " isBinding ? " + result); } @@ -103,13 +103,10 @@ public class DataBinding { StringBuilder buffer = new StringBuilder(); if (compiler.hasProcessDataBinding()) { buffer.append(" else "); -// compiler.appendProcessDataBinding(" else "); } else { buffer.append(" "); -// compiler.appendProcessDataBinding(" "); } - buffer.append("if (" + compiler.getJavaCode(id) + ".equals($dest)) {" + eol); -// compiler.appendProcessDataBinding("if (" + compiler.getJavaCode(id) + ".equals($dest)) {" + eol); + buffer.append("if (").append(compiler.getJavaCode(id)).append(".equals($dest)) {").append(eol); String objectCode = dataSource.getObjectCode(); if (log.isDebugEnabled()) { log.debug(id + " objectCode= " + objectCode); @@ -118,19 +115,14 @@ public class DataBinding { // boolean needTest = objectCode != null; boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); if (needTest) { - buffer.append(" if (" + objectCode + " != null) {" + eol); + buffer.append(" if (").append(objectCode).append(" != null) {").append(eol); buffer.append(" "); -// compiler.appendProcessDataBinding(" if (" + objectCode + " != null) {" + eol); -// compiler.appendProcessDataBinding(" "); } - buffer.append(" " + assignment.trim()); -// compiler.appendProcessDataBinding(" " + assignment.trim()); + buffer.append(" ").append(assignment.trim()); if (needTest) { - buffer.append(eol + " }"); -// compiler.appendProcessDataBinding(eol + " }"); + buffer.append(eol).append(" }"); } - buffer.append(eol + " }"); -// compiler.appendProcessDataBinding(eol + " }"); + buffer.append(eol).append(" }"); compiler.appendProcessDataBinding(buffer.toString()); return true; } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java b/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java index 2f1dfae..3f3435e 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java @@ -25,6 +25,7 @@ import jaxx.compiler.CompilerException; import jaxx.compiler.JAXXCompiler; import jaxx.compiler.UnsupportedAttributeException; import jaxx.compiler.java.JavaField; +import jaxx.compiler.java.JavaFileGenerator; import jaxx.compiler.java.parser.JavaParser; import jaxx.compiler.java.parser.JavaParserConstants; import jaxx.compiler.java.parser.JavaParserTreeConstants; @@ -45,6 +46,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -66,6 +68,7 @@ public class DataSource { */ private class NULL { } + /** * id of data source */ @@ -145,26 +148,23 @@ public class DataSource { * * @param propertyChangeListenerCode Java code snippet which evaluates to a <code>PropertyChangeListener</code> * @return <code>true</code> if the expression has dependencies, <code>false</code> otherwise - * @throws CompilerException if a compilation error occurs + * @throws CompilerException if a compilation error occurs * @throws IllegalStateException if data source was already compiled */ public boolean compile(String propertyChangeListenerCode) throws CompilerException, IllegalStateException { if (compiled) { throw new IllegalStateException(this + " has already been compiled"); } -// String listenerId = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(getClass())); listenerId = compiler.getAutoId(getClass().getSimpleName()); if (log.isDebugEnabled()) { log.debug("listenerId=" + listenerId); } JavaParser p = new JavaParser(new StringReader(source)); -// JavaParser p = new JavaParser(new StringReader(source + ";")); while (!p.Line()) { SimpleNode node = p.popNode(); if (log.isDebugEnabled()) { log.debug("will scan node " + node.getText()); } -// scanNode(node, listenerId); scanNode(node); } if (log.isDebugEnabled()) { @@ -180,27 +180,22 @@ public class DataSource { // add listener codes in compiler -// compileListeners(); String javaCodeId = TypeManager.getJavaCode(id); String eol = JAXXCompiler.getLineSeparator(); -// if (addListenerCode.length() > 0) { if (compiler.hasApplyDataBinding()) { compiler.appendApplyDataBinding(" else "); } compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {"); compiler.appendApplyDataBinding(" " + addListenerCode + eol); compiler.appendApplyDataBinding("}"); -// } -// if (removeListenerCode.length() > 0) { if (compiler.hasRemoveDataBinding()) { compiler.appendRemoveDataBinding(" else "); } compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {"); compiler.appendRemoveDataBinding(" " + removeListenerCode + eol); compiler.appendRemoveDataBinding("}"); -// } } //TC-20091027 if no dependency symbols then no listeners // compileListeners(); @@ -219,12 +214,10 @@ public class DataSource { /** * Examines a node to identify any dependencies it contains. * - * @param node node to scan - // * @param listenerId id of listener + * @param node node to scan * @throws CompilerException ? */ private void scanNode(SimpleNode node) throws CompilerException { -// private void scanNode(SimpleNode node, String listenerId) throws CompilerException { if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION || node.getId() == JavaParserTreeConstants.JJTFIELDDECLARATION) { return; @@ -246,7 +239,6 @@ public class DataSource { type = ClassDescriptorLoader.getClassDescriptor(Class.class); break; case JavaParserTreeConstants.JJTPRIMARYEXPRESSION: -// type = determineExpressionType(node, listenerId); type = determineExpressionType(node); break; case JavaParserTreeConstants.JJTLITERAL: @@ -278,10 +270,8 @@ public class DataSource { * can be tracked. * * @param expression the node to scan - // * @param listenerId id of the listener * @return the class descriptor of the return type or null */ -// private ClassDescriptor determineExpressionType(SimpleNode expression, String listenerId) { private ClassDescriptor determineExpressionType(SimpleNode expression) { assert expression.getId() == JavaParserTreeConstants.JJTPRIMARYEXPRESSION; SimpleNode prefix = expression.getChild(0); @@ -291,7 +281,6 @@ public class DataSource { prefix.setJavaType(prefix.getChild(0).getJavaType()); } else if (type == JavaParserTreeConstants.JJTNAME && expression.jjtGetNumChildren() == 1) { // name with no arguments after it -// prefix.setJavaType(scanCompoundSymbol(prefix.getText().trim(), compiler.getRootObject().getObjectClass(), false, listenerId)); prefix.setJavaType(scanCompoundSymbol(prefix.getText().trim(), compiler.getRootObject().getObjectClass(), false)); } } @@ -311,7 +300,6 @@ public class DataSource { if (suffix.jjtGetNumChildren() == 1 && suffix.getChild(0).getId() == JavaParserTreeConstants.JJTARGUMENTS) { if (suffix.getChild(0).jjtGetNumChildren() == 0) { // at the moment only no-argument methods are trackable -// contextClass = scanCompoundSymbol(lastNode, contextClass, true, listenerId); contextClass = scanCompoundSymbol(lastNode, contextClass, true); if (contextClass == null) { return null; @@ -327,7 +315,6 @@ public class DataSource { String methodName = lastNode.substring(dotPos + 1).trim(); try { MethodDescriptor method = contextClass.getMethodDescriptor(methodName); -// trackMemberIfPossible(code, contextClass, method.getName(), true, listenerId); trackMemberIfPossible(code, contextClass, method.getName(), true); return method.getReturnType(); } catch (NoSuchMethodException e) { @@ -348,17 +335,6 @@ public class DataSource { "removePropertyChangeListener(\"" + propertyName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator()); contextClass = newMethod.getReturnType(); } -// MethodDescriptor[] newMethods = compiler.getScriptMethods(); -// for (MethodDescriptor newMethod : newMethods) { -// if (newMethod.getName().equals(methodName)) { -// addListener(compiler.getRootObject().getId(), -// null, -// "addPropertyChangeListener(\"" + propertyName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator(), -// "removePropertyChangeListener(\"" + propertyName + "\", " + listenerId + ");" + JAXXCompiler.getLineSeparator()); -// contextClass = newMethod.getReturnType(); -// break; -// } -// } } } } @@ -411,10 +387,8 @@ public class DataSource { * @param symbol symbol to scan * @param contextClass current class context * @param isMethod flag to search a method - // * @param listenerId id of the listener * @return the type of the symbol (or null if it could not be determined). */ -// private ClassDescriptor scanCompoundSymbol(String symbol, ClassDescriptor contextClass, boolean isMethod, String listenerId) { private ClassDescriptor scanCompoundSymbol(String symbol, ClassDescriptor contextClass, boolean isMethod) { String[] tokens = symbol.split("\\s*\\.\\s*"); StringBuffer currentSymbol = new StringBuffer(); @@ -445,7 +419,6 @@ public class DataSource { } else { try { FieldDescriptor field = contextClass.getFieldDescriptor(memberName); -// trackMemberIfPossible(tokensSeenSoFar.toString(), contextClass, field.getName(), false, listenerId); trackMemberIfPossible(tokensSeenSoFar.toString(), contextClass, field.getName(), false); contextClass = field.getType(); currentSymbol.setLength(0); @@ -490,7 +463,6 @@ public class DataSource { return contextClass; } -// private void trackMemberIfPossible(String objectCode, ClassDescriptor objectClass, String memberName, boolean method, String listenerId) { private void trackMemberIfPossible(String objectCode, ClassDescriptor objectClass, String memberName, boolean method) { // if (objectClass.isInterface()) { // // might be technically possible to track in some cases, but for now @@ -523,9 +495,8 @@ public class DataSource { addListenerCode.append(eol); if (needTest) { addListenerCode.append(" if (").append(objectCode).append(" != null) {").append(eol); - addListenerCode.append(" "); } - addListenerCode.append(" ").append(addCode.trim()); + addListenerCode.append(JavaFileGenerator.indent(addCode, needTest ? 8 : 4, false, eol)); if (needTest) { addListenerCode.append(eol).append(" }"); } @@ -533,64 +504,11 @@ public class DataSource { removeListenerCode.append(eol); if (needTest) { removeListenerCode.append(" if (").append(objectCode).append(" != null) {").append(eol); - removeListenerCode.append(" "); } - removeListenerCode.append(" ").append(removeCode.trim()); + removeListenerCode.append(JavaFileGenerator.indent(removeCode, needTest ? 8 : 4, false, eol)); if (needTest) { removeListenerCode.append(eol).append(" }"); } } } -// /** -// * Adds type information to nodes where possible, and as a side effect adds event listeners to nodes which -// * can be tracked. -// * -// * @param node node to scan -// * @param listenerId the listener id -// */ -//// private void determineNodeType(SimpleNode node, String listenerId) { -// private void determineNodeType(SimpleNode node) { -// ClassDescriptor type = null; -// if (node.jjtGetNumChildren() == 1) { -// type = node.getChild(0).getJavaType(); -// } -// switch (node.getId()) { -// case JavaParserTreeConstants.JJTCLASSORINTERFACETYPE: -// type = ClassDescriptorLoader.getClassDescriptor(Class.class); -// break; -// case JavaParserTreeConstants.JJTPRIMARYEXPRESSION: -// type = determineExpressionType(node, listenerId); -// break; -// case JavaParserTreeConstants.JJTLITERAL: -// type = determineLiteralType(node); -// break; -// case JavaParserTreeConstants.JJTCASTEXPRESSION: -// type = TagManager.resolveClass(node.getChild(0).getText(), compiler); -// break; -// } -// node.setJavaType(type); -// } -// private void compileListeners() { -// String javaCodeId = TypeManager.getJavaCode(id); -// String eol = JAXXCompiler.getLineSeparator(); -// if (addListenerCode.length() > 0) { -// if (compiler.hasApplyDataBinding()) { -// compiler.appendApplyDataBinding(" else "); -// } -//// compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {" + eol); -// compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {"); -// compiler.appendApplyDataBinding(" " + addListenerCode + eol); -// compiler.appendApplyDataBinding("}"); -// } -// -// if (removeListenerCode.length() > 0) { -// if (compiler.hasRemoveDataBinding()) { -// compiler.appendRemoveDataBinding(" else "); -// } -//// compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {" + eol); -// compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {"); -// compiler.appendRemoveDataBinding(" " + removeListenerCode + eol); -// compiler.appendRemoveDataBinding("}"); -// } -// } } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java b/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java index f074c4a..b4a8367 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java @@ -146,7 +146,7 @@ public class StylesheetHelper { 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 + ")"); + new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");"); return; } @@ -192,7 +192,7 @@ public class StylesheetHelper { 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 + ")"); + new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");"); return; } @@ -268,7 +268,7 @@ public class StylesheetHelper { 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 dataBinding = compiler.processDataBindings(e.getValue()); String valueCode; if (dataBinding != null) { valueCode = "new jaxx.runtime.css.DataBinding(" + compiler.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; @@ -316,7 +316,7 @@ public class StylesheetHelper { 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 dataBinding = compiler.processDataBindings(e.getValue()); String valueCode; if (dataBinding != null) { valueCode = "new jaxx.runtime.css.DataBinding(" + compiler.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java b/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java index f87db50..6646eaf 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java @@ -35,10 +35,7 @@ import jaxx.compiler.reflect.ClassDescriptor; import jaxx.compiler.reflect.ClassDescriptorLoader; import jaxx.compiler.reflect.FieldDescriptor; import jaxx.compiler.reflect.MethodDescriptor; -import jaxx.runtime.Base64Coder; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.JAXXObjectDescriptor; -import jaxx.runtime.JAXXContext; +import jaxx.runtime.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -47,7 +44,7 @@ import static java.lang.reflect.Modifier.*; import java.util.Iterator; import java.util.List; import java.util.Map; -import jaxx.runtime.Util; + import static jaxx.compiler.java.JavaFileGenerator.*; /** @@ -102,11 +99,6 @@ public class DefaultFinalizer implements JAXXCompilerFinalizer { /** * */ - protected static final JavaField DELEGATE_CONTEXT_FIELD = newField(PROTECTED, - JAXXContext.class.getName(), "delegateContext", true); - /** - * - */ protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = newField(0, "java.beans.PropertyChangeSupport", "$propertyChangeSupport", false); /** @@ -149,13 +141,13 @@ public class DefaultFinalizer implements JAXXCompilerFinalizer { * */ protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = newMethod(PUBLIC, "<O extends Container> O", "getParentContainer", - "return delegateContext.getParentContainer(source, clazz);", true, + "return Util.getParentContainer(source, clazz);", true, new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz")); /** * */ protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = newMethod(PUBLIC, "<O extends Container> O", "getParentContainer", - "return delegateContext.getParentContainer(clazz);", true, + "return Util.getParentContainer(this, clazz);", true, new JavaArgument("Class<O>", "clazz")); /** * @@ -272,7 +264,8 @@ public class DefaultFinalizer implements JAXXCompilerFinalizer { javaFile.addField(ACTIVE_BINDINGS_FIELD); // JAXXContext - javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "(this);")); + javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "()")); +// javaFile.addField(newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", true, "new " + jaxxContextImplementorClass + "(this)")); javaFile.addMethod(SET_CONTEXT_VALUE_METHOD); javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD); javaFile.addMethod(GET_CONTEXT_VALUE_METHOD); @@ -373,6 +366,10 @@ public class DefaultFinalizer implements JAXXCompilerFinalizer { protected void finalizeBindings(JAXXCompiler compiler, boolean superclassIsJAXXObject) { String eol = JAXXCompiler.getLineSeparator(); + if (compiler.getDataBindings() != null && !compiler.getDataBindings().isEmpty()) { + compiler.addImport(DataBindingListener.class.getName()); + } + for (DataBinding dataBinding : compiler.getDataBindings()) { if (dataBinding.compile(compiler, true)) { String expression = "applyDataBinding(" + compiler.getJavaCode(dataBinding.getId()) + ");" + eol; @@ -471,6 +468,7 @@ public class DefaultFinalizer implements JAXXCompilerFinalizer { int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0; if (isPublic(modifiers)) { // we have all the support we need + return; } if (isProtected(modifiers)) { // there is property change support but the firePropertyChange method is protected @@ -534,7 +532,7 @@ public class DefaultFinalizer implements JAXXCompilerFinalizer { } } if (!superclassIsJAXXObject) { - code.append(Util.class.getName() + ".initContext(this, parentContext);"); + code.append(Util.class.getName()).append(".initContext(this, parentContext);"); code.append(eol); } code.append("$initialize();"); diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java b/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java index a425c35..d5e7a0a 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java @@ -39,6 +39,7 @@ import java.awt.event.FocusListener; import java.beans.IntrospectionException; import java.io.IOException; import java.lang.reflect.Field; + import jaxx.runtime.Util; import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; @@ -338,26 +339,34 @@ public class DefaultComponentHandler extends DefaultObjectHandler { */ 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); +// } +// } + safeInit(); if (container) { - try { - init(); - if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) { - container = false; - } - } catch (IntrospectionException e) { - throw new RuntimeException(e); + if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) { + container = false; } } return container; } public String getContainerDelegate() { - try { - init(); - return containerDelegate; - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } +// try { +// init(); +// return containerDelegate; +// } catch (IntrospectionException e) { +// throw new RuntimeException(e); +// } + safeInit(); + return containerDelegate; } } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java b/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java index 2971f13..38ff946 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java @@ -235,11 +235,7 @@ public class DefaultObjectHandler implements TagHandler { * @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); - } + safeInit(); JAXXPropertyDescriptor property = properties.get(propertyName); if (property != null) { @@ -258,11 +254,7 @@ public class DefaultObjectHandler implements TagHandler { * @throws UnsupportedAttributeException if attribute is not supported */ public boolean isMemberBound(String name) throws UnsupportedAttributeException { - try { - init(); - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } + safeInit(); if (eventInfos != null && eventInfos.containsKey(name)) { return true; @@ -294,16 +286,16 @@ public class DefaultObjectHandler implements TagHandler { 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}; - } +// /** +// * @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 @@ -341,10 +333,12 @@ public class DefaultObjectHandler implements TagHandler { } String code = objectCode + (eventInfo.modelName != null ? ".get" + 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(compiler.getJavaCode(methodName)).append("));\n"); + //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name + result.append(code).append('.').append(eventInfo.addMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(compiler.getJavaCode(methodName)).append("));"); + result.append(JAXXCompiler.getLineSeparator()); if (eventInfo.modelName != null) { result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), - Util.class.getName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", + Util.class.getSimpleName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", compiler)); } return result.toString(); @@ -372,11 +366,9 @@ public class DefaultObjectHandler implements TagHandler { // check for property-specific addPropertyChangeListener method getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); -// return objectCode + ".addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; return prefix + "addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; } catch (NoSuchMethodException e) { // no property-specific method, use general one -// return objectCode + ".addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; return prefix + "addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; } } @@ -408,13 +400,14 @@ public class DefaultObjectHandler implements TagHandler { String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : ""); String eol = JAXXCompiler.getLineSeparator(); result.append(modelClassName).append(" $target = ((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\"));").append(eol); + //TC-20091105 test if $target is not null result.append("if ($target != null) {").append(eol); - result.append(" $target.").append(eventInfo.removeMethod).append("(jaxx.runtime.Util.getEventListener(").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(compiler.getJavaCode(methodName)).append("));").append(eol); + //TC-20091105 Util.getEventListener is generic, no more need cast and use simple listener name + result.append(" $target.").append(eventInfo.removeMethod).append("( Util.getEventListener(").append(eventInfo.listenerClass.getSimpleName()).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(compiler.getJavaCode(methodName)).append("));").append(eol); result.append("}").append(eol); -// 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(compiler.getJavaCode(methodName)).append("));\n"); if (eventInfo.modelName != null) { result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), - Util.class.getName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", + Util.class.getSimpleName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", compiler)); } return result.toString(); @@ -445,11 +438,9 @@ public class DefaultObjectHandler implements TagHandler { // check for property-specific removePropertyChangeListener method getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); -// return objectCode + ".removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; return prefix + "removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; } catch (NoSuchMethodException e) { // no property-specific method, use general one -// return objectCode + ".removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; return prefix + "removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; } } @@ -569,11 +560,7 @@ public class DefaultObjectHandler implements TagHandler { @Override public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { - try { - init(); - } catch (IntrospectionException e) { - throw new CompilerException(e); - } + safeInit(); 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"); @@ -586,12 +573,13 @@ public class DefaultObjectHandler implements TagHandler { 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; - } + //TC-20091105, can apply genericType everyWhere, should just test that class is generic (not possible actually) +// 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); } @@ -829,25 +817,25 @@ public class DefaultObjectHandler implements TagHandler { 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, compiler.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 ""; - } +// public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) { +// ClassDescriptor type = getPropertyType(object, propertyName, compiler); +// String binding = compiler.processDataBindings(stringValue); +// 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, compiler.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. @@ -861,6 +849,8 @@ public class DefaultObjectHandler implements TagHandler { */ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) { try { + //FIXME TC-20091105 we should to this later when all binding are compiled + // because we don't know yet if this is a databinding if (ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(object.getObjectClass())) { // check for data binding & remove if found JAXXObjectDescriptor jaxxObjectDescriptor = object.getObjectClass().getJAXXObjectDescriptor(); @@ -870,41 +860,26 @@ public class DefaultObjectHandler implements TagHandler { if (object == compiler.getRootObject()) { prefix = ""; } else { - prefix = object.getId() + "."; + prefix = object.getJavaCode() + "."; } object.appendInitializationCode(prefix + "removeDataBinding(" + compiler.getJavaCode(root.getId() + "." + propertyName) + ");"); -// object.appendInitializationCode(object.getJavaCode() + ".removeDataBinding(" + compiler.getJavaCode(root.getId() + "." + propertyName) + ");"); } object.addProperty(propertyName, stringValue); ClassDescriptor type = getPropertyType(object, propertyName, compiler); - String binding = compiler.processDataBindings(stringValue, type); + String binding = compiler.processDataBindings(stringValue); + if (inline) { + compiler.addInlineStyle(object, propertyName, binding != null); + } if (binding != null) { - if (inline) { - compiler.addInlineStyle(object, propertyName, true); - } - //TC-20091027 : make sure this code is never used ? -// 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 + ")"; -// } String setPropertyCode = getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler); - if (propertyName.equals(LAYOUT_ATTRIBUTE)) { // handle containerDelegate (e.g. contentPane on JFrame) + if (propertyName.equals(LAYOUT_ATTRIBUTE)) { + // handle containerDelegate (e.g. contentPane on JFrame) // have to set layout early, before children are added object.appendInitializationCode(setPropertyCode); } -// object.registerDataBinding(binding, propertyName, getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler), compiler); compiler.registerDataBinding(binding, object.getId() + "." + propertyName, setPropertyCode); - } else { // no bindings, convert from string - if (inline) { - compiler.addInlineStyle(object, propertyName, false); - } + } else { + // no bindings, convert from string try { Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; Object value = convertFromString(propertyName, stringValue, typeClass); @@ -1027,11 +1002,7 @@ public class DefaultObjectHandler implements TagHandler { * @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); - } + safeInit(); JAXXPropertyDescriptor property = properties.get(name); if (property != null) { @@ -1066,7 +1037,6 @@ public class DefaultObjectHandler implements TagHandler { prefix = javaCode + "."; } return prefix + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");"; -// return javaCode + '.' + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");"; } throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " is read-only"); } @@ -1238,4 +1208,12 @@ public class DefaultObjectHandler implements TagHandler { public String toString() { return getClass().getName() + "[" + getBeanClass().getName() + "]"; } + + protected void safeInit() { + try { + init(); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } } diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java b/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java index 8452d35..fd7fd60 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java @@ -44,11 +44,11 @@ public class TagManager { * Logger */ 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/"; +// /** +// * 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). */ @@ -119,7 +119,7 @@ public class TagManager { * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified * <code>TagHandler</code> will be invoked to run it. * - * @param <T> + * @param <T> type of handler * @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> @@ -169,7 +169,7 @@ public class TagManager { * 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 <T> type of handler * @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 diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java b/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java index f343046..fec4acb 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java @@ -66,7 +66,7 @@ public class ItemHandler implements TagHandler { continue; } if (name.equals(Item.LABEL_PROPERTY)) { - String labelBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(String.class)); + String labelBinding = compiler.processDataBindings(attrValue); if (labelBinding != null) { compiler.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");"); } else { @@ -75,7 +75,7 @@ public class ItemHandler implements TagHandler { continue; } if (name.equals(Item.VALUE_PROPERTY)) { - String valueBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Object.class)); + String valueBinding = compiler.processDataBindings(attrValue); if (valueBinding != null) { value = DATA_BINDING; compiler.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");"); @@ -85,7 +85,7 @@ public class ItemHandler implements TagHandler { continue; } if (name.equals(Item.SELECTED_PROPERTY)) { - String selectedBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Boolean.class)); + String selectedBinding = compiler.processDataBindings(attrValue); if (selectedBinding != null) { compiler.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");"); } else { diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java b/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java index 5d39daa..945964c 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java @@ -73,7 +73,7 @@ public class TabHandler implements TagHandler { value = value.trim(); TabInfo tabInfo = tabs.tabInfo; String id = tabInfo.getId(); - String binding = compiler.processDataBindings(value, ClassDescriptorLoader.getClassDescriptor(Object.class)); + String binding = compiler.processDataBindings(value); if (binding != null) { compiler.registerDataBinding(binding, id + "." + name, id + ".set" + org.apache.commons.lang.StringUtils.capitalize(name) + "(" + binding + ");"); return; diff --git a/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java b/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java index 329c76b..5375cc6 100644 --- a/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java +++ b/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java @@ -40,7 +40,7 @@ public class FieldValidatorHandler implements TagHandler { /** 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.debug(tag); diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java b/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java index d731cf3..427afea 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java @@ -20,8 +20,6 @@ */ package jaxx.runtime; -import java.awt.Container; - /** * The {@link jaxx.runtime.JAXXContext} contract defines a generic context. * <p/> @@ -50,37 +48,37 @@ public interface JAXXContext { * 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 + * @param o the value to push in context */ - public <T> void setContextValue(T o); + <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 <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); + <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 <T> type of data to remove from context * @param klazz the klazz entry */ - public <T> void removeContextValue(Class<T> klazz); + <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 <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); + <T> void removeContextValue(Class<T> klazz, String name); /** * Seek for a unamed entry in the context @@ -89,42 +87,42 @@ public interface JAXXContext { * <p/> * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code> * - * @param <T> type of data to obtain from context + * @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); + <T> T getContextValue(Class<T> clazz); /** * Seek for a named entry in the context * - * @param <T> type of data to obtain from 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); + <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 - * @deprecated since 2.0.0 : breaks neutral since Swing - */ - @Deprecated - 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 - * @deprecated since 2.0.0 : breaks neutral since Swing - */ - @Deprecated - public <O extends Container> O getParentContainer(Object top, Class<O> clazz); +// /** +// * 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 +// * @deprecated since 2.0.0 : breaks neutral since Swing +// */ +// @Deprecated +// 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 +// * @deprecated since 2.0.0 : breaks neutral since Swing +// */ +// @Deprecated +// public <O extends Container> O getParentContainer(Object top, Class<O> clazz); } diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java b/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java index dbb12ee..0638f57 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java @@ -20,10 +20,11 @@ */ package jaxx.runtime; +import java.awt.*; import java.io.Serializable; import java.util.Map; -/** +/** * The <code>JAXXObject</code> interface is implemented by all classes * produced by the JAXX compiler. */ @@ -45,13 +46,13 @@ public interface JAXXObject extends JAXXContext, Serializable { Map<String, Object> get$objectMap(); /** - * * @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); @@ -83,4 +84,53 @@ public interface JAXXObject extends JAXXContext, Serializable { * @param newValue the new value of the property */ void firePropertyChange(String name, Object oldValue, Object newValue); + + /** + * Register a general {@link java.beans.PropertyChangeListener}. + * + * @param listener the listener to register + */ + void addPropertyChangeListener(java.beans.PropertyChangeListener listener); + + /** + * Register a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. + * + * @param property the property name to listen + * @param listener the listener to register + */ + void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener); + + /** + * Unregister a general {@link java.beans.PropertyChangeListener}. + * + * @param listener the listener to unregister + */ + void removePropertyChangeListener(java.beans.PropertyChangeListener listener); + + /** + * Unregister a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}. + * + * @param property the property name to listen + * @param listener the listener to unregister + */ + void removePropertyChangeListener(String property, java.beans.PropertyChangeListener listener); + + /** + * 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 + */ + <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 + */ + <O extends Container> O getParentContainer(Object top, Class<O> clazz); } diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/Util.java b/jaxx-runtime/src/main/java/jaxx/runtime/Util.java index 18e5f03..b49fa49 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/Util.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/Util.java @@ -28,8 +28,7 @@ import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.UIManager; -import java.awt.Component; -import java.awt.Dimension; +import java.awt.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListenerProxy; import java.io.IOException; @@ -50,7 +49,7 @@ public class Util { public static final String DEFAULT_ICON_PATH = "/icons/"; public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path"; - /** + /** * Logger */ static private final Log log = LogFactory.getLog(Util.class); @@ -121,11 +120,34 @@ public class Util { } public static <O> JAXXContextEntryDef<List<O>> newListContextEntryDef(String name) { - Class<List<O>> castList = Util.<O>castList(); + Class<List<O>> castList = Util.castList(); JAXXContextEntryDef<List<O>> contextEntryDef = new JAXXContextEntryDef<List<O>>(name, castList); return contextEntryDef; } + /** + * 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 + */ + @SuppressWarnings({"unchecked"}) + public static <O extends Container> O getParentContainer(Object top, Class<O> clazz) { + 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; + } + @SuppressWarnings({"unchecked"}) protected static <O> Class<List<O>> castList() { return (Class<List<O>>) Collections.emptyList().getClass(); @@ -133,8 +155,8 @@ public class Util { /** * Method to initialize the context of a ui. - * - * @param ui the ui + * + * @param ui the ui * @param parentContext the context to set in ui */ public static void initContext(JAXXObject ui, JAXXContext parentContext) { @@ -151,7 +173,7 @@ public class Util { } } - public static <E extends EventListener> E getEventListener(Class<E> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) { + public static <E extends EventListener> E getEventListener(Class<E> 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; if (descriptors == null) { @@ -334,7 +356,7 @@ public class Util { * <p/> * If entry is found, return his value in context. * - * @param <T> the type of required data + * @param <T> the type of required data * @param context the context to test * @param def the definition of the entry to seek in context * @return the value from the context diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java b/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java index c8de9fc..7162959 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java @@ -21,15 +21,15 @@ package jaxx.runtime.context; import jaxx.runtime.JAXXContext; -import jaxx.runtime.*; -import java.awt.Container; +import jaxx.runtime.Util; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + 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 @@ -60,25 +60,25 @@ public abstract class DataContext { 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 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) { diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java b/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java index cb20060..f0b6859 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java @@ -84,7 +84,7 @@ public class DefaultApplicationContext extends DefaultJAXXContext { /** * Define a forward to a target class. When the target class - * will be asked with method {@link #getContextValue(java.lang.Class, java.lang.String)} + * will be asked with method {@link JAXXContext#getContextValue(java.lang.Class, java.lang.String)} * it will be delegating to this class. * * @return the forwarded class @@ -107,9 +107,9 @@ public class DefaultApplicationContext extends DefaultJAXXContext { pcs = new PropertyChangeSupport(this); } - public DefaultApplicationContext(JAXXObject ui) { - super(ui); - } +// public DefaultApplicationContext(JAXXObject ui) { +// super(); +// } /** to use log facility, just put in your code: log.info(\"...\"); */ static private final Log log = LogFactory.getLog(DefaultApplicationContext.class); @@ -119,7 +119,7 @@ public class DefaultApplicationContext extends DefaultJAXXContext { @SuppressWarnings({"unchecked"}) @Override public <T> T getContextValue(Class<T> clazz, String name) { - Object value = null; + Object value; MethodAccess access; Class<?> realClass; @@ -237,9 +237,9 @@ public class DefaultApplicationContext extends DefaultJAXXContext { protected Object newInstance(Class<?> clazz) throws IllegalArgumentException { - Object value = null; + Object value; - Constructor<?> constructor = null; + Constructor<?> constructor; try { constructor = clazz.getConstructor(); // auto instanciate the class diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java b/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java index 17b36e2..eb682ea 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java @@ -20,12 +20,12 @@ */ package jaxx.runtime.context; -import jaxx.runtime.*; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; import jaxx.runtime.Util; 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; @@ -48,19 +48,19 @@ public class DefaultJAXXContext implements JAXXContext { * entry of the parent context */ protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = Util.newContextEntryDef(JAXXContext.class); - /** + /** * Logger */ static private final Log log = LogFactory.getLog(DefaultJAXXContext.class); - /** - * l'ui auquel est rattache le context - */ - protected JAXXObject ui; - /** +// /** +// * 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; @@ -69,10 +69,10 @@ public class DefaultJAXXContext implements JAXXContext { data = new HashMap<JAXXContextEntryDef<?>, Object>(); } - public DefaultJAXXContext(JAXXObject ui) { - this(); - this.ui = ui; - } +// public DefaultJAXXContext(JAXXObject ui) { +// this(); +// this.ui = ui; +// } @Override public <T> void setContextValue(T o) { @@ -139,33 +139,33 @@ public class DefaultJAXXContext implements JAXXContext { 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; - } +// @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 @@ -185,13 +185,13 @@ public class DefaultJAXXContext implements JAXXContext { data.clear(); } - protected JAXXObject getUi() { - return ui; - } - - protected void setUi(JAXXObject ui) { - this.ui = ui; - } +// protected JAXXObject getUi() { +// return ui; +// } +// +// protected void setUi(JAXXObject ui) { +// this.ui = ui; +// } protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) { return Util.newContextEntryDef(name, klass); diff --git a/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java b/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java index 2b1aaed..b853001 100644 --- a/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java +++ b/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java @@ -21,10 +21,10 @@ package jaxx.runtime.context; import jaxx.runtime.JAXXContext; -import java.awt.Container; -import java.util.Map.Entry; import jaxx.runtime.JAXXObject; +import java.util.Map.Entry; + /** * An initial context to be inject in a {@link JAXXObject}. * <p/> @@ -115,13 +115,13 @@ public class JAXXInitialContext extends DefaultJAXXContext { 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"); - } +// @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"); +// } } diff --git a/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java b/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java index 3e9012f..ba84cbe 100644 --- a/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java +++ b/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java @@ -27,9 +27,12 @@ import org.junit.Before; import org.junit.Test; import java.awt.Container; +import java.beans.PropertyChangeListener; import java.util.Map; -/** @author chemit */ +/** + * @author chemit + */ public class DefaultJAXXContextTest { DefaultJAXXContext ctxt; @@ -41,40 +44,40 @@ public class DefaultJAXXContextTest { 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(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 { @@ -292,30 +295,64 @@ public class DefaultJAXXContextTest { } private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject { + private static final long serialVersionUID = 1L; + @Override public Object getObjectById(String id) { return null; } + @Override public Map<String, Object> get$objectMap() { return null; } + @Override public void applyDataBinding(String id) { } + @Override public void removeDataBinding(String id) { } + @Override public JAXXContext getDelegateContext() { return null; } + @Override public void processDataBinding(String dest) { } + @Override public void firePropertyChange(String name, Object oldValue, Object newValue) { } + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + } + + @Override + public void addPropertyChangeListener(String property, PropertyChangeListener listener) { + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + } + + @Override + public void removePropertyChangeListener(String property, PropertyChangeListener listener) { + } + + @Override + public <O extends Container> O getParentContainer(Class<O> clazz) { + return null; + } + + @Override + public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { + return null; + } + } } diff --git a/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx b/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx index 47b2496..12bf31e 100644 --- a/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx +++ b/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx @@ -20,7 +20,7 @@ */ --> -<Table fill='both' insets='0' +<Table fill='both' insets='0' genericType='O' onFocusGained='combobox.requestFocus()' onFocusLost='hidePopup()'> @@ -33,6 +33,7 @@ <!-- show decorator property --> <Boolean id='showDecorator' javaBean='true'/> + <!-- editable combo property --> <Boolean id='editable' javaBean='true'/> <!-- bean property linked state --> @@ -48,14 +49,14 @@ <Integer id='index' javaBean='0'/> <!-- datas of the combo-box --> - <java.util.List id='data' javaBean='null'/> + <java.util.List id='data' genericType='O' javaBean='null'/> <!-- model of sorted property --> <ButtonGroup id='indexes' useToolTipText='true' onStateChanged='setIndex((Integer)indexes.getSelectedValue())'/> <!-- ui handler --> - <EntityComboBoxHandler id='handler' constructorParams='this'/> + <EntityComboBoxHandler id='handler' genericType='O' constructorParams='this'/> <String id='selectedToolTipText' javaBean='null'/> @@ -84,7 +85,7 @@ public static final String DEFAULT_SELECTED_TOOLTIP = n_("entitycombobox.sort.on public static final String DEFAULT_NOT_SELECTED_TOOLTIP = n_("entitycombobox.sort.off"); -public <O> void init(JXPathDecorator<O> decorator, java.util.List<O> data) { +public void init(JXPathDecorator<O> decorator, java.util.List<O> data) { handler.init(decorator, data); } diff --git a/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java b/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java index 9877f68..0abcf23 100644 --- a/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java +++ b/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java @@ -70,7 +70,7 @@ public class EntityComboBoxHandler<O> implements PropertyChangeListener { public static final String AUTO_COMPLETE_PROPERTY = "autoComplete"; public static final String DATA_PROPERTY = "data"; /** ui if the handler */ - protected EntityComboBox ui; + protected EntityComboBox<O> ui; /** the mutator method on the property of boxed bean in the ui */ protected Method mutator; /** the original document of the combbo box editor (keep it to make possible undecorate) */ @@ -81,7 +81,7 @@ public class EntityComboBoxHandler<O> implements PropertyChangeListener { protected MultiJXPathDecorator<O> decorator; protected boolean init; - public EntityComboBoxHandler(EntityComboBox ui) { + public EntityComboBoxHandler(EntityComboBox<O> ui) { this.ui = ui; } protected final FocusListener EDITOR_TEXT_COMP0NENT_FOCUSLISTENER = new FocusListener() { diff --git a/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx b/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx index 98d2e64..7285241 100644 --- a/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx +++ b/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx @@ -1,36 +1,14 @@ -<!-- - -/** - * *##% jaxx-runtime-swing-widget - * 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>. ##%* - */ - ---> -<JToggleButton id='hidor' - icon='{updateIcon(isTargetVisible())}' +<JToggleButton id='hidor' toolTipText='{updateToolTipText(isTargetVisible())}' - _collapseIcon='{SwingUtil.createActionIcon("collapse")}' - _expandIcon='{SwingUtil.createActionIcon("expand")}' - _collapseTip='{_("hidor.collapseTip")}' - _expandTip='{_("hidor.expandTip")}' + icon='{SwingUtil.createActionIcon("collapse")}' + pressedIcon='{SwingUtil.createActionIcon("expand")}' onActionPerformed='setTargetVisible(!targetVisible)'> - <!--selected='{updateCollapseIcon(isTargetVisible())}'--> - <Boolean id='targetVisible' javaBean='true'/> + <Boolean id='targetVisible' javaBean='null'/> + + <String id='collapseTip' javaBean='_("hidor.collapseTip")'/> + + <String id='expandTip' javaBean='_("hidor.expandTip")'/> <script><![CDATA[ import jaxx.runtime.SwingUtil; @@ -61,15 +39,16 @@ public void setTarget(JComponent target) { firePropertyChange("target", oldValue, target); } -protected Icon updateIcon(boolean c) { - String key = c ? "collapseIcon" : "expandIcon"; - Icon i = (Icon) getClientProperty(key); - return i; +public void setExpandIcon(Icon icon) { + setSelectedIcon(icon); +} + +public void setCollapseIcon(Icon icon) { + setIcon(icon); } protected String updateToolTipText(boolean c) { - String key = c ? "collapseTip" : "expandTip"; - String i = (String) getClientProperty(key); + String i = c ? collapseTip : expandTip; return i; } ]]> diff --git a/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx b/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx new file mode 100644 index 0000000..6e5477f --- /dev/null +++ b/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx @@ -0,0 +1,153 @@ +<JPanel layout='{new BorderLayout()}' genericType='B'> + + <Boolean id='modified' javaBean='false'/> + + <String id='addToListTip' javaBean='"+"'/> + + <String id='addToComboTip' javaBean='"-"'/> + + <ListCellRenderer id='renderer' javaBean='null'/> + + <script><![CDATA[ + +/** + * @return the datas from the combo box. + */ +public java.util.List<B> getComboDatas() { + java.util.List<B> datas = new java.util.ArrayList<B>(); + ComboBoxModel comboModel = combo.getModel(); + for (int i = 0, j = comboModel.getSize(); i < j; i++) { + B g = (B) comboModel.getElementAt(i); + datas.add(g); + } + return datas; +} + +/** + * @return the data for the list. + */ +public java.util.List<B> getListDatas() { + java.util.List<B> datas = new java.util.ArrayList<B>(); + ListModel listModel = list.getModel(); + for (int i = 0, j = listModel.getSize(); i < j; i++) { + B g = (B) listModel.getElementAt(i); + datas.add(g); + } + return datas; +} + +/** + * Initialize the component. + * + * @param toCombo datas to set in combo + * @param toList datas to set in list + */ +public void init(java.util.List<B> toCombo, java.util.List<B> toList) { + setComboDatas(toCombo); + setListDatas(toList); + // after init, always unmodified editor + // TODO should avoid to fire a changed ? + setModified(false); +} + +/** + * Transfert the {@code b} data from combo box to list. + * + * @param b the data to transfert + */ +protected void transfertToList(B b) { + ((DefaultListModel) list.getModel()).addElement(b); + ((DefaultComboBoxModel) combo.getModel()).removeElement(b); + setModified(true); +} + +/** + * Transfert the {@code b} data from list to combo box. + * + * @param b the data to transfert + */ +protected void transfertToCombo(B b) { + ((DefaultListModel) list.getModel()).removeElement(b); + ((DefaultComboBoxModel) combo.getModel()).addElement(b); + setModified(true); +} + +/** + * @param enabled databinding + * @return {@code true} if add button should be enabled + */ +protected boolean updateAddEnabled(boolean enabled) { + return enabled && combo.getModel().getSize() > 0; +} + +/** + * @param enabled databinding + * @return {@code true} if remove button should be enabled + */ +protected boolean updateRemoveEnabled(boolean enabled) { + return enabled && list.getModel().getSize() > 0; +} + +/** + * Set the data in combo box model. + * + * @param toCombo datas to set in combo box model + */ +protected void setComboDatas(java.util.List<B> toCombo) { + SwingUtil.fillComboBox(combo, toCombo, null); + //Note : there is a case when combo was selected, then come here with an empty + // combo model : no propertyChanged is fired, so add button stays enabled... + processDataBinding("add.enabled"); +} + +/** + * Set the data in the list model. + * + * @param toList datas to set in list model + */ +protected void setListDatas(java.util.List<B> toList) { + SwingUtil.fillList(list, toList, null); +} + +]]> + </script> + + <JScrollPane constraints='BorderLayout.CENTER' + columnHeaderView='{header}' + verticalScrollBarPolicy='vertical_scrollbar_always' + minimumSize='{SwingUtil.newMinDimension()}'> + <JList id='list' + enabled='{isEnabled()}' + model='{new DefaultListModel()}' + minimumSize='{SwingUtil.newMinDimension()}' + maximumSize='{new Dimension(100,200)}' + font-size='11' + cellRenderer='{getRenderer()}'/> + </JScrollPane> + + <Table id="header" insets='0' constraints='BorderLayout.SOUTH'> + <row> + <cell fill='horizontal' weightx='1' anchor="west"> + <JComboBox id='combo' enabled='{isEnabled()}' + model='{new DefaultComboBoxModel()}' + renderer='{getRenderer()}'/> + </cell> + <cell anchor='east'> + <JToolBar floatable='false'> + <JButton id="add" + toolTipText='{getAddToListTip()}' + actionIcon='add' + enabled='{updateAddEnabled(combo.isEnabled() && combo.getSelectedIndex() > -1)}' + onActionPerformed='transfertToList((B) combo.getSelectedItem());'/> + + <JButton id="remove" + toolTipText='{getAddToComboTip()}' + actionIcon='remove' + enabled='{updateRemoveEnabled(list.isEnabled() && list.getSelectedIndex() > -1)}' + onActionPerformed='transfertToCombo((B) list.getSelectedValue());'/> + </JToolBar> + </cell> + </row> + </Table> + +</JPanel> \ No newline at end of file diff --git a/jaxx-widgets/src/main/resources/icons/action-add.png b/jaxx-widgets/src/main/resources/icons/action-add.png new file mode 100644 index 0000000..6332fef Binary files /dev/null and b/jaxx-widgets/src/main/resources/icons/action-add.png differ diff --git a/jaxx-widgets/src/main/resources/icons/action-remove.png b/jaxx-widgets/src/main/resources/icons/action-remove.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/jaxx-widgets/src/main/resources/icons/action-remove.png differ diff --git a/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java index 546612c..8d6f6ad 100644 --- a/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java +++ b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java @@ -23,7 +23,7 @@ package org.nuiton.jaxx.plugin.DataBinding; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; -public class BeanImpl { +public class BeanImpl implements Bean{ protected String text; PropertyChangeSupport p; diff --git a/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java index c442745..408eca4 100644 --- a/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java +++ b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java @@ -38,8 +38,8 @@ public class DataBindingTest extends JaxxBaseTest { assertNumberJaxxFiles(1); // no bindings - checkPattern(mojo, "new jaxx.runtime.DataBindingListener(this, \"nobinding1.text\");", false); - checkPattern(mojo, "new jaxx.runtime.DataBindingListener(this, \"nobinding2.text\");", false); + checkPattern(mojo, "new DataBindingListener(this, \"nobinding1.text\");", false); + checkPattern(mojo, "new DataBindingListener(this, \"nobinding2.text\");", false); // with bindings checkBinding(mojo, "binding8.text"); @@ -47,7 +47,7 @@ public class DataBindingTest extends JaxxBaseTest { protected void checkBinding(GenerateMojo mojo, String... bindings) throws IOException { for (String b : bindings) { - checkPattern(mojo, "new jaxx.runtime.DataBindingListener(this, \"" + b + "\");", true); + checkPattern(mojo, "new DataBindingListener(this, \"" + b + "\");", true); } } } diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JavaTaist.java b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java similarity index 67% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JavaTaist.java rename to maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java index e15c38b..e0d0ab4 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JavaTaist.java +++ b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java @@ -1,4 +1,4 @@ -package testcases.ClassReferences; +package org.nuiton.jaxx.plugin.compilerTest.classReferences; import javax.swing.*; diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java rename to maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java b/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java rename to maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml index 4538ee8..8342298 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml @@ -17,8 +17,9 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <i18nable>false</i18nable> + <verbose>true</verbose> <includes> - <value>**/compilerTest/CSSTests/*.jaxx</value> + <value>**/compilerTest/cSSTests/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml index 4822db4..c289627 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml @@ -17,7 +17,7 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> - <value>**/compilerTest/ClassReferences/*.jaxx</value> + <value>**/compilerTest/classReferences/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml index 03a151c..ad41798 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml @@ -17,7 +17,7 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> - <value>**/compilerTest/Initializers/*.jaxx</value> + <value>**/compilerTest/initializers/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml index 42f9345..aacc750 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml @@ -17,7 +17,7 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> - <value>**/compilerTest/InnerClasses/*.jaxx</value> + <value>**/compilerTest/innerClasses/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml index a39d1a5..ff9451c 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml @@ -17,7 +17,7 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> - <value>**/compilerTest/OverridingDataBindings/*.jaxx</value> + <value>**/compilerTest/overridingDataBindings/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml index ec71e3f..df270eb 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml @@ -17,7 +17,7 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> - <value>**/compilerTest/Script/*.jaxx</value> + <value>**/compilerTest/script/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml index 9683bcc..824d13f 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml @@ -17,7 +17,7 @@ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> - <value>**/compilerTest/SpecialSubclassing/*.jaxx</value> + <value>**/compilerTest/specialSubclassing/*.jaxx</value> </includes> </configuration> </plugin> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/CSSTests.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx similarity index 81% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/CSSTests.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx index 9dacdff..3f49b68 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/CSSTests.jaxx +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx @@ -1,6 +1,6 @@ <Application title='CSSTests'> <style> - Application { lookAndFeel: {lookAndFeel.getSelectedValue()}; } + Application { lookAndFeel: {String.valueOf(lookAndFeel.getSelectedValue())}; } </style> <JMenuBar> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/Child.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/Child.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/Child2.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/Child2.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Child2.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/GrandChild.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/GrandChild.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChild.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/GrandChildButton.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/GrandChildButton.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/GrandChildButton.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/Pseudoclasses.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/Pseudoclasses.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/Pseudoclasses.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/SimpleCSS.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/SimpleCSS.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/SimpleCSS.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/ClassReferences.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/ClassReferences.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ClassReferences.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/ConstructorReferenceTest.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/ConstructorReferenceTest.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ConstructorReferenceTest.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JAXXReferenceTest.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JAXXReferenceTest.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXReferenceTest.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JAXXTest.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JAXXTest.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JAXXTest.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/StaticMethodTest.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/StaticMethodTest.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/StaticMethodTest.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/TypeReference.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/TypeReference.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/TypeReference.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers/Initializers.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers/Initializers.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/Initializers.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses/InnerClasses.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses/InnerClasses.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/InnerClasses.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/CurrentTime.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/CurrentTime.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/CurrentTime.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/OverriddenCurrentTime.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/OverriddenCurrentTime.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverriddenCurrentTime.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/OverridingDataBindings.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/OverridingDataBindings.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/OverridingDataBindings.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script/JScriptInitializer.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script/JScriptInitializer.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/JScriptInitializer.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JComboBoxTest1.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JComboBoxTest1.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest1.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JComboBoxTest2.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JComboBoxTest2.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JComboBoxTest2.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JListTest1.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JListTest1.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest1.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JListTest2.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JListTest2.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JListTest2.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JTreeTest1.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JTreeTest1.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest1.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JTreeTest2.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/JTreeTest2.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/JTreeTest2.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/SpecialSubclassing.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx similarity index 100% rename from maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/SpecialSubclassing.jaxx rename to maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/SpecialSubclassing.jaxx diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx index 1469d97..d85b2c7 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx @@ -7,7 +7,7 @@ <!-- errors model --> <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors' - onContentsChanged='ok.setEnabled(errors.size()==0)'/> + onContentsChanged='ok.setEnabled(errors.isEmpty())'/> <!-- validators --> <BeanValidator id='validator' bean='model' errorListModel='errors'> @@ -89,7 +89,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JLabel text='{model.getRatio()}'/> + <JLabel text='{model.getRatio()+""}'/> </cell> </row> </Table> @@ -158,7 +158,7 @@ <JLabel text='Ratio:'/> </cell> <cell> - <JLabel text='{model2.getRatio()}'/> + <JLabel text='{model2.getRatio()+""}'/> </cell> </row> </Table> @@ -244,7 +244,7 @@ <JLabel text='Age:'/> </cell> <cell> - <JLabel text='{identity.getAge()}'/> + <JLabel text='{identity.getAge()+""}'/> </cell> </row> </Table> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx index 6eb200b..e9a5e97 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx @@ -91,7 +91,7 @@ <JLabel text='Age:'/> </cell> <cell> - <JLabel text='{identity.getAge()}'/> + <JLabel text='{identity.getAge()+""}'/> </cell> </row> </Table> diff --git a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx index 157d7d8..44d5646 100644 --- a/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx +++ b/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx @@ -4,8 +4,8 @@ <java.io.File id='file' constructorParams='""'/> <java.io.File id='file2' javaBean='new File("")'/> - <org.nuiton.jaxx.plugin.DataBinding.Bean id='bean' javaBean='new BeanImpl()'/> - <org.nuiton.jaxx.plugin.DataBinding.BeanImpl id='beanImpl' javaBean='new BeanImpl()'/> + <org.nuiton.jaxx.plugin.DataBinding.Bean id='bean' javaBean='new org.nuiton.jaxx.plugin.DataBinding.BeanImpl()'/> + <org.nuiton.jaxx.plugin.DataBinding.BeanImpl id='beanImpl' javaBean='new org.nuiton.jaxx.plugin.DataBinding.BeanImpl()'/> <JLabel id='nobinding1' text='{file.getAbsolutePath()}'/> <JLabel id='nobinding2' text='{getFile().getAbsolutePath()}'/> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.