Author: tchemit Date: 2010-04-30 13:50:43 +0200 (Fri, 30 Apr 2010) New Revision: 1862 Url: http://nuiton.org/repositories/revision/jaxx/1862 Log: Anomalie #559: Can not use in css jaxx widgets Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java trunk/maven-jaxx-plugin/src/main/resources/log4j.properties Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -25,58 +25,40 @@ package jaxx.compiler; -import java.io.File; import jaxx.runtime.JAXXContext; +import java.io.File; + /** * Configuration of a compiler task. - * + * * @author tchemit <chemit@codelutin.com> * @since 2.0.0 */ public interface CompilerConfiguration { - /** - * - * @return the class loader used by compilers - */ + /** @return the class loader used by compilers */ ClassLoader getClassLoader(); - /** - * - * @return the type of compiler to use - */ + /** @return the type of compiler to use */ Class<? extends JAXXCompiler> getCompilerClass(); - /** - * - * @return the type of default decorator to use if none specified - */ + /** @return the type of default decorator to use if none specified */ Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass(); - /** - * - * @return the type of the default error UI to use for validation - */ + /** @return the type of the default error UI to use for validation */ Class<?> getDefaultErrorUI(); - /** - * - * @return extra imports to add on all generated jaxx object - */ + /** @return extra imports to add on all generated jaxx object */ String[] getExtraImports(); /** - * * @return the FQN of the help broker (can not directly a type since - * the help broker should (may?) be inside the sources. + * the help broker should (may?) be inside the sources. */ String getHelpBrokerFQN(); - /** - * - * @return the type of context to use in each generated jaxx object - */ + /** @return the type of context to use in each generated jaxx object */ Class<? extends JAXXContext> getJaxxContextClass(); /** @@ -88,74 +70,59 @@ /** * Returns whether or not auto css should be used. - * @return {@code true} if a css file with same name as jaxx file should be included in jaxx file if found. + * + * @return {@code true} if a css file with same name as jaxx file should + * be included in jaxx file if found. + * @since 2.0.2 */ boolean isAutoImportCss(); /** - * Returns the target directory. + * Returns whether or not should recurse in css for existing JAXX Object. * - * @return the target directory + * <b>Note:</b> This functionnality was here at the beginning of the project + * but offers nothing very usefull, will be remove probably in JAXX 3.0. + * + * @return {@code true} if a css file with same name as jaxx file should + * be included in jaxx file if found. + * @since 2.0.2 */ - File getTargetDirectory(); + boolean isAutoRecurseInCss(); /** + * Returns the target directory. * - * @return the type of validator to use + * @return the target directory */ + File getTargetDirectory(); + + /** @return the type of validator to use */ Class<?> getValidatorClass(); - /** - * - * @return {@code true} if a logger must add on each generated jaxx object - */ + /** @return {@code true} if a logger must add on each generated jaxx object */ boolean isAddLogger(); - /** - * - * @return {@code true} if we are generating help - */ + /** @return {@code true} if we are generating help */ boolean isGenerateHelp(); - /** - * - * @return {@code true} if we use the i18n system - */ + /** @return {@code true} if we use the i18n system */ boolean isI18nable(); - /** - * - * @return {@code true} to generate optimized code - */ + /** @return {@code true} to generate optimized code */ boolean isOptimize(); - /** - * - * @return {@code true} if a profile pass must be done - */ + /** @return {@code true} if a profile pass must be done */ boolean isProfile(); - /** - * - * @return {@code true} if states must be reset after the compilation - */ + /** @return {@code true} if states must be reset after the compilation */ boolean isResetAfterCompile(); - /** - * - * @return {@code true} if UIManager is used to retrieve icons - */ + /** @return {@code true} if UIManager is used to retrieve icons */ boolean isUseUIManagerForIcon(); - /** - * - * @return {@code true} if compiler is verbose - */ + /** @return {@code true} if compiler is verbose */ boolean isVerbose(); - /** - * - * @return the encoding to use to write files - */ + /** @return the encoding to use to write files */ String getEncoding(); } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -117,6 +117,8 @@ private boolean autoImportCss; + private boolean autoRecurseInCss; + @Override public File getTargetDirectory() { return targetDirectory; @@ -222,6 +224,11 @@ } @Override + public boolean isAutoRecurseInCss() { + return autoRecurseInCss; + } + + @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -758,7 +758,12 @@ public void applyStylesheets() { for (Object o : new ArrayList<CompiledObject>(objects.values())) { CompiledObject object = (CompiledObject) o; - TagManager.getTagHandler(object.getObjectClass()).applyStylesheets(object, this); + DefaultObjectHandler tagHandler = TagManager.getTagHandler(object.getObjectClass()); + if (log.isDebugEnabled()) { + log.debug("will apply css on object " + object.getId()+" from handler " + tagHandler); + } + + tagHandler.applyStylesheets(object, this); } } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/binding/PseudoClassDataBinding.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -57,6 +57,10 @@ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); String id = object.getId() + ".style." + pseudoClass + "." + methodName; + + if (log.isDebugEnabled()) { + log.debug("will test if databinding : ["+ pseudoClass +"] " + id); + } binding = new PseudoClassDataBinding(id, pseudoClass, propertyCode, invertTest); } return binding; Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/css/StylesheetHelper.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -44,6 +44,8 @@ import jaxx.runtime.css.Rule; import jaxx.runtime.css.Selector; import jaxx.runtime.css.Stylesheet; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -60,6 +62,9 @@ */ public class StylesheetHelper { + /** Logger */ + static private final Log log = LogFactory.getLog(StylesheetHelper.class); + public static String loadCssFile(JAXXCompiler compiler, File styleFile) throws IOException { FileReader in = new FileReader(styleFile); @@ -172,6 +177,7 @@ mouseup("mouseReleased", "mousePressed"); final String addMethod; + final String removeMethod; // ClassDescriptor mouseListenerDescriptor; @@ -185,41 +191,10 @@ public String getProperty(int i) { return i == 0 ? addMethod : removeMethod; } - -// public ClassDescriptor getMouseEventDescriptor() { -// if (mouseEventDescriptor == null) { -// mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); -// } -// return mouseEventDescriptor; -// } -// -// public ClassDescriptor getMouseListenerDescriptor() { -// if (mouseListenerDescriptor == null) { -// mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); -// } -// return mouseListenerDescriptor; -// } -// -// public MethodDescriptor getAddMouseListenerMethod(CompiledObject object) { -// try { -// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", getMouseListenerDescriptor()); -// return addMouseListener; -// } catch (NoSuchMethodException e) { -// throw new CompilerException("could not find addMouseListener for object " + object); -// } -// } -// -// public MethodDescriptor getMouseListenerMethod(CompiledObject object, String property) { -// try { -// MethodDescriptor methodDescriptor = getMouseListenerDescriptor().getMethodDescriptor(property, getMouseEventDescriptor()); -// return methodDescriptor; -// } catch (NoSuchMethodException e) { -// throw new CompilerException("could not find " + property + " for object " + object); -// } -// } } static ClassDescriptor mouseListenerDescriptor; + static ClassDescriptor mouseEventDescriptor; public static ClassDescriptor getMouseEventDescriptor() { @@ -317,136 +292,6 @@ } } -// /** -// * Replaces all references to the variable "object" with the actual object ID. -// * -// * @param code ? -// * @param id ? -// * @return ? -// * @throws CompilerException ? -// */ -// public static String replaceObjectReferences(String code, String id) throws CompilerException { -// JavaParser p = new JavaParser(new StringReader(code + ";")); -// p.Expression(); -// jaxx.compiler.java.parser.SimpleNode node = p.popNode(); -// scanNode(node, id); -// return node.getText(); -// } -// -// public static void scanNode(SimpleNode node, String id) { -// if (node.getId() == JavaParserTreeConstants.JJTNAME) { -// String name = node.getText(); -// if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) { -// node.firstToken.image = id; -// } -// } else { -// int count = node.jjtGetNumChildren(); -// for (int i = 0; i < count; i++) { -// scanNode(node.getChild(i), id); -// } -// } -// } - -// public static void compilePseudoClassAdd(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException { -// -// if (pseudoClass.startsWith("{")) { -// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); -// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); -// String dest = object.getId() + ".style." + pseudoClass + ".add"; -// String destCode = TypeManager.getJavaCode(dest); -// DataBindingHelper bindingHelper = compiler.getBindingHelper(); -// if (bindingHelper.hasProcessDataBinding()) { -// bindingHelper.appendProcessDataBinding("else "); -// } -// bindingHelper.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { " + propertyCode + "} }"); -// new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); -// bindingHelper.appendInitDataBindings("applyDataBinding(" + destCode + ");"); -// return; -// } -// -// MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); -// -// String property = null; -// switch (constant) { -// case mousedown: -// property = "mousePressed"; -// break; -// case mouseout: -// property = "mouseExited"; -// break; -// case mouseover: -// property = "mouseEntered"; -// break; -// case mouseup: -// property = "mouseReleased"; -// break; -// } -// -// ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); -// ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); -// -// try { -// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor); -// MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor); -// object.addEventHandler("style." + pseudoClass + ".add", addMouseListener, methodDescriptor, propertyCode, compiler); -// -// } catch (NoSuchMethodException e) { -// compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)"); -// } -// } - -// public static void compilePseudoClassRemove(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException { -// if (pseudoClass.startsWith("{")) { -// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); -// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); -// String dest = object.getId() + ".style." + pseudoClass + ".remove"; -// String destCode = TypeManager.getJavaCode(dest); -// DataBindingHelper bindingHelper = compiler.getBindingHelper(); -// if (bindingHelper.hasProcessDataBinding()) { -// bindingHelper.appendProcessDataBinding("else "); -// } -// bindingHelper.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }"); -// new DataSource(dest, pseudoClass, compiler).compile("new DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")"); -// bindingHelper.appendInitDataBindings("applyDataBinding(" + destCode + ");"); -// return; -// } -// -// MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); -// -// String property = null; -// switch (constant) { -// case mousedown: -// property = "mousePressed"; -// break; -// case mouseout: -// property = "mouseReleased"; -// break; -// case mouseover: -// property = "mouseExited"; -// break; -// case mouseup: -// property = "mousePressed"; -// break; -// } -// -// ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class); -// ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class); -// -// try { -// MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor); -// MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor); -// object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener, methodDescriptor, propertyCode, compiler); -// -// } catch (NoSuchMethodException e) { -// compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)"); -// } -// } -// -// public static String invert(String javaCode) { -// javaCode = javaCode.trim(); -// return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")"; -// } - public static String unwrap(ClassDescriptor type, String valueCode) { if (ClassDescriptorLoader.getClassDescriptor(boolean.class).equals(type)) { return "((java.lang.Boolean) " + valueCode + ").booleanValue()"; @@ -508,17 +353,15 @@ for (Map.Entry<String, String> e : properties.entrySet()) { String property = e.getKey(); ClassDescriptor type = handler.getPropertyType(object, property, compiler); + if (log.isDebugEnabled()) { + log.debug("will test if databinding : [" + e.getValue() + "] type=" + type); + } String dataBindingCode = DataBindingHelper.processDataBindings(e.getValue()); String valueCode; if (dataBindingCode != null) { valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; DataBinding binding = new DataBinding(object.getId() + "." + property + "." + priority, dataBindingCode, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); bindingHelper.registerDataBinding(binding); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); -// DataBinding dataBinding1 = new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler)); -// DataBinding dataBinding1 = new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler)); -// binding.compile(compiler); -// dataBinding1.compile(compiler, false); } else { try { Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; @@ -547,21 +390,6 @@ // throw new RuntimeException("could not find " + PseudoClassEnum.class + " with pseudoClass " + pseudoClass, e); } -// if (pseudoClass.equals("focused")) { -// pseudoClass = "{ object.hasFocus() }"; -// } else if (pseudoClass.equals("unfocused")) { -// pseudoClass = "{ !object.hasFocus() }"; -// } else if (pseudoClass.equals("enabled")) { -// pseudoClass = "{ object.isEnabled() }"; -// } else if (pseudoClass.equals("disabled")) { -// pseudoClass = "{ !object.isEnabled() }"; -// } else if (pseudoClass.equals("selected")) { -// pseudoClass = "{ object.isSelected() }"; -// } else if (pseudoClass.equals("deselected")) { -// pseudoClass = "{ !object.isSelected() }"; -// } - -// compilePseudoClassAdd(pseudoClass, object, buffer.toString(), compiler); compilePseudoClass(pseudoClass, object, buffer.toString(), 0, "add", compiler, false); buffer.setLength(0); @@ -569,17 +397,15 @@ for (Map.Entry<String, String> e : properties.entrySet()) { String property = e.getKey(); ClassDescriptor type = handler.getPropertyType(object, property, compiler); + if (log.isDebugEnabled()) { + log.debug("will test if databinding : [" + e.getValue() + "] type=" + type); + } String dataBindingCode = DataBindingHelper.processDataBindings(e.getValue()); String valueCode; if (dataBindingCode != null) { valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")"; DataBinding binding = new DataBinding(object.getId() + "." + property + "." + priority, dataBindingCode, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler), false); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler)); -// DataBinding binding = new DataBinding(dataBindingCode, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBindingCode, compiler)); bindingHelper.registerDataBinding(binding); -// binding.compile(compiler); -// binding.compile(compiler, false); } else { try { Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null; @@ -599,7 +425,6 @@ buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + unwrappedValue, compiler)).append(eol); buffer.append("}").append(eol); } -// compilePseudoClassRemove(pseudoClass, object, buffer.toString(), compiler); compilePseudoClass(pseudoClass, object, buffer.toString(), 1, "remove", compiler, true); } @@ -610,15 +435,6 @@ compiler.getBindingHelper().registerDataBinding(binding); return; } -// if (pseudoClass.startsWith("{")) { -// pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim(); -// pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode()); -// String id = object.getId() + ".style." + pseudoClass + "." + methodName; -// PseudoClassDataBinding binding = new PseudoClassDataBinding(id, pseudoClass, propertyCode, invertTest); -// compiler.getBindingHelper().registerDataBinding(binding); -//// binding.compile(compiler); -// return; -// } MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass); String property = constant.getProperty(pos); MethodDescriptor addMouseListener = getAddMouseListenerMethod(object); 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-29 14:16:39 UTC (rev 1861) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -63,43 +63,51 @@ public class DefaultObjectHandler implements TagHandler { 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 INITIALIZER_ATTRIBUTE = "initializer"; + 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. - */ + + /** 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>(); public ProxyEventInfo getEventInfo(String memberName) { @@ -114,14 +122,12 @@ */ public static 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 * managing the property, this is the name of the property where that object can be @@ -131,13 +137,11 @@ * 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; public String getAddMethod() { @@ -201,9 +205,7 @@ } } - /** - * @return the class which this <code>DefaultObjectHandler</code> supports. - */ + /** @return the class which this <code>DefaultObjectHandler</code> supports. */ public ClassDescriptor getBeanClass() { return beanClass; } @@ -514,6 +516,7 @@ } // TODO: remove this temporary method, complete switchover to ClassDescriptors + public void addProxyEventInfo(String memberName, Class<?> listenerClass, String modelName, String addMethod, String removeMethod) { try { @@ -714,11 +717,11 @@ String name = attribute.getName(); String value = attribute.getValue().trim(); 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())) { + 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; } @@ -827,8 +830,8 @@ */ protected int getAttributeOrdering(Attr attr) { if (attr.getName().equals(DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE) || - attr.getName().equals(DISPLAYED_MNEMONIC_ATTRIBUTE) || - attr.getName().equals(MNEMONIC_ATTRIBUTE)) { + attr.getName().equals(DISPLAYED_MNEMONIC_ATTRIBUTE) || + attr.getName().equals(MNEMONIC_ATTRIBUTE)) { return 1; } return 0; @@ -935,13 +938,23 @@ applyStylesheets(object, compiler, null); } - private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) { + private void applyStylesheets(CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) { applyStylesheets(object, compiler, overrides, true); } - private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) { + private void applyStylesheets(CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) { try { Stylesheet stylesheet = compiler.getStylesheet(); + if (!compiler.getConfiguration().isAutoRecurseInCss()) { + + // do not do any recurse mode in css from existing jaxx objects. + 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(); @@ -951,11 +964,11 @@ 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); + "((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " + + object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))", + classDescriptor, + compiler, + true); ComponentDescriptor parentDescriptor = descriptor.getParent(); CompiledObject currentObject = child; while (parentDescriptor != null) { @@ -982,9 +995,10 @@ TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot); object.appendInitializationCode(child.getInitializationCode(compiler)); } - } else if (stylesheet != null) { - StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); } +// } else if (stylesheet != null) { +// StylesheetHelper.applyTo(object, compiler, stylesheet, overrides); +// } } catch (ClassNotFoundException e) { throw new CompilerException(e); } catch (IllegalArgumentException e) { @@ -1151,14 +1165,14 @@ * @see #constantValue */ protected Object convertFromString(String key, String value, Class<?> type) { - if (type == null || type == Object.class) { + if (type == null || Object.class.equals(type)) { return value; } try { return TypeManager.convertFromString(value, type); } catch (NumberFormatException e) { - if (type == int.class || type == Integer.class) { + if (int.class.equals(type) || Integer.class.equals(type)) { return constantValue(key, value); } throw e; Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java =================================================================== --- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2010-04-30 11:50:43 UTC (rev 1862) @@ -210,6 +210,19 @@ protected boolean autoImportCss; /** + * To let jaxx recurses in css when a JAXX Object auto import css files + * for a jaxx file. + * + * <b>Warning:</b> This option will be removed in version 3.0 or at least + * default value will become {@code false}. + * + * + * @parameter expression="${jaxx.autoRecurseInCss}" default-value="true" + * @since 2.0.2 + */ + protected boolean autoRecurseInCss; + + /** * flag to add logger to each generated jaxx file. * <p/> * By default, always add it. @@ -305,19 +318,13 @@ */ private Class<?> validatorClass; - /** - * type of {@link CompiledObjectDecorator} to use - */ + /** type of {@link CompiledObjectDecorator} to use */ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass; - /** - * type of {@link JAXXContext} to use - */ + /** type of {@link JAXXContext} to use */ private Class<? extends JAXXContext> jaxxContextClass; - /** - * type of compiler to use - */ + /** type of compiler to use */ private Class<? extends JAXXCompiler> compilerClass; /** @@ -325,9 +332,7 @@ */ private String[] extraImports; - /** - * internal state to known if a files has to be generated - */ + /** internal state to known if a files has to be generated */ private boolean nofiles; /** @@ -525,8 +530,13 @@ public boolean isAutoImportCss() { return autoImportCss; } - + @Override + public boolean isAutoRecurseInCss() { + return autoRecurseInCss; + } + + @Override public boolean isI18nable() { return i18nable; } Modified: trunk/maven-jaxx-plugin/src/main/resources/log4j.properties =================================================================== --- trunk/maven-jaxx-plugin/src/main/resources/log4j.properties 2010-04-29 14:16:39 UTC (rev 1861) +++ trunk/maven-jaxx-plugin/src/main/resources/log4j.properties 2010-04-30 11:50:43 UTC (rev 1862) @@ -7,3 +7,5 @@ log4j.logger.org.nuiton.i18n=ERROR log4j.logger.jaxx=INFO +#log4j.logger.jaxx.compiler=DEBUG +#log4j.logger.jaxx.runtime=DEBUG