Author: tchemit Date: 2010-04-30 22:09:43 +0200 (Fri, 30 Apr 2010) New Revision: 1863 Url: http://nuiton.org/repositories/revision/jaxx/1863 Log: resolve Anomalie 558 Added: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorsCss.xml trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/css/ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/css/UnsupportedPseudoclass.jaxx Removed: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2010-04-30 11:50:43 UTC (rev 1862) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2010-04-30 20:09:43 UTC (rev 1863) @@ -178,8 +178,7 @@ /** * Performs introspection on the beanClass and stores the results. * - * @throws java.beans.IntrospectionException - * if any pb + * @throws IntrospectionException if any pb */ protected void init() throws IntrospectionException { if (jaxxBeanInfo == null) { @@ -228,8 +227,7 @@ * * @param beanClass the bean class for which to retrieve <code>JAXXBeanInfo</code> * @return the class' <code>JAXXBeanInfo</code> - * @throws java.beans.IntrospectionException - * if any pb + * @throws IntrospectionException if any pb */ public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor beanClass) throws IntrospectionException { return JAXXIntrospector.getJAXXBeanInfo(beanClass); @@ -942,63 +940,84 @@ applyStylesheets(object, compiler, overrides, true); } - private void applyStylesheets(CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) { + private void applyStylesheets(CompiledObject object, + JAXXCompiler compiler, + Stylesheet overrides, + boolean recurse) { + + Stylesheet stylesheet = compiler.getStylesheet(); + + ClassDescriptor objectClass = object.getObjectClass(); + ClassDescriptor jaxxObjectClassDescriptor = + ClassDescriptorLoader.getClassDescriptor(JAXXObject.class); + + // to apply styleSheet to a jaxx object, + // since 2.0.2, this process can be skip if configuration + // autoRecurseInCss is set to false since this does not work + boolean applyInside = + recurse && + jaxxObjectClassDescriptor.isAssignableFrom(objectClass) && + // new since 2.0.2 to skip old buggy mode + compiler.getConfiguration().isAutoRecurseInCss(); + try { - Stylesheet stylesheet = compiler.getStylesheet(); - if (!compiler.getConfiguration().isAutoRecurseInCss()) { - // do not do any recurse mode in css from existing jaxx objects. + if (!applyInside) { + + // this is the safe mode to use, just apply stlySheet to object if (stylesheet != null) { StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); } return; } - // old strange mode to de remove soon (or really improved...) - ClassDescriptor objectClass = object.getObjectClass(); - if (recurse && ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(objectClass)) { - JAXXObjectDescriptor jaxxObjectDescriptor = objectClass.getJAXXObjectDescriptor(); - ComponentDescriptor[] descriptors = jaxxObjectDescriptor.getComponentDescriptors(); - for (ComponentDescriptor descriptor : descriptors) { - ClassDescriptor classDescriptor = ClassDescriptorLoader.getClassDescriptor(descriptor.getJavaClassName()); - boolean isRoot = classDescriptor != objectClass; - String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId(); - CompiledObject child = new CompiledObject(id, - "((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " + - object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))", - classDescriptor, - compiler, - true); - ComponentDescriptor parentDescriptor = descriptor.getParent(); - CompiledObject currentObject = child; - while (parentDescriptor != null) { - CompiledObject parent = new CompiledObject("internal", ClassDescriptorLoader.getClassDescriptor(parentDescriptor.getJavaClassName()), compiler); - currentObject.setParent(parent); - currentObject = parent; - parentDescriptor = parentDescriptor.getParent(); + //FIXME TC-20100430 This is an old mode which try to apply inside a + // detected jaxx object stysheets (cascade) : + // It does not work in fact and must be repair... + + JAXXObjectDescriptor jaxxObjectDescriptor = + objectClass.getJAXXObjectDescriptor(); + ComponentDescriptor[] descriptors = + jaxxObjectDescriptor.getComponentDescriptors(); + for (ComponentDescriptor descriptor : descriptors) { + ClassDescriptor classDescriptor = + ClassDescriptorLoader.getClassDescriptor( + descriptor.getJavaClassName() + ); + boolean isRoot = classDescriptor != objectClass; + String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId(); + CompiledObject child = new CompiledObject(id, + "((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " + + object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))", + classDescriptor, + compiler, + true); + ComponentDescriptor parentDescriptor = descriptor.getParent(); + CompiledObject currentObject = child; + while (parentDescriptor != null) { + CompiledObject parent = new CompiledObject("internal", ClassDescriptorLoader.getClassDescriptor(parentDescriptor.getJavaClassName()), compiler); + currentObject.setParent(parent); + currentObject = parent; + parentDescriptor = parentDescriptor.getParent(); + } + currentObject.setParent(object); + String styleClass = object.getStyleClass(); + if (styleClass == null) { + styleClass = descriptor.getStyleClass(); + } + child.setStyleClass(styleClass); + Stylesheet mergedStylesheet = overrides; + Stylesheet childOverrides = jaxxObjectDescriptor.getStylesheet(); + if (childOverrides != null) { + if (mergedStylesheet == null) { + mergedStylesheet = childOverrides; + } else { + mergedStylesheet.add(childOverrides.getRules()); } - currentObject.setParent(object); - String styleClass = object.getStyleClass(); - if (styleClass == null) { - styleClass = descriptor.getStyleClass(); - } - child.setStyleClass(styleClass); - Stylesheet mergedStylesheet = overrides; - Stylesheet childOverrides = jaxxObjectDescriptor.getStylesheet(); - if (childOverrides != null) { - if (mergedStylesheet == null) { - mergedStylesheet = childOverrides; - } else { - mergedStylesheet.add(childOverrides.getRules()); - } - } - TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot); - object.appendInitializationCode(child.getInitializationCode(compiler)); } + TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot); + object.appendInitializationCode(child.getInitializationCode(compiler)); } -// } else if (stylesheet != null) { -// StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); -// } } catch (ClassNotFoundException e) { throw new CompilerException(e); } catch (IllegalArgumentException e) { Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java =================================================================== --- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2010-04-30 11:50:43 UTC (rev 1862) +++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2010-04-30 20:09:43 UTC (rev 1863) @@ -29,6 +29,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.SystemStreamLog; +import org.junit.Ignore; import org.junit.Test; import java.io.File; @@ -122,7 +123,7 @@ // init mojo to get alls files to treate mojo.init(); - assertNumberJaxxFiles(34); + assertNumberJaxxFiles(33); mojo.setLog(new SystemStreamLog() { @Override @@ -162,7 +163,55 @@ } } + + @SuppressWarnings({"unchecked"}) @Test + public void ErrorsCss() throws Exception { + GenerateMojo mojo = getMojo(); + // init mojo to get alls files to treate + mojo.init(); + + assertNumberJaxxFiles(1); + mojo.setLog(new SystemStreamLog() { + + @Override + public boolean isErrorEnabled() { + return false; + } + + @Override + public void error(Throwable error) { + //do nothing + } + + @Override + public void error(CharSequence content) { + //do nothing + } + + @Override + public void error(CharSequence content, Throwable error) { + //do nothing + } + }); + + // execute mjo on each jaxx file to produce the error + for (String file : mojo.files) { + log.info("test bad file " + file); + mojo.files = new String[]{file}; + try { + mojo.doAction(); + // should never pass + fail(); + } catch (MojoExecutionException e) { + // ok jaxx compiler failed + assertTrue(true); + assertError(mojo.getEngine(), file, 1); + } + } + } + + @Test public void Initializers() throws Exception { executeMojo(); assertNumberJaxxFiles(1); Modified: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml 2010-04-30 11:50:43 UTC (rev 1862) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/Errors.xml 2010-04-30 20:09:43 UTC (rev 1863) @@ -14,6 +14,7 @@ <configuration> <src>${basedir}/target/test-classes</src> <outJava>${basedir}/target/generated-sources/test-java</outJava> + <autoRecurseInCss>true</autoRecurseInCss> <!--outResource>${basedir}/target/it-generated-sources/resources</outResource--> <force>true</force> <includes> Added: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorsCss.xml =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorsCss.xml (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorsCss.xml 2010-04-30 20:09:43 UTC (rev 1863) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.jaxx.test</groupId> + <artifactId>test</artifactId> + <version>0</version> + <build> + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-jaxx-plugin</artifactId> + <configuration> + <src>${basedir}/target/test-classes</src> + <outJava>${basedir}/target/generated-sources/test-java</outJava> + <autoRecurseInCss>false</autoRecurseInCss> + <force>true</force> + <includes> + <value>**/compilerTest/errors/css/*.jaxx</value> + </includes> + </configuration> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Property changes on: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/ErrorsCss.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx 2010-04-30 11:50:43 UTC (rev 1862) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/UnsupportedPseudoclass.jaxx 2010-04-30 20:09:43 UTC (rev 1863) @@ -1,5 +0,0 @@ -<JButton> - <style> - :opaque { enabled: false; } - </style> -</JButton> \ No newline at end of file Added: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/css/UnsupportedPseudoclass.jaxx =================================================================== --- trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/css/UnsupportedPseudoclass.jaxx (rev 0) +++ trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/css/UnsupportedPseudoclass.jaxx 2010-04-30 20:09:43 UTC (rev 1863) @@ -0,0 +1,5 @@ +<JButton> + <style> + :opaque { enabled: false; } + </style> +</JButton> \ No newline at end of file Property changes on: trunk/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/compilerTest/errors/css/UnsupportedPseudoclass.jaxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL