Author: tchemit Date: 2009-11-05 21:44:42 +0100 (Thu, 05 Nov 2009) New Revision: 1633 Added: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-add.png branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-remove.png branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/initializers/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/innerClasses/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/overridingDataBindings/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/script/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/specialSubclassing/ Removed: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing/ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx Log: - 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 Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -127,7 +127,7 @@ 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,18 +140,18 @@ return child; } - public void setChild(CompiledObject child) { - this.child = child; - } +// public void setChild(CompiledObject child) { +// this.child = child; +// } +// +// public String getConstraints() { +// return constraints; +// } +// +// public void setConstraints(String constraints) { +// this.constraints = constraints; +// } - public String getConstraints() { - return constraints; - } - - public void setConstraints(String constraints) { - this.constraints = constraints; - } - public String getChildJavaCode() { return childJavaCode; } @@ -160,14 +160,14 @@ this.childJavaCode = childJavaCode; } - public String getDelegateCode() { - return delegateCode; - } +// public String getDelegateCode() { +// return delegateCode; +// } +// +// public void setDelegateCode(String delegateCode) { +// this.delegateCode = 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 String prefix; @@ -177,10 +177,8 @@ 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 @@ 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 @@ childRef.addToAdditionCode(buffer, compiler.getRootObject() == this); } additionCode = buffer.append(additionCode); - return; } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -82,6 +82,7 @@ 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 @@ */ public class JAXXCompiler { - /** + /** * Logger */ protected static final Log log = LogFactory.getLog(JAXXCompiler.class); @@ -112,7 +113,7 @@ * */ 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 @@ /*------------------------------------------------------------------------*/ /*-- 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 @@ * 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 @@ * {@link #registerStylesheet}. */ protected Stylesheet stylesheet; - /** + /** * Contains all attributes defined inline on class tags. */ protected List<Rule> inlineStyles = new ArrayList<Rule>(); @@ -195,11 +196,11 @@ * 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 @@ * 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 @@ /** * 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 @@ 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 @@ } }); } - 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -416,7 +416,7 @@ * 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 @@ /** * 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 @@ "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") + ); } /** Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataBinding.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -54,7 +54,7 @@ * 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 @@ // 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 @@ 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 @@ // 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; } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/binding/DataSource.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -25,6 +25,7 @@ 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.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 @@ */ private class NULL { } + /** * id of data source */ @@ -145,26 +148,23 @@ * * @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 @@ // 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 @@ /** * 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 @@ type = ClassDescriptorLoader.getClassDescriptor(Class.class); break; case JavaParserTreeConstants.JJTPRIMARYEXPRESSION: -// type = determineExpressionType(node, listenerId); type = determineExpressionType(node); break; case JavaParserTreeConstants.JJTLITERAL: @@ -278,10 +270,8 @@ * 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 @@ 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 @@ 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 @@ 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 @@ "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 @@ * @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 @@ } 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 @@ 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 @@ 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 @@ 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("}"); -// } -// } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -146,7 +146,7 @@ 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 @@ 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 @@ 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 @@ 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) + ")"; Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/finalizers/DefaultFinalizer.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -35,10 +35,7 @@ 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 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 @@ /** * */ - 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 @@ * */ 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 @@ 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 @@ 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 @@ 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 @@ } } 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();"); Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -39,6 +39,7 @@ 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 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; } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -235,11 +235,7 @@ * @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 @@ * @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 @@ 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 @@ } 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 @@ // 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 @@ 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 @@ // 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 @@ @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 @@ 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 @@ 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 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 @@ 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 @@ * @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 @@ 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 String toString() { return getClass().getName() + "[" + getBeanClass().getName() + "]"; } + + protected void safeInit() { + try { + init(); + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -44,12 +44,12 @@ * 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). */ private static Map<String, String> defaultNamespaces = new HashMap<String, String>(); @@ -119,7 +119,7 @@ * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified * <code>TagHandler</code> will be invoked to 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 @@ * 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 Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -66,7 +66,7 @@ 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 @@ 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 @@ 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 { Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -73,7 +73,7 @@ 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; Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -40,7 +40,7 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(FieldValidatorHandler.class); - @Override + public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { if (compiler.getConfiguration().isVerbose()) { log.debug(tag); Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -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 @@ * 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 @@ * <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); } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -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 @@ 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 @@ * @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); } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -28,8 +28,7 @@ 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 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,20 +120,43 @@ } 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(); } /** * 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 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 @@ * <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 Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -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,27 +60,27 @@ 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 +// 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 - public <O extends Container> O getParentContainer(Class<O> clazz) { - throw new IllegalStateException("can not use this method for this type of context"); - } - - @Override - public <O extends Container> O getParentContainer(Object top, Class<O> clazz) { - throw new IllegalStateException("can not use this method for this type of context"); - } - - @Override - protected JAXXObject getUi() { - throw new IllegalStateException("can not use this method for this type of context"); - } - - @Override protected void setParentContext(JAXXContext parentContext) { throw new IllegalStateException("can not use this method for this type of context"); } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -84,7 +84,7 @@ /** * 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 @@ 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 @@ @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 @@ 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 Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -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 @@ * 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 @@ 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 @@ remove0(klazz, name); } - @Override - public <O extends Container> O getParentContainer(Class<O> clazz) { - return this.getParentContainer(ui, clazz); - } +// @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; +// } - @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,14 +185,14 @@ data.clear(); } - protected JAXXObject getUi() { - return ui; - } +// protected JAXXObject getUi() { +// return ui; +// } +// +// protected void setUi(JAXXObject ui) { +// this.ui = ui; +// } - protected void setUi(JAXXObject ui) { - this.ui = ui; - } - protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) { return Util.newContextEntryDef(name, klass); } Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -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 @@ 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"); +// } } Modified: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java =================================================================== --- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -27,9 +27,12 @@ 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,41 +44,41 @@ ctxt = new DefaultJAXXContext(); } - @Test(expected = IllegalStateException.class) - public void testParentContainerFail_IllegalStateException() throws Exception { - ctxt.getParentContainer(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 = 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 = IllegalArgumentException.class) - public void testParentContainerFail_IllegalArgumentException() throws Exception { - - // attach a fake ui (which is NOT a Container) - ctxt.setUi(new MyJAXXObject()); - ctxt.getParentContainer(Container.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testParentContainerFail_IllegalArgumentException2() throws Exception { - - // attach a fake ui (which is NOT a Container) - ctxt.setUi(new MyJAXXObject()); - ctxt.getParentContainer(null, Container.class); - } - - @Test(expected = IllegalArgumentException.class) - public void testParentContainerFail_IllegalArgumentException3() throws Exception { - - // attach a fake ui (which is NOT a Container) - ctxt.setUi(new MyJAXXObject()); - ctxt.getParentContainer("null", Container.class); - } - @Test public void testGetParentContext() throws Exception { JAXXContext expected, result; @@ -292,30 +295,64 @@ } 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; + } + } } Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -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_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); } Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -70,7 +70,7 @@ 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 @@ 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() { Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -1,37 +1,15 @@ -<!-- - -/** - * *##% 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 @@ 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; } ]]> Added: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx (rev 0) +++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -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 Added: branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-add.png =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-add.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-remove.png =================================================================== (Binary files differ) Property changes on: branches/jaxx-2.X/jaxx-widgets/src/main/resources/icons/action-remove.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBinding/BeanImpl.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -23,7 +23,7 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; -public class BeanImpl { +public class BeanImpl implements Bean{ protected String text; PropertyChangeSupport p; Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DataBindingTest.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -38,8 +38,8 @@ 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 @@ 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); } } } Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java (rev 0) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -0,0 +1,9 @@ +package org.nuiton.jaxx.plugin.compilerTest.classReferences; + +import javax.swing.*; + +public class JavaTaist extends JLabel { + public void setCustomProperty(String label) { + setText(label); + } +} \ No newline at end of file Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java (from rev 1626, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java) =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java (rev 0) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -0,0 +1,79 @@ +package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +public class Identity { + + protected String firstName = ""; + + protected String lastName = ""; + + protected String email = "dummy@codelutin.com"; + + protected int age = 51; + + + PropertyChangeSupport p; + + public Identity() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public String getEmail() { + return email; + } + + public int getAge() { + return age; + } + + public void setFirstName(String firstName) { + String oldFirstName = this.firstName; + this.firstName = firstName; + p.firePropertyChange("firstName", oldFirstName, firstName); + } + + public void setLastName(String lastName) { + String oldLastName = this.lastName; + this.lastName = lastName; + p.firePropertyChange("lastName", oldLastName, lastName); + } + + public void setEmail(String email) { + String oldEmail =this.email; + this.email = email; + p.firePropertyChange("email", oldEmail, email); + } + + public void setAge(int age) { + int oldAge = this.age; + this.age = age; + p.firePropertyChange("age", oldAge, age); + } +} \ No newline at end of file Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java (from rev 1626, branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java) =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java (rev 0) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -0,0 +1,66 @@ +package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; + +import java.beans.*; + +public class Model { + + protected String text = "text"; + + protected String text2 = "text2"; + + protected int ratio = 51; + + + PropertyChangeSupport p; + + public Model() { + p = new PropertyChangeSupport(this); + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + p.addPropertyChangeListener(listener); + } + + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + p.removePropertyChangeListener(listener); + } + + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + p.removePropertyChangeListener(propertyName, listener); + } + + + public String getText() { + return text; + } + + public String getText2() { + return text2; + } + + public int getRatio() { + return ratio; + } + + public void setText(String text) { + String oldText = this.text; + this.text = text; + p.firePropertyChange("text", oldText, text); + } + + public void setText2(String text2) { + String oldText2 = this.text2; + this.text2 = text2; + p.firePropertyChange("text2", oldText2, text2); + } + + public void setRatio(int ratio) { + int oldRatio = this.ratio; + this.ratio = ratio; + p.firePropertyChange("ratio",oldRatio, ratio); + } +} \ No newline at end of file Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Initializers.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/InnerClasses.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/OverridingDataBindings.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Script.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/SpecialSubclassing.xml 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/CSSTests/CSSTests.jaxx 2009-11-03 23:15:39 UTC (rev 1626) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/cSSTests/CSSTests.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -1,6 +1,6 @@ <Application title='CSSTests'> <style> - Application { lookAndFeel: {lookAndFeel.getSelectedValue()}; } + Application { lookAndFeel: {String.valueOf(lookAndFeel.getSelectedValue())}; } </style> <JMenuBar> Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ClassReferences/JavaTaist.java 2009-11-03 23:15:39 UTC (rev 1626) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/classReferences/JavaTaist.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -1,9 +0,0 @@ -package testcases.ClassReferences; - -import javax.swing.*; - -public class JavaTaist extends JLabel { - public void setCustomProperty(String label) { - setText(label); - } -} \ No newline at end of file Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Identity.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -1,79 +0,0 @@ -package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -public class Identity { - - protected String firstName = ""; - - protected String lastName = ""; - - protected String email = "dummy@codelutin.com"; - - protected int age = 51; - - - PropertyChangeSupport p; - - public Identity() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - - public String getFirstName() { - return firstName; - } - - public String getLastName() { - return lastName; - } - - public String getEmail() { - return email; - } - - public int getAge() { - return age; - } - - public void setFirstName(String firstName) { - String oldFirstName = this.firstName; - this.firstName = firstName; - p.firePropertyChange("firstName", oldFirstName, firstName); - } - - public void setLastName(String lastName) { - String oldLastName = this.lastName; - this.lastName = lastName; - p.firePropertyChange("lastName", oldLastName, lastName); - } - - public void setEmail(String email) { - String oldEmail =this.email; - this.email = email; - p.firePropertyChange("email", oldEmail, email); - } - - public void setAge(int age) { - int oldAge = this.age; - this.age = age; - p.firePropertyChange("age", oldAge, age); - } -} \ No newline at end of file Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Model.java 2009-11-05 20:44:42 UTC (rev 1633) @@ -1,66 +0,0 @@ -package org.nuiton.jaxx.plugin.compilerValidatorTest.validator.ok; - -import java.beans.*; - -public class Model { - - protected String text = "text"; - - protected String text2 = "text2"; - - protected int ratio = 51; - - - PropertyChangeSupport p; - - public Model() { - p = new PropertyChangeSupport(this); - } - - public void addPropertyChangeListener(PropertyChangeListener listener) { - p.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.addPropertyChangeListener(propertyName, listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) { - p.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { - p.removePropertyChangeListener(propertyName, listener); - } - - - public String getText() { - return text; - } - - public String getText2() { - return text2; - } - - public int getRatio() { - return ratio; - } - - public void setText(String text) { - String oldText = this.text; - this.text = text; - p.firePropertyChange("text", oldText, text); - } - - public void setText2(String text2) { - String oldText2 = this.text2; - this.text2 = text2; - p.firePropertyChange("text2", oldText2, text2); - } - - public void setRatio(int ratio) { - int oldRatio = this.ratio; - this.ratio = ratio; - p.firePropertyChange("ratio",oldRatio, ratio); - } -} \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/Validation.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -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> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerValidatorTest/validator/ok/ValidationBeanClass.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -91,7 +91,7 @@ <JLabel text='Age:'/> </cell> <cell> - <JLabel text='{identity.getAge()}'/> + <JLabel text='{identity.getAge()+""}'/> </cell> </row> </Table> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx 2009-11-05 17:02:40 UTC (rev 1632) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/dataBindingTest/First.jaxx 2009-11-05 20:44:42 UTC (rev 1633) @@ -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()}'/>