Author: tchemit Date: 2011-04-15 12:46:53 +0200 (Fri, 15 Apr 2011) New Revision: 2255 Url: http://nuiton.org/repositories/revision/jaxx/2255 Log: Anomalie #1460: Can't use <SwingValidator context="myContext"> Anomalie #1461: Warnings are not displayed Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXFactory.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java 2011-04-11 12:00:34 UTC (rev 2254) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXEngine.java 2011-04-15 10:46:53 UTC (rev 2255) @@ -200,7 +200,7 @@ } /** Resets all state in preparation for a new compilation session. */ - protected void reset() { + protected void reset(boolean cleanReports) { for (JAXXCompilerFile compilerFile : compilingFiles) { compilerFile.clear(); } @@ -209,7 +209,9 @@ profiler.clear(); profiler = null; } - clearReports(); + if (cleanReports) { + clearReports(); + } ClassDescriptorHelper.setShowLoading(false); } @@ -364,9 +366,8 @@ log.error(e.getMessage(), e); return -1; } finally { - //TC - 20081018 only reset when no error was detected - if (configuration.isResetAfterCompile() && errors.isEmpty()) { - reset(); + if (configuration.isResetAfterCompile()) { + reset(false); } } } Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXFactory.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXFactory.java 2011-04-11 12:00:34 UTC (rev 2254) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/JAXXFactory.java 2011-04-15 10:46:53 UTC (rev 2255) @@ -84,7 +84,7 @@ public static JAXXEngine newEngine(File basedir, String... relativePaths) { checkConfiguration(); if (engine != null) { - engine.reset(); + engine.reset(true); } engine = new JAXXEngine(configuration, basedir, relativePaths); return engine; Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2011-04-11 12:00:34 UTC (rev 2254) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2011-04-15 10:46:53 UTC (rev 2255) @@ -754,7 +754,7 @@ /** * Set a single property on an object. The value may be either a simple value or contain data binding expressions. - * Simple values are first converted to the property's type using {@link #convertFromString}. + * Simple values are first converted to the property's type using {@link #convertFromString(String, String, Class)}. * * @param object the object on which to set the property * @param propertyName the name of the property to set Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java =================================================================== --- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2011-04-11 12:00:34 UTC (rev 2254) +++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2011-04-15 10:46:53 UTC (rev 2255) @@ -88,6 +88,12 @@ public static final String STRICT_MODE_ATTRIBUTE = "strictMode"; + public static final String CONTEXT_ATTRIBUTE = "context"; + + /** + * @deprecated since 2.4.1, now use the {@link #CONTEXT_ATTRIBUTE}. + */ + @Deprecated public static final String CONTEXT_NAME_ATTRIBUTE = "contextName"; //public static final String SCOPE_ATTRIBUTE = "scope"; @@ -135,8 +141,8 @@ } @Override - public void compileSecondPass( - Element tag, JAXXCompiler compiler) throws CompilerException, IOException { + public void compileSecondPass(Element tag, + JAXXCompiler compiler) throws CompilerException, IOException { super.compileSecondPass(tag, compiler); @@ -164,14 +170,6 @@ error = info.addBean(tag, this, compiler); } - /*if (!error) { - error = info.addContextName(this, compiler); - }*/ - - /*if (!error) { - error = info.addScope(this, compiler); - }*/ - if (!error) { error = info.addParentValidator(tag, this, compiler); } @@ -202,6 +200,12 @@ if (log.isDebugEnabled()) { log.debug(propertyName + " : " + stringValue + " for " + object); } + if (CONTEXT_NAME_ATTRIBUTE.equals(propertyName)) { + if (stringValue != null && !stringValue.trim().isEmpty()) { + // usage of a deprecated contextName, says it to user... + compiler.reportWarning("You are using a validator attribute named 'contextName' which is deprecated, prefer use now a context attribute."); + } + } // delegate to the compiled object with is statefull // (but not the tag handler) object.addProperty(propertyName, stringValue); @@ -223,7 +227,7 @@ protected String beanClass; - protected String contextName; + protected String context; protected String uiClass; @@ -295,11 +299,19 @@ if (CONTEXT_NAME_ATTRIBUTE.equals(property)) { if (value != null && !value.trim().isEmpty()) { - contextName = value.trim(); + context= value.trim(); } + return; } + if (CONTEXT_ATTRIBUTE.equals(property)) { + if (value != null && !value.trim().isEmpty()) { + context = value.trim(); + } + return; + } + if (BEAN_CLASS_ATTRIBUTE.equals(property)) { if (value != null && !value.trim().isEmpty()) { beanClass = value.trim(); @@ -397,8 +409,8 @@ return beanClass; } - public String getContextName() { - return contextName; + public String getContext() { + return context; } public String getParentValidator() { @@ -755,7 +767,7 @@ String type = compiler.getImportedType(beanClassName); // contextName must be in constructor to able to init validator with his correct contextName String constructorParams = type + ".class, " + - TypeManager.getJavaCode(contextName); + TypeManager.getJavaCode(context); // setConstructorParams(constructorParams); String prefix = compiler.getImportedType(SwingValidatorUtil.class); setInitializer(