r1599 - in branches/jaxx-2.X: jaxx-compiler/src/main/java/jaxx/compiler jaxx-compiler/src/main/java/jaxx/compiler/decorators jaxx-compiler/src/main/java/jaxx/compiler/spi jaxx-compiler/src/main/java/jaxx/compiler/tags maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest maven-jaxx-plugin/src/t
Author: tchemit Date: 2009-10-26 03:47:48 +0100 (Mon, 26 Oct 2009) New Revision: 1599 Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/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/decorators/DefaultCompiledObjectDecorator.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test1.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test2.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test3.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/BoxedDecorator.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/text/JButton.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JDialog.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane2.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JButton.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane2.jaxx branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane3.jaxx Log: - remove commented unused code, clean code, add javadoc - improve warning and error management in JAXXEngine and plugin - improve databinding generation (do not test nullity on root object) - remove when possible the root object prefix in method invocation Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang.StringUtils; /** * Represents an object in the <code>.java</code> file being generated during compilation. There is @@ -25,21 +26,34 @@ */ public class CompiledObject { - /** The object's id. */ + /** + * The object's id. + */ private String id; - /** Java code referring to the object. */ + /** + * Java code referring to the object. + */ private String javaCode; - /** The object's class. */ + /** + * The object's class. + */ private ClassDescriptor objectClass; - /** The style class. */ + /** + * The style class. + */ private String styleClass; - /** The container containing this CompiledObject. */ + /** + * The container containing this CompiledObject. + */ private CompiledObject parent; - /** true if this object overrides an object of the same id in a superclass of the object being compiled */ + /** + * true if this object overrides an object of the same id in a superclass + * of the object being compiled + */ private boolean override; /** - * Comma-separated Java code snippets representing the parameters that should be passed to the object's - * constructor. + * Comma-separated Java code snippets representing the parameters that + * should be passed to the object's constructor. */ private String constructorParams; /** @@ -54,17 +68,30 @@ * CompiledObjects from initializationCode -- you must refer to them from additionCode instead. */ private StringBuffer additionCode = new StringBuffer(); - /** List of all registered event handlers. */ + /** + * List of all registered event handlers. + */ private List<EventHandler> eventHandlers = new ArrayList<EventHandler>(); - /** All properties that have been applied to this CompiledObject. */ + /** + * All properties that have been applied to this CompiledObject. + */ private Map<String, String> properties = new HashMap<String, String>(); - /** generic types of the compiled object */ + /** + * generic types of the compiled object + */ private String[] genericTypes; - /** a flag to indicate if javaBean full support must be support for this object by root object */ + /** + * a flag to indicate if javaBean full support must be support for this + * object by root object + */ private boolean javaBean; - /** code to initialize the bean (can be null) */ + /** + * code to initialize the bean (can be null) + */ private String javaBeanInitCode; - /** the type of the override object (can be null if no oveeride) */ + /** + * the type of the override object (can be null if no overide) + */ private ClassDescriptor overrideType; /** * the decorator @@ -121,11 +148,20 @@ this.delegateCode = delegateCode; } - public void addToAdditionCode(StringBuffer buffer) { + public void addToAdditionCode(StringBuffer buffer, boolean isRootObject) { + //TC-20091026 do not prefix if on root object + String prefix; + if (isRootObject) { + prefix = ""; + } else { + prefix = javaCode + delegateCode + "."; + } if (constraints != null) { - buffer.append(javaCode).append(delegateCode).append(".add(").append(childJavaCode).append(", ").append(constraints).append(");"); +// 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(javaCode).append(delegateCode).append(".add(").append(childJavaCode).append(");"); + buffer.append(prefix).append("add(").append(childJavaCode).append(");"); } buffer.append(JAXXCompiler.getLineSeparator()); } @@ -209,8 +245,9 @@ } /** - * True if this object overrides an object in the superclass of the class being compiled. For this to be true, the - * class currently being compiled must be a subclass of another <code>JAXXObject</code> which has an + * True if this object overrides an object in the superclass of the class + * being compiled. For this to be true, the class currently being compiled + * must be a subclass of another <code>JAXXObject</code> which has an * identically-named object. * * @return <code>true</code> if this object is an override @@ -221,7 +258,8 @@ } /** - * Sets whether this class overrides an identically-named object in the parent class. + * Sets whether this class overrides an identically-named object in the + * parent class. * * @param override <code>true</code> if this object is an override * @see #isOverride @@ -249,7 +287,8 @@ } /** - * Returns this object's parent container. Non-visual components (and the root container) return <code>null</code>. + * Returns this object's parent container. Non-visual components (and + * the root container) return <code>null</code>. * * @return the object's parent container */ @@ -261,8 +300,9 @@ * Sets this object's parent container. * * @param parent the parent container + * @throws IllegalArgumentException if parent is not a {@link Container} */ - public void setParent(CompiledObject parent) { + public void setParent(CompiledObject parent) throws IllegalArgumentException { if (!ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(parent.getObjectClass())) { throw new IllegalArgumentException("parent must descend from java.awt.Container"); } @@ -270,23 +310,26 @@ } /** - * Returns the name of the method that should be generated in the compiled <code>.java</code> file - * in order to create this object. This is just a suggestion and may be ignored. + * Returns the name of the method that should be generated in the compiled + * <code>.java</code> file + * in order to create this object. This is just a suggestion and may be + * ignored. * * @return the suggested name of the method which initializes this object */ public String getCreationMethodName() { - return "create" + org.apache.commons.lang.StringUtils.capitalize(getId()); + return "create" + StringUtils.capitalize(getId()); } /** - * Returns the name of the method that should be generated in the compiled <code>.java</code> file - * in order to add children to this object. This is just a suggestion and may be ignored. + * Returns the name of the method that should be generated in the compiled + * <code>.java</code> file in order to add children to this object. This + * is just a suggestion and may be ignored. * * @return the suggested name of the method which completes this object's setup */ public String getAdditionMethodName() { - return "addChildrenTo" + org.apache.commons.lang.StringUtils.capitalize(getId()); + return "addChildrenTo" + StringUtils.capitalize(getId()); } /** @@ -299,7 +342,8 @@ } /** - * Returns this object's id. Generally, a field with this name will be created in the compiled <code>.java</code> + * Returns this object's id. Generally, a field with this name will be + * created in the compiled <code>.java</code> * file in order to represent this object. * * @return the id used to refer to this object @@ -309,8 +353,8 @@ } /** - * Returns Java code used to refer to this object in the compiled Java file. This is usually the same as its - * id. + * Returns Java code used to refer to this object in the compiled Java file. + * This is usually the same as its id. * * @return the Java code for this object */ @@ -329,7 +373,7 @@ } String result = "((" + JAXXCompiler.getCanonicalName(getObjectClass()) + ") " + javaCode + ")"; - String methodName = org.apache.commons.lang.StringUtils.capitalize(property); + String methodName = StringUtils.capitalize(property); try { MethodDescriptor methodDescriptor = overrideType.getMethodDescriptor("get" + methodName); if (methodDescriptor != null) { @@ -345,8 +389,8 @@ } /** - * Returns a list of comma-separated Java code snippets that represent the parameters to pass to this - * object's constructor. + * Returns a list of comma-separated Java code snippets that represent the + * parameters to pass to this object's constructor. * * @return the raw constructor params * @see #setConstructorParams @@ -358,7 +402,8 @@ /** * Sets the parameters to pass to this object's constructor. * - * @param constructorParams comma-separated Java code snippets representing constructor params + * @param constructorParams comma-separated Java code snippets representing + * constructor params * @see #getConstructorParams */ public void setConstructorParams(String constructorParams) { @@ -366,9 +411,10 @@ } /** - * Returns the code that performs basic initialization of this object, after it has already been constructed. - * This basic code should not reference any other <code>CompiledObjects</code> as they may not have - * been created yet. + * Returns the code that performs basic initialization of this object, + * after it has already been constructed. + * This basic code should not reference any other + * <code>CompiledObjects</code> as they may not have been created yet. * * @param compiler compiler to use * @return the code which initializes this object @@ -385,15 +431,18 @@ protected String getInitializationCode(EventHandler handler, JAXXCompiler compiler) { 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, " + - compiler.getJavaCode(handler.getListenerMethod().getName()) + ", " + compiler.getRootObject().getJavaCode() + ", " + + compiler.getJavaCode(handler.getListenerMethod().getName()) + ", this, " + + // compiler.getJavaCode(handler.getListenerMethod().getName()) + ", " + compiler.getRootObject().getJavaCode() + ", " + compiler.getJavaCode(compiler.getEventHandlerMethodName(handler)) + "));" + JAXXCompiler.getLineSeparator(); } /** - * Returns Java code to complete final setup on this object. This code may reference other - * <code>CompiledObjects</code>, as they are guaranteed to have all been created by this point. + * Returns Java code to complete final setup on this object. This code may + * reference other <code>CompiledObjects</code>, as they are guaranteed to + * have all been created by this point. * * @return code which adds children and performs final setup */ @@ -402,7 +451,8 @@ } /** - * Appends code to the initialization code block. A line separator is automatically appended to the end. + * Appends code to the initialization code block. A line separator is + * automatically appended to the end. * * @param code the code to add to the initialization block * @see #getInitializationCode @@ -415,7 +465,8 @@ } /** - * Appends code to the addition code block. A line separator is automatically appended to the end. + * Appends code to the addition code block. A line separator is + * automatically appended to the end. * * @param code the code to add to the addition block * @see #getAdditionCode @@ -428,8 +479,8 @@ } /** - * Stores a property for this object. The only effect of calling this method is that the property will - * be returned by <code>getProperties()</code>. + * Stores a property for this object. The only effect of calling this + * method is that the property will be returned by {@code getProperties()}. * * @param property the name of the property * @param value the property's value @@ -486,7 +537,8 @@ } /** - * Adds an event listener to this object. The generated code will appear in the initialization block. + * Adds an event listener to this object. The generated code will appear + * in the initialization block. * * @param eventId unique (per CompiledObject) identifier for the event handler * @param addMethod the method which adds the event listener @@ -500,13 +552,15 @@ compiler.registerEventHandler(handler); eventHandlers.add(handler); - if (getJavaCode().indexOf(".") != -1) { // object lives in another JAXX file and consequently its initialization code won't be output + if (getJavaCode().indexOf(".") != -1) { + // object lives in another JAXX file and consequently its initialization code won't be output compiler.appendInitializerCode(getInitializationCode(handler, compiler)); } } /** - * Adds a child component to this container. The child is added without layout constraints. + * Adds a child component to this container. The child is added without + * layout constraints. * * @param child the component to add * @param compiler the current <code>JAXXCompiler</code> @@ -518,8 +572,8 @@ } /** - * Adds a child component to this container. This variant allows the Java code for a layout constraints - * object to be specified. + * Adds a child component to this container. This variant allows the Java + * code for a layout constraints object to be specified. * * @param child the component to add * @param constraints Java code for the layout constraints object @@ -538,7 +592,8 @@ if (!child.isOverride()) { TagHandler tagHandler = TagManager.getTagHandler(getObjectClass()); - if (tagHandler instanceof DefaultComponentHandler && !((DefaultComponentHandler) tagHandler).isContainer()) { + if (tagHandler instanceof DefaultComponentHandler && + !((DefaultComponentHandler) tagHandler).isContainer()) { compiler.reportError("component " + this + " may not have children"); } @@ -556,10 +611,6 @@ return getObjectClass().getName() + "[id='" + id + "']"; } -// public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException { -// compiler.registerDataBinding(src, getId() + "." + property, assignment); -// } - public String getGenericTypes() { if (getGenericTypesLength() == 0) { // not using it @@ -619,19 +670,18 @@ this.decorator = decorator; } - public void finalizeCompiler() { - StringBuffer buffer = new StringBuffer(); + public void finalizeCompiler(JAXXCompiler compiler) { List<CompiledObject.ChildRef> refList = getChilds(); - if (refList == null || refList.isEmpty()) { + if (refList != null && !refList.isEmpty()) { + // compute additionCode for all childs + StringBuffer buffer = new StringBuffer(); + for (ChildRef childRef : refList) { + childRef.addToAdditionCode(buffer, compiler.getRootObject() == this); + } + additionCode = buffer.append(additionCode); return; } - - for (ChildRef childRef : refList) { - childRef.addToAdditionCode(buffer); - } - - additionCode = buffer.append(additionCode); } public int getGenericTypesLength() { Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,27 +1,31 @@ -/* - * Copyright 2006 Ethan Nicholas. All rights reserved. - * Use is subject to license terms. - */ package jaxx.compiler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** - * Represents a data binding in a JAXX file. <code>DataBinding</code> uses {@link DataSource} to - * track changes to a source expression and update the destination. + * Represents a data binding in a JAXX file. <code>DataBinding</code> uses + * {@link DataSource} to track changes to a source expression and update the destination. */ public class DataBinding { + /** + * Logger + */ + protected static final Log log = LogFactory.getLog(DataBinding.class); + /** + * Id of the data binding + */ private String id; - /** The DatSource which tracks source expression changes. */ - private DataSource dataSource; - /** The data binding destination in the form <code><id>.<propertyName></code>. */ - private String dest; /** + * source of the data binding + */ + private String source; + /** * A Java snippet which will cause the destination property to be updated with the current value of * the binding. */ private String assignment; - /** The current <code>JAXXCompiler</code>. */ - private JAXXCompiler compiler; /** * Creates a new data binding. @@ -29,14 +33,14 @@ * @param source the Java source code for the data binding expression * @param dest 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 - * @param compiler the current <code>JAXXCompiler</code> */ - public DataBinding(String source, String dest, String assignment, JAXXCompiler compiler) { + public DataBinding(String source, String dest, String assignment) { this.id = dest; - this.dataSource = new DataSource(id, source, compiler); - this.dest = dest; + this.source = source; this.assignment = assignment; - this.compiler = compiler; + if (log.isDebugEnabled()) { + log.debug("id=" + id + " assignement=" + assignment + " source=" + source); + } } public String getId() { @@ -44,21 +48,29 @@ } /** - * Compiles the data binding expression. This method calls methods in <code>JAXXCompiler</code> - * to add the Java code that performs the data binding setup. + * Compiles the data binding expression. This method calls methods in + * <code>JAXXCompiler</code> to add the Java code that performs the data + * binding setup. * + * @param compiler compiler which includes the data binding * @param quickNoDependencies true to optimize bindings with no dependencies by simply running them at startup time * @return <code>true</code> if the expression has dependencies, <code>false</code> otherwise * @throws CompilerException if a compilation error occurs */ - public boolean compile(boolean quickNoDependencies) throws CompilerException { - // DataSource.compile handles all of the listener additions - boolean result = dataSource.compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + compiler.getJavaCode(id) + ")"); + public boolean compile(JAXXCompiler compiler, boolean quickNoDependencies) throws CompilerException { + DataSource dataSource = new DataSource(id, source, compiler); + + // 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) + ")"); + + String eol = JAXXCompiler.getLineSeparator(); if (!result && quickNoDependencies) { - if (!dest.endsWith(".layout")) // layout is specially handled early in the chain - { - compiler.appendInitDataBindings(assignment + JAXXCompiler.getLineSeparator()); + // layout is specially handled early in the chain + if (!id.endsWith(".layout")) { + compiler.appendInitDataBindings(assignment + eol); } return false; // no dependencies, just a static expression } @@ -67,17 +79,20 @@ } else { compiler.appendProcessDataBinding(" "); } - compiler.appendProcessDataBinding("if (" + compiler.getJavaCode(id) + ".equals($dest)) {" + JAXXCompiler.getLineSeparator()); + compiler.appendProcessDataBinding("if (" + compiler.getJavaCode(id) + ".equals($dest)) {" + eol); String objectCode = dataSource.getObjectCode(); - if (objectCode != null) { - compiler.appendProcessDataBinding(" if (" + objectCode + " != null) {" + JAXXCompiler.getLineSeparator()); + //TC-20091026 no need to test objectCode not null if on root object +// boolean needTest = objectCode != null; + boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); + if (needTest) { + compiler.appendProcessDataBinding(" if (" + objectCode + " != null) {" + eol); compiler.appendProcessDataBinding(" "); } - compiler.appendProcessDataBinding(" " + assignment.trim()); - if (objectCode != null) { - compiler.appendProcessDataBinding(JAXXCompiler.getLineSeparator() + " }"); + compiler.appendProcessDataBinding(" " + assignment.trim()); + if (needTest) { + compiler.appendProcessDataBinding(eol + " }"); } - compiler.appendProcessDataBinding(JAXXCompiler.getLineSeparator() + " }"); + compiler.appendProcessDataBinding(eol + " }"); return true; } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -34,19 +34,42 @@ */ public class DataSource { + /** + * type attached to "null" constants in parsed expressions + */ private class NULL { - } // type attached to "null" constants in parsed expressions + } + /** + * id of data source + */ private String id; - /** The Java source code for the expression. */ + /** + * The Java source code for the expression. + */ private String source; - /** The current <code>JAXXCompiler</code>. */ + /** + * The current <code>JAXXCompiler</code>. + */ private JAXXCompiler compiler; - /** List of symbols which this data source expression depends on. */ + /** + * List of symbols which this data source expression depends on. + */ private List<String> dependencySymbols = new ArrayList<String>(); + /** + * + */ private StringBuffer addListenerCode = new StringBuffer(); + /** + * + */ private StringBuffer removeListenerCode = new StringBuffer(); + /** + * + */ private boolean compiled; - /** the delegate of property to be required */ + /** + * the delegate of property to be required + */ private String objectCode; /** @@ -85,8 +108,9 @@ * @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 IllegalStateException if data source was already compiled */ - public boolean compile(String propertyChangeListenerCode) throws CompilerException { + public boolean compile(String propertyChangeListenerCode) throws CompilerException, IllegalStateException { if (compiled) { throw new IllegalStateException(this + " has already been compiled"); } @@ -100,7 +124,7 @@ if (dependencySymbols.size() > 0) { //TC 20081108 prefer add a real JavaField instead of raw code //compiler.appendBodyCode("private PropertyChangeListener " + id + " = " + propertyChangeListenerCode + ";\n"); - compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getName(), autoId,false, propertyChangeListenerCode)); + compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getSimpleName(), autoId, false, propertyChangeListenerCode)); } compileListeners(); @@ -287,7 +311,8 @@ for (int i = 1; i < expression.jjtGetNumChildren(); i++) { SimpleNode suffix = expression.getChild(i); 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 + if (suffix.getChild(0).jjtGetNumChildren() == 0) { + // at the moment only no-argument methods are trackable contextClass = scanCompoundSymbol(lastNode, contextClass, true, listenerId); if (contextClass == null) { return null; @@ -339,9 +364,10 @@ } private void trackMemberIfPossible(String objectCode, ClassDescriptor objectClass, String memberName, boolean method, String listenerId) { - if (objectClass.isInterface()) // might be technically possible to track in some cases, but for now - { - return; // we can't create a DefaultObjectHandler for interfaces + if (objectClass.isInterface()) { + // might be technically possible to track in some cases, but for now + // we can't create a DefaultObjectHandler for interfaces + return; } DefaultObjectHandler handler = TagManager.getTagHandler(objectClass); @@ -389,25 +415,30 @@ private void addListener(String dependencySymbol, String objectCode, String addCode, String removeCode) { this.objectCode = objectCode; + //TC-20091026 no need to test objectCode not null if on root object + boolean needTest = objectCode != null && !compiler.getRootObject().getId().equals(objectCode); +// boolean needTest = objectCode != null; if (!dependencySymbols.contains(dependencySymbol)) { dependencySymbols.add(dependencySymbol); String eol = JAXXCompiler.getLineSeparator(); - if (objectCode != null) { - addListenerCode.append("if (").append(objectCode).append(" != null) {").append(eol); + addListenerCode.append(eol); + if (needTest) { + addListenerCode.append(" if (").append(objectCode).append(" != null) {").append(eol); addListenerCode.append(" "); } - addListenerCode.append(" ").append(addCode); - if (objectCode != null) { - addListenerCode.append(" ").append("}"); + addListenerCode.append(" ").append(addCode.trim()); + if (needTest) { + addListenerCode.append(eol).append(" }"); } - if (objectCode != null) { - removeListenerCode.append("if (").append(objectCode).append(" != null) {").append(eol); + removeListenerCode.append(eol); + if (needTest) { + removeListenerCode.append(" if (").append(objectCode).append(" != null) {").append(eol); removeListenerCode.append(" "); } - removeListenerCode.append(" ").append(removeCode); - if (objectCode != null) { - removeListenerCode.append(" }"); + removeListenerCode.append(" ").append(removeCode.trim()); + if (needTest) { + removeListenerCode.append(eol).append(" }"); } } } @@ -419,28 +450,20 @@ if (compiler.hasApplyDataBinding()) { compiler.appendApplyDataBinding(" else "); } - compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {" + eol); +// compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {" + eol); + compiler.appendApplyDataBinding("if (" + javaCodeId + ".equals($binding)) {"); compiler.appendApplyDataBinding(" " + addListenerCode + eol); compiler.appendApplyDataBinding("}"); - //if (compiler.applyDataBinding.length() > 0) - // compiler.applyDataBinding.append("else "); - //compiler.applyDataBinding.append("if ($binding.equals(").append(TypeManager.getJavaCode(id)).append(")) {").append(JAXXCompiler.getLineSeparator()); - //compiler.applyDataBinding.append(" ").append(addListenerCode).append(JAXXCompiler.getLineSeparator()); - //compiler.applyDataBinding.append("}").append(JAXXCompiler.getLineSeparator()); } if (removeListenerCode.length() > 0) { if (compiler.hasRemoveDataBinding()) { compiler.appendRemoveDataBinding(" else "); } - compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {" + eol); +// compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {" + eol); + compiler.appendRemoveDataBinding("if (" + javaCodeId + ".equals($binding)) {"); compiler.appendRemoveDataBinding(" " + removeListenerCode + eol); compiler.appendRemoveDataBinding("}"); - //if (compiler.removeDataBinding.length() > 0) - // compiler.removeDataBinding.append("else "); - //compiler.removeDataBinding.append("if ($binding.equals(").append(TypeManager.getJavaCode(id)).append(")) {").append(JAXXCompiler.getLineSeparator()); - //compiler.removeDataBinding.append(" ").append(removeListenerCode).append(JAXXCompiler.getLineSeparator()); - //compiler.removeDataBinding.append("}").append(JAXXCompiler.getLineSeparator()); } } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -67,6 +67,7 @@ import java.util.regex.Pattern; import jaxx.compiler.java.JavaFileGenerator; import jaxx.compiler.types.TypeManager; +import org.apache.commons.lang.StringUtils; /** * Compiles JAXX files into Java classes. @@ -99,6 +100,10 @@ */ public static final int INLINE_THRESHOLD = 300; /** + * Line separator cached value + */ + protected static String lineSeparator = System.getProperty("line.separator", "\n"); + /** * The unique object handler used in first pass */ protected final DefaultObjectHandler firstPassClassTagHandler; @@ -107,7 +112,7 @@ /*-- compiler fields -----------------------------------------------------*/ /*------------------------------------------------------------------------*/ /** - * flag to detec if an error occurs while compiling jaxx file + * flag to detect if an error occurs while compiling jaxx file */ protected boolean failed; /** @@ -131,7 +136,7 @@ */ protected int autogenID = 0; /** - * + * data bindings detected */ protected List<DataBinding> dataBindings = new ArrayList<DataBinding>(); /** @@ -385,10 +390,10 @@ if (symbolTable.getSuperclassName() == null) { symbolTable.setSuperclassName(fullClassName); } - String id = tag.getAttribute("id"); + String id = tag.getAttribute(DefaultObjectHandler.ID_ATTRIBUTE); if (id.length() > 0) { symbolTable.getClassTagIds().put(id, fullClassName); - if (tag.getAttributeNode("javaBean") != null) { + if (tag.getAttributeNode(DefaultObjectHandler.JAVA_BEAN_ATTRIBUTE) != null) { // add java bean support for this property String capitalizeName = org.apache.commons.lang.StringUtils.capitalize(id); // add method @@ -582,6 +587,10 @@ /*------------------------------------------------------------------------*/ /*-- DataBinding methods -------------------------------------------------*/ /*------------------------------------------------------------------------*/ + public List<DataBinding> getDataBindings() { + return dataBindings; + } + /** * Examine an attribute value for data binding expressions. Returns a 'cooked' expression which * can be used to determine the resulting value. It is expected that this expression will be used @@ -647,7 +656,8 @@ // if (log.isDebugEnabled()) { // log.info(getRootObject().getId() + " src=" + src + ", dst=" + dest.trim()); // } - dataBindings.add(new DataBinding(src, dest, assignment, this)); + dataBindings.add(new DataBinding(src, dest, assignment)); +// dataBindings.add(new DataBinding(src, dest, assignment, this)); } catch (CompilerException e) { reportError("While parsing data binding for '" + dest.substring(dest.lastIndexOf(".") + 1) + "': " + e.getMessage()); } @@ -679,8 +689,7 @@ // to make possible inheritance String id = handler.getEventId().substring(0, handler.getEventId().indexOf(".")); - result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id; - //result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + handler.getObjectCode(); + result = "do" + StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id; } eventHandlerMethodNames.put(handler, result); } @@ -776,16 +785,12 @@ } StringBuilder buffer = new StringBuilder(); buffer.append(srcFile); -// System.err.print(srcFile); if (lineNumber != null) { buffer.append(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1)); -// System.err.print(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1)); } buffer.append(getLineSeparator()).append(warning.trim()); -// System.err.println(": Warning: " + warning); if (engine != null) { engine.addWarning(buffer.toString()); -// engine.warningCount++; } else { System.err.println(buffer.toString()); } @@ -848,16 +853,12 @@ } StringBuilder buffer = new StringBuilder(); buffer.append(errorFile != null ? errorFile.getPath() : "<unknown source>"); -// System.err.print(errorFile != null ? errorFile.getPath() : "<unknown source>"); if (lineNumber > 0) { buffer.append(":" + lineNumber); -// System.err.print(":" + lineNumber); } buffer.append(getLineSeparator()).append(": " + error); -// System.err.println(": " + error); if (engine != null) { engine.addError(buffer.toString()); -// engine.errorCount++; } else { System.err.println(buffer.toString()); } @@ -871,10 +872,6 @@ return objects; } - public List<DataBinding> getDataBindings() { - return dataBindings; - } - public Map<String, Map<ClassDescriptor, List<EventHandler>>> getEventHandlers() { return eventHandlers; } @@ -1064,49 +1061,45 @@ } public void appendInitializerCode(String code) { - getInitializer().append(code); + initializer.append(code); } public void appendBodyCode(String code) { - getBodyCode().append(code); + bodyCode.append(code); } public void appendInitDataBindings(String code) { - getInitDataBindings().append(code); + initDataBindings.append(code); } public void appendProcessDataBinding(String code) { - getProcessDataBinding().append(code); + processDataBinding.append(code); } public void appendApplyDataBinding(String code) { - getApplyDataBinding().append(code); + applyDataBinding.append(code); } public void appendRemoveDataBinding(String code) { - getRemoveDataBinding().append(code); + removeDataBinding.append(code); } public void appendLateInitializer(String code) { - getLateInitializer().append(code); + lateInitializer.append(code); } public boolean hasProcessDataBinding() { - return getProcessDataBinding().length() > 0; + return processDataBinding.length() > 0; } public boolean hasApplyDataBinding() { - return getApplyDataBinding().length() > 0; + return applyDataBinding.length() > 0; } public boolean hasRemoveDataBinding() { - return getRemoveDataBinding().length() > 0; + return removeDataBinding.length() > 0; } - public void addMethodToJavaFile(JavaMethod method) { - getJavaFile().addMethod(method); - } - public boolean hasMethod(String methodName) { for (JavaMethod method : getJavaFile().getMethods()) { if (methodName.equals(method.getName())) { @@ -1370,7 +1363,7 @@ } for (CompiledObject object : getObjects().values()) { - object.finalizeCompiler(); + object.finalizeCompiler(this); } for (JAXXCompilerFinalizer generator : generatorIterator) { @@ -1404,8 +1397,6 @@ } } } - /** line separator cached value */ - protected static String lineSeparator = System.getProperty("line.separator", "\n"); /** * Returns the system line separator string. 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-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -134,46 +134,38 @@ initializer.initialize(); } } - /** + /** * configuration of the launchor and underlines compilers */ protected CompilerConfiguration configuration; - /** + /** * original list of files to run */ protected final File[] files; - /** + /** * original list of classes to run */ protected final String[] classNames; - /** + /** * Files to be treated while compilation. */ private List<File> jaxxFiles = new ArrayList<File>(); - /** + /** * Class names corresponding to the files in the jaxxFiles list. */ private List<String> jaxxFileClassNames = new ArrayList<String>(); - /** + /** * Maps the names of classes being compiled to the compiler instance handling the compilation. */ protected Map<String, JAXXCompiler> compilers = new HashMap<String, JAXXCompiler>(); - /** + /** * Maps the names of classes being compiled to their symbol tables (created after the first compiler pass). */ protected Map<File, SymbolTable> symbolTables = new HashMap<File, SymbolTable>(); /** - * + * current pass of the engine */ private LifeCycle currentPass; -// /** -// * -// */ -// protected int errorCount; -// /** -// * -// */ -// protected int warningCount; /** * Warnings detected while running. */ @@ -183,10 +175,6 @@ */ protected List<String> errors = new ArrayList<String>(); /** - * number of registred compiler - */ - protected int compilerCount; - /** * profile attached to the engine (can be null) */ protected JAXXProfile profiler; @@ -215,7 +203,6 @@ @Override public boolean run(JAXXEngine engine) { boolean success = true; - engine.compilerCount = 0; engine.warnings.clear(); engine.errors.clear(); // init decorators @@ -226,7 +213,6 @@ engine.decorators.put(decorator.getName(), decorator); } } - // init finalizers engine.finalizers = new ArrayList<JAXXCompilerFinalizer>(); for (JAXXCompilerFinalizer finalizer : ServiceLoader.load(JAXXCompilerFinalizer.class)) { @@ -274,8 +260,6 @@ log.warn("could not create directory " + destDir); continue; } - } else { - //destDir = file.getParentFile(); } JAXXCompiler compiler = engine.newCompiler(file.getParentFile(), file, className); addStartProfileTime(engine, compiler); @@ -393,7 +377,7 @@ } }, /** - * display profile + * display profile results */ profile_pass { @@ -408,6 +392,13 @@ } }; + /** + * Run the pass. + * + * @param engine the engine to use + * @return {@code true} if pass was ok, {@ocde false} otherwise + * @throws Exception if any pb + */ public abstract boolean run(JAXXEngine engine) throws Exception; void addStartProfileTime(JAXXEngine engine, JAXXCompiler compiler) { @@ -431,9 +422,10 @@ } } - /** Resets all state in preparation for a new compilation session. */ + /** + * Resets all state in preparation for a new compilation session. + */ protected void reset() { -// errorCount = warningCount = 0; jaxxFiles.clear(); jaxxFileClassNames.clear(); symbolTables.clear(); @@ -457,7 +449,8 @@ } /** - * Creates a dummy Compiler for use in unit testing. + * Creates a dummy Compiler for use in unit testing or dettached use of an + * engine. * * @param classLoader class loader to use * @return the compiler @@ -469,6 +462,8 @@ } /** + * Obtain the jaxx compiler of the given class name. + * * @param className the name of the class to use * @return the compiler instance which is processing the specified JAXX class. Each class is compiled by a * different compiler instance. @@ -478,6 +473,8 @@ } /** + * Obtain the symbo table for the given class name. + * * @param className the name of the class to use * @return the symbol table for the specified JAXX class. Must be called during the second compiler pass. * Returns <code>null</code> if no such symbol table could be found. @@ -490,14 +487,27 @@ return compiler.getSymbolTable(); } - public CompiledObjectDecorator getDecorator(String name) { + /** + * Obtain the decorator of the given name. + * + * @param name the name of the decorator + * @return the decorator found. + * @throws IllegalArgumentException if decorator not found for the given name. + */ + public CompiledObjectDecorator getDecorator(String name) throws IllegalArgumentException { CompiledObjectDecorator decorator = decorators.get(name); if (decorator == null) { - throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + decorators.keySet()); + throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + decorators.keySet() + ")"); } return decorator; } + /** + * Obtain the decorator of the given type. + * + * @param type the type of the decorator (syas his fqn) + * @return the decorator found + */ public CompiledObjectDecorator getDecorator(Class<?> type) { for (CompiledObjectDecorator decorator : decorators.values()) { if (type == decorator.getClass()) { @@ -507,18 +517,34 @@ return null; } + /** + * Add a warning to the engine. + * + * @param warning the warning to add + */ public void addWarning(String warning) { warnings.add(warning); } + /** + * Add an error to the engine. + * + * @param error the error to add + */ public void addError(String error) { errors.add(error); } + /** + * @return the errors of the engine + */ public List<String> getErrors() { return errors; } + /** + * @return the warnings of the engine + */ public List<String> getWarnings() { return warnings; } @@ -526,34 +552,35 @@ /** * Compiled a set of files. * - * @return <code>true</code> if compilation succeeds, <code>false</code> otherwise + * @return {@code -1} if errors appears, the number of generated files + * otherwise. */ - public synchronized boolean run() { + public synchronized int run() { try { boolean success = true; for (LifeCycle state : LifeCycle.values()) { if (!success) { - return false; + // stop as soon as a engine phase failed + break; } currentPass = state; if (configuration.isVerbose()) { - log.info("start " + state + " on " + jaxxFiles.size() + " file(s)"); + log.info("'" + state + "' on " + jaxxFiles.size() + " file(s)"); } success = state.run(this); } - return success; + return success ? compilers.size() : -1; //FIXME : deal better the exception treatment... } catch (CompilerException e) { System.err.println(e.getMessage()); e.printStackTrace(); - return false; + return -1; } catch (Throwable e) { e.printStackTrace(); - return false; + return -1; } finally { - compilerCount = compilers.size(); //TC - 20081018 only reset when no error was detected if (configuration.isResetAfterCompile() && errors.isEmpty()) { reset(); @@ -561,11 +588,15 @@ } } - public int getCompilerCount() { - return compilerCount; - } - - protected JAXXCompiler getCompiler(String className, String message) { + /** + * Obtain the compiler for the given class name. + * + * @param className the class name of the searched compiler + * @param message the message to throw if compiler not found + * @return the compiler found + * @throws CompilerException if compiler not found + */ + protected JAXXCompiler getCompiler(String className, String message) throws CompilerException { JAXXCompiler compiler = compilers.get(className); if (compiler == null) { throw new CompilerException(message); @@ -573,6 +604,18 @@ return compiler; } + /** + * Create a new compiler. + * + * @param parentFile + * @param file + * @param className + * @return the new compiler + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws InstantiationException + * @throws NoSuchMethodException + */ 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[]{ @@ -594,6 +637,14 @@ })); } + /** + * Add a profile time for the given compiler and key. + * + * Note: if {@link #profiler} is {@code null}, do nothing + * + * @param compiler the compiler to profile + * @param key the key of profiling + */ public void addProfileTime(JAXXCompiler compiler, String key) { if (profiler != null) { profiler.addTime(compiler, key); Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -82,7 +82,7 @@ //TC-20091025 generate client properties at creation time (not at setup time) // in some case can save to create a setup method (when there is only client properties // to store) - addClientProperties(object); + addClientProperties(object, result, eol); return result.toString(); } @@ -124,7 +124,7 @@ //TC-20091025 generate client properties at creation time (not at setup time) // in some case can save to create a setup method (when there is only client properties // to store) - addClientProperties(object); + addClientProperties(object, code, eol); code.append(eol); } } else { @@ -144,12 +144,12 @@ return lastWasMethodCall; } - protected void addClientProperties(CompiledObject object) { + protected void addClientProperties(CompiledObject object, StringBuffer code, String eol) { //TC-20090327 generate client properties if (object.hasClientProperties()) { // generate putClientProperty invocations for (Entry<String, String> entry : object.getClientProperties().entrySet()) { - object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");"); + code.append(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");").append(eol); } } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -129,7 +129,6 @@ registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.TAG, new FieldValidatorHandler()); registerTag(JAXXCompiler.JAXX_NAMESPACE, ExcludeFieldValidatorHandler.TAG, new FieldValidatorHandler()); - // // Register beans // 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-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -29,8 +29,25 @@ public class DefaultComponentHandler extends DefaultObjectHandler { - /** log */ + public static final String ACTION_ICON_ATTRIBUTE = "actionIcon"; + public static final String CONTAINER_DELEGATE_ATTRIBUTE = "containerDelegate"; + public static final String FONT_FACE_ATTRIBUTE = "font-face"; + public static final String FONT_SIZE_ATTRIBUTE = "font-size"; + public static final String FONT_STYLE_ATTRIBUTE = "font-style"; + public static final String FONT_WEIGHT_ATTRIBUTE = "font-weight"; + public static final String HEIGHT_ATTRIBUTE = "height"; + public static final String ICON_ATTRIBUTE = "icon"; + public static final String NAME_ATTRIBUTE = "name"; + public static final String WIDTH_ATTRIBUTE = "width"; + public static final String X_ATTRIBUTE = "x"; + public static final String Y_ATTRIBUTE = "y"; + /** + * Logger + */ protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class); + /** + * container delegate (if any) + */ private String containerDelegate; public DefaultComponentHandler(ClassDescriptor beanClass) { @@ -43,7 +60,7 @@ if (jaxxBeanInfo == null) { super.init(); - containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate"); + containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue(CONTAINER_DELEGATE_ATTRIBUTE); if (containerDelegate == null && ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass().getSuperclass())) { containerDelegate = ((DefaultComponentHandler) TagManager.getTagHandler(getBeanClass().getSuperclass())).getContainerDelegate(); } @@ -71,7 +88,7 @@ @Override protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { super.setDefaults(object, tag, compiler); - setAttribute(object, "name", object.getId(), false, compiler); + setAttribute(object, NAME_ATTRIBUTE, object.getId(), false, compiler); openComponent(object, tag, compiler); } @@ -87,7 +104,7 @@ } protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException { - String constraints = tag.getAttribute("constraints"); + String constraints = tag.getAttribute(CONSTRAINTS_ATTRIBUTE); if (constraints != null && constraints.length() > 0) { compiler.openComponent(object, constraints); } else { @@ -106,11 +123,16 @@ @Override public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException { - if (propertyName.equals("x") || propertyName.equals("y") || propertyName.equals("width") || propertyName.equals("height") || - "font-size".equals(propertyName)) { + if (propertyName.equals(X_ATTRIBUTE) || + propertyName.equals(Y_ATTRIBUTE) || + propertyName.equals(WIDTH_ATTRIBUTE) || + propertyName.equals(HEIGHT_ATTRIBUTE) || + FONT_SIZE_ATTRIBUTE.equals(propertyName)) { return ClassDescriptorLoader.getClassDescriptor(Integer.class); } - if (propertyName.equals("font-face") || propertyName.equals("font-style") || propertyName.equals("font-weight")) { + if (propertyName.equals(FONT_FACE_ATTRIBUTE) || + propertyName.equals(FONT_STYLE_ATTRIBUTE) || + propertyName.equals(FONT_WEIGHT_ATTRIBUTE)) { return ClassDescriptorLoader.getClassDescriptor(String.class); } return super.getPropertyType(object, propertyName, compiler); @@ -118,16 +140,16 @@ @Override public String getGetPropertyCode(String id, String name, JAXXCompiler compiler) throws CompilerException { - if (name.equals("font-face")) { + if (name.equals(FONT_FACE_ATTRIBUTE)) { return id + ".getFont().getFontName()"; } - if (name.equals("font-size")) { + if (name.equals(FONT_SIZE_ATTRIBUTE)) { return id + ".getFont().getSize()"; } - if (name.equals("font-weight")) { + if (name.equals(FONT_WEIGHT_ATTRIBUTE)) { return "(" + id + ".getFont().getStyle() & Font.BOLD) != 0 ? \"bold\" : \"normal\""; } - if (name.equals("font-style")) { + if (name.equals(FONT_STYLE_ATTRIBUTE)) { return "(" + id + ".getFont().getStyle() & Font.ITALIC) != 0 ? \"italic\" : \"normal\""; } return super.getGetPropertyCode(id, name, compiler); @@ -135,25 +157,26 @@ @Override public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException { - if (name.equals("x")) { + if (name.equals(X_ATTRIBUTE)) { return id + ".setLocation(" + valueCode + ", " + id + ".getY());"; } - if (name.equals("y")) { + if (name.equals(Y_ATTRIBUTE)) { return id + ".setLocation(" + id + ".getX(), " + valueCode + ");"; } - if (name.equals("width")) { // need to optimize case when both width and height are being assigned + if (name.equals(WIDTH_ATTRIBUTE)) { + // need to optimize case when both width and height are being assigned return Util.class.getName() + ".setComponentWidth(" + id + "," + valueCode + ");"; } - if (name.equals("height")) { + if (name.equals(HEIGHT_ATTRIBUTE)) { return Util.class.getName() + ".setComponentHeight(" + id + "," + valueCode + ");"; } - if (name.equals("font-face")) { + if (name.equals(FONT_FACE_ATTRIBUTE)) { return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(new Font(" + valueCode + ", " + id + ".getFont().getStyle(), " + id + ".getFont().getSize()));\n}"; } - if (name.equals("font-size")) { + if (name.equals(FONT_SIZE_ATTRIBUTE)) { return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont((float) " + valueCode + "));\n}"; } - if (name.equals("font-weight")) { + if (name.equals(FONT_WEIGHT_ATTRIBUTE)) { if (valueCode.equals("\"bold\"")) { return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));\n}"; } @@ -168,7 +191,7 @@ compiler.reportError("font-weight must be either \"normal\" or \"bold\", found " + valueCode); return ""; } - if (name.equals("font-style")) { + if (name.equals(FONT_STYLE_ATTRIBUTE)) { if (valueCode.equals("\"italic\"")) { return "if (" + id + ".getFont() != null) {\n " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));\n}"; } @@ -183,8 +206,9 @@ compiler.reportError("font-style must be either \"normal\" or \"italic\", found " + valueCode); return ""; } - if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame) - String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate"); + if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals(LAYOUT_ATTRIBUTE)) { + // handle containerDelegate (e.g. contentPane on JFrame) + String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue(CONTAINER_DELEGATE_ATTRIBUTE); if (cDelegate != null) { return id + '.' + cDelegate + "().setLayout(" + valueCode + ");"; } @@ -210,27 +234,27 @@ //object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");"); return; } - if ("icon".equals(propertyName)) { + if (ICON_ATTRIBUTE.equals(propertyName)) { if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) { // this is a customized icon, add the icon creation code if (compiler.getConfiguration().isUseUIManagerForIcon()) { - stringValue = "{" + jaxx.runtime.Util.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}"; + stringValue = "{" + Util.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}"; } else { - stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; + stringValue = "{" + Util.class.getName() + ".createImageIcon(\"" + stringValue + "\")}"; } } - } else if ("actionIcon".equals(propertyName)) { + } else if (ACTION_ICON_ATTRIBUTE.equals(propertyName)) { // customized actionIcon property if (stringValue.startsWith("{") && stringValue.endsWith("}")) { // there is a script to define the action icon, this is forbidden compiler.reportError("the actionIcon does not support script, remove braces..., fix the file " + compiler.getOutputClassName()); return; } - propertyName = "icon"; + propertyName = ICON_ATTRIBUTE; if (compiler.getConfiguration().isUseUIManagerForIcon()) { - stringValue = "{" + jaxx.runtime.Util.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}"; + stringValue = "{" + Util.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}"; } else { - stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; + stringValue = "{" + Util.class.getName() + ".createActionIcon(\"" + stringValue + "\")}"; } } super.setAttribute(object, propertyName, stringValue, inline, compiler); @@ -273,7 +297,7 @@ */ @Override protected int constantValue(String key, String value) { - if ((key.equals("mnemonic") || key.equals("displayedMnemonic"))) { + if ((key.equals(MNEMONIC_ATTRIBUTE) || key.equals(DISPLAYED_MNEMONIC_ATTRIBUTE))) { if (value.length() == 1) { return value.charAt(0); } 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-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -7,13 +7,13 @@ import jaxx.compiler.CompilerException; import jaxx.compiler.UnsupportedAttributeException; import jaxx.compiler.CompiledObject; +import jaxx.compiler.CompiledObjectDecorator; import jaxx.compiler.JAXXCompiler; import jaxx.compiler.beans.JAXXBeanInfo; import jaxx.compiler.beans.JAXXEventSetDescriptor; import jaxx.compiler.beans.JAXXIntrospector; import jaxx.compiler.beans.JAXXPropertyDescriptor; import jaxx.compiler.css.StylesheetHelper; -import jaxx.compiler.CompiledObjectDecorator; import jaxx.compiler.java.JavaArgument; import jaxx.compiler.java.JavaMethod; import jaxx.compiler.reflect.ClassDescriptor; @@ -24,6 +24,7 @@ import jaxx.runtime.ComponentDescriptor; import jaxx.runtime.JAXXObject; import jaxx.runtime.JAXXObjectDescriptor; +import jaxx.runtime.Util; import jaxx.runtime.css.Stylesheet; import org.w3c.dom.Attr; import org.w3c.dom.Element; @@ -44,7 +45,7 @@ import java.util.List; import java.util.Map; import java.util.WeakHashMap; -import jaxx.runtime.Util; +import org.apache.commons.lang.StringUtils; /** * Default handler for class tags. Class tags are tags which represent instances of Java classes, @@ -59,17 +60,43 @@ */ public class DefaultObjectHandler implements TagHandler { - /** The class that this handler provides support for. */ + public static final String ABSTRACT_ATTRIBUTE = "abstract"; + public static final String CONSTRAINTS_ATTRIBUTE = "constraints"; + public static final String CONSTRUCTOR_PARAMS_ATTRIBUTE = "constructorParams"; + public static final String DECORATOR_ATTRIBUTE = "decorator"; + public static final String DISPLAYED_MNEMONIC_ATTRIBUTE = "displayedMnemonic"; + public static final String DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE = "displayedMnemonicIndex"; + public static final String GENERICTYPE_ATTRIBUTE = "genericType"; + public static final String ID_ATTRIBUTE = "id"; + public static final String IMPLEMENTS_ATTRIBUTE = "implements"; + public static final String JAVA_BEAN_ATTRIBUTE = "javaBean"; + public static final String LAYOUT_ATTRIBUTE = "layout"; + public static final String MNEMONIC_ATTRIBUTE = "mnemonic"; + public static final String STYLE_CLASS_ATTRIBUTE = "styleClass"; + public static final String SUPER_GENERIC_TYPE_ATTRIBUTE = "superGenericType"; + /** + * The class that this handler provides support for. + */ private ClassDescriptor beanClass; - /** The JAXXBeanInfo for the beanClass. */ + /** + * The JAXXBeanInfo for the beanClass. + */ protected JAXXBeanInfo jaxxBeanInfo; - /** Maps property names to their respective JAXXPropertyDescriptors. */ + /** + * Maps property names to their respective JAXXPropertyDescriptors. + */ private Map<String, JAXXPropertyDescriptor> properties; - /** Maps event names to their respective JAXXEventSetDescriptors. */ + /** + * Maps event names to their respective JAXXEventSetDescriptors. + */ private Map<String, JAXXEventSetDescriptor> events; - /** Maps property names to their respective ProxyEventInfos. */ + /** + * Maps property names to their respective ProxyEventInfos. + */ private Map<String, ProxyEventInfo> eventInfos; - /** Maps XML tags to the CompiledObjects created from them. */ + /** + * Maps XML tags to the CompiledObjects created from them. + */ protected static Map<Element, CompiledObject> objectMap = new WeakHashMap<Element, CompiledObject>(); /** @@ -80,9 +107,13 @@ */ private class ProxyEventInfo { - /** The name of the method or field being proxied, e.g. "getText". */ + /** + * The name of the method or field being proxied, e.g. "getText". + */ String memberName; - /** The "actual" event listener for the property in question, e.g. DocumentListener. */ + /** + * The "actual" event listener for the property in question, e.g. DocumentListener. + */ ClassDescriptor listenerClass; /** * In cases where a different object (such as a model) is more directly responsible for @@ -93,9 +124,13 @@ * attached to the new value, and the data binding to be processed. */ String modelName; - /** The name of the method used to add the "native" event listener, e.g. "addDocumentListener". */ + /** + * The name of the method used to add the "native" event listener, e.g. "addDocumentListener". + */ String addMethod; - /** The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". */ + /** + * The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". + */ String removeMethod; } @@ -112,8 +147,7 @@ /** * Performs introspection on the beanClass and stores the results. * - * @throws java.beans.IntrospectionException - * TODO + * @throws java.beans.IntrospectionException if any pb */ protected void init() throws IntrospectionException { if (jaxxBeanInfo == null) { @@ -164,8 +198,7 @@ * * @param beanClass the bean class for which to retrieve <code>JAXXBeanInfo</code> * @return the class' <code>JAXXBeanInfo</code> - * @throws java.beans.IntrospectionException - * ? + * @throws java.beans.IntrospectionException if any pb */ public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor beanClass) throws IntrospectionException { return JAXXIntrospector.getJAXXBeanInfo(beanClass); @@ -196,14 +229,13 @@ } /** - * @param name ? + * @param name name of the property * @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code> * when modified). Members are either fields (represented by the simple name of the field) or <code>get/is</code> * methods (represented by the simple name of the method, <b>not</b> the simplified JavaBeans-style name). * Methods which are not actually bound in their native class, but for which proxy events have been * configured (such as <code>JTextField.getText</code>, return <code>true</code>. - * @throws UnsupportedAttributeException - * ? + * @throws UnsupportedAttributeException if attribute is not supported */ public boolean isMemberBound(String name) throws UnsupportedAttributeException { try { @@ -282,15 +314,15 @@ boolean methodExists = compiler.hasMethod(methodName); ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); if (!methodExists) { - compiler.addMethodToJavaFile(new JavaMethod(Modifier.PUBLIC, "void", methodName, + compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, propertyChangeListenerCode + ".propertyChange(null);", false)); } - String code = objectCode + (eventInfo.modelName != null ? ".get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName) + "()" : ""); + 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"); if (eventInfo.modelName != null) { - result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName), + result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), Util.class.getName() + ".getDataBindingUpdateListener(this , \"" + dataBinding + "\")", compiler)); } @@ -310,14 +342,21 @@ } } if (propertyName != null) { + //TC-20091026 when on root object, do not prefix with objectCode + String prefix = objectCode.trim() + "."; + if (objectCode.equals(compiler.getRootObject().getJavaCode())) { + prefix = ""; + } try { // check for property-specific addPropertyChangeListener method getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); - return objectCode + ".addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; +// 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 objectCode + ".addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; + return prefix + "addPropertyChangeListener(" + propertyChangeListenerCode + ");\n"; } } return null; @@ -330,23 +369,25 @@ } ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null; - if (eventInfo != null) { // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents + if (eventInfo != null) { + // a "proxied" event is one that doesn't fire PropertyChangeEvent, + // so we need to convert its native event type into PropertyChangeEvents StringBuffer result = new StringBuffer(); String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode); boolean methodExists = compiler.hasMethod(methodName); if (!methodExists) { ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass); - compiler.addMethodToJavaFile(new JavaMethod(Modifier.PUBLIC, "void", methodName, + compiler.getJavaFile().addMethod(new JavaMethod(Modifier.PUBLIC, "void", methodName, new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null, propertyChangeListenerCode + ".propertyChange(null);", false)); } try { - String modelMemberName = eventInfo.modelName != null ? "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName) : null; + String modelMemberName = eventInfo.modelName != null ? "get" + StringUtils.capitalize(eventInfo.modelName) : null; String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass()); String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : ""); result.append("((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\")).").append(eventInfo.removeMethod).append("((").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(") jaxx.runtime.Util.getEventListener(").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(compiler.getJavaCode(methodName)).append("));\n"); if (eventInfo.modelName != null) { - result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName), + result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + StringUtils.capitalize(eventInfo.modelName), Util.class.getName() + ".getDataBindingUpdateListener(this, \"" + dataBinding + "\")", compiler)); } @@ -369,14 +410,21 @@ } } if (propertyName != null) { + //TC-20091026 when on root object, do not prefix with objectCode + String prefix = objectCode.trim() + "."; + if (objectCode.equals(compiler.getRootObject().getJavaCode())) { + prefix = ""; + } try { // check for property-specific removePropertyChangeListener method getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class), ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class)); - return objectCode + ".removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n"; +// 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 objectCode + ".removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; + return prefix + "removePropertyChangeListener(" + propertyChangeListenerCode + ");\n"; } } return null; @@ -505,7 +553,7 @@ throw new IllegalStateException("unable to find CompiledObject associated with tag <" + tag.getTagName() + ">; should have been registered before second pass"); } compiler.checkOverride(object); - String constructorParams = tag.getAttribute("constructorParams"); + String constructorParams = tag.getAttribute(CONSTRUCTOR_PARAMS_ATTRIBUTE); if (constructorParams != null && constructorParams.length() > 0) { object.setConstructorParams(compiler.getScriptManager().trimScript(constructorParams)); } @@ -522,13 +570,13 @@ } public void registerCompiledObject(Element tag, JAXXCompiler compiler) { - String id = tag.getAttribute("id"); + String id = tag.getAttribute(ID_ATTRIBUTE); if (id == null || id.length() == 0) { id = compiler.getAutoId(getBeanClass()); } CompiledObject object = createCompiledObject(id, compiler); objectMap.put(tag, object); - String styleClass = tag.getAttribute("styleClass").trim(); + String styleClass = tag.getAttribute(STYLE_CLASS_ATTRIBUTE).trim(); if (styleClass.length() > 0) { object.setStyleClass(styleClass); } @@ -536,7 +584,8 @@ } /** - * Creates the <code>CompiledObject</code> which will represent the object created by this <code>TagHandler</code>. + * Creates the <code>CompiledObject</code> which will represent the object + * created by this <code>TagHandler</code>. * * @param id the <code>CompiledObject's</code> ID. * @param compiler compiler to use @@ -547,8 +596,8 @@ } /** - * Initializes the default settings of the object, prior to setting its attribute values. The default - * implementation does nothing. + * Initializes the default settings of the object, prior to setting its + * attribute values. The default implementation does nothing. * * @param object the object to initialize * @param tag the tag being compiled @@ -561,8 +610,7 @@ * @param property property name to test * @return <code>true</code> if the specified property should be inherited by child components when specified * via CSS. - * @throws UnsupportedAttributeException - * ? + * @throws UnsupportedAttributeException if attribute is not supported */ public boolean isPropertyInherited(String property) throws UnsupportedAttributeException { return false; @@ -596,13 +644,13 @@ for (Attr attribute : attributes) { String name = attribute.getName(); String value = attribute.getValue(); - if (name.equals("javaBean")) { + if (name.equals(JAVA_BEAN_ATTRIBUTE)) { //compiler.preprocessScript(value); continue; } - if (name.equals("constraints") || isEventHandlerName(name)) { + if (name.equals(CONSTRAINTS_ATTRIBUTE) || isEventHandlerName(name)) { compiler.preprocessScript(value); // adds dependencies as a side effect - } else if (name.equals("constructorParams")) { + } else if (name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE)) { for (String param : value.split("\\s*,\\s*")) { compiler.preprocessScript(param); } @@ -633,22 +681,26 @@ for (Attr attribute : attributes) { String name = attribute.getName(); String value = attribute.getValue().trim(); - if (name.equals("id") || name.equals("constraints") || name.equals("constructorParams") || name.equals("styleClass") || - name.startsWith("xmlns") || JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + if (name.equals(ID_ATTRIBUTE) || + name.equals(CONSTRAINTS_ATTRIBUTE) || + name.equals(CONSTRUCTOR_PARAMS_ATTRIBUTE) || + name.equals(STYLE_CLASS_ATTRIBUTE) || + name.startsWith(XMLNS_ATTRIBUTE) || + JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { // ignore, already handled continue; } - if (name.equals("javaBean")) { + if (name.equals(JAVA_BEAN_ATTRIBUTE)) { object.setJavaBean(true); if (!value.isEmpty()) { object.setJavaBeanInitCode(value); } continue; } - if (name.equals("implements")) { + if (name.equals(IMPLEMENTS_ATTRIBUTE)) { if (object != compiler.getRootObject()) { // can ony be apply to root object - compiler.reportError("'implements' attribute can only be found on root tag but was found on tag " + tag); + compiler.reportError("'" + IMPLEMENTS_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); return; } String[] interfaces = value.split(","); @@ -656,17 +708,17 @@ continue; } - if (name.equals("abstract")) { + if (name.equals(ABSTRACT_ATTRIBUTE)) { if (object != compiler.getRootObject()) { // can ony be apply to root object - compiler.reportError("'abstract' attribute can only be found on root tag but was found on tag " + tag); + compiler.reportError("'" + ABSTRACT_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); return; } compiler.setAbstractClass(true); continue; } - if (name.equals("genericType")) { + if (name.equals(GENERICTYPE_ATTRIBUTE)) { //TC-20090313 check after all atributes been processed if (object == compiler.getRootObject()) { compiler.setGenericType(value); @@ -676,17 +728,17 @@ continue; } - if (name.equals("superGenericType")) { + if (name.equals(SUPER_GENERIC_TYPE_ATTRIBUTE)) { if (object != compiler.getRootObject()) { // can ony be apply to root object - compiler.reportError("'superGenericType' attribute can only be found on root tag but was found on tag " + tag); + compiler.reportError("'" + SUPER_GENERIC_TYPE_ATTRIBUTE + "' attribute can only be found on root tag but was found on tag " + tag); return; } compiler.setSuperGenericType(value); continue; } - if (name.equals("decorator")) { + if (name.equals(DECORATOR_ATTRIBUTE)) { if (!value.isEmpty()) { CompiledObjectDecorator decorator = compiler.getEngine().getDecorator(value); object.setDecorator(decorator); @@ -734,7 +786,9 @@ * @return the attribute's priority */ protected int getAttributeOrdering(Attr attr) { - if (attr.getName().equals("displayedMnemonicIndex") || attr.getName().equals("displayedMnemonic") || attr.getName().equals("mnemonic")) { + if (attr.getName().equals(DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE) || + attr.getName().equals(DISPLAYED_MNEMONIC_ATTRIBUTE) || + attr.getName().equals(MNEMONIC_ATTRIBUTE)) { return 1; } return 0; @@ -776,7 +830,15 @@ // check for data binding & remove if found JAXXObjectDescriptor jaxxObjectDescriptor = object.getObjectClass().getJAXXObjectDescriptor(); ComponentDescriptor root = jaxxObjectDescriptor.getComponentDescriptors()[0]; - object.appendInitializationCode(object.getJavaCode() + ".removeDataBinding(" + compiler.getJavaCode(root.getId() + "." + propertyName) + ");"); + //TC-20091026 do not prefix binding by object id if on root object + String prefix; + if (object == compiler.getRootObject()) { + prefix = ""; + } else { + prefix = object.getId() + "."; + } + 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); @@ -796,7 +858,7 @@ propertyType != ClassDescriptorLoader.getClassDescriptor(Character.class)) { //binding = "((" + propertyType.getName() + ") " + binding + ")"; } - if (propertyName.equals("layout")) { // 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(getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler)); } @@ -959,7 +1021,15 @@ JAXXPropertyDescriptor property = properties.get(name); if (property != null) { if (property.getWriteMethodDescriptor() != null) { - return javaCode + '.' + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");"; + //TC-20091026 do not prefix by javaCode if on root object + String prefix; + if (compiler.getRootObject().getJavaCode().equals(javaCode)) { + prefix = ""; + } else { + 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"); } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -27,6 +27,8 @@ */ public class ScriptHandler implements TagHandler { + public static final String SOURCE_ATTRIBUTE = "source"; + @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { File scriptFile = null; @@ -35,7 +37,7 @@ Attr attribute = (Attr) attributes.item(i); String name = attribute.getName(); String attrValue = attribute.getValue(); - if (name.equals("source")) { + if (name.equals(SOURCE_ATTRIBUTE)) { scriptFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar)); StringWriter scriptBuffer = new StringWriter(); try { @@ -49,7 +51,8 @@ compiler.reportError("script file not found: " + scriptFile); } compiler.registerScript(scriptBuffer.toString(), scriptFile); - } else if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + } else if (!name.startsWith(XMLNS_ATTRIBUTE) && + !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { throw new UnsupportedAttributeException(name); } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -38,6 +38,7 @@ * @author Ethan Nicholas */ public class StyleHandler implements TagHandler { + public static final String SOURCE_ATTRIBUTE = "source"; @Override public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException { @@ -47,7 +48,7 @@ Attr attribute = (Attr) attributes.item(i); String name = attribute.getName(); String attrValue = attribute.getValue(); - if (name.equals("source")) { + if (name.equals(SOURCE_ATTRIBUTE)) { source = true; File styleFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar)); StringWriter styleBuffer = new StringWriter(); @@ -64,7 +65,8 @@ compiler.getSourceFiles().push(styleFile); compiler.registerStylesheet(processStylesheet(styleBuffer.toString())); compiler.getSourceFiles().pop(); - } else if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { + } else if (!name.startsWith(XMLNS_ATTRIBUTE) && + !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) { throw new UnsupportedAttributeException(name); } } Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -20,6 +20,8 @@ */ public interface TagHandler { + String XMLNS_ATTRIBUTE = "xmlns"; + /** * Performs the first pass of compilation on an XML tag from a JAXX source file. * <code>TagHandler</code> implementations affect the generated <code>.java</code> 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-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -18,21 +18,32 @@ import java.util.Map; import java.util.Set; -/** Manages TagHandlers, including automatically compiling .jaxx files corresponding to class tags. */ +/** + * Manages TagHandlers, including automatically compiling .jaxx files + * corresponding to class tags. + */ public class TagManager { - /** log */ + /** + * 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/"; - /** Maps simple tag names to their default namespaces (package names). */ + /** + * Maps simple tag names to their default namespaces (package names). + */ private static Map<String, String> defaultNamespaces = new HashMap<String, String>(); - /** Maps qualified tag names to the TagHandlers responsible for processing them. */ + /** + * Maps qualified tag names to the TagHandlers responsible for processing them. + */ private static Map<QName, TagHandler> registeredTags = new HashMap<QName, TagHandler>(); - /** Keeps track of whether or not named classes exist. */ + /** + * Keeps track of whether or not named classes exist. + */ private static Map<String, Boolean> classExistenceCache = new HashMap<String, Boolean>(); /** * Maps bean classes to their TagHandler classes. The mapping is to TagHandler classes, rather than to @@ -233,21 +244,23 @@ boolean found = false; ClassLoader classLoader = compiler.getClassLoader(); try { - Class.forName(className, true,classLoader); + Class.forName(className, true, classLoader); found = true; } catch (ClassNotFoundException e) { // ignore ? - } catch (NoClassDefFoundError e) { + } catch (NoClassDefFoundError e) { // we obtain this instead of ClassNotFoundException on case-insensitive file systems when // looking up a class with the wrong case } - if (!found) { // couldn't find .class, check for .java + if (!found) { + // couldn't find .class, check for .java URL javaURL = classLoader.getResource(className.replace('.', '/') + ".java"); found = javaURL != null; } - if (!found) { // couldn't find .java, check for .jaxx + if (!found) { + // couldn't find .java, check for .jaxx URL jaxxURL = classLoader.getResource(className.replace('.', '/') + ".jaxx"); found = jaxxURL != null; } @@ -260,12 +273,14 @@ private static String determinePackage(String simpleClassName, String defaultPackage, JAXXCompiler compiler) { String namespace = null; Set<String> classes = compiler.getImportedClasses(); - for (String className : classes) { // search class imports (e.g. import java.util.Date;) + for (String className : classes) { + // search class imports (e.g. import java.util.Date;) if (className.equals(simpleClassName) || className.endsWith("." + simpleClassName)) { namespace = className.substring(0, className.lastIndexOf(".") + 1) + "*"; } } - if (namespace == null) { // search package imports (e.g. import java.util.*;) + if (namespace == null) { + // search package imports (e.g. import java.util.*;) Set<String> searchList = compiler.getImportedPackages(); if (defaultPackage != null) { if (!defaultPackage.endsWith("*")) { @@ -278,7 +293,8 @@ for (String currentPackage : searchList) { String className = currentPackage + simpleClassName; if (classExists(className, compiler)) { - if (namespace != null) { // we've already found the same name in another package + if (namespace != null) { + // we've already found the same name in another package compiler.reportError("symbol '" + simpleClassName + "' is ambiguous, found matching classes " + namespace.substring(0, namespace.length() - 1) + simpleClassName + " and " + currentPackage + simpleClassName + ". Use fully-qualified name to disambiguate."); return null; } Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -37,8 +37,6 @@ import java.io.File; import java.io.IOException; import java.util.Map; -import java.net.URL; -import java.net.URLClassLoader; import java.util.Arrays; import java.util.HashMap; import java.util.Set; @@ -379,7 +377,11 @@ } if (verbose) { - printInit(); + getLog().info(toString()); + getLog().info("includes : " + Arrays.toString(includes)); + for (String file : files) { + getLog().info("will parse " + file); + } } return true; } @@ -400,12 +402,12 @@ TagManager.reset(verbose); engine = JAXXEngine.newLaunchor(src, files, this); - boolean success = engine.run(); + int nbFiles = engine.run(); report(engine); - if (!success) { + if (nbFiles == -1) { throw new MojoExecutionException("Aborting due to errors reported by jaxxc"); } - getLog().info("Generated " + engine.getCompilerCount() + " file(s). "); + getLog().info("Generated " + nbFiles + " file(s). "); if (generateHelp) { // generate help @@ -540,34 +542,6 @@ } } - protected void printInit() { - getLog().info(toString()); - getLog().info("includes : " + Arrays.toString(includes)); - for (String file : files) { - getLog().info("will parse " + file); - } - - ClassLoader threadLoader = Thread.currentThread().getContextClassLoader(); - getLog().info(threadLoader.toString()); - if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) { - try { - java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs"); - m.setAccessible(true); - URL[] urls = (URL[]) m.invoke(threadLoader); - - for (URL url : urls) { - getLog().info("url in class loader " + url); - } - } catch (Exception e) { - getLog().warn("??? : " + e.getMessage(), e); - } - } else if (threadLoader instanceof URLClassLoader) { - for (URL u : ((URLClassLoader) threadLoader).getURLs()) { - getLog().info("url in class loader " + u); - } - } - } - protected void generateHelp() throws IOException { Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds(); if (helpIds.isEmpty()) { Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -12,7 +12,7 @@ assertNumberJaxxFiles(3); checkPattern(mojo, "implements java.io.Serializable", true); - checkPattern(mojo, "label.setText(_(\"test\"))", true); + checkPattern(mojo, "setText(_(\"test\"))", true); } } \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -9,7 +9,7 @@ GenerateMojo mojo = getMojo(); mojo.execute(); assertNumberJaxxFiles(1); - checkPattern(mojo, "root.add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true); + checkPattern(mojo, "add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true); } } \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-10-26 02:47:48 UTC (rev 1599) @@ -9,11 +9,11 @@ GenerateMojo mojo = getMojo(); mojo.i18nable = false; mojo.execute(); - checkPattern(mojo, "testId.setText(_(\"test.text\"));", false); + checkPattern(mojo, "setText(_(\"test.text\"));", false); mojo.i18nable = true; mojo.execute(); - checkPattern(mojo, "testId.setText(_(\"test.text\"));", true); + checkPattern(mojo, "setText(_(\"test.text\"));", true); checkPattern(mojo, "\"_(\\\"test.text\\\")\"", false); } @@ -22,11 +22,11 @@ GenerateMojo mojo = getMojo(); mojo.i18nable = false; mojo.execute(); - checkPattern(mojo, "testId.setTitle(_(\"test.title\"));", false); + checkPattern(mojo, "setTitle(_(\"test.title\"));", false); mojo.i18nable = true; mojo.execute(); - checkPattern(mojo, "testId.setTitle(_(\"test.title\"));", true); + checkPattern(mojo, "setTitle(_(\"test.title\"));", true); checkPattern(mojo, "\"_(\\\"test.title\\\")\"", false); } @@ -35,11 +35,11 @@ GenerateMojo mojo = getMojo(); mojo.i18nable = false; mojo.execute(); - checkPattern(mojo, "testId.setToolTipText(_(\"test.toolTipText\"));", false); + checkPattern(mojo, "setToolTipText(_(\"test.toolTipText\"));", false); mojo.i18nable = true; mojo.execute(); - checkPattern(mojo, "testId.setToolTipText(_(\"test.toolTipText\"));", true); + checkPattern(mojo, "setToolTipText(_(\"test.toolTipText\"));", true); checkPattern(mojo, "\"_(\\\"test.toolTipText\\\")\"", false); } } Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test1.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test1.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test1.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1 +1 @@ -<JLabel id='label' implements="java.io.Serializable" text='test'/> \ No newline at end of file +<JLabel implements="java.io.Serializable" text='test'/> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test2.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test2.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1 +1 @@ -<JLabel id='label' text='test' implements="java.io.Serializable"/> \ No newline at end of file +<JLabel text='test' implements="java.io.Serializable"/> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test3.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test3.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Test3.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1 +1 @@ -<JLabel implements="java.io.Serializable" text='test' id='label'/> \ No newline at end of file +<JLabel implements="java.io.Serializable" text='test'/> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/BoxedDecorator.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/BoxedDecorator.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/BoxedDecorator.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,3 +1,3 @@ -<JPanel id='root'> +<JPanel> <JButton id='boxedButton' decorator='boxed'/> </JPanel> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/text/JButton.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/text/JButton.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/text/JButton.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1 +1 @@ -<javax.swing.JButton id='testId' text='test.text'/> \ No newline at end of file +<javax.swing.JButton text='test.text'/> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JDialog.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JDialog.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JDialog.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1 +1 @@ -<JDialog id='testId' title='test.title'/> +<JDialog title='test.title'/> Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,3 +1,3 @@ <JTabbedPane> - <tab id="testId" title='test.title'/> + <tab title='test.title'/> </JTabbedPane> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane2.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/title/JTabbedPane2.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,5 +1,5 @@ <JTabbedPane> - <tab id="testId" title='test.title'> + <tab title='test.title'> <JLabel text='testLabel'/> </tab> </JTabbedPane> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JButton.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JButton.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JButton.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1 +1 @@ -<javax.swing.JButton id='testId' toolTipText='test.toolTipText'/> \ No newline at end of file +<javax.swing.JButton toolTipText='test.toolTipText'/> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,3 +1,3 @@ - <JTabbedPane id="testId" toolTipText='test.toolTipText'> + <JTabbedPane toolTipText='test.toolTipText'> <tab title="text"/> </JTabbedPane> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane2.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane2.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane2.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,3 +1,3 @@ <JTabbedPane> - <tab id="testId" toolTipText='test.toolTipText'/> + <tab toolTipText='test.toolTipText'/> </JTabbedPane> \ No newline at end of file Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane3.jaxx =================================================================== --- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane3.jaxx 2009-10-26 02:45:10 UTC (rev 1598) +++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/tooltiptext/JTabbedPane3.jaxx 2009-10-26 02:47:48 UTC (rev 1599) @@ -1,5 +1,5 @@ <JTabbedPane> - <tab id="testId" toolTipText='test.toolTipText'> + <tab toolTipText='test.toolTipText'> <JLabel text='yo'/> </tab> </JTabbedPane> \ No newline at end of file
participants (1)
-
tchemit@users.nuiton.org