Author: Alex.Kolonitsky
Date: 2010-03-01 08:40:54 -0500 (Mon, 01 Mar 2010)
New Revision: 16509
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EmptyVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitor.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor-primitive.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes-old.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_copyright.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods-old.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedTagHandler.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedValidator.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java
Modified:
root/cdk/trunk/plugins/generator/pom.xml
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-string-method.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - generate Taglib and TagHandlers
Modified: root/cdk/trunk/plugins/generator/pom.xml
===================================================================
--- root/cdk/trunk/plugins/generator/pom.xml 2010-03-01 13:29:51 UTC (rev 16508)
+++ root/cdk/trunk/plugins/generator/pom.xml 2010-03-01 13:40:54 UTC (rev 16509)
@@ -1,244 +1,257 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <parent>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-plugins</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>generator</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <name>Java Server Faces component generator</name>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>com.sun.xsom</groupId>
- <artifactId>xsom</artifactId>
- <version>20081112</version>
- </dependency>
- <dependency>
- <groupId>com.google.collections</groupId>
- <artifactId>google-collections</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.groovy.maven</groupId>
- <artifactId>gmaven-plugin</artifactId>
- <version>1.0</version>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <properties>
-
<sourceSchema>src/main/resources/META-INF/schema/xhtml-el.xsd</sourceSchema>
-
<
targetNamespace>http://richfaces.org/cdk/xhtml-el</targetNamespace>
-
<outputFile>generated-resources/META-INF/cdk/attributes/xhtml-el.xml</outputFile>
- </properties>
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>generator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>Java Server Faces component generator</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.xsom</groupId>
+ <artifactId>xsom</artifactId>
+ <version>20081112</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <properties>
+
<sourceSchema>src/main/resources/META-INF/schema/xhtml-el.xsd</sourceSchema>
+
<
targetNamespace>http://richfaces.org/cdk/xhtml-el</targetNamespace>
+
<outputFile>generated-resources/META-INF/cdk/attributes/xhtml-el.xml</outputFile>
+ </properties>
<classpath>
- <element>
- <groupId>com.sun.xsom</groupId>
- <artifactId>xsom</artifactId>
- </element>
- <element>
- <groupId>com.google.collections</groupId>
- <artifactId>google-collections</artifactId>
- </element>
- </classpath>
-
<source>${project.basedir}/src/main/script/SchemaAttributesParserTask.groovy</source>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.codehaus.groovy.maven.runtime</groupId>
- <artifactId>gmaven-runtime-1.6</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <inherited>true</inherited>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <useManifestOnlyJar>false</useManifestOnlyJar>
- <useSystemClassLoader>true</useSystemClassLoader>
- </configuration>
- </plugin>
- <!--
- plugin> <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId> <executions>
<execution>
- <goals> <goal>xjc</goal> </goals> </execution>
</executions>
- <configuration> <packageName>org.richfaces.cdk.model</packageName>
- </configuration> </plugin
- -->
- </plugins>
- <resources>
- <resource>
- <directory>
- src/main/resources
- </directory>
- </resource>
- <resource>
- <directory>
- ${project.build.directory}/generated-resources
- </directory>
- </resource>
- </resources>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.6</version>
- <scope>test</scope>
- </dependency>
+ <element>
+ <groupId>com.sun.xsom</groupId>
+ <artifactId>xsom</artifactId>
+ </element>
+ <element>
+
<groupId>com.google.collections</groupId>
+
<artifactId>google-collections</artifactId>
+ </element>
+ </classpath>
+
<source>${project.basedir}/src/main/script/SchemaAttributesParserTask.groovy</source>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.groovy.maven.runtime</groupId>
+ <artifactId>gmaven-runtime-1.6</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <useManifestOnlyJar>false</useManifestOnlyJar>
+ <useSystemClassLoader>true</useSystemClassLoader>
+ </configuration>
+ </plugin>
+ <!--
+ plugin> <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
<executions> <execution>
+ <goals> <goal>xjc</goal> </goals>
</execution> </executions>
+ <configuration>
<packageName>org.richfaces.cdk.model</packageName>
+ </configuration> </plugin
+ -->
+ </plugins>
+ <resources>
+ <resource>
+ <directory>
+ src/main/resources
+ </directory>
+ </resource>
+ <resource>
+ <directory>
+ ${project.build.directory}/generated-resources
+ </directory>
+ </resource>
+ </resources>
+ </build>
+ <dependencies>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- <version>1.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.freemarker</groupId>
- <artifactId>freemarker</artifactId>
- <version>2.3.9</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>annotations</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>attributes</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>xinclude</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>com.sun.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>2.0.3-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.el</groupId>
- <artifactId>jboss-el</artifactId>
- <version>1.0_02.CR4</version>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>2.9.1</version>
- <exclusions>
- <exclusion>
- <artifactId>xml-apis</artifactId>
- <groupId>xml-apis</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <!--
- <dependency> <groupId>com.google.collections</groupId>
- <artifactId>google-collections</artifactId>
- <version>1.0-rc2</version> </dependency> <dependency>
- <groupId>org.w3c.css</groupId> <artifactId>sac</artifactId>
- <version>1.3</version> </dependency>
- -->
- <dependency>
- <groupId>com.wutka</groupId>
- <artifactId>dtdparser</artifactId>
- <version>1.21</version>
- </dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ <version>1.2</version>
+ </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>2.5.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.collections</groupId>
- <artifactId>google-collections</artifactId>
- </dependency><!--
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- </dependency>
- --><dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>com.google.inject.extensions</groupId>
- <artifactId>guice-multibindings</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>com.google.inject.extensions</groupId>
- <artifactId>guice-assisted-inject</artifactId>
- <version>2.0</version>
- </dependency>
+ <dependency>
+ <groupId>org.freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>attributes</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>xinclude</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>2.0.3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ <version>1.0_02.CR4</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>xml-apis</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!--
+ <dependency> <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ <version>1.0-rc2</version> </dependency>
<dependency>
+ <groupId>org.w3c.css</groupId>
<artifactId>sac</artifactId>
+ <version>1.3</version> </dependency>
+ -->
+ <dependency>
+ <groupId>com.wutka</groupId>
+ <artifactId>dtdparser</artifactId>
+ <version>1.21</version>
+ </dependency>
- <dependency>
- <groupId>com.sun.xsom</groupId>
- <artifactId>xsom</artifactId>
- </dependency>
- <!--
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- <exclusions>
- <exclusion>
- <artifactId>xml-apis</artifactId>
- <groupId>xml-apis</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- --></dependencies>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xsom</groupId>
+ <artifactId>xsom</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>xml-apis</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>2.0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>2.0.9</version>
+ </dependency>
+<!-- <dependency>
+ <groupId>com.google.code.guice</groupId>
+ <artifactId>guice</artifactId>
+ <version>1.0</version>
+ </dependency>-->
+
+<!-- <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>-->
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-multibindings</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <!-- <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-assisted-inject</artifactId>
+ <version>2.0</version>
+ </dependency>-->
+ </dependencies>
</project>
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -36,6 +36,7 @@
import org.richfaces.cdk.apt.AptModule;
import org.richfaces.cdk.freemarker.FreeMakerModule;
import org.richfaces.cdk.generate.java.ClassGeneratorModule;
+import org.richfaces.cdk.generate.java.taghandler.TagHandlerModule;
import org.richfaces.cdk.generate.taglib.TaglibModule;
import org.richfaces.cdk.model.ModelModule;
import org.richfaces.cdk.templatecompiler.TemplateModule;
@@ -109,8 +110,17 @@
public void init(){
- injector = Guice.createInjector(Stage.PRODUCTION,new CdkConfigurationModule(),new
AptModule(),new ModelModule(),
- new ClassGeneratorModule(),new FreeMakerModule(),new TemplateModule(),new
XmlModule(),new TaglibModule());
+ injector = Guice.createInjector(Stage.PRODUCTION,
+ new CdkConfigurationModule(),
+ new AptModule(),
+ new ModelModule(),
+ new TagHandlerModule(),
+ new ClassGeneratorModule(),
+ new FreeMakerModule(),
+ new TemplateModule(),
+ new XmlModule(),
+ new TaglibModule());
+
// Create builder instance.
this.libraryBuilder = injector.getInstance(LibraryBuilder.class);
}
@@ -118,6 +128,8 @@
public void execute() {
checkNotNull(libraryBuilder, "initialized");
libraryBuilder.build();
+
+// libraryBuilder.generate(); // TODO ?
}
public static final class EmptyFileManager implements FileManager {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -38,22 +38,18 @@
*/
public interface LibraryBuilder {
-
-
-
/**
* <p class="changed_added_4_0">
* Build library model from all available sources.
* </p>
*
- * @param templates
* @throws CdkException
*/
public void build() throws CdkException ;
/**
* Generate all types of files from library model.
- * @param library
+ *
* @throws CdkException
*/
public void generate() throws CdkException ;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -52,10 +52,13 @@
@Inject
private CompilationTaskFactory taskFactory;
-
@Inject
private Set<CdkWriter> generators;
+ public AptBuilder() {
+ System.out.println("AptBuilder.AptBuilder");
+ }
+
public void build() throws CdkException {
CompilationTask task = taskFactory.get();
if (!task.call()) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -50,6 +50,7 @@
setBinder.addBinding().to(RendererProcessor.class);
setBinder.addBinding().to(ConverterProcessor.class);
setBinder.addBinding().to(ValidatorProcessor.class);
+
bind(Processor.class).to(CdkProcessor.class);
bind(CompilationTaskFactory.class).to(TaskFactoryImpl.class);
bind(LibraryBuilder.class).to(AptBuilder.class);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -15,7 +15,7 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
@@ -46,7 +46,7 @@
* @return
*/
public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends
Annotation> annotation,
- ClassDescription type) {
+ ClassName type) {
Set<BeanProperty> properties = Sets.newHashSet();
List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(asTypeElement(type));
@@ -113,15 +113,15 @@
return properties;
}
- private ClassDescription asClassDescription(TypeMirror type) {
- return new ClassDescription(type.toString());
+ private ClassName asClassDescription(TypeMirror type) {
+ return new ClassName(type.toString());
}
- public String getDocComment(ClassDescription componentElement) {
+ public String getDocComment(ClassName componentElement) {
return
this.processingEnv.getElementUtils().getDocComment(asTypeElement(componentElement));
}
- public Object getConstant(ClassDescription componentElement, String name) {
+ public Object getConstant(ClassName componentElement, String name) {
List<VariableElement> fieldsIn =
ElementFilter.fieldsIn(this.processingEnv.getElementUtils().getAllMembers(asTypeElement(componentElement)));
Object value = null;
@@ -138,11 +138,11 @@
}
- public void visitSupertypes(ClassDescription type, SuperTypeVisitor visitor) {
+ public void visitSupertypes(ClassName type, SuperTypeVisitor visitor) {
visitSupertypes(asTypeElement(type).asType(),visitor);
}
- private TypeElement asTypeElement(ClassDescription type) {
+ private TypeElement asTypeElement(ClassName type) {
return processingEnv.getElementUtils().getTypeElement(type.toString());
}
@@ -167,7 +167,7 @@
private Element element;
private boolean exists;
private final String name;
- private ClassDescription type;
+ private ClassName type;
/**
* <p class="changed_added_4_0">
@@ -244,7 +244,7 @@
return processingEnv.getElementUtils().getDocComment(element);
}
- public ClassDescription getType() {
+ public ClassName getType() {
return type;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -23,17 +23,15 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.model.ClassDescription;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import javax.faces.view.facelets.BehaviorHandler;
+import java.lang.annotation.Annotation;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -46,8 +44,11 @@
public void process(TypeElement element) throws CdkProcessingException {
JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
- BehaviorModel behaviorModel = new BehaviorModel(behavior.id(), new
ClassDescription(element.getQualifiedName().toString()));
+ BehaviorModel behaviorModel = new BehaviorModel(behavior.id());
setClassNames(element, behaviorModel, behavior);
+
+ setTagInfo(behavior.tag(), behaviorModel);
+
setDescription(element, behaviorModel);
getLibrary().getBehaviors().add(behaviorModel);
@@ -58,24 +59,18 @@
return JsfBehavior.class;
}
- // TODO remove this method
- public static void setClassNames(TypeElement componentElement, BehaviorModel
validatorModel, JsfBehavior validator) {
- String baseClass = componentElement.getQualifiedName().toString();
- if (validator == null) {
- validatorModel.setClassNames(baseClass, null);
+ public void setClassNames(TypeElement element, BehaviorModel behaviorModel,
JsfBehavior behavior) {
+ String baseClass = element.getQualifiedName().toString();
+ if (behavior == null) {
+ behaviorModel.setClassNames(baseClass, null);
return;
}
- String validatorClass = validator.behaviorClass();
- if (validatorClass == null || validatorClass.isEmpty() ||
baseClass.equals(validatorClass)) {
- if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
- throw new IllegalStateException("You can't use an abstract class
as a validator. Please set the validatorClass or remove the 'abstract'
modifier.");
- } else {
- validatorModel.setClassNames(baseClass, null);
- }
- } else {
- validatorModel.setClassNames(validatorClass, baseClass);
- }
+ setClassNames(element, behaviorModel, behavior.behaviorClass(), baseClass);
}
+ @Override
+ protected String getDafaultParentTagHandlerClass() {
+ return BehaviorHandler.class.getName();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -25,46 +25,27 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.faces.event.FacesEvent;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.MirroredTypeException;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeMirror;
-
+import com.google.common.collect.Lists;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Attributes;
-import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.annotations.DefaultValue;
-import org.richfaces.cdk.annotations.DisplayName;
+import org.richfaces.cdk.annotations.*;
import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.EventNames;
-import org.richfaces.cdk.annotations.Facet;
-import org.richfaces.cdk.annotations.Facets;
-import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.annotations.Fires;
-import org.richfaces.cdk.annotations.Generate;
-import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.annotations.Signature;
-import org.richfaces.cdk.annotations.SuggestedValue;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.FacetModel;
-import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.model.ComponentModel.Type;
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
-import com.google.common.collect.Lists;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.faces.event.FacesEvent;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeMirror;
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
/**
* <p class="changed_added_4_0">That class process component-related
annotations such as {@link Component} or
@@ -82,8 +63,8 @@
// Process class-level annotations.
// Calculate type for base UI component class.
String explicitType = getComponentType(componentElement);
- // Because component type is a primary key for components collection, we have to
infer explicit
- // value here.
+ // Because component type is a primary key for components collection,
+ // we have to infer explicit value here.
String type = getNamingConventions().inferComponentType(explicitType,
componentElement.getQualifiedName().toString());
ComponentModel component = new ComponentModel();
@@ -91,17 +72,22 @@
// Should that component be generated ?
setClassNames(componentElement, component);
setComponentProperties(componentElement, component);
+
+ Component annotation = componentElement.getAnnotation(Component.class);
+ component.setGenerate(annotation.generate());
+ setTagInfo(annotation.tag(), component);
+
library.getComponents().add(component);
}
+
+
protected String getComponentType(TypeElement componentElement) {
Component componentAnnotation = componentElement.getAnnotation(Component.class);
- String explicitType = componentAnnotation.value();
- return explicitType;
+ return componentAnnotation.value();
}
-
private void setComponentProperties(TypeElement componentElement, ComponentModel
component)
throws CdkException {
@@ -200,28 +186,16 @@
private void setClassNames(TypeElement componentElement, ComponentModel component) {
Generate generate = componentElement.getAnnotation(Generate.class);
+ String name = generate == null ? null : generate.value();
- // Set generated and base class names.
- ClassDescription baseClass = asClassDesctiption(componentElement);
+ String baseClass = componentElement.getQualifiedName().toString();
- if (null != generate) {
- component.setComponentClass(new ClassDescription(generate.value()));
- component.setBaseClass(baseClass);
- component.setGenerate(true);
- } else if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
-
- // Final component class will be set by validator.
- component.setBaseClass(baseClass);
- component.setGenerate(true);
- } else {
- component.setComponentClass(baseClass);
- component.setGenerate(false);
- }
+ setClassNames(componentElement, component, name, baseClass);
}
protected void processAttributes(TypeElement componentElement, final ComponentModel
component)
throws CdkException {
-
+
// Process XML files with standard attributes definitions.
Attributes attributes = componentElement.getAnnotation(Attributes.class);
@@ -239,7 +213,7 @@
sourceUtils.visitSupertypes(asClassDesctiption(componentElement), new
SuperTypeVisitor() {
@Override
- public void visit(ClassDescription type) {
+ public void visit(ClassName type) {
try {
component.getAttributes().putAll(parseProperties(
CdkEntityResolver.URN_ATTRIBUTES + type.toString() +
".xml"));
@@ -287,18 +261,21 @@
Signature signature = beanProperty.getAnnotation(Signature.class);
if (null != signature) {
- List<ClassDescription> parameters = Lists.newArrayList();
+ List<ClassName> parameters = Lists.newArrayList();
+
try {
for (Class<?> parameterType : signature.parameters()) {
- parameters.add(new ClassDescription(parameterType.getName()));
+ parameters.add(new ClassName(parameterType.getName()));
}
+ } catch (MirroredTypeException e) {
+ TypeMirror parameterType = e.getTypeMirror();
+ parameters.add(new ClassName(parameterType.toString()));
} catch (MirroredTypesException e) {
for (TypeMirror parameterType : e.getTypeMirrors()) {
- parameters.add(new ClassDescription(parameterType.toString()));
+ parameters.add(new ClassName(parameterType.toString()));
}
}
-
// signature parameters always should be replaced.
attribute.setSignature(parameters);
@@ -334,7 +311,6 @@
// Flags.
attribute.setGenerate(!beanProperty.isExists() || null !=
beanProperty.getAnnotation(Generate.class));
}
-
}
private void setBehaviorEvent(Property attribute, EventName eventName) {
@@ -351,4 +327,9 @@
public Class<? extends Annotation> getProcessedAnnotation() {
return Component.class;
}
+
+ @Override
+ protected String getDafaultParentTagHandlerClass() {
+ return ComponentHandler.class.getName();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -21,18 +21,17 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.annotations.JsfConverter;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ConverterModel;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.MirroredTypeException;
+import javax.faces.view.facelets.ConverterHandler;
+import java.lang.annotation.Annotation;
-import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.annotations.JsfConverter;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ConverterModel;
-
/**
* @author akolonitsky
* @since Jan 4, 2010
@@ -48,14 +47,16 @@
converterModel.setConverterId(converter.id());
try {
- converterModel.setConverterForClass(new
ClassDescription(converter.forClass().getName()));
+ converterModel.setConverterForClass(new
ClassName(converter.forClass().getName()));
} catch (MirroredTypeException e) {
- converterModel.setConverterForClass(new
ClassDescription(e.getTypeMirror().toString()));
+ converterModel.setConverterForClass(new
ClassName(e.getTypeMirror().toString()));
}
setDescription(element, converterModel);
setClassNames(element, converterModel, converter);
+ setTagInfo(converter.tag(), converterModel);
+
getLibrary().getConverters().add(converterModel);
}
@@ -65,22 +66,18 @@
}
// TODO same method in the ValidatorProcessor move their in one class
- public static void setClassNames(TypeElement componentElement, ConverterModel
converterModel, JsfConverter converter) {
+ public void setClassNames(TypeElement componentElement, ConverterModel
converterModel, JsfConverter converter) {
String baseClass = componentElement.getQualifiedName().toString();
if (converter == null) {
converterModel.setClassNames(baseClass, null);
return;
}
- String validatorClass = converter.converterClass();
- if (validatorClass == null || validatorClass.isEmpty() ||
baseClass.equals(validatorClass)) {
- if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
- throw new IllegalStateException("You can't use an abstract class
as a validator. Please set the validatorClass or remove the 'abstract'
modifier.");
- } else {
- converterModel.setClassNames(baseClass, null);
- }
- } else {
- converterModel.setClassNames(validatorClass, baseClass);
- }
+ setClassNames(componentElement, converterModel, converter.converterClass(),
baseClass);
}
+
+ @Override
+ protected String getDafaultParentTagHandlerClass() {
+ return ConverterHandler.class.getName();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,25 +1,27 @@
package org.richfaces.cdk.apt;
-import java.util.Map;
-
-import javax.lang.model.element.TypeElement;
-
+import com.google.inject.Inject;
+import com.google.inject.Provider;
import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.DisplayName;
import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeMirror;
+import java.util.List;
+import java.util.Map;
-public class ProcessorBase {
+public abstract class ProcessorBase {
-
+ private static final String TAG_HANDLER_DEFULT_CLASS =
Tag.DEFAULT.class.getName().replace('$', '.');
+
@Inject
private ComponentLibrary library;
@@ -56,6 +58,48 @@
return this.namingConventions;
}
+ protected void setTagInfo(Tag tag, ModelElementBase model) {
+ String tagHandlerClass = null;
+ try {
+ tagHandlerClass = tag.handler().getName();
+ } catch (MirroredTypesException mirror) {
+ List<? extends TypeMirror> mirrors = mirror.getTypeMirrors();
+ if (!mirrors.isEmpty()) {
+ tagHandlerClass = mirrors.get(0).toString();
+ }
+ } catch (MirroredTypeException mirror) {
+ tagHandlerClass = mirror.getTypeMirror().toString();
+ }
+
+ if (TAG_HANDLER_DEFULT_CLASS.equals(tagHandlerClass)) {
+ tagHandlerClass = null;
+ }
+
+ String tagHandlerParentClass = null;
+ try {
+ tagHandlerParentClass = tag.baseHandler().getName();
+ } catch (MirroredTypesException mirror) {
+ List<? extends TypeMirror> mirrors = mirror.getTypeMirrors();
+ if (!mirrors.isEmpty()) {
+ tagHandlerParentClass = mirrors.get(0).toString();
+ }
+ } catch (MirroredTypeException mirror) {
+ tagHandlerParentClass = mirror.getTypeMirror().toString();
+ }
+
+ if (TAG_HANDLER_DEFULT_CLASS.equals(tagHandlerParentClass)) {
+ tagHandlerParentClass = getDafaultParentTagHandlerClass();
+ }
+
+ if (!tag.name().isEmpty()) {
+ model.setTag(new TagModel(tag.name(), tagHandlerClass,
tagHandlerParentClass));
+ }
+ }
+
+ protected String getDafaultParentTagHandlerClass() {
+ return null;
+ }
+
/**
* <p class="changed_added_4_0"></p>
* @param component
@@ -99,12 +143,26 @@
}
}
+ protected void setClassNames(TypeElement componentElement, ModelElementBase
modelElement,
+ String generatedClass, String baseClass) {
+
+ if (generatedClass == null || generatedClass.isEmpty() ||
baseClass.equals(generatedClass)) {
+ if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
+ generatedClass =
namingConventions.inferUIComponentClass(modelElement.getId(), null, baseClass, true);
+ modelElement.setClassNames(generatedClass, baseClass);
+ } else {
+ modelElement.setClassNames(baseClass, null);
+ }
+ } else {
+ modelElement.setClassNames(generatedClass, baseClass);
+ }
+ }
+
protected Map<String, Property> parseProperties(String attributesConfig) {
- return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES
+attributesConfig+".xml");
+ return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES +
attributesConfig + ".xml");
}
- protected ClassDescription asClassDesctiption(TypeElement componentElement) {
- return new ClassDescription(componentElement.getQualifiedName().toString());
+ protected ClassName asClassDesctiption(TypeElement componentElement) {
+ return new ClassName(componentElement.getQualifiedName().toString());
}
-
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -26,7 +26,7 @@
import java.lang.annotation.Annotation;
import java.util.Set;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
/**
* <p class="changed_added_4_0"></p>
@@ -36,38 +36,38 @@
public class ReflectionUtils implements SourceUtils {
/* (non-Javadoc)
- * @see
org.richfaces.cdk.apt.SourceUtils#getBeanPropertiesAnnotatedWith(java.lang.Class,
org.richfaces.cdk.model.ClassDescription)
+ * @see
org.richfaces.cdk.apt.SourceUtils#getBeanPropertiesAnnotatedWith(java.lang.Class,
org.richfaces.cdk.model.ClassName)
*/
@Override
public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends
Annotation> annotation,
- ClassDescription type) {
+ ClassName type) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.apt.SourceUtils#getConstant(org.richfaces.cdk.model.ClassDescription,
java.lang.String)
+ * @see
org.richfaces.cdk.apt.SourceUtils#getConstant(org.richfaces.cdk.model.ClassName,
java.lang.String)
*/
@Override
- public Object getConstant(ClassDescription componentElement, String name) {
+ public Object getConstant(ClassName componentElement, String name) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.apt.SourceUtils#getDocComment(org.richfaces.cdk.model.ClassDescription)
+ * @see
org.richfaces.cdk.apt.SourceUtils#getDocComment(org.richfaces.cdk.model.ClassName)
*/
@Override
- public String getDocComment(ClassDescription componentElement) {
+ public String getDocComment(ClassName componentElement) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
- * @see
org.richfaces.cdk.apt.SourceUtils#visitSupertypes(org.richfaces.cdk.model.ClassDescription,
org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor)
+ * @see
org.richfaces.cdk.apt.SourceUtils#visitSupertypes(org.richfaces.cdk.model.ClassName,
org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor)
*/
@Override
- public void visitSupertypes(ClassDescription type, SuperTypeVisitor visitor) {
+ public void visitSupertypes(ClassName type, SuperTypeVisitor visitor) {
// TODO Auto-generated method stub
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -64,7 +64,12 @@
}
protected String getComponentType(TypeElement componentElement) {
- return componentElement.getAnnotation(Component.class).value();
+ Component annotation = componentElement.getAnnotation(Component.class);
+ if (annotation != null) {
+ return annotation.value();
+ }
+
+ return null;
}
private void setRendererProperties(TypeElement componentElement, RendererModel
renderer)
@@ -123,10 +128,10 @@
// Generate generate = componentElement.getAnnotation(Generate.class);
//
// // Set generated and base class names.
-// ClassDescription baseClass = new
ClassDescription(componentElement.getQualifiedName().toString());
+// ClassName baseClass = new
ClassName(componentElement.getQualifiedName().toString());
//
// if (null != generate) {
-// renderer.setRendererClass(new ClassDescription(generate.value()));
+// renderer.setRendererClass(new ClassName(generate.value()));
// renderer.setBaseClass(baseClass);
// renderer.setGenerate(true);
// } else if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -26,7 +26,7 @@
import java.lang.annotation.Annotation;
import java.util.Set;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import com.google.inject.ProvidedBy;
@@ -47,7 +47,7 @@
*
*/
public interface SuperTypeVisitor {
- public void visit(ClassDescription type);
+ public void visit(ClassName type);
}
@@ -74,7 +74,7 @@
*/
public String getDocComment();
- public ClassDescription getType();
+ public ClassName getType();
/**
* <p class="changed_added_4_0"></p>
@@ -97,13 +97,13 @@
* @return
*/
public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends
Annotation> annotation,
- ClassDescription type);
+ ClassName type);
- public String getDocComment(ClassDescription componentElement);
+ public String getDocComment(ClassName componentElement);
- public Object getConstant(ClassDescription componentElement, String name);
+ public Object getConstant(ClassName componentElement, String name);
- public void visitSupertypes(ClassDescription type, SuperTypeVisitor visitor);
+ public void visitSupertypes(ClassName type, SuperTypeVisitor visitor);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -21,17 +21,15 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfValidator;
-import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ValidatorModel;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import javax.faces.view.facelets.ValidatorHandler;
+import java.lang.annotation.Annotation;
+
/**
* @author akolonitsky
* @since Jan 13, 2010
@@ -43,10 +41,12 @@
public void process(TypeElement element) throws CdkProcessingException {
JsfValidator validator = element.getAnnotation(JsfValidator.class);
- ValidatorModel validatorModel = new ValidatorModel(validator.id(), new
ClassDescription(element.getQualifiedName().toString()));
+ ValidatorModel validatorModel = new ValidatorModel(validator.id());
setClassNames(element, validatorModel, validator);
setDescription(element, validatorModel);
+ setTagInfo(validator.tag(), validatorModel);
+
getLibrary().getValidators().add(validatorModel);
}
@@ -55,22 +55,19 @@
return JsfValidator.class;
}
- public static void setClassNames(TypeElement componentElement, ValidatorModel
validatorModel, JsfValidator validator) {
+ public void setClassNames(TypeElement componentElement, ValidatorModel
validatorModel,
+ JsfValidator validator) {
String baseClass = componentElement.getQualifiedName().toString();
if (validator == null) {
validatorModel.setClassNames(baseClass, null);
return;
}
- String validatorClass = validator.validatorClass();
- if (validatorClass == null || validatorClass.isEmpty() ||
baseClass.equals(validatorClass)) {
- if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
- throw new IllegalStateException("You can't use an abstract class
as a validator. Please set the validatorClass or remove the 'abstract'
modifier.");
- } else {
- validatorModel.setClassNames(baseClass, null);
- }
- } else {
- validatorModel.setClassNames(validatorClass, baseClass);
- }
+ setClassNames(componentElement, validatorModel, validator.validatorClass(),
baseClass);
}
+
+ @Override
+ protected String getDafaultParentTagHandlerClass() {
+ return ValidatorHandler.class.getName();
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/CdkConfiguration.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -42,7 +42,7 @@
private Logger log;
@Inject
- public CdkConfiguration(ObjectWrapper wrapper,Logger log) {
+ public CdkConfiguration(ObjectWrapper wrapper, Logger log) {
super();
this.log = log;
@@ -54,10 +54,4 @@
// Add context variables
// this.setSharedVariable("context", new BeanModel(context, new
BeansWrapper()));
}
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the context
- */
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -26,6 +26,7 @@
package org.richfaces.cdk.freemarker;
import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.TagModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
@@ -55,6 +56,10 @@
return new ModelElementBaseTemplateModel((ModelElementBase) obj, this);
}
+ if (obj instanceof TagModel) {
+ return new TagTemplateModel((TagModel) obj, this);
+ }
+
return super.wrap(obj);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -25,13 +25,14 @@
package org.richfaces.cdk.freemarker;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.util.Strings;
-
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.util.Strings;
/**
* <p class="changed_added_4_0"></p>
@@ -44,10 +45,11 @@
/**
* <p class="changed_added_4_0"></p>
+ * @param name
* @param object
* @param wrapper
*/
- public PropertyModel(String name,Property object, BeansWrapper wrapper) {
+ public PropertyModel(String name, Property object, BeansWrapper wrapper) {
super(object, wrapper);
this.name = name;
property = object;
@@ -71,8 +73,24 @@
value = getSetterName();
} else if ("name".equals(key)) {
value = getName();
+ } else if ("capitalizeName".equals(key)) {
+ value = capitalizeName();
+ } else if ("simpleTypeName".equals(key)) {
+ value = this.property.getType().getSimpleName();
+ } else if ("boxingClass".equals(key)) {
+ value = this.property.getType().getBoxingName();
+ } else if ("isPrimitive".equals(key)) {
+ value = this.property.isPrimitive();
+ } else if ("isPredefined".equals(key)) {
+ value = this.property.isPrimitive() ||
isFromJavaLang(this.property.getType());
+ } else if ("typeForCasting".equals(key)) {
+ value = typeForCasting();
} else if ("required".equals(key)) {
value = String.valueOf(this.property.isRequired());
+ } else if ("isBingingAttribute".equals(key)) {
+ value = isBingingAttribute();
+ } else if ("isBinging".equals(key)) {
+ value = isBinging();
} else {
return super.get(key);
}
@@ -80,12 +98,99 @@
return wrapper.wrap(value);
}
+ private String typeForCasting() {
+ ClassName type = this.property.getType();
+ return ClassName.getSimpleName(type.isPrimitive() ? type.getBoxingName() :
type.getSimpleName());
+ }
+
// Model utility methods.
public String getGetterName() {
- return property.getType().getGetterPrefix() +
Strings.firstToUpperCase(getName().toString());
+ return property.getType().getGetterPrefix() + capitalizeName();
}
public String getSetterName() {
- return "set" + Strings.firstToUpperCase(getName().toString());
+ return "set" + capitalizeName();
}
+
+ public String capitalizeName() {
+ return Strings.firstToUpperCase(getName());
+ }
+
+ public boolean isFromJavaLang(ClassName type) {
+ return "java.lang".equals(type.getPackage());
+ }
+
+ public String getTypeName() {
+ ClassName type = this.property.getType();
+ return isFromJavaLang(type) ? type.getSimpleName() : type.getName();
+ }
+
+ public boolean isBingingAttribute() {
+ return isBinging() || isInstanceof("javax.el.MethodExpression");
+ }
+
+ public boolean isBinging() {
+ return isInstanceof("javax.faces.el.MethodBinding");
+ }
+
+ public boolean isInstanceof(String name) {
+ String classname = this.property.getType().getName();
+ if (null == classname) {
+ String msg = "classname not set in " + getClass().getName() +
" for element " + getName();
+ getLog().error(msg);
+ throw new NullPointerException(msg);
+ }
+
+ if (classname.equals(name)) {
+ return true;
+ }
+
+ try {
+ Class<?> beanClass = getLoader().loadClass(classname);
+ Class<?> superClass = getLoader().loadClass(name);
+ return superClass.isAssignableFrom(beanClass);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+// getLog().warn("Could't instantiate for testing class " +
classname);
+ } catch (Exception e) {
+// getLog().warn("Error in testing class " + classname);
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+/* public String getMethodArgsClasses(){
+ if(null != this._methodargs){
+ StringBuffer result = new StringBuffer();
+ String[] classes = SEPARATOR_PATTERN.split(this._methodargs.trim());
+ for (int i = 0; i < classes.length; i++) {
+ String argumentClass = classes[i];
+
+ if (argumentClass.length() != 0) {
+ if(i!=0){
+ result.append(',');
+ }
+ result.append(argumentClass).append(".class");
+ } else {
+ if (classes.length == 1) {
+ //no arguments
+ break;
+ } else {
+ throw new IllegalArgumentException("Error parsing methodargs: " +
this._methodargs);
+ }
+ }
+ }
+ return result.toString();
+ } else {
+ return null;
+ }
+ }*/
+
+ private ClassLoader getLoader() {
+ return Thread.currentThread().getContextClassLoader(); // TODO ???
+ }
+
+ private Logger getLog() {
+ return null;
+ }
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.freemarker;
+
+import org.richfaces.cdk.model.*;
+
+import java.util.*;
+
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.beans.BeanModel;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import com.google.common.base.Predicate;
+
+/**
+ * @author akolonitsky
+ * @since Feb 23, 2010
+ */
+public class TagTemplateModel extends BeanModel implements TemplateModel{
+ private final TagModel model;
+ private Set<EventName> eventNames;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param object
+ * @param wrapper
+ */
+ public TagTemplateModel(TagModel object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ model = object;
+ }
+
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ if ("attributes".equals(key)) {
+ return attributes();
+ } else if ("generatedAttributes".equals(key)) {
+ return generatedAttributes();
+ } else if ("eventNames".equals(key)) {
+ return eventNames();
+ } else if ("defaultEvent".equals(key)) {
+ return defaultEvent();
+ } else if ("objectType".equals(key)) {
+ return getObjectType();
+ }
+
+ return super.get(key);
+ }
+
+ private TemplateModel getObjectType() throws TemplateModelException {
+ ModelElementBase modelElementBase = this.model.getModel();
+ if (modelElementBase instanceof ComponentModel) {
+ return wrapper.wrap("Component");
+ }
+
+ if (modelElementBase instanceof BehaviorModel) {
+ return wrapper.wrap("Behavior");
+ }
+
+ if (modelElementBase instanceof ConverterModel) {
+ return wrapper.wrap("Converter");
+ }
+
+ if (modelElementBase instanceof ValidatorModel) {
+ return wrapper.wrap("Validator");
+ }
+
+ return null;
+ }
+
+ private TemplateModel eventNames() throws TemplateModelException {
+ return wrapper.wrap(getEventNames());
+ }
+
+ private TemplateModel defaultEvent() throws TemplateModelException {
+ Set<EventName> names = getEventNames();
+
+ try {
+ EventName defaultEvent = Iterables.find(names, new
Predicate<EventName>() {
+ @Override
+ public boolean apply(EventName event) {
+ return event.isDefaultEvent();
+ }
+ });
+
+ return wrapper.wrap(defaultEvent);
+ } catch (NoSuchElementException e) {
+ return wrapper.wrap(null);
+ }
+ }
+
+ private Set<EventName> getEventNames() {
+ if (null == eventNames) {
+ eventNames = Sets.newHashSet();
+
+ for (Property property : model.getModel().getAttributes().values()) {
+ eventNames.addAll(property.getEventNames());
+ }
+ }
+
+ return eventNames;
+ }
+
+ private TemplateModel generatedAttributes() throws TemplateModelException {
+ Map<String, Property> attributes = model.getModel().getAttributes();
+ Collection<PropertyModel> models = new
ArrayList<PropertyModel>(attributes.size());
+ for (Map.Entry<String, Property> entry : attributes.entrySet()) {
+ if (entry.getValue().isGenerate()) {
+ models.add(new PropertyModel(entry.getKey(), entry.getValue(),
wrapper));
+ }
+ }
+ return wrapper.wrap(models);
+ }
+ private TemplateModel attributes() throws TemplateModelException {
+ Map<String, Property> attributes = model.getModel().getAttributes();
+ Collection<PropertyModel> models = new
ArrayList<PropertyModel>(attributes.size());
+ for (Map.Entry<String, Property> entry : attributes.entrySet()) {
+ models.add(new PropertyModel(entry.getKey(), entry.getValue(), wrapper));
+ }
+ return wrapper.wrap(models);
+ }
+
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -40,7 +40,7 @@
*/
@Override
protected void configure() {
- Multibinder<CdkWriter> setBinder =
Multibinder.newSetBinder(binder(),CdkWriter.class);
+ Multibinder<CdkWriter> setBinder = Multibinder.newSetBinder(binder(),
CdkWriter.class);
setBinder.addBinding().to(ComponentClassGenerator.class);
setBinder.addBinding().to(ConverterClassGenerator.class);
setBinder.addBinding().to(ValidatorClassGenerator.class);
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java.taghandler;
+
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Output;
+import org.richfaces.cdk.Outputs;
+import org.richfaces.cdk.model.TagModel;
+import org.richfaces.cdk.model.Trackable;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+public class TagHandlerClassGenerator {
+
+ private static final String TAGHANDLER_TEMPLATE = "taghandler.ftl";
+
+ private final Template template;
+
+ private final FileManager output;
+
+ @Inject
+ public TagHandlerClassGenerator(Configuration configuration,
+ @Output(Outputs.JAVA_CLASSES) FileManager output) {
+ this.output = output;
+
+ try {
+ template = configuration.getTemplate(TAGHANDLER_TEMPLATE);
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
+
+ public boolean process(TagModel tag) throws CdkException {
+ try {
+ Writer writer = getOutput(tag);
+
+ template.process(tag, writer);
+ writer.close();
+ } catch (IOException e) {
+ throw new CdkException(e);
+ } catch (TemplateException e) {
+ throw new CdkException(e);
+ }
+
+ return false;
+ }
+
+ private Writer getOutput(TagModel tag) throws CdkException {
+ long lastModified = Long.MIN_VALUE;
+
+ if (tag instanceof Trackable) {
+ lastModified = ((Trackable) tag).lastModified();
+ }
+
+ try {
+ return output.createOutput(getOutputFileName(tag), lastModified);
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
+
+ private String getOutputFileName(TagModel tag) {
+ return tag.getTagHandlerClass().replace('.', File.separatorChar) +
".java";
+ }
+}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java.taghandler;
+
+import org.richfaces.cdk.model.*;
+
+/**
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+public class TagHandlerGeneratorVisitor extends EmptyVisitor {
+ public void visitComponent(ComponentModel model) {
+ generateTagHandler(model);
+ }
+
+ public void visitConverter(ConverterModel model) {
+ generateTagHandler(model);
+ }
+
+ public void visitValidator(ValidatorModel model) {
+ generateTagHandler(model);
+ }
+
+ public void visitBehavior(BehaviorModel model) {
+ generateTagHandler(model);
+ }
+
+ private void generateTagHandler(ModelElementBase model) {
+ TagModel tag = model.getTag();
+ if (tag == null) {
+ return;
+ }
+
+ generateTagHandler(tag);
+ }
+
+ private void generateTagHandler(TagModel model) {
+
+ }
+}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java.taghandler;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+import org.richfaces.cdk.CdkWriter;
+
+/**
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+public class TagHandlerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ Multibinder.newSetBinder(binder(), CdkWriter.class)
+ .addBinding().to(TagHandlerWriter.class);
+ }
+}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerWriter.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java.taghandler;
+
+import com.google.inject.Inject;
+import org.richfaces.cdk.*;
+import org.richfaces.cdk.generate.taglib.TaglibGeneratorVisitor;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+public class TagHandlerWriter implements CdkWriter {
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ @Output(Outputs.JAVA_CLASSES)
+ private FileManager output;
+
+ @Override
+ public void render() throws CdkException {
+ TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
+ library.accept(visitor);
+ }
+
+ public ComponentLibrary getLibrary() {
+ return library;
+ }
+
+ public void setLibrary(ComponentLibrary library) {
+ this.library = library;
+ }
+
+ public FileManager getOutput() {
+ return output;
+ }
+
+ public void setOutput(FileManager output) {
+ this.output = output;
+ }
+}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.taglib;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.richfaces.cdk.model.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author akolonitsky
+ * @since Feb 3, 2010
+ */
+public class TaglibGeneratorVisitor implements Visitor {
+ private static final String COMPONENT = "component";
+ private static final String COMPONENT_TYPE = "component-type";
+
+ private Document document = DocumentHelper.createDocument();
+ private Element faceletTaglib;
+
+ public Document getDocument() {
+ return document;
+ }
+
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+ public void visitComponentLibrary(ComponentLibrary model) {
+ faceletTaglib = document.addElement("facelet-taglib",
"http://java.sun.com/xml/ns/javaee");
+
+ faceletTaglib.addAttribute("version", "2.0");
+ faceletTaglib.addAttribute("id", "a4j"); // TODO do it as
param param
+
+
faceletTaglib.addElement("namespace").addText("http://rich...;
// TODO do it as param param
+ }
+
+ public void visitComponent(ComponentModel model) {
+ Element tag = createTag(getComponentTagName(model)); // TODO change to tag name!
+ Element component = tag.addElement(COMPONENT);
+ component.addElement(COMPONENT_TYPE).addText(model.getType().getType());
+ component.addElement("renderer-type").addText(model.getType().getType()
+ "Renderer");
+
+ addTagHandler(component, model.getTag());
+ appendAttributs(tag, model);
+ }
+
+ private void addTagHandler(Element parent, TagModel tag) {
+ if (tag != null && tag.getTagHandlerClass() != null) {
+
parent.addElement("handler-class").addText(tag.getTagHandlerClass());
+ }
+ }
+
+ private String getComponentTagName(ComponentModel model) {
+ return getTagName(model, getTagName(model.getType().getType()));
+ }
+
+ private String getTagName(ModelElementBase model, String defaults) {
+ try {
+ return model.getTag().getName();
+ } catch (NullPointerException e) {
+ return defaults;
+ }
+ }
+
+ private String getTagName(String type) {
+ String name = ClassName.getSimpleName(type);
+ return name.substring(0, 1).toLowerCase() + name.substring(1);
+ }
+
+ public void visitConverter(ConverterModel model) {
+ Element tag = createTag(getTagName(model, getTagName(model.getConverterId())));
+ Element converter = tag.addElement("converter");
+ converter.addElement("converter-id", model.getConverterId());
+
+ addTagHandler(converter, model.getTag());
+ appendAttributs(tag, model);
+ }
+
+ /**
+ * <tag>
+ * <tag-name>formatValidator</tag-name>
+ * <validator>
+ * <validator-id></validator-id>
+ * <handler-class></handler-class>
+ * </validator>
+ *
+ * <attribute>
+ * ...
+ * </attribute>
+ * </tag>
+ *
+ * */
+ public void visitValidator(ValidatorModel model) {
+ Element tag = createTag(getTagName(model, getTagName(model.getValidatorId())));
+ Element validator = tag.addElement("validator");
+ validator.addElement("validator-id", model.getValidatorId());
+
+ addTagHandler(validator, model.getTag());
+ appendAttributs(tag, model);
+ }
+
+
+ private void appendAttributs(Element tag, Attributable model) {
+ for (Map.Entry<String, Property> entry : model.getAttributes().entrySet())
{
+ createAttributeElement(tag, entry.getKey(), entry.getValue());
+ }
+ }
+
+ /**
+ * <attribute>
+ * <description></description>
+ * <name>formatPatterns</name>
+ * <required>true</required>
+ * <type>String</type>
+ * </attribute>
+ *
+ * @param tag
+ * @param name
+ * @param attribute
+ *
+ * @return
+ * */
+ private Element createAttributeElement(Element tag, String name, Property attribute)
{
+ Element attr = tag.addElement("attribute");
+ attr.addElement("name").addText(name);
+ if (attribute.getDescription() != null) {
+
attr.addElement("description").addText(attribute.getDescription());
+ }
+ attr.addElement("type").addText(attribute.getType().toString());
+ return attr;
+ }
+
+ private Element createTag(String tagName) {
+ Element tag = faceletTaglib.addElement("tag");
+ tag.addElement("tag-name").addText(tagName);
+
+ return tag;
+ }
+
+ public void visitBehavior(BehaviorModel model) {
+ Element tag = createTag(getTagName(model));
+ Element validator = tag.addElement("behavior");
+ validator.addElement("behavior-id").addText(model.getBehaviorId());
+
+ addTagHandler(validator, model.getTag());
+ appendAttributs(tag, model);
+ }
+
+ private String getTagName(ModelElementBase model) {
+ return getTagName(model, getTagName(model.getId()));
+ }
+
+ public void visitFacet(FacetModel model) {
+
+ }
+
+ public void visitEvent(EventModel model) {
+
+ }
+
+ public void visitBehaviorRenderer(BehaviorRenderer model) {
+
+ }
+
+ public void visitProperty(Property model) {
+
+ }
+
+ public void visitRenderKit(RenderKitModel model) {
+ for (RendererModel renderer : model.getRenderers()) {
+ visitRender(renderer);
+ }
+ }
+
+ public void visitRender(RendererModel model) {
+ if (true) {
+ return; // TODO remove when renderer annotation will be implemented
+ }
+
+ Element component = findComponent(model.getFamily());
+ if (component == null) {
+ return;
+ }
+
+ component.addElement("renderer-type", model.getType().getType());
+ }
+
+ private Element findComponent(String family) {
+ // TODO rewrite method by XPath
+ List<Element> tags = faceletTaglib.elements("tag");
+ for (Element tag : tags) {
+ Element component = tag.element(COMPONENT);
+ if (component != null) {
+ // TODO find by family instead type
+ Element type = component.element(COMPONENT_TYPE);
+ if (type != null && type.getTextTrim().equals(family)) {
+ return component;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public void visitListener(ListenerModel model) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void visit(ModelElement model) {
+ // TODO do default implementation for new classes
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibModule.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibModule.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -23,14 +23,13 @@
package org.richfaces.cdk.generate.taglib;
-import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.model.Visitable;
-
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.MapBinder;
import com.google.inject.multibindings.Multibinder;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.model.Visitable;
/**
* <p class="changed_added_4_0"></p>
@@ -39,14 +38,14 @@
*/
public class TaglibModule extends AbstractModule {
- /* (non-Javadoc)
- * @see com.google.inject.AbstractModule#configure()
- */
@Override
protected void configure() {
- Multibinder<CdkWriter> setBinder =
Multibinder.newSetBinder(binder(),CdkWriter.class);
- setBinder.addBinding().to(TaglibGenerator.class);
- MapBinder<Class<? extends Visitable>, TagGenerator<? extends
Visitable>> mapBinder = MapBinder.newMapBinder(binder(), new
TypeLiteral<Class<? extends Visitable>>(){}, new
TypeLiteral<TagGenerator<? extends Visitable>>(){});
+ Multibinder<CdkWriter> setBinder = Multibinder.newSetBinder(binder(),
CdkWriter.class);
+ setBinder.addBinding().to(TaglibWriter.class);
+ MapBinder<Class<? extends Visitable>, TagGenerator<? extends
Visitable>> mapBinder =
+ MapBinder.newMapBinder(binder(),
+ new TypeLiteral<Class<? extends Visitable>>(){},
+ new TypeLiteral<TagGenerator<? extends Visitable>>(){});
mapBinder.addBinding(ValidatorModel.class).to(ValidatorTagGenerator.class);
// mapBinder.addBinding(ComponentModel.class).to(ComponentTagGenerator.class);
TODO
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibWriter.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.taglib;
+
+import com.google.inject.Inject;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.richfaces.cdk.*;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author akolonitsky
+ * @since Feb 9, 2010
+ */
+public class TaglibWriter implements CdkWriter {
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ @Output(Outputs.RESOURCES)
+ private FileManager output;
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
+ */
+ @Override
+ public void render() throws CdkException {
+ TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
+ library.accept(visitor);
+
+ try {
+ OutputFormat format1 = OutputFormat.createPrettyPrint();
+ format1.setIndentSize(4);
+
+ XMLWriter writer = new XMLWriter(getOutput(), format1);
+ writer.write(visitor.getDocument());
+ writer.close();
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO
+ }
+ }
+
+ protected Writer getOutput() throws CdkException {
+ try {
+ return output.createOutput("META-INF/taglib.xml",
library.lastModified());
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
+ }
+
+ public ComponentLibrary getLibrary() {
+ return library;
+ }
+
+ public void setLibrary(ComponentLibrary library) {
+ this.library = library;
+ }
+
+ public void setOutput(FileManager output) {
+ this.output = output;
+ }
+}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.model;
+
+import java.util.Map;
+
+/**
+ * @author akolonitsky
+ * @since Jan 22, 2010
+ *
+ * Please rename it with more suitable name
+ */
+public class Attributable extends DescriptionGroupBase {
+
+ private final ModelMap<String,Property> attributes =
ModelMap.<String,Property>create();
+
+ /**
+ * <p class="changed_added_4_0">
+ * Represents JSF component attributes and properties.
+ * </p>
+ *
+ * @return the attributes
+ */
+ public Map<String,Property> getAttributes() {
+ return attributes;
+ }
+
+ public Property getAttribute(String name) {
+ return attributes.get(name);
+ }
+
+ public Property addAttribute(String attributeName) {
+ Property attribute = attributes.get(attributeName);
+ if (null == attribute) {
+ attribute = new Property();
+ attributes.put(attributeName, attribute);
+ }
+
+ return attribute;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -36,70 +36,30 @@
private static final long serialVersionUID = -5023589072935390357L;
- private boolean generate = false;
-
- private String behaviorId;
-
- private ClassDescription behaviorClass;
-
- private ClassDescription baseClass;
-
public BehaviorModel() {
}
- public BehaviorModel(String behaviorId, ClassDescription behaviorClass) {
- setBehaviorId(behaviorId);
- setBehaviorClass(behaviorClass);
+ public BehaviorModel(String behaviorId) {
+ setId(behaviorId);
}
- public boolean isGenerate() {
- return generate;
- }
-
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
public String getBehaviorId() {
- return behaviorId;
+ return getId();
}
- public void setBehaviorId(String behaviorId) {
- this.behaviorId = behaviorId;
+ public ClassName getBehaviorClass() {
+ return getGeneratedClass();
}
- public ClassDescription getBehaviorClass() {
- return behaviorClass;
- }
-
- public void setBehaviorClass(ClassDescription behaviorClass) {
- this.behaviorClass = behaviorClass;
- }
-
- public ClassDescription getBaseClass() {
- return baseClass;
- }
-
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
-
- public void setClassNames(String validatorClass, String baseClass) {
- this.behaviorClass = new ClassDescription(validatorClass);
-
- if (baseClass != null) {
- this.baseClass = new ClassDescription(baseClass);
- this.generate = true;
- } else {
- this.generate = false;
- }
- }
-
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitBehavior(this);
+ }
+
@Override
public void merge(BehaviorModel other) {
ComponentLibrary.merge(this, other);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -34,7 +34,7 @@
*/
@SuppressWarnings("serial")
public class BehaviorRenderer implements ModelElement<BehaviorRenderer> {
- private ClassDescription rendererClass;
+ private ClassName rendererClass;
private Type type;
public BehaviorRenderer(Type type) {
@@ -65,7 +65,7 @@
* <p class="changed_added_4_0"></p>
* @return the rendererClass
*/
- public ClassDescription getRendererClass() {
+ public ClassName getRendererClass() {
return rendererClass;
}
@@ -73,7 +73,7 @@
* <p class="changed_added_4_0"></p>
* @param rendererClass the rendererClass to set
*/
- public void setRendererClass(ClassDescription rendererClass) {
+ public void setRendererClass(ClassName rendererClass) {
this.rendererClass = rendererClass;
}
@@ -87,6 +87,10 @@
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitBehaviorRenderer(this);
+ }
+
@Override
public boolean same(BehaviorRenderer other) {
if(null != getType() && null != other.getType()){
Deleted:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,241 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.model;
-
-import java.io.Serializable;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * <p class="changed_added_4_0">
- * Tthat class represents information about Jsf object class.
- * </p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class ClassDescription implements Serializable {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -846623207703750456L;
-
- private static final ImmutableMap<String, String> PRIMITIVE_TYPES =
- ImmutableMap.<String, String>builder()
- .put(boolean.class.getName(), Boolean.class.getName())
- .put(byte.class.getName(), Byte.class.getName())
- .put(char.class.getName(), Character.class.getName())
- .put(short.class.getName(), Short.class.getName())
- .put(int.class.getName(), Integer.class.getName())
- .put(long.class.getName(), Long.class.getName())
- .put(float.class.getName(), Float.class.getName())
- .put(double.class.getName(), Double.class.getName())
- .build();
-
- private final String boxingClassName;
- private final String fullName;
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private final String name;
- private final boolean primitive;
-
- /**
- * <p class="changed_added_4_0">Id parameters for that
class</p>
- * TODO append type parameters to key.
- */
- private String typeParameters;
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param cl
- */
- public ClassDescription(Class<?> cl) {
-
- // TODO get information directly from class.
- this(cl.getName());
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param name
- */
- public ClassDescription(String name) {
- fullName = name;
-
- if (PRIMITIVE_TYPES.containsKey(name)) {
- this.name = name;
- boxingClassName = PRIMITIVE_TYPES.get(name);
- primitive = true;
- } else {
- int i = name.indexOf('<');
-
- if (i > 0) {
- this.name = name.substring(0, i);
- this.typeParameters = name.substring(i);
- } else {
- this.name = name;
- }
-
- boxingClassName = name;
- primitive = false;
- }
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the typeParameters
- */
- public String getTypeParameters() {
- return typeParameters;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param typeParameters the typeParameters to set
- */
- public void setTypeParameters(String typeParameters) {
- this.typeParameters = typeParameters;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return package name.
- */
- public String getPackage() {
- int indexOfPeriod = name.lastIndexOf('.');
-
- if (indexOfPeriod > 0) {
- return name.substring(0, indexOfPeriod);
- } else {
- return null;
- }
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return package name.
- */
- public String getSimpleName() {
- int indexOfPeriod = name.lastIndexOf('.');
-
- if (indexOfPeriod > 0) {
- return name.substring(indexOfPeriod + 1);
- } else {
- return name;
- }
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the primitive
- */
- public boolean isPrimitive() {
- return primitive;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the boxingClassName
- */
- public String getBoxingName() {
- return boxingClassName;
- }
-
- public String getGetterPrefix() {
- return Boolean.class.getName().equals(boxingClassName) ? "is" :
"get";
- }
-
- @Override
- public String toString() {
- return fullName;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((name == null) ? 0 : name.hashCode());
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (!(obj instanceof ClassDescription)) {
- return false;
- }
-
- ClassDescription other = (ClassDescription) obj;
-
- if (fullName == null) {
- if (other.fullName != null) {
- return false;
- }
- } else if (!fullName.equals(other.fullName)) {
- return false;
- }
-
- return true;
- }
-}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.model;
+
+import java.io.Serializable;
+
+/**
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+public class ClassDescriptor implements Serializable {
+
+ private final ClassName name;
+
+ private ClassName parent;
+
+ public ClassDescriptor(String name) {
+ this(new ClassName(name));
+ }
+
+ public ClassDescriptor(String name, String parent) {
+ this(name);
+
+ if (parent != null) {
+ this.parent = new ClassName(parent);
+ }
+ }
+
+ public ClassDescriptor(Class name) {
+ this(new ClassName(name));
+ }
+
+ public ClassDescriptor(Class name, Class parent) {
+ this(name);
+
+ if (parent != null) {
+ this.parent = new ClassName(parent);
+ }
+ }
+
+ public ClassDescriptor(ClassName name) {
+ this.name = name;
+ }
+
+ public ClassDescriptor(ClassName name, ClassName parent) {
+ this(name);
+ this.parent = parent;
+ }
+
+ public String getPackage() {
+ return name.getPackage();
+ }
+
+ public String getSimpleName() {
+ return name.getSimpleName();
+ }
+
+ @Override
+ public String toString() {
+ return name.toString();
+ }
+
+ public ClassName getName() {
+ return name;
+ }
+
+ public ClassName getParent() {
+ return parent;
+ }
+}
Copied:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
(from rev 16483,
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,237 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.model;
+
+import java.io.Serializable;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * <p class="changed_added_4_0">
+ * Tthat class represents information about Jsf object class.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ */
+public class ClassName implements Serializable {
+
+ private static final long serialVersionUID = -846623207703750456L;
+
+ private static final ImmutableMap<String, String> PRIMITIVE_TYPES =
+ ImmutableMap.<String, String>builder()
+ .put(boolean.class.getName(), Boolean.class.getName())
+ .put(byte.class.getName(), Byte.class.getName())
+ .put(char.class.getName(), Character.class.getName())
+ .put(short.class.getName(), Short.class.getName())
+ .put(int.class.getName(), Integer.class.getName())
+ .put(long.class.getName(), Long.class.getName())
+ .put(float.class.getName(), Float.class.getName())
+ .put(double.class.getName(), Double.class.getName())
+ .build();
+
+ private final String boxingClassName;
+ private final String fullName;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ */
+ private final String name;
+ private final boolean primitive;
+
+ /**
+ * <p class="changed_added_4_0">Id parameters for that
class</p>
+ * TODO append type parameters to key.
+ */
+ private String typeParameters;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param cl
+ */
+ public ClassName(Class<?> cl) {
+
+ // TODO get information directly from class.
+ this(cl.getName());
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param name
+ */
+ public ClassName(String name) {
+ fullName = name;
+
+ if (PRIMITIVE_TYPES.containsKey(name)) {
+ this.name = name;
+ boxingClassName = PRIMITIVE_TYPES.get(name);
+ primitive = true;
+ } else {
+ int i = name.indexOf('<');
+
+ if (i > 0) {
+ this.name = name.substring(0, i);
+ this.typeParameters = name.substring(i);
+ } else {
+ this.name = name;
+ }
+
+ boxingClassName = name;
+ primitive = false;
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the typeParameters
+ */
+ public String getTypeParameters() {
+ return typeParameters;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param typeParameters the typeParameters to set
+ */
+ public void setTypeParameters(String typeParameters) {
+ this.typeParameters = typeParameters;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return package name.
+ */
+ public String getPackage() {
+ int indexOfPeriod = name.lastIndexOf('.');
+
+ if (indexOfPeriod > 0) {
+ return name.substring(0, indexOfPeriod);
+ } else {
+ return null;
+ }
+ }
+
+ public String getSimpleName() {
+ return getSimpleName(name);
+ }
+
+ public static String getSimpleName(String name) {
+ int indexOfPeriod = name.lastIndexOf('.');
+
+ if (indexOfPeriod > 0) {
+ return name.substring(indexOfPeriod + 1);
+ } else {
+ return name;
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the primitive
+ */
+ public boolean isPrimitive() {
+ return primitive;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the boxingClassName
+ */
+ public String getBoxingName() {
+ return boxingClassName;
+ }
+
+ public String getGetterPrefix() {
+ return Boolean.class.getName().equals(boxingClassName) ? "is" :
"get";
+ }
+
+ @Override
+ public String toString() {
+ return fullName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (!(obj instanceof ClassName)) {
+ return false;
+ }
+
+ ClassName other = (ClassName) obj;
+
+ if (fullName == null) {
+ if (other.fullName != null) {
+ return false;
+ }
+ } else if (!fullName.equals(other.fullName)) {
+ return false;
+ }
+
+ return true;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -53,7 +53,7 @@
*
*/
@Singleton
-public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>,
Trackable {
+public class ComponentLibrary implements Serializable, Extensible<ConfigExtension>,
Trackable, Visitable {
public static final String CDK_EXTENSIONS_NAMESPACE =
"http://richfaces.org/cdk/extensions";
public static final String FACES_CONFIG_NAMESPACE =
"http://java.sun.com/xml/ns/javaee";
public static final String FACES_CONFIG_SCHEMA_LOCATION =
@@ -107,6 +107,7 @@
this.tagLibrary = new TagLibrary();
}
+ @Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
R result = accept(components, visitor, param, null);
@@ -120,12 +121,35 @@
return result;
}
+ public void accept(Visitor visitor) {
+ visitor.visitComponentLibrary(this);
+
+ visitCollection(visitor, components);
+ visitMap(visitor, renderKits);
+ visitCollection(visitor, converters);
+ visitCollection(visitor, validators);
+ visitCollection(visitor, listeners);
+ visitCollection(visitor, events);
+ visitCollection(visitor, behaviors);
+ }
+
+ private void visitMap(Visitor visitor, ModelMap<Id, RenderKitModel> modelMap)
{
+ for (RenderKitModel renderKit : modelMap.values()) {
+ renderKit.accept(visitor);
+ }
+ }
+
+ private void visitCollection(Visitor visitor, ModelCollection<?> models) {
+ for (ModelElement component : models) {
+ component.accept(visitor);
+ }
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
*
* @param renderKitId
- * @param rendererType
* @return
*/
public RenderKitModel addRenderKit(String renderKitId) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -16,11 +16,6 @@
private static final long serialVersionUID = 2297349356280370771L;
/**
- * <p class="changed_added_4_0">Is that component c</p>
- */
- private boolean generate = false;
-
- /**
* <p class="changed_added_4_0">
* Facets recognised by the component
* </p>
@@ -42,19 +37,6 @@
*/
private final ModelCollection<RendererModel> renderers =
ModelCollection.<RendererModel>create();
- /**
- * <p class="changed_added_4_0">
- * Cenerated component class
- * </p>
- */
- private ClassDescription baseClass;
-
- /**
- * <p class="changed_added_4_0">
- * Cenerated component class
- * </p>
- */
- private ClassDescription componentClass;
private String family;
/**
@@ -77,6 +59,14 @@
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitComponent(this);
+
+ for (RendererModel renderer : renderers) {
+ renderer.accept(visitor);
+ }
+ }
+
@Override
public void merge(ComponentModel otherComponent) {
//merge facets, renderers, events ...
@@ -85,6 +75,7 @@
ComponentLibrary.merge(events, otherComponent.getEvents());
ComponentLibrary.merge(renderers, otherComponent.getRenderers());
ComponentLibrary.merge(this, otherComponent);
+ this.setGenerate(this.isGenerate() || otherComponent.isGenerate());
}
@Override
@@ -109,6 +100,11 @@
return type;
}
+ @Override
+ public String getId() {
+ return type.getType();
+ }
+
/**
* <p class="changed_added_4_0">
* Reepresent a component family. In the faces-config element that property encoded
as
@@ -140,62 +136,12 @@
* @return the componentClass
*/
@Merge
- public ClassDescription getComponentClass() {
- return componentClass;
+ public ClassName getComponentClass() {
+ return getGeneratedClass();
}
/**
- * <p class="changed_added_4_0">Represents class of that component.
- * </p>
- *
- * @param componentClass
- * the componentClass to set
- */
- public void setComponentClass(ClassDescription componentClass) {
- this.componentClass = componentClass;
- }
-
- /**
- * <p class="changed_added_4_0">Base class for generated components.
- * </p>
- *
- * @return the baseClass
- */
- @Merge
- public ClassDescription getBaseClass() {
- return baseClass;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param baseClass
- * the baseClass to set
- */
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
-
- /**
* <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @Merge
- public boolean isGenerate() {
- return generate;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
* @return the facets
*/
public Map<String, FacetModel> getFacets() {
@@ -223,7 +169,7 @@
// TODO - use a single events collection from library.
EventModel event = new EventModel();
- event.setType(new ClassDescription(className));
+ event.setType(new ClassName(className));
events.add(event);
return event;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -34,82 +34,46 @@
private static final long serialVersionUID = -6238591637703737886L;
- private boolean generate = false;
+ private ClassName converterForClass;
- private String converterId;
-
- private ClassDescription converterClass;
-
- private ClassDescription baseClass;
-
- private ClassDescription converterForClass;
-
public ConverterModel() {
}
- public ConverterModel(String converterId, ClassDescription converterClass) {
- this.converterId = converterId;
- this.converterClass = converterClass;
+ public ConverterModel(String converterId) {
+ setId(converterId);
}
- public boolean isGenerate() {
- return generate;
- }
-
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
public String getConverterId() {
- return converterId;
+ return getId();
}
public void setConverterId(String converterId) {
- this.converterId = converterId;
+ setId(converterId);
}
@Merge(false)
- public ClassDescription getConverterForClass() {
+ public ClassName getConverterForClass() {
return converterForClass;
}
- public void setConverterForClass(ClassDescription converterForClass) {
+ public void setConverterForClass(ClassName converterForClass) {
this.converterForClass = converterForClass;
}
@Merge(false)
- public ClassDescription getConverterClass() {
- return converterClass;
+ public ClassName getConverterClass() {
+ return getGeneratedClass();
}
- public void setConverterClass(ClassDescription converterClass) {
- this.converterClass = converterClass;
- }
-
- public ClassDescription getBaseClass() {
- return baseClass;
- }
-
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
-
- public void setClassNames(String converterClass, String baseClass) {
- this.converterClass = new ClassDescription(converterClass);
-
- if (baseClass != null) {
- this.baseClass = new ClassDescription(baseClass);
- this.generate = true;
- } else {
- this.generate = false;
- }
- }
-
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitConverter(this);
+ }
+
@Override
public void merge(ConverterModel other) {
ComponentLibrary.merge(this, other);
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.model;
+
+/**
+ * @author akolonitsky
+ * @since Jan 22, 2010
+ */
+public class DescriptionGroupBase implements DescriptionGroup,
Extensible<ConfigExtension> {
+
+ /**
+ * <p class="changed_added_4_0">Is that bean property generate in
the class or should be generated ?</p>
+ */
+ private boolean generate = false;
+
+ /**
+ * <p class="changed_added_4_0">
+ * Long description for documentation
+ * </p>
+ */
+ private String description;
+
+ /**
+ * <p class="changed_added_4_0">
+ * Short name for IDE tools
+ * </p>
+ */
+ private String displayname;
+ /**
+ * <p class="changed_added_4_0">
+ * Icon name for IDE tools
+ * </p>
+ */
+ private Icon icon;
+
+ private ConfigExtension extension;
+
+ public final String getDescription() {
+ return description;
+ }
+
+ public final void setDescription(String description) {
+ this.description = description;
+ }
+
+ public final String getDisplayname() {
+ return displayname;
+ }
+
+ public final void setDisplayname(String displayname) {
+ this.displayname = displayname;
+ }
+
+ public final Icon getIcon() {
+ return icon;
+ }
+
+ public final void setIcon(Icon icon) {
+ this.icon = icon;
+ }
+
+ public boolean isGenerate() {
+ return generate;
+ }
+
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the extension
+ */
+ public final ConfigExtension getExtension() {
+ return extension;
+ }
+
+ public final void setExtension(ConfigExtension extension) {
+ this.extension = extension;
+ }
+}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EmptyVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EmptyVisitor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EmptyVisitor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.model;
+
+/**
+ * Implementation for easy on inheritance.
+ *
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+public abstract class EmptyVisitor implements Visitor{
+ public void visitComponentLibrary(ComponentLibrary model) {
+ // Do nothing.
+ }
+
+ public void visitComponent(ComponentModel model) {
+ // Do nothing.
+ }
+
+ public void visitConverter(ConverterModel model) {
+ // Do nothing.
+ }
+
+ public void visitValidator(ValidatorModel model) {
+ // Do nothing.
+ }
+
+ public void visitBehavior(BehaviorModel model) {
+ // Do nothing.
+ }
+
+ public void visitFacet(FacetModel model) {
+ // Do nothing.
+ }
+
+ public void visitEvent(EventModel model) {
+ // Do nothing.
+ }
+
+ public void visitBehaviorRenderer(BehaviorRenderer model) {
+ // Do nothing.
+ }
+
+ public void visitProperty(Property model) {
+ // Do nothing.
+ }
+
+ public void visitRenderKit(RenderKitModel model) {
+ // Do nothing.
+ }
+
+ public void visitRender(RendererModel model) {
+ // Do nothing.
+ }
+
+ public void visitListener(ListenerModel model) {
+ // Do nothing.
+ }
+
+ public void visit(ModelElement model) {
+ // Do nothing.
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/EventModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -37,14 +37,14 @@
@SuppressWarnings("serial")
public class EventModel implements ModelElement<EventModel> {
private String description;
- private ClassDescription listenerInterface;
- private ClassDescription sourceInterface;
- private ClassDescription tagHandler;
+ private ClassName listenerInterface;
+ private ClassName sourceInterface;
+ private ClassName tagHandler;
/**
* <p class="changed_added_4_0"></p>
*/
- private ClassDescription type;
+ private ClassName type;
/**
@@ -67,7 +67,7 @@
* <p class="changed_added_4_0"></p>
* @return the type
*/
- public ClassDescription getType() {
+ public ClassName getType() {
return this.type;
}
@@ -75,7 +75,7 @@
* <p class="changed_added_4_0"></p>
* @param type the type to set
*/
- public void setType(ClassDescription type) {
+ public void setType(ClassName type) {
this.type = type;
}
@@ -83,7 +83,7 @@
* <p class="changed_added_4_0"></p>
* @return the listenerInterface
*/
- public ClassDescription getListenerInterface() {
+ public ClassName getListenerInterface() {
return listenerInterface;
}
@@ -91,7 +91,7 @@
* <p class="changed_added_4_0"></p>
* @param listenerInterface the listenerInterface to set
*/
- public void setListenerInterface(ClassDescription listenerInterface) {
+ public void setListenerInterface(ClassName listenerInterface) {
this.listenerInterface = listenerInterface;
}
@@ -99,7 +99,7 @@
* <p class="changed_added_4_0"></p>
* @return the sourceInterface
*/
- public ClassDescription getSourceInterface() {
+ public ClassName getSourceInterface() {
return sourceInterface;
}
@@ -107,7 +107,7 @@
* <p class="changed_added_4_0"></p>
* @param sourceInterface the sourceInterface to set
*/
- public void setSourceInterface(ClassDescription sourceInterface) {
+ public void setSourceInterface(ClassName sourceInterface) {
this.sourceInterface = sourceInterface;
}
@@ -115,7 +115,7 @@
* <p class="changed_added_4_0"></p>
* @return the tagHandler
*/
- public ClassDescription getTagHandler() {
+ public ClassName getTagHandler() {
return tagHandler;
}
@@ -123,7 +123,7 @@
* <p class="changed_added_4_0"></p>
* @param tagHandler the tagHandler to set
*/
- public void setTagHandler(ClassDescription tagHandler) {
+ public void setTagHandler(ClassName tagHandler) {
this.tagHandler = tagHandler;
}
@@ -136,7 +136,11 @@
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
-
+
+ public void accept(Visitor visitor) {
+ visitor.visitEvent(this);
+ }
+
@Override
public boolean same(EventModel other) {
return null != getType() && getType().equals(other.getType());
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -32,33 +32,12 @@
* @author asmirnov(a)exadel.com
*
*/
-@SuppressWarnings("serial")
-public class FacetModel extends ModelElementBase implements
ModelElement<FacetModel> {
-
- private boolean generate;
- /**
- * <p class="changed_added_4_0"></p>
- * @param name
- */
+public class FacetModel extends DescriptionGroupBase implements
ModelElement<FacetModel> {
+ private static final long serialVersionUID = 7723771279129598243L;
+
public FacetModel() {
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the generate
- */
- public boolean isGenerate() {
- return generate;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param generate the generate to set
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
@Override
public void merge(FacetModel other) {
ComponentLibrary.merge(this, other);
@@ -68,7 +47,11 @@
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
-
+
+ public void accept(Visitor visitor) {
+ visitor.visitFacet(this);
+ }
+
@Override
public boolean same(FacetModel other) {
return equals(other);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -52,6 +52,10 @@
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitListener(this);
+ }
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.model.ModelElement#getType()
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -178,4 +178,8 @@
return result;
}
+ public void accept(Visitor visitor) {
+ // TODO
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,99 +1,69 @@
package org.richfaces.cdk.model;
-import java.util.Map;
-
/**
* <p class="changed_added_4_0">Base class for the most JSF components
taht have description
* attributes and support extensions in faces-config.</p>
* @author asmirnov(a)exadel.com
*
*/
-public class ModelElementBase implements DescriptionGroup,
Extensible<ConfigExtension> {
+public class ModelElementBase extends Attributable {
- /**
- * <p class="changed_added_4_0">
- * Long description for documentation
- * </p>
- */
- private String description;
+ private String id;
- /**
- * <p class="changed_added_4_0">
- * Short name for IDE tools
- * </p>
- */
- private String displayname;
- private ConfigExtension extension;
+ private ClassDescriptor generatedClass;
- /**
- * <p class="changed_added_4_0">
- * Icon name for IDE tools
- * </p>
- */
- private Icon icon;
+ private TagModel tag;
- private final ModelMap<String,Property> attributes =
ModelMap.<String,Property>create();
-
- public ModelElementBase() {
- super();
+ public TagModel getTag() {
+ return tag;
}
- public final String getDescription() {
- return description;
+ public void setTag(TagModel tag) {
+ this.tag = tag;
}
- public final void setDescription(String description) {
- this.description = description;
+ public String getId() {
+ return id;
}
- public final String getDisplayname() {
- return displayname;
+ public void setId(String id) {
+ this.id = id;
}
- public final void setDisplayname(String displayname) {
- this.displayname = displayname;
+ public void setGeneratedClass(String generatedClass) {
+ setGeneratedClass(new ClassDescriptor(generatedClass));
}
- public final Icon getIcon() {
- return icon;
+ public void setGeneratedClass(Class generatedClass) {
+ setGeneratedClass(new ClassDescriptor(generatedClass));
}
- public final void setIcon(Icon icon) {
- this.icon = icon;
+ public void setGeneratedClass(ClassName generatedClass) {
+ setGeneratedClass(new ClassDescriptor(generatedClass));
}
- /**
- * <p class="changed_added_4_0">
- * Represents JSF component attributes and properties.
- * </p>
- *
- * @return the attributes
- */
- public Map<String,Property> getAttributes() {
- return attributes;
+ public void setGeneratedClass(ClassDescriptor generatedClass) {
+ this.generatedClass = generatedClass;
}
- public Property addAttribute(String attributeName) {
- Property attribute = attributes.get(attributeName);
- if (null == attribute) {
- attribute = new Property();
- attributes.put(attributeName, attribute);
+ public ClassName getGeneratedClass() {
+ if (this.generatedClass == null) {
+ return null;
}
- return attribute;
+ return this.generatedClass.getName();
}
+ public ClassName getBaseClass() {
+ if (this.generatedClass == null) {
+ return null;
+ }
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the extension
- */
- public final ConfigExtension getExtension() {
- return extension;
+ return this.generatedClass.getParent();
}
- public final void setExtension(ConfigExtension extension) {
- this.extension = extension;
+ public void setClassNames(String className, String parentClassName) {
+ setGenerate(parentClassName != null);
+ this.generatedClass = new ClassDescriptor(className, parentClassName);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -36,14 +36,10 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Property extends ModelElementBase implements ModelElement<Property> {
+public class Property extends DescriptionGroupBase implements
ModelElement<Property> {
private static final long serialVersionUID = 3483864006602184580L;
- /**
- * <p class="changed_added_4_0">Is that bean property generate in
the class or should be generated ?</p>
- */
- private boolean generate = false;
private boolean hidden = false;
private boolean literal = false;
private boolean required = false;
@@ -52,12 +48,12 @@
//TODO nick - ordering seems to be important!
private Set<EventName> eventNames = Sets.newLinkedHashSet();
- private List<ClassDescription> signature = Lists.newArrayList();
+ private List<ClassName> signature = Lists.newArrayList();
private Set<String> aliases = Sets.newHashSet();
private String defaultValue;
private String suggestedValue;
- private ClassDescription type;
+ private ClassName type;
/**
* <p class="changed_added_4_0"></p>
@@ -70,7 +66,7 @@
* @return the type
*/
@Merge
- public ClassDescription getType() {
+ public ClassName getType() {
return type;
}
@@ -78,7 +74,7 @@
* <p class="changed_added_4_0"></p>
* @param type the type to set
*/
- public void setType(ClassDescription type) {
+ public void setType(ClassName type) {
this.type = type;
}
@@ -118,23 +114,6 @@
/**
* <p class="changed_added_4_0"></p>
- * @return the generate
- */
- @Merge
- public boolean isGenerate() {
- return generate;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param exists - the generate to set
- */
- public void setGenerate(boolean exists) {
- this.generate = exists;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
* @return the eventNames
*/
@Merge
@@ -235,7 +214,7 @@
* @return the signature
*/
@Merge(true)
- public List<ClassDescription> getSignature() {
+ public List<ClassName> getSignature() {
return signature;
}
@@ -243,7 +222,7 @@
* <p class="changed_added_4_0"></p>
* @param signature the signature to set
*/
- public void setSignature(List<ClassDescription> signature) {
+ public void setSignature(List<ClassName> signature) {
this.signature = signature;
}
@@ -263,6 +242,10 @@
this.aliases = aliases;
}
+ public boolean isPrimitive() {
+ return getType().isPrimitive();
+ }
+
@Override
public void merge(Property other) {
ComponentLibrary.merge(this, other);
@@ -273,6 +256,10 @@
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitProperty(this);
+ }
+
@Override
public boolean same(Property other) {
return this == other;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -36,12 +36,13 @@
* @author asmirnov(a)exadel.com
*
*/
-@SuppressWarnings("serial")
-public class RenderKitModel extends ModelElementBase implements
ModelElement<RenderKitModel> {
+public class RenderKitModel extends DescriptionGroupBase implements
ModelElement<RenderKitModel> {
+ private static final long serialVersionUID = -7387781530198813352L;
+
private final ModelCollection<RendererModel> renderers =
ModelCollection.<RendererModel>create();
private final ModelCollection<BehaviorRenderer> behaviorRenderers =
ModelCollection.<BehaviorRenderer>create();
- private ClassDescription renderKitClass;
+ private ClassName renderKitClass;
public RenderKitModel() {
}
@@ -51,7 +52,7 @@
* @return the renderKitClass
*/
@Merge
- public ClassDescription getRenderKitClass() {
+ public ClassName getRenderKitClass() {
return renderKitClass;
}
@@ -59,7 +60,7 @@
* <p class="changed_added_4_0"></p>
* @param renderKitClass the renderKitClass to set
*/
- public void setRenderKitClass(ClassDescription renderKitClass) {
+ public void setRenderKitClass(ClassName renderKitClass) {
this.renderKitClass = renderKitClass;
}
@@ -90,6 +91,10 @@
return ComponentLibrary.accept(renderers, visitor, param, result);
}
+ public void accept(Visitor visitor) {
+ visitor.visitRenderKit(this);
+ }
+
@Override
public void merge(RenderKitModel other) {
ComponentLibrary.merge(renderers,other.renderers);
@@ -108,12 +113,12 @@
* @author asmirnov(a)exadel.com
*
*/
- @SuppressWarnings("serial")
public static final class Id extends Key {
+ private static final long serialVersionUID = 9169827614943311779L;
/**
* <p class="changed_added_4_0"></p>
- * @param id
+ * @param type
*/
public Id(String type) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -25,8 +25,6 @@
package org.richfaces.cdk.model;
-import java.util.Map;
-
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.templatecompiler.model.Template;
@@ -36,26 +34,19 @@
*
*/
//@SuppressWarnings("serial")
-public class RendererModel extends ModelElementBase implements
ModelElement<RendererModel> {
+public class RendererModel extends Attributable implements
ModelElement<RendererModel> {
private static final long serialVersionUID = -5802466539382148578L;
private String family;
- private ClassDescription rendererClass;
+ private ClassName rendererClass;
private Template template;
private Type type;
private boolean rendersChildren;
- private Tag tag;
+ private TagModel tag;
- /**
- * <p class="changed_added_4_0">
- * Component attributes
- * </p>
- */
- private final ModelMap<String,Property> attributes =
ModelMap.<String,Property>create();
-
public RendererModel() {}
public RendererModel(Type type) {
@@ -120,7 +111,7 @@
* <p class="changed_added_4_0"></p>
* @return the rendererClass
*/
- public ClassDescription getRendererClass() {
+ public ClassName getRendererClass() {
return rendererClass;
}
@@ -128,7 +119,7 @@
* <p class="changed_added_4_0"></p>
* @param rendererClass the rendererClass to set
*/
- public void setRendererClass(ClassDescription rendererClass) {
+ public void setRendererClass(ClassName rendererClass) {
this.rendererClass = rendererClass;
}
@@ -150,17 +141,9 @@
/**
* <p class="changed_added_4_0"></p>
- * @return the attributes
- */
- public Map<String,Property> getAttributes() {
- return this.attributes;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
* @return the tag
*/
- public Tag getTag() {
+ public TagModel getTag() {
return this.tag;
}
@@ -168,7 +151,7 @@
* <p class="changed_added_4_0"></p>
* @param tag the tag to set
*/
- public void setTag(Tag tag) {
+ public void setTag(TagModel tag) {
this.tag = tag;
}
@@ -177,6 +160,10 @@
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitRender(this);
+ }
+
@Override
public void merge(RendererModel other) {
ComponentLibrary.merge(this, other);
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,118 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.richfaces.cdk.model;
-
-import java.io.Serializable;
-
-/**
- * <p class="changed_added_4_0">That bean represents VDL tag</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class Tag implements Serializable {
-
- private static final long serialVersionUID = 3875718626199223087L;
-
- /**
- * <p class="changed_added_4_0">Component that the tag creates. This
in bidirectional one to one relation.</p>
- * TODO - tag should also works with {@code Validator}, {@code Converter}, {@code
Behavior}, {@code FacesListener}
- */
- private ModelElement<?> component;
-
- /**
- * <p class="changed_added_4_0">Jsp tag class</p>
- */
- private String jspClass;
-
- /**
- * <p class="changed_added_4_0">Tag library for which that tag is
belong.
- * This is bidirectional many to one relation.</p>
- */
- private TagLibrary library;
-
- /**
- * <p class="changed_added_4_0">Tag name</p>
- */
- private String name;
-
- /**
- * <p class="changed_added_4_0">Facelets VDL tag handler
class.</p>
- */
- private String tagHandlerClass;
-
- /**
- * <p class="changed_added_4_0">Facelets VDL tag handler base class
for generation.</p>
- */
- private String tagHandlerSuperClass;
-
- public ModelElement<?> getComponent() {
- return component;
- }
-
- public void setComponent(ModelElement<?> component) {
- this.component = component;
- }
-
- public String getJspClass() {
- return jspClass;
- }
-
- public void setJspClass(String jspClass) {
- this.jspClass = jspClass;
- }
-
- public TagLibrary getLibrary() {
- return library;
- }
-
- public void setLibrary(TagLibrary library) {
- this.library = library;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getTagHandlerClass() {
- return tagHandlerClass;
- }
-
- public void setTagHandlerClass(String tagHandlerClass) {
- this.tagHandlerClass = tagHandlerClass;
- }
-
- public String getTagHandlerSuperClass() {
- return tagHandlerSuperClass;
- }
-
- public void setTagHandlerSuperClass(String tagHandlerSuperClass) {
- this.tagHandlerSuperClass = tagHandlerSuperClass;
- }
-}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagLibrary.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -40,7 +40,7 @@
/**
* <p class="changed_added_4_0">Collection of tags associated with
that library</p>
*/
- private final List<Tag> tags = new ArrayList<Tag>();
+ private final List<TagModel> tags = new ArrayList<TagModel>();
private String shortName;
@@ -50,7 +50,7 @@
*
* @return the tags
*/
- public List<Tag> getTags() {
+ public List<TagModel> getTags() {
return tags;
}
/**
Copied:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java (from
rev 16413,
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Tag.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,137 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+
+package org.richfaces.cdk.model;
+
+import java.io.Serializable;
+
+/**
+ * <p class="changed_added_4_0">That bean represents VDL tag</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TagModel implements Serializable {
+
+ private static final long serialVersionUID = 3875718626199223087L;
+
+ /**
+ * <p class="changed_added_4_0">Component that the tag creates. This
in bidirectional one to one relation.</p>
+ * TODO - tag should also works with {@code Validator}, {@code Converter}, {@code
Behavior}, {@code FacesListener}
+ */
+ private ModelElementBase model;
+
+ /**
+ * <p class="changed_added_4_0">Jsp tag class</p>
+ */
+ private String jspClass;
+
+ /**
+ * <p class="changed_added_4_0">Tag library for which that tag is
belong.
+ * This is bidirectional many to one relation.</p>
+ */
+ private TagLibrary library;
+
+ /**
+ * <p class="changed_added_4_0">Tag name</p>
+ */
+ private String name;
+
+ /**
+ * <p class="changed_added_4_0">Facelets VDL tag handler
class.</p>
+ */
+ private ClassDescriptor handler;
+
+ public TagModel() {
+ }
+
+ public TagModel(String name, String tagHandlerClass) {
+ this(name, tagHandlerClass, null);
+ }
+
+ public TagModel(String name, String tagHandlerClass, String tagHandlerParentClass) {
+ this.name = name;
+
+ if (tagHandlerClass != null) {
+ this.handler = new ClassDescriptor(tagHandlerClass, tagHandlerParentClass);
+ }
+ }
+
+ public ModelElementBase getModel() {
+ return model;
+ }
+
+ public void setModel(ModelElementBase model) {
+ this.model = model;
+ }
+
+ public String getJspClass() {
+ return jspClass;
+ }
+
+ public void setJspClass(String jspClass) {
+ this.jspClass = jspClass;
+ }
+
+ public TagLibrary getLibrary() {
+ return library;
+ }
+
+ public void setLibrary(TagLibrary library) {
+ this.library = library;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ClassDescriptor getHandler() {
+ return handler;
+ }
+
+ public void setHandler(ClassDescriptor handler) {
+ this.handler = handler;
+ }
+
+ public String getTagHandlerClass() {
+ if (handler != null) {
+ return handler.getName().getName();
+ }
+
+ return null;
+ }
+
+ public String getTagHandlerSuperClass() {
+ if (handler != null) {
+ return handler.getParent().getName();
+ }
+ return null;
+ }
+
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -33,71 +33,35 @@
public class ValidatorModel extends ModelElementBase implements
ModelElement<ValidatorModel> {
private static final long serialVersionUID = -6097027070372673266L;
- private boolean generate = false;
-
- private String validatorId;
-
- private ClassDescription validatorClass;
-
- private ClassDescription baseClass;
-
public ValidatorModel() {
}
- public ValidatorModel(String validatorId, ClassDescription validatorClass) {
+ public ValidatorModel(String validatorId) {
setValidatorId(validatorId);
- setValidatorClass(validatorClass);
}
- public boolean isGenerate() {
- return generate;
- }
-
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
public String getValidatorId() {
- return validatorId;
+ return getId();
}
public void setValidatorId(String validatorId) {
- this.validatorId = validatorId;
+ setId(validatorId);
}
@Merge(false)
- public ClassDescription getValidatorClass() {
- return validatorClass;
+ public ClassName getValidatorClass() {
+ return getGeneratedClass();
}
- public void setValidatorClass(ClassDescription validatorClass) {
- this.validatorClass = validatorClass;
- }
-
- public ClassDescription getBaseClass() {
- return baseClass;
- }
-
- public void setBaseClass(ClassDescription baseClass) {
- this.baseClass = baseClass;
- }
-
- public void setClassNames(String validatorClass, String baseClass) {
- this.validatorClass = new ClassDescription(validatorClass);
-
- if (baseClass != null) {
- this.baseClass = new ClassDescription(baseClass);
- this.generate = true;
- } else {
- this.generate = false;
- }
- }
-
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visitValidator(this);
+ }
+
@Override
public void merge(ValidatorModel other) {
ComponentLibrary.merge(this, other);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -17,4 +17,6 @@
* @return
*/
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException;
+
+ public void accept(Visitor visitor);
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitor.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitor.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.model;
+
+/**
+ * @author akolonitsky
+ * @since Jan 23, 2010
+ */
+public interface Visitor {
+ void visitComponentLibrary(ComponentLibrary model);
+
+ void visitComponent(ComponentModel model);
+
+ void visitConverter(ConverterModel model);
+
+ void visitValidator(ValidatorModel model);
+
+ void visitBehavior(BehaviorModel model);
+
+ void visitFacet(FacetModel model);
+
+ void visitEvent(EventModel model);
+
+ void visitBehaviorRenderer(BehaviorRenderer model);
+
+ void visitProperty(Property model);
+
+ void visitRenderKit(RenderKitModel model);
+
+ void visitRender(RendererModel model);
+
+ void visitListener(ListenerModel model);
+
+ void visit(ModelElement model);
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -38,12 +38,8 @@
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.RenderKitModel;
-import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.templatecompiler.model.Attribute;
import org.richfaces.cdk.templatecompiler.model.ClientBehavior;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
@@ -116,12 +112,12 @@
return result;
}
- private List<ClassDescription> parseSignature(String signatureString) {
+ private List<ClassName> parseSignature(String signatureString) {
if (signatureString == null || signatureString.trim().length() == 0) {
return null;
}
- List<ClassDescription> result = Lists.newArrayList();
+ List<ClassName> result = Lists.newArrayList();
if (signatureString != null) {
Matcher parametersStringMatcher =
PARAMETERS_STRING_PATTERN.matcher(signatureString);
@@ -136,7 +132,7 @@
String[] parameters = COMMA_SEPARATED_PATTERN.split(parametersString);
for (String parameter : parameters) {
String trimmedParameter = parameter.trim();
- result.add(new ClassDescription(trimmedParameter));
+ result.add(new ClassName(trimmedParameter));
}
}
}
@@ -176,7 +172,7 @@
renderer.setFamily(family);
}
- renderer.setRendererClass(new
ClassDescription(compositeInterface.getJavaClass()));
+ renderer.setRendererClass(new ClassName(compositeInterface.getJavaClass()));
renderer.setTemplate(template);
Boolean rendersChildren = compositeInterface.getRendersChildren();
@@ -224,14 +220,14 @@
rendererProperty.setRequired(templateAttribute.isRequired());
- List<ClassDescription> parsedSignature =
parseSignature(templateAttribute.getMethodSignature());
+ List<ClassName> parsedSignature =
parseSignature(templateAttribute.getMethodSignature());
if (parsedSignature != null) {
rendererProperty.getSignature().addAll(parsedSignature);
}
String templateAttributeType = templateAttribute.getType();
if (templateAttributeType != null) {
- rendererProperty.setType(new
ClassDescription(templateAttributeType));
+ rendererProperty.setType(new ClassName(templateAttributeType));
}
rendererAttributes.put(templateAttribute.getName(), rendererProperty);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -50,10 +50,13 @@
+ ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
private static final String FACES_CONFIG_XML =
"META-INF/faces-config.xml";
+
@Inject
private JAXB jaxbBinding;
+
@Inject
private ComponentLibrary library;
+
@Inject @Output(Outputs.RESOURCES)
private FileManager outputFileManager;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -49,8 +49,10 @@
@Inject
private JAXB jaxbBinding;
+
@Inject
private ComponentLibrary library;
+
@Inject @Source(Sources.FACES_CONFIGS)
private FileManager configFiles;
@@ -62,7 +64,6 @@
*/
@Override
public void build() throws CdkException {
-
for (File file : configFiles.getFiles()) {
FacesConfigBean unmarshal = unmarshalFacesConfig(file);
if (null != unmarshal) {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -25,43 +25,26 @@
package org.richfaces.cdk.xmlconfig;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Collection;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.UnmarshallerHandler;
-import javax.xml.bind.util.ValidationEventCollector;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamResult;
-
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Inject;
import org.apache.cocoon.pipeline.component.sax.XIncludeTransformer;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.Extensible;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.EntityResolver2;
import org.xml.sax.helpers.XMLReaderFactory;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Inject;
+import javax.xml.bind.*;
+import javax.xml.bind.util.ValidationEventCollector;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collection;
/**
* <p class="changed_added_4_0">
@@ -71,21 +54,14 @@
*
*/
public class JAXBBinding implements JAXB {
+ public static final ImmutableSet<String> IGNORE_PROPERTIES =
ImmutableSet.of("class", "extension");
private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new
FacesConfigNamespacePreffixMapper();
- private static final ImmutableSet<String> IGNORE_PROPERTIES =
ImmutableSet.of("class", "extension");
@Inject
private EntityResolver2 resolver;
public JAXBBinding() { }
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param context
- */
-
/* (non-Javadoc)
* @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.io.File, java.lang.String,
java.lang.Class)
*/
@@ -145,12 +121,9 @@
// Setup JAXB to unmarshal
// TODO - create xinclude content handler that process xinclude directives
// and send SAX event to the unmarshaller handler.
- JAXBContext jc = JAXBContext.newInstance(bindClass);
- Unmarshaller u = jc.createUnmarshaller();
- ValidationEventCollector vec = new ValidationEventCollector();
+ Unmarshaller u = JAXBContext.newInstance(bindClass).createUnmarshaller();
+ u.setEventHandler(new ValidationEventCollector());
- u.setEventHandler(vec);
-
XIncludeTransformer xIncludeTransformer = new XIncludeTransformer();
if (null != inputSource.getSystemId()) {
@@ -264,181 +237,7 @@
}
}
- /**
- * <p class="changed_added_4_0">
- * This method creates adapter object and copies properties from model
- * object to adapter.
- * </p>
- *
- * @param <A>
- * type of adapter object
- * @param <T>
- * type of model object.
- * @param adapterClass
- * adapter class.
- * @param modelObject
- * model object class.
- * @return initialized instance of adapter object.
- */
- public static <A, T> A createAdapter(Class<A> adapterClass, T
modelObject) throws CdkException {
- try {
- A adapter = adapterClass.newInstance();
-
- // Copy properties from model to adapter.
- copyProperties(modelObject, adapter);
- copyExtensions(modelObject, adapter, true);
-
- return adapter;
- } catch (InstantiationException e) {
- throw new CdkException("JAXB adapter class instantiation error",
e);
- } catch (IllegalAccessException e) {
- throw new CdkException("JAXB adapter class instantiation error",
e);
- }
- }
-
- public static <A, T> T createModelElement(Class<T> modelClass,
- A adapter) throws CdkException {
-
- try {
-
- T modelBean = modelClass.newInstance();
-
- copyProperties(adapter, modelBean);
- copyExtensions(adapter, modelBean, false);
-
- return modelBean;
- } catch (Exception e) {
- throw new CdkException("CDK model class instantiation error", e);
- }
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <S>
- * @param <D>
- * @param source
- * @param destination
- * @param fromModel
- * @throws CdkException
- */
- public static <S, D> void copyExtensions(S source, D destination, boolean
fromModel) throws CdkException {
- try {
- if (source instanceof Extensible && destination instanceof
Extensible) {
- Extensible extensibleSource = (Extensible) source;
- Extensible<ConfigExtension> extensibleDestination =
(Extensible<ConfigExtension>) destination;
- ConfigExtension sourceExtension = extensibleSource.getExtension();
-
- if (null != sourceExtension) {
- ConfigExtension destinationExtension = createExtension(destination);
-
- destinationExtension.setExtensions(sourceExtension.getExtensions());
-
- if (fromModel) {
- copyProperties(source, destinationExtension);
- } else {
- copyProperties(sourceExtension, destination);
- }
-
- extensibleDestination.setExtension(destinationExtension);
- } else if (fromModel) {
- ConfigExtension destinationExtension = createExtension(destination);
-
- copyProperties(source, destinationExtension);
- extensibleDestination.setExtension(destinationExtension);
- }
- }
- } catch (Exception e) {
- throw new CdkException("Properties copiing error", e);
- }
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <D>
- * @param destination
- * @return
- * @throws NoSuchMethodException
- * @throws InstantiationException
- * @throws IllegalAccessException
- */
- private static <D> ConfigExtension createExtension(D destination)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException {
-
- Method method = destination.getClass().getMethod("getExtension");
- Class<? extends ConfigExtension> destinationExtensionType =
- (Class<? extends ConfigExtension>) method.getReturnType();
-
- return destinationExtensionType.newInstance();
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param <S>
- * @param <D>
- * @param source
- * @param destination
- * @throws CdkException
- */
- public static <S, D> void copyProperties(S source, D destination) throws
CdkException {
- try {
- PropertyDescriptor[] targetProperties =
-
Introspector.getBeanInfo(destination.getClass()).getPropertyDescriptors();
- PropertyDescriptor[] sourceProperties =
- Introspector.getBeanInfo(source.getClass()).getPropertyDescriptors();
-
- for (PropertyDescriptor targetProperty : targetProperties) {
- Method writeMethod = targetProperty.getWriteMethod();
- String name = targetProperty.getName();
-
- for (PropertyDescriptor sourceProperty : sourceProperties) {
- Method readMethod = sourceProperty.getReadMethod();
-
- if (!IGNORE_PROPERTIES.contains(name) &&
name.equals(sourceProperty.getName())
- && null != readMethod) {
- Class<?> targetType = targetProperty.getPropertyType();
- Class<?> sourceType = sourceProperty.getPropertyType();
- Object propertyValue = readMethod.invoke(source);
-
- if (null != propertyValue) {
- if (null != writeMethod) {
- if (targetType.equals(sourceType)) {
- writeMethod.invoke(destination, propertyValue);
- } else if (targetType.equals(String.class)) {
- writeMethod.invoke(destination,
propertyValue.toString());
- } else if (isCollections(targetType, propertyValue)) {
- Collection targetCollection =
- (Collection)
targetProperty.getReadMethod().invoke(destination);
-
- if (null != targetCollection) {
- targetCollection.addAll((Collection)
propertyValue);
- } else {
- writeMethod.invoke(destination, propertyValue);
- }
- }
- } else if (isCollections(targetType, propertyValue)) {
- Collection targetCollection =
- (Collection)
targetProperty.getReadMethod().invoke(destination);
-
- if (null != targetCollection) {
- targetCollection.addAll((Collection) propertyValue);
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
- throw new CdkException("Properties copiing error", e);
- }
- }
-
- private static boolean isCollections(Class<?> targetType, Object propertyValue)
{
+ public static boolean isCollections(Class<?> targetType, Object propertyValue)
{
return Collection.class.isAssignableFrom(targetType) && propertyValue
instanceof Collection;
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -45,9 +45,10 @@
bind(EntityResolver2.class).to(CdkEntityResolver.class);
bind(JAXB.class).to(JAXBBinding.class);
bind(NamespacePrefixMapper.class).to(FacesConfigNamespacePreffixMapper.class);
- Multibinder<ModelBuilder> modelBinder = Multibinder.newSetBinder(binder(),
ModelBuilder.class);
- modelBinder.addBinding().to(FacesConfigParser.class);
-
Multibinder.newSetBinder(binder(),CdkWriter.class).addBinding().to(FacesConfigGenerator.class);
+ Multibinder.newSetBinder(binder(), ModelBuilder.class)
+ .addBinding().to(FacesConfigParser.class);
+ Multibinder.newSetBinder(binder(),CdkWriter.class)
+ .addBinding().to(FacesConfigGenerator.class);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AdapterBase.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,45 +30,197 @@
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ModelElement;
+import org.richfaces.cdk.model.Extensible;
+import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.util.Collection;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.beans.PropertyDescriptor;
+import java.beans.Introspector;
/**
* <p class="changed_added_4_0"></p>
*
* @author asmirnov(a)exadel.com
*/
-public abstract class AdapterBase<K, V> extends XmlAdapter<K, V> {
+public abstract class AdapterBase<Bean, Model> extends XmlAdapter<Bean,
Model> {
@Override
- public K marshal(V model) throws CdkException {
- K bean = JAXBBinding.createAdapter(getBeanClass(model), model);
+ public Bean marshal(Model model) throws CdkException {
+ Bean bean = createBean(getBeanClass(model), model);
postMarshal(model, bean);
return bean;
}
- protected void postMarshal(V model, K bean) {
+ /**
+ * <p class="changed_added_4_0">
+ * This method creates adapter object and copies properties from model
+ * object to adapter.
+ * </p>
+ *
+ * @param beanClass
+ * adapter class.
+ * @param model
+ * model object class.
+ * @return initialized instance of adapter object.
+ *
+ * @throws org.richfaces.cdk.CdkException
+ */
+ public Bean createBean(Class<? extends Bean> beanClass, Model model) throws
CdkException {
+ try {
+ Bean adapter = beanClass.newInstance();
+
+ // Copy properties from model to adapter.
+ copyProperties(model, adapter);
+ if (model instanceof Extensible && adapter instanceof Extensible) {
+ copyExtensions((Extensible) model, (Extensible) adapter, true);
+ }
+
+ return adapter;
+ } catch (InstantiationException e) {
+ throw new CdkException("JAXB adapter class instantiation error",
e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("JAXB adapter class instantiation error",
e);
+ }
+ }
+
+ protected void postMarshal(Model model, Bean bean) {
// template method to perform additional conversations
}
- protected abstract Class<? extends K> getBeanClass(V model);
+ protected abstract Class<? extends Bean> getBeanClass(Model model);
@Override
- public V unmarshal(K bean) throws CdkException {
- V model = JAXBBinding.createModelElement(getModelClass(bean), bean);
+ public Model unmarshal(Bean bean) throws CdkException {
+ Model model = createModelElement(getModelClass(bean), bean);
postUnmarshal(bean, model);
return model;
}
- protected void postUnmarshal(K bean, V model) {
+ protected <D, E extends ConfigExtension> E createExtension(D destination)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException {
+
+ Method method = destination.getClass().getMethod("getExtension");
+ return ((Class<E>) method.getReturnType()).newInstance();
+ }
+
+ private void copyExtensions(Extensible source, Extensible<ConfigExtension>
destination, boolean fromModel) {
+ try {
+ ConfigExtension sourceExtension = source.getExtension();
+
+ if (null != sourceExtension) {
+ ConfigExtension destinationExtension = createExtension(destination);
+
+ destinationExtension.setExtensions(sourceExtension.getExtensions());
+
+ if (fromModel) {
+ copyProperties(source, destinationExtension);
+ } else {
+ copyProperties(sourceExtension, destination);
+ }
+
+ destination.setExtension(destinationExtension);
+ } else if (fromModel) {
+ ConfigExtension destinationExtension = createExtension(destination);
+
+ copyProperties(source, destinationExtension);
+ destination.setExtension(destinationExtension);
+ }
+ } catch (Exception e) {
+ throw new CdkException("Properties copiing error", e);
+ }
+ }
+
+ protected static void copyProperties(Object source, Object destination) throws
CdkException {
+ try {
+ PropertyDescriptor[] targetProperties =
+
Introspector.getBeanInfo(destination.getClass()).getPropertyDescriptors();
+ PropertyDescriptor[] sourceProperties =
+ Introspector.getBeanInfo(source.getClass()).getPropertyDescriptors();
+
+ for (PropertyDescriptor targetProperty : targetProperties) {
+ String name = targetProperty.getName();
+
+ for (PropertyDescriptor sourceProperty : sourceProperties) {
+ if (!JAXBBinding.IGNORE_PROPERTIES.contains(name)
+ && name.equals(sourceProperty.getName())) {
+
+ writeProperty(source, destination, targetProperty,
sourceProperty);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new CdkException("Properties copiing error", e);
+ }
+ }
+
+ private static void writeProperty(Object source, Object destination,
PropertyDescriptor targetProperty, PropertyDescriptor sourceProperty) throws
IllegalAccessException, InvocationTargetException {
+ Method readMethod = sourceProperty.getReadMethod();
+ if (readMethod == null) {
+ return;
+ }
+
+ Object propertyValue = readMethod.invoke(source);
+ if (propertyValue != null) {
+ Class<?> targetType = targetProperty.getPropertyType();
+ Class<?> sourceType = sourceProperty.getPropertyType();
+
+ Method writeMethod = targetProperty.getWriteMethod();
+ if (JAXBBinding.isCollections(targetType, propertyValue)) {
+ Collection targetCollection =
+ (Collection) targetProperty.getReadMethod().invoke(destination);
+
+ if (null != targetCollection) {
+ targetCollection.addAll((Collection) propertyValue);
+ } else if (writeMethod != null) {
+ writeMethod.invoke(destination, propertyValue);
+ }
+ } else if (writeMethod != null) {
+ if (targetType.equals(sourceType)) {
+ writeMethod.invoke(destination, propertyValue);
+ } else if (targetType.equals(String.class)) {
+ writeMethod.invoke(destination, propertyValue.toString());
+ }
+ }
+ }
+ }
+
+ protected Model createModelElement(Class<? extends Model> modelClass, Bean
adapter) {
+ try {
+
+ Model modelBean = modelClass.newInstance();
+
+ copyProperties(adapter, modelBean);
+
+ if (adapter instanceof Extensible && modelBean instanceof Extensible)
{
+ copyExtensions((Extensible) adapter, (Extensible) modelBean, false);
+ }
+
+ return modelBean;
+ } catch (Exception e) {
+ throw new CdkException("CDK model class instantiation error", e);
+ }
+ }
+
+ protected void postUnmarshal(Bean bean, Model model) {
// template method to perform additional conversations
}
- protected abstract Class<? extends V> getModelClass(K bean);
+ protected abstract Class<? extends Model> getModelClass(Bean bean);
- protected <K, B extends MapEntry<K>, M extends ModelElement<? super
M>> List<B> marshalMap(Map<K, M> map,
+ /**
+ *
+ * @param map
+ * @param adapter
+ *
+ * @return
+ *
+ * */
+ protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>
& Extensible> List<B> marshalMap(Map<K, M> map,
AdapterBase<B, M> adapter) throws CdkException {
List<B> result = Lists.newArrayList();
@@ -82,7 +234,7 @@
return result;
}
- protected <K, B extends MapEntry<K>, M extends ModelElement<? super
M>> Map<K, M> unmarshalMap(
+ protected <K, B extends MapEntry<K>, M extends ModelElement<? super M>
& Extensible> Map<K, M> unmarshalMap(
List<B> list, AdapterBase<B, M> adapter) throws CdkException {
Map<K, M> map = Maps.newHashMap();
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -35,12 +35,12 @@
@Override
protected Class<? extends PropertyBase> getBeanClass(Property prop) {
- return prop instanceof AttributeModel ?AttributeBean.class:PropertyBean.class;
+ return prop instanceof AttributeModel ? AttributeBean.class :
PropertyBean.class;
}
@Override
protected Class<? extends Property> getModelClass(PropertyBase bean) {
- return bean instanceof AttributeBean? AttributeModel.class:Property.class;
+ return bean instanceof AttributeBean ? AttributeModel.class : Property.class;
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -27,7 +27,7 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
/**
@@ -35,8 +35,8 @@
*
* @author asmirnov(a)exadel.com
*/
-@XmlType(name="faces-config-attributeType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
-
propOrder={"key","type","defaultValue","suggestedValue","extension"})
+@XmlType(name = "faces-config-attributeType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ propOrder = {"key", "type", "defaultValue",
"suggestedValue", "extension"})
public class AttributeBean extends PropertyBase {
/**
@@ -44,7 +44,7 @@
*
* @return the name
*/
- @XmlElement(name = "attribute-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,required=true)
+ @XmlElement(name = "attribute-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE, required = true)
public String getKey() {
return super.getKey();
}
@@ -54,24 +54,24 @@
*
* @return the type
*/
- @XmlElement(name = "attribute-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,required=true)
+ @XmlElement(name = "attribute-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE, required = true)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getType() {
+ public ClassName getType() {
return super.getType();
}
@Override
- public void setType(ClassDescription type) {
+ public void setType(ClassName type) {
super.setType(type);
}
-
+
@Override
@XmlElement(name = "default-value", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public String getDefaultValue() {
return super.getDefaultValue();
}
-
+
@Override
public void setDefaultValue(String defaultValue) {
super.setDefaultValue(defaultValue);
@@ -88,7 +88,7 @@
public void setSuggestedValue(String suggestedValue) {
super.setSuggestedValue(suggestedValue);
}
-
+
@Override
@XmlElement(name = "attribute-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public PropertyExtension getExtension() {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -27,7 +27,7 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
@@ -38,7 +38,7 @@
*/
@XmlType(name = "faces-config-client-behavior-rendererType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class BehaviorRendererBean {
- private ClassDescription rendererClass;
+ private ClassName rendererClass;
private String type;
/**
@@ -67,7 +67,7 @@
*/
@XmlElement(name = "client-behavior-renderer-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRendererClass() {
+ public ClassName getRendererClass() {
return rendererClass;
}
@@ -76,7 +76,7 @@
*
* @param rendererClass the rendererClass to set
*/
- public void setRendererClass(ClassDescription rendererClass) {
+ public void setRendererClass(ClassName rendererClass) {
this.rendererClass = rendererClass;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -25,16 +25,16 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
/**
* <p class="changed_added_4_0"></p>
*
* @author asmirnov(a)exadel.com
*/
-public class ClassAdapter extends XmlAdapter<ClassBean, ClassDescription> {
+public class ClassAdapter extends XmlAdapter<ClassBean, ClassName> {
@Override
- public ClassBean marshal(ClassDescription v) throws Exception {
+ public ClassBean marshal(ClassName v) throws Exception {
ClassBean bean = new ClassBean();
bean.setName(v.getName());
@@ -43,7 +43,7 @@
}
@Override
- public ClassDescription unmarshal(ClassBean v) throws Exception {
- return new ClassDescription(v.getName());
+ public ClassName unmarshal(ClassBean v) throws Exception {
+ return new ClassName(v.getName());
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -24,9 +24,9 @@
package org.richfaces.cdk.xmlconfig.model;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.FacetModel;
-import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.*;
+
+import java.util.Collection;
import org.richfaces.cdk.model.ComponentModel.Type;
@@ -50,24 +50,34 @@
protected Class<? extends ComponentModel> getModelClass(ComponentBean b) {
return ComponentModel.class;
}
-
+
@Override
protected void postMarshal(ComponentModel model, ComponentBean bean) {
// Copy properties/attributes
- bean.setAttributes(marshalMap(model.getAttributes(),ATTRIBUTE_ADAPTER));
- bean.setFacets(marshalMap(model.getFacets(),FACET_ADAPTER));
+ bean.setAttributes(marshalMap(model.getAttributes(), ATTRIBUTE_ADAPTER));
+ bean.setFacets(marshalMap(model.getFacets(), FACET_ADAPTER));
}
-
+
@Override
protected void postUnmarshal(ComponentBean bean, ComponentModel model) {
+ model.setGenerate(false);
+ model.setGeneratedClass(bean.getComponentClass());
+
// Copy type.
String type = bean.getType();
- if(null != type){
+ if (null != type) {
model.setType(new Type(type.trim()));
}
// Copy properties/attributes
- model.getAttributes().putAll(this.<String, PropertyBase,
Property>unmarshalMap(bean.getAttributes(), ATTRIBUTE_ADAPTER));
+ model.getAttributes().putAll(this.<String, PropertyBase,
Property>unmarshalMap(
+ bean.getAttributes(), ATTRIBUTE_ADAPTER));
model.getFacets().putAll(this.<String, FacetBean,
FacetModel>unmarshalMap(bean.getFacets(), FACET_ADAPTER));
-// model.getFacets().putAll(unmarshalMap(bean.getExtension().getRendererTypes(),
FACET_ADAPTER));
+ Collection<RendererModel> renderers = model.getRenderers();
+ ComponentBean.ComponentExtension extension = bean.getExtension();
+ if (renderers != null && extension != null) {
+ for (String renderType : extension.getRendererTypes()) {
+ renderers.add(new RendererModel(new RendererModel.Type(renderType)));
+ }
+ }
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,7 +30,7 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.EventModel;
@@ -47,9 +47,11 @@
"attributes", "extension"})
@XmlJavaTypeAdapter(ComponentAdapter.class)
public class ComponentBean extends ExtensibleBean<ComponentBean.ComponentExtension>
{
+ private boolean generate = false;
+
private List<PropertyBase> attributes = Lists.newArrayList();
private List<FacetBean> facets = Lists.newArrayList();
- private ClassDescription componentClass;
+ private ClassName componentClass;
private String type;
/**
@@ -78,16 +80,16 @@
*/
@XmlElement(name = "component-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getComponentClass() {
+ public ClassName getComponentClass() {
return componentClass;
}
/**
* <p class="changed_added_4_0"></p>
*
- * @param componentClass the componentClass to set
+ * @param className the componentClass to set
*/
- public void setComponentClass(ClassDescription className) {
+ public void setComponentClass(ClassName className) {
this.componentClass = className;
}
@@ -114,7 +116,7 @@
/**
* <p class="changed_added_4_0"></p>
*
- * @param attributes the attributes to set
+ * @param property the attributes to set
*/
public void setAttributes(List<PropertyBase> property) {
this.attributes = property;
@@ -158,7 +160,7 @@
public static class ComponentExtension extends ConfigExtension {
private List<String> rendererTypes = Lists.newArrayList();
private List<EventModel> events = Lists.newArrayList();
- private ClassDescription baseClass;
+ private ClassName baseClass;
private String family;
private boolean generate;
@@ -188,7 +190,7 @@
*/
@XmlElement(name = "base-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getBaseClass() {
+ public ClassName getBaseClass() {
return baseClass;
}
@@ -197,7 +199,7 @@
*
* @param baseClass the baseClass to set
*/
- public void setBaseClass(ClassDescription baseClass) {
+ public void setBaseClass(ClassName baseClass) {
this.baseClass = baseClass;
}
@@ -259,4 +261,12 @@
this.events = events;
}
}
+
+ public boolean isGenerate() {
+ return generate;
+ }
+
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -99,7 +99,7 @@
/**
* <p class="changed_added_4_0"></p>
*
- * @param attributes the attributes to set
+ * @param property the attributes to set
*/
public void setAttributes(List<PropertyBase> property) {
this.attributes = property;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -6,8 +6,8 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.DescriptionGroup;
-@XmlType(name="descriptionType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"description","displayname","icon"})
+@XmlType(name = "descriptionType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ propOrder = {"description", "displayname",
"icon"})
public class DescriptionGroupBean implements DescriptionGroup {
private String description;
private String displayname;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/EventBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -27,7 +27,7 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
/**
@@ -38,9 +38,9 @@
@XmlType(name = "faces-eventType", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public class EventBean {
private String description;
- private ClassDescription listenerInterface;
- private ClassDescription sourceInterface;
- private ClassDescription tagHandler;
+ private ClassName listenerInterface;
+ private ClassName sourceInterface;
+ private ClassName tagHandler;
private String type;
/**
@@ -88,7 +88,7 @@
*/
@XmlElement(name = "listener-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getListenerInterface() {
+ public ClassName getListenerInterface() {
return listenerInterface;
}
@@ -97,7 +97,7 @@
*
* @param listenerInterface the listenerInterface to set
*/
- public void setListenerInterface(ClassDescription listenerInterface) {
+ public void setListenerInterface(ClassName listenerInterface) {
this.listenerInterface = listenerInterface;
}
@@ -108,7 +108,7 @@
*/
@XmlElement(name = "source-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getSourceInterface() {
+ public ClassName getSourceInterface() {
return sourceInterface;
}
@@ -117,7 +117,7 @@
*
* @param sourceInterface the sourceInterface to set
*/
- public void setSourceInterface(ClassDescription sourceInterface) {
+ public void setSourceInterface(ClassName sourceInterface) {
this.sourceInterface = sourceInterface;
}
@@ -128,7 +128,7 @@
*/
@XmlElement(name = "tag-handler-class", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getTagHandler() {
+ public ClassName getTagHandler() {
return tagHandler;
}
@@ -137,7 +137,7 @@
*
* @param tagHandler the tagHandler to set
*/
- public void setTagHandler(ClassDescription tagHandler) {
+ public void setTagHandler(ClassName tagHandler) {
this.tagHandler = tagHandler;
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -48,7 +48,7 @@
* @author asmirnov(a)exadel.com
*/
@XmlRootElement(name = "faces-config", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
-@XmlType(name="faces-configType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+@XmlType(name = "faces-configType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
public class FacesConfigBean implements
Extensible<FacesConfigBean.FacesConfigExtension> {
@XmlElement(name = "component", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ComponentAdapter.class)
@@ -72,7 +72,7 @@
@XmlAttribute
private String version = "2.0";
- @XmlAttribute(name="metadata-complete")
+ @XmlAttribute(name = "metadata-complete")
private boolean metadataComplete;
@XmlElement(name = "faces-config-extension", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,7 +30,7 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.EventName;
@@ -47,7 +47,7 @@
private String defaultValue;
private String name;
private String suggestedValue;
- private ClassDescription type;
+ private ClassName type;
/**
* <p class="changed_added_4_0"></p>
@@ -72,7 +72,7 @@
*
* @return the type
*/
- public ClassDescription getType() {
+ public ClassName getType() {
return type;
}
@@ -81,7 +81,7 @@
*
* @param type the type to set
*/
- public void setType(ClassDescription type) {
+ public void setType(ClassName type) {
this.type = type;
}
@@ -139,7 +139,7 @@
public static class PropertyExtension extends ConfigExtension {
private boolean passThrough = false;
private Set<EventName> eventNames = Sets.newLinkedHashSet();
- private List<ClassDescription> signature = Lists.newArrayList();
+ private List<ClassName> signature = Lists.newArrayList();
private Set<String> aliases = Sets.newHashSet();
private boolean generate;
private boolean hidden;
@@ -288,7 +288,7 @@
@XmlElementWrapper(name = "signature", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlElement(name = "param", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public List<ClassDescription> getSignature() {
+ public List<ClassName> getSignature() {
return signature;
}
@@ -297,7 +297,7 @@
*
* @param signature the signature to set
*/
- public void setSignature(List<ClassDescription> signature) {
+ public void setSignature(List<ClassName> signature) {
this.signature = signature;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -27,7 +27,7 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
/**
@@ -61,13 +61,13 @@
*/
@XmlElement(name = "property-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getType() {
+ public ClassName getType() {
return super.getType();
}
@Override
- public void setType(ClassDescription type) {
+ public void setType(ClassName type) {
super.setType(type);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,12 +30,8 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.BehaviorRenderer;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.RenderKitModel;
-import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.model.RenderKitModel.Id;
import com.google.common.collect.Lists;
@@ -51,7 +47,7 @@
private List<RendererModel> renderers = Lists.newArrayList();
private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
- private ClassDescription renderkitClass;
+ private ClassName renderkitClass;
private Id key = new Id(RenderKitFactory.HTML_BASIC_RENDER_KIT);
@@ -74,7 +70,7 @@
*/
@XmlElement(name = "render-kit-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRenderkitClass() {
+ public ClassName getRenderkitClass() {
return renderkitClass;
}
@@ -83,7 +79,7 @@
*
* @param renderkitClass the renderkitClass to set
*/
- public void setRenderkitClass(ClassDescription renderkitClass) {
+ public void setRenderkitClass(ClassName renderkitClass) {
this.renderkitClass = renderkitClass;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,10 +30,10 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.richfaces.cdk.model.AttributeModel;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.Tag;
+import org.richfaces.cdk.model.TagModel;
import com.google.common.collect.Lists;
@@ -50,7 +50,7 @@
private List<AttributeModel> attributes = Lists.newArrayList();
private String family;
- private ClassDescription rendererClass;
+ private ClassName rendererClass;
private String type;
/**
@@ -103,7 +103,7 @@
*/
@XmlElement(name = "renderer-class", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ClassAdapter.class)
- public ClassDescription getRendererClass() {
+ public ClassName getRendererClass() {
return rendererClass;
}
@@ -113,7 +113,7 @@
*
* @param rendererClass the rendererClass to set
*/
- public void setRendererClass(ClassDescription rendererClass) {
+ public void setRendererClass(ClassName rendererClass) {
this.rendererClass = rendererClass;
}
@@ -161,7 +161,7 @@
* @author asmirnov(a)exadel.com
*/
public static class RendererExtension extends ConfigExtension {
- private Tag tag;
+ private TagModel tag;
private boolean rendersChildren;
@@ -169,10 +169,12 @@
* <p class="changed_added_4_0">
* </p>
*
+ * TODO
+ *
* @return the tag
*/
- @XmlElement(name = "tag", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public Tag getTag() {
+// @XmlElement(name = "tag", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public TagModel getTag() {
return this.tag;
}
@@ -182,7 +184,7 @@
*
* @param tag the tag to set
*/
- public void setTag(Tag tag) {
+ public void setTag(TagModel tag) {
this.tag = tag;
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -14,7 +14,7 @@
@javax.xml.bind.annotation.XmlNs(prefix = "",
namespaceURI = ComponentLibrary.FACES_CONFIG_NAMESPACE)})
@XmlJavaTypeAdapters({
- @XmlJavaTypeAdapter(type = ClassDescription.class, value = ClassAdapter.class),
+ @XmlJavaTypeAdapter(type = ClassName.class, value = ClassAdapter.class),
@XmlJavaTypeAdapter(type = ComponentLibrary.class, value = FacesConfigAdapter.class)
})
package org.richfaces.cdk.xmlconfig.model;
@@ -24,6 +24,6 @@
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor-primitive.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor-primitive.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor-primitive.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,21 @@
+ public void ${attribute.setterName}(${attribute.simpleTypeName} ${attribute.name}) {
+ this.${attribute.name} = ${attribute.name};
+ this.is${attribute.capitalizeName}Setted = true;
+ }
+
+ public ${attribute.simpleTypeName} ${attribute.getterName}() {
+ if (this.is${attribute.capitalizeName}Setted) {
+ return ${attribute.name};
+ }
+
+ ValueBinding vb = getValueBinding("${attribute.name}");
+ if (vb != null) {
+ ${attribute.typeForCasting} value = (${attribute.typeForCasting})
vb.getValue(getFacesContext());
+ if (value == null) {
+ return ${attribute.name};
+ }
+ return value;
+ } else {
+ return this.${attribute.name};
+ }
+ }
\ No newline at end of file
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attribute-accessor.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,16 @@
+ public void ${attribute.setterName}(${attribute.simpleTypeName} ${attribute.name}) {
+ this.${attribute.name} = ${attribute.name};
+ }
+
+ public ${attribute.simpleTypeName} ${attribute.getterName}() {
+ if (${attribute.name} != null) {
+ return ${attribute.name};
+ }
+
+ ValueBinding vb = getValueBinding("${attribute.name}");
+ if (null != vb) {
+ return (${attribute.simpleTypeName}) vb.getValue(getFacesContext());
+ }
+
+ return ${attribute.name};
+ }
\ No newline at end of file
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes-old.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes-old.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes-old.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,21 @@
+ <#list generatedAttributes as attribute>
+ private ${attribute.simpleTypeName} ${attribute.name};
+ <#if (attribute.isPrimitive)>private boolean
is${attribute.capitalizeName}Setted = false;</#if>
+ </#list>
+
+ <#list generatedAttributes as attribute>
+
+ <#if (attribute.isPrimitive)>
+ <#include "_attribute-accessor-primitive.ftl" />
+ <#else>
+ <#include "_attribute-accessor.ftl" />
+ </#if>
+ </#list>
+
+ private static FacesContext getFacesContext() {
+ return FacesContext.getCurrentInstance();
+ }
+
+ private static ValueBinding getValueBinding(String name) {
+ return getFacesContext().getApplication().createValueBinding(name);
+ }
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,28 @@
+ protected enum Properties {
+ <#list generatedAttributes as attribute>${attribute.name}<#if
attribute_has_next>${",\n "}</#if></#list>
+ }
+
+ <#list generatedAttributes as attribute>
+
+ <#if (attribute.description?if_exists) >
+ /**
+ * ${attribute.description}
+ **/
+ </#if>
+ public ${attribute.simpleTypeName} ${attribute.getterName}() {
+ return (${attribute.typeForCasting})
getStateHelper().eval(Properties.${attribute.name});
+ }
+
+ public void ${attribute.setterName}(${attribute.simpleTypeName} ${attribute.name}) {
+ getStateHelper().put(Properties.${attribute.name}, ${attribute.name});
+ }
+ </#list>
+
+ private StateHelper stateHelper = null;
+
+ protected StateHelper getStateHelper() {
+ if (stateHelper == null) {
+ stateHelper = new PartialStateHolderHelper(this);
+ }
+ return stateHelper;
+ }
\ No newline at end of file
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,2 @@
+<#list generatedAttributes as attribute><#if (!attribute.isPredefined)
>import ${attribute.type};
+</#if></#list>
\ No newline at end of file
Copied:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_copyright.ftl
(from rev 16354,
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_copyright.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_copyright.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,21 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
\ No newline at end of file
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods-old.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods-old.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods-old.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,61 @@
+ // ----------------------------------------------------- StateHolder Methods
+ @Override
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (!initialStateMarked()) {
+ Object values[] = new Object[1];
+ <#list generatedAttributes as attribute>
+ values[${attribute_index}] = this.${attribute.getterName}();
+ </#list>
+
+ return values;
+ }
+ return null;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ Object values[] = (Object[]) state;
+ <#list generatedAttributes as attribute>
+ ${attribute.setterName}((${attribute.typeForCasting})
values[${attribute_index}]);
+ </#list>
+ }
+
+ private boolean transientValue = false;
+
+ @Override
+ public boolean isTransient() {
+ return this.transientValue;
+ }
+
+ @Override
+ public void setTransient(boolean transientValue) {
+ this.transientValue = transientValue;
+ }
+
+
+ private boolean initialState;
+
+ @Override
+ public void markInitialState() {
+ initialState = true;
+ }
+
+ @Override
+ public boolean initialStateMarked() {
+ return initialState;
+ }
+
+ @Override
+ public void clearInitialState() {
+ initialState = false;
+ }
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_state-holder-methods.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,40 @@
+ // ----------------------------------------------------- StateHolder Methods
+ @Override
+ public Object saveState(FacesContext context) {
+ return stateHelper.saveState(context);
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ stateHelper.restoreState(context, state);
+ }
+
+ private boolean transientValue = false;
+
+ @Override
+ public boolean isTransient() {
+ return this.transientValue;
+ }
+
+ @Override
+ public void setTransient(boolean transientValue) {
+ this.transientValue = transientValue;
+ }
+
+ private boolean initialState;
+
+ @Override
+ public void markInitialState() {
+ initialState = true;
+ }
+
+ @Override
+ public boolean initialStateMarked() {
+ return initialState;
+ }
+
+ @Override
+ public void clearInitialState() {
+ initialState = false;
+ }
+
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,13 +1,14 @@
-<#include "copyright.ftl">
+<#include "_copyright.ftl">
package ${behaviorClass.package};
import javax.annotation.Generated;
import javax.faces.component.PartialStateHolder;
-import javax.faces.component.StateHelper;
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.event.BehaviorEvent;
+import javax.faces.el.ValueBinding;
+<#include "_attributes_import.ftl">
/**
* ${description?if_exists}
@@ -19,93 +20,7 @@
public void broadcast(BehaviorEvent event) {
}
- protected enum Properties {
- <#list generatedAttributes as attribute>${attribute.name}<#if
attribute_has_next>${",\n "}</#if></#list>
- }
+ <#include "_attributes-old.ftl">
- <#list generatedAttributes as attribute>
- /**
- * ${attribute.description?if_exists}
- **/
- public ${attribute.type} ${attribute.getterName}(){
- return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
- }
-
- /**
- * Setter for ${attribute.name}
- **/
- public void ${attribute.setterName}(${attribute.type} ${attribute.name}){
- getStateHelper().put(Properties.${attribute.name},${attribute.name});
- }
- </#list>
-
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
- }
-
- protected StateHelper getStateHelper(boolean create) {
- return null;
- }
-
- // ----------------------------------------------------- StateHolder Methods
- @Override
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (!initialStateMarked()) {
- Object values[] = new Object[1];
- <#list generatedAttributes as attribute>
- values[${attribute_index}] = this.${attribute.getterName}();
- </#list>
-
- return values;
- }
- return null;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- Object values[] = (Object[]) state;
- <#list generatedAttributes as attribute>
- ${attribute.setterName}((${attribute.type}) values[${attribute_index}]);
- </#list>
- }
-
- private boolean transientValue = false;
-
- @Override
- public boolean isTransient() {
- return this.transientValue;
- }
-
- @Override
- public void setTransient(boolean transientValue) {
- this.transientValue = transientValue;
- }
-
-
- private boolean initialState;
-
- @Override
- public void markInitialState() {
- initialState = true;
- }
-
- @Override
- public boolean initialStateMarked() {
- return initialState;
- }
-
- @Override
- public void clearInitialState() {
- initialState = false;
- }
+ <#include "_state-holder-methods-old.ftl">
}
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -3,7 +3,7 @@
<#nested item/><#if item_has_next>${delimiter}</#if>
</#list>
</#macro>
-<#include "copyright.ftl">
+<#include "_copyright.ftl">
package ${componentClass.package};
@@ -19,12 +19,13 @@
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
+import ${baseClass};
/**
* ${description?if_exists}
**/
@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
-public class ${componentClass.simpleName} extends ${baseClass} <#if (eventNames?size
> 0)>implements ClientBehaviorHolder</#if> {
+public class ${componentClass.simpleName} extends ${baseClass.simpleName} <#if
(eventNames?size > 0)>implements ClientBehaviorHolder</#if> {
public static final String COMPONENT_TYPE="${type}";
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,13 +1,15 @@
-<#include "copyright.ftl">
+<#include "_copyright.ftl">
package ${converterClass.package};
import javax.annotation.Generated;
-import javax.faces.component.StateHelper;
import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import org.richfaces.PartialStateHolderHelper;
+<#include "_attributes_import.ftl">
/**
* ${description?if_exists}
@@ -15,103 +17,17 @@
@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
public class ${converterClass.simpleName} extends ${baseClass} implements Converter,
PartialStateHolder {
+ @Override
public Object getAsObject(FacesContext context, UIComponent component, String value)
{
return null;
}
+ @Override
public String getAsString(FacesContext context, UIComponent component, Object value)
{
return null;
}
- protected enum Properties {
- <#list generatedAttributes as attribute>${attribute.name}<#if
attribute_has_next>${",\n "}</#if></#list>
- }
+ <#include "_attributes.ftl">
- <#list generatedAttributes as attribute>
- /**
- * ${attribute.description?if_exists}
- **/
- public ${attribute.type} ${attribute.getterName}() {
- return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
- }
-
- /**
- * Setter for ${attribute.name}
- **/
- public void ${attribute.setterName}(${attribute.type} ${attribute.name}) {
- getStateHelper().put(Properties.${attribute.name},${attribute.name});
- }
- </#list>
-
-
-
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
- }
-
- protected StateHelper getStateHelper(boolean create) {
- return null;
- }
-
- // ----------------------------------------------------- StateHolder Methods
- @Override
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (!initialStateMarked()) {
- Object values[] = new Object[1];
- <#list generatedAttributes as attribute>
- values[${attribute_index}] = this.${attribute.getterName}();
- </#list>
-
- return values;
- }
- return null;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- Object values[] = (Object[]) state;
- <#list generatedAttributes as attribute>
- ${attribute.setterName}((${attribute.type}) values[${attribute_index}]);
- </#list>
- }
-
- private boolean transientValue = false;
-
- @Override
- public boolean isTransient() {
- return this.transientValue;
- }
-
- @Override
- public void setTransient(boolean transientValue) {
- this.transientValue = transientValue;
- }
-
-
- private boolean initialState;
-
- @Override
- public void markInitialState() {
- initialState = true;
- }
-
- @Override
- public boolean initialStateMarked() {
- return initialState;
- }
-
- @Override
- public void clearInitialState() {
- initialState = false;
- }
+ <#include "_state-holder-methods.ftl">
}
\ No newline at end of file
Deleted:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,21 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-string-method.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-string-method.ftl 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/java/conversion-to-string-method.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1 +1 @@
-return (object != null ? object.toString() : "");
\ No newline at end of file
+return object != null ? object.toString() : "";
\ No newline at end of file
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,45 @@
+<#include "_copyright.ftl">
+
+package ${handler.package};
+
+import javax.faces.view.facelets.*;
+import org.richfaces.MethodMetadata;
+import ${model.generatedClass.name};
+
+public class ${handler.simpleName} extends ${handler.parent.simpleName} {
+
+ private static final ${handler.simpleName}MetaRule metaRule = new
${handler.simpleName}MetaRule();
+
+
+ public ${handler.simpleName}(${objectType}Config config) {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(metaRule);
+ return m;
+ }
+
+ static class ${handler.simpleName}MetaRule extends MetaRule{
+
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(${model.generatedClass.simpleName}.class)) {
+ <#list model.generatedAttributes as prop>
+ <#if (prop.isBingingAttribute) >
+ if ("${prop.name}".equals(name)) {
+ return new MethodMetadata(attribute) {
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((${model.generatedClass.simpleName})
instance).${prop.setterName}(
+ <#if
(prop.isBinging)>getMethodBinding(ctx));<#else>getMethodExpression(ctx));</#if>
+ }
+ };
+ }
+
+ </#if>
+ </#list>
+ }
+ return null;
+ }
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,14 +1,15 @@
-<#include "copyright.ftl">
+<#include "_copyright.ftl">
package ${validatorClass.package};
import javax.annotation.Generated;
-import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.component.PartialStateHolder;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
+import javax.faces.el.ValueBinding;
+<#include "_attributes_import.ftl">
/**
* ${description?if_exists}
@@ -21,96 +22,7 @@
}
- protected enum Properties {
- <#list generatedAttributes as attribute>${attribute.name}<#if
attribute_has_next>${",\n "}</#if></#list>
- }
+ <#include "_attributes-old.ftl">
-
- <#list generatedAttributes as attribute>
- /**
- * ${attribute.description?if_exists}
- **/
- public ${attribute.type} ${attribute.getterName}(){
- return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
- }
-
- /**
- * Setter for ${attribute.name}
- **/
- public void ${attribute.setterName}(${attribute.type} ${attribute.name}){
- getStateHelper().put(Properties.${attribute.name},${attribute.name});
- }
- </#list>
-
-
-
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
- }
-
- protected StateHelper getStateHelper(boolean create) {
- return null;
- }
-
- // ----------------------------------------------------- StateHolder Methods
- @Override
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (!initialStateMarked()) {
- Object values[] = new Object[1];
- <#list generatedAttributes as attribute>
- values[${attribute_index}] = this.${attribute.getterName}();
- </#list>
-
- return values;
- }
- return null;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- Object values[] = (Object[]) state;
- <#list generatedAttributes as attribute>
- ${attribute.setterName}((${attribute.type}) values[${attribute_index}]);
- </#list>
- }
-
- private boolean transientValue = false;
-
- @Override
- public boolean isTransient() {
- return this.transientValue;
- }
-
- @Override
- public void setTransient(boolean transientValue) {
- this.transientValue = transientValue;
- }
-
-
- private boolean initialState;
-
- @Override
- public void markInitialState() {
- initialState = true;
- }
-
- @Override
- public boolean initialStateMarked() {
- return initialState;
- }
-
- @Override
- public void clearInitialState() {
- initialState = false;
- }
+ <#include "_state-holder-methods-old.ftl">
}
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,3 +1,4 @@
+
/**
*
*/
@@ -3,41 +4,207 @@
package org.richfaces.cdk;
-import org.junit.After;
-import org.junit.Before;
+import org.apache.maven.model.FileSet;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.DirectoryScanner;
import org.junit.Test;
+import org.junit.Ignore;
+import org.richfaces.cdk.apt.AptBuilder;
+import java.io.File;
+import java.util.*;
+import java.net.MalformedURLException;
+
/**
* @author asmirnov
- *
+ *
*/
public class LibraryBuilderTest extends CdkTestBase {
+ private static final String PROJECT_BASE =
"E:\\_richfaces\\svn\\richfaces_root\\ui\\components\\core\\";
+ private static final String[] JAVA_INCLUDES = new String[]{"**/*.java"};
+ private static final String MAIN_CONFIG = "src/main/config";
+ private static final String MAIN_TEMPLATES = "src/main/templates";
+ private static final String[] STRINGS_ARRAY = new String[0];
+ private static final String XML_INCLUDES = "**/*.xml";
+ protected File outputJavaDirectory = new File(PROJECT_BASE +
"target/generated-sources/main/java");
+ protected File outputResourcesDirectory = new File(PROJECT_BASE +
"target/generated-sources/main/resources");
+ protected File outputTestDirectory = new File(PROJECT_BASE +
"target/generated-sources/test/java");
+ protected File outputTestResourcesDirectory = new File(PROJECT_BASE +
"target/generated-sources/test/resources");
+
+ @Test
+// @Ignore
+ public void createInstance() throws Exception {
+ List<String> compileSourceRoots = Arrays.asList("");
+
+ Generator generator = new Generator();
+ generator.setLoader(createClassLoader());
+ // Set source folders.
+ ArrayList<File> folders = new
ArrayList<File>(compileSourceRoots.size());
+
+ for (String sourceFolder : compileSourceRoots) {
+ File folder = new File(sourceFolder);
+
+ if (folder.exists() && folder.isDirectory()) {
+ folders.add(folder);
+ }
+ }
+
+
+ generator.addSources(Sources.JAVA_SOURCES, findJavaFiles(), folders);
+ // TODO - detect templates and configs directories.
+ generator.addSources(Sources.RENDERER_TEMPLATES, findTemplateFiles(), null);
+ generator.addSources(Sources.FACES_CONFIGS, findFacesConfigFiles(), null);
+
+
+ // Setup output folders.
+ setOutput(generator, outputJavaDirectory, Outputs.JAVA_CLASSES);
+ setOutput(generator, outputResourcesDirectory, Outputs.RESOURCES);
+ setOutput(generator, outputTestDirectory, Outputs.TEST_JAVA_CLASSES);
+ setOutput(generator, outputTestResourcesDirectory, Outputs.TEST_RESOURCES);
+
+ // configure CDK workers.
+// setupPlugins(generator);
+
+ try {
+
+ // Build JSF library.
+ // LibraryBuilder builder = LibraryBuilder.createInstance(context);
+ generator.init();
+ generator.execute();
+ } catch (CdkException e) {
+ throw new MojoExecutionException("CDK build error", e);
+ }
+
+ System.out.println("LibraryBuilderTest.createInstance");
+ }
+
+ protected CdkClassLoader createClassLoader() {
+ return new CdkClassLoader(this.getClass().getClassLoader());
+ }
+
/**
- * @throws java.lang.Exception
+ * <p class="changed_added_4_0">This utility method sets output
directory for particular type.
+ * I such directory does not exist, it is created.</p>
+ *
+ * @param generator
+ * @param directory
+ * @param type
*/
- @Before
- public void setUp() throws Exception {
+ private static void setOutput(Generator generator, File directory, Outputs type) {
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+
+ generator.addOutputFolder(type, directory);
}
/**
- * @throws java.lang.Exception
+ * <p class="changed_added_4_0">This method checks library
configuration and sets default values if necessary.</p>
*/
- @After
- public void tearDown() throws Exception {
+ protected void checkLibraryConfig() {
+
+ // TODO Auto-generated method stub
}
+ private File resolveRelativePath(File file) {
+ File result = file;
+ if (!result.isAbsolute()) {
+ result = new File(PROJECT_BASE, result.getPath());
+ }
+
+ return result;
+ }
+
+ private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ FileSet[] templates = null;
+ File defaultDirectory = resolveRelativePath(new File(MAIN_TEMPLATES));
+
+ if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+ FileSet fileSet = new FileSet();
+
+ fileSet.setDirectory(MAIN_TEMPLATES);
+ fileSet.addInclude(XML_INCLUDES);
+ templates = new FileSet[]{fileSet};
+ }
+
+ return doScan(templates);
+ }
+
+ private Iterable<File> findJavaFiles() throws MojoExecutionException {
+ Set<File> javaSources = new HashSet<File>();
+ String[] includes = JAVA_INCLUDES;
+ String compileSourceRoots[] = new String[]{PROJECT_BASE +
"\\src\\main\\java"};
+ for (String compileRoot : compileSourceRoots) {
+ File rootFolder = new File(compileRoot);
+ String[] sources = doScan(includes, null, rootFolder);
+
+ for (String src : sources) {
+ javaSources.add(new File(rootFolder, src));
+ }
+ }
+
+ return javaSources;
+ }
+
+ private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
+ FileSet[] facesConfigs = null;
+ File defaultDirectory = resolveRelativePath(new File(MAIN_CONFIG));
+
+ if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+ FileSet fileSet = new FileSet();
+
+ fileSet.setDirectory(MAIN_CONFIG);
+ fileSet.addInclude(XML_INCLUDES);
+ facesConfigs = new FileSet[]{fileSet};
+ }
+
+ return doScan(facesConfigs);
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root:
\'" + rootFolder + "\'", e);
+ }
+ }
+
/**
- * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
- *
- * @throws Exception
+ * Skan Array of filesets for selected resources.
+ *
+ * @param filesets
+ * @return
+ * @throws MojoExecutionException
*/
- @Test
- public void testInit() throws Exception {
- Generator generator = new Generator();
- // setup CDK configuration.
- generator.setLoader(createClassLoader());
- // Test dependencies tree.
- generator.init();
+ @SuppressWarnings("unchecked")
+ protected Collection<File> doScan(FileSet[] filesets) throws
MojoExecutionException {
+ List<File> files = new ArrayList<File>();
+
+ if (null != filesets) {
+ for (FileSet fileSet : filesets) {
+ String[] includes = (String[])
fileSet.getIncludes().toArray(STRINGS_ARRAY);
+ String[] excludes = (String[])
fileSet.getExcludes().toArray(STRINGS_ARRAY);
+ File fileSetDirectory = resolveRelativePath(new
File(fileSet.getDirectory()));
+ String[] scan = doScan(includes, excludes, fileSetDirectory);
+
+ for (String filename : scan) {
+ files.add(resolveRelativePath(new File(fileSetDirectory,
filename)));
+ }
+ }
+ }
+
+ return files;
}
-
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -72,58 +72,31 @@
assertEquals("foo.baz.Test",
conventions.inferComponentType("", "foo.baz.component.UITest"));
}
- /**
- * Test method for
- * {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- *
- * @throws Exception
- */
+
@Test
public void testInferComponentTypeFromAbstractClass() throws Exception {
assertEquals("foo.baz.Test",
conventions.inferComponentType("",
"foo.baz.component.AbstractTest"));
}
- /**
- * Test method for
- * {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- *
- * @throws Exception
- */
@Test
public void testInferComponentTypeFromBaseClass() throws Exception {
assertEquals("foo.baz.Test",
conventions.inferComponentType("", "foo.baz.component.TestBase"));
}
- /**
- * Test method for
- * {@link org.richfaces.cdk.RichFacesConventions#inferComponentType(java.lang.String,
java.lang.String)}.
- *
- * @throws Exception
- */
@Test
public void testInferComponentTypeFromMarkupClass() throws Exception {
assertEquals("foo.baz.HtmlTest",
conventions.inferComponentType("",
"foo.baz.component.html.HtmlTest"));
}
- /**
- * Test method for
- * {@link
org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String,
java.lang.String, java.lang.String, boolean)}
- * .
- */
@Test
public void testInferUIComponentClassFromExplicit() throws Exception {
- assertEquals("foo.bar.UITest",
conventions.inferUIComponentClass("foo.bar.Test", "foo.bar.UITest",
- "foo.bar.AbstractClass", true));
+ assertEquals("foo.bar.UITest",
+ conventions.inferUIComponentClass("foo.bar.Test",
"foo.bar.UITest", "foo.bar.AbstractClass", true));
}
- /**
- * Test method for
- * {@link
org.richfaces.cdk.RichFacesConventions#inferUIComponentClass(java.lang.String,
java.lang.String, java.lang.String, boolean)}
- * .
- */
@Test
public void testInferUIComponentClassFromType() throws Exception {
- assertEquals("foo.bar.component.UITest",
conventions.inferUIComponentClass("foo.bar.Test", "",
- "foo.bar.AbstractClass", true));
+ assertEquals("foo.bar.component.UITest",
+ conventions.inferUIComponentClass("foo.bar.Test", "",
"foo.bar.AbstractClass", true));
}
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -40,6 +40,7 @@
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Property;
@@ -98,6 +99,16 @@
public String value() {
return "foo.Bar";
}
+
+ public boolean generate() {
+ return true;
+ }
+
+ public Tag tag() {
+ return null;
+ }
+
+
});
replay(log, utils, componentElement, jaxb, conventions);
processor.process(componentElement);
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,7 +30,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
@@ -56,7 +56,7 @@
assertEquals(3, converters.size());
ConverterModel converterModel = Iterables.get(converters, 0);
- ClassDescription forClass = converterModel.getConverterForClass();
+ ClassName forClass = converterModel.getConverterForClass();
if (forClass != null &&
!Object.class.getName().equals(forClass.getName())) {
assertEquals(Integer.class.getName(), forClass.getName());
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -74,6 +74,7 @@
}
}
+ // TODO create Test for ProcessorBase
@Test
@Ignore
public void testSetNames() {
@@ -158,7 +159,7 @@
}
EasyMock.verify();
- ValidatorProcessor.setClassNames(element, validatorModel, validator);
+// ValidatorProcessor.setClassNames(element, validatorModel, validator);
return validatorModel;
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -39,11 +39,8 @@
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.freemarker.CdkConfiguration;
import org.richfaces.cdk.freemarker.LibraryModelWrapper;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.*;
import com.google.inject.Inject;
@@ -73,7 +70,7 @@
protected static Property addAttribute(ModelElementBase model, String attributeName,
Class<?> type, boolean generate) {
Property attribute = model.addAttribute(attributeName);
- attribute.setType(new ClassDescription(type));
+ attribute.setType(new ClassName(type));
attribute.setGenerate(generate);
return attribute;
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -47,21 +47,13 @@
@Inject
private BehaviorClassGenerator generator;
- /**
- * Test method for
- * {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}
- * .
- *
- * @throws Exception
- */
@Test
public void testGetOutputFileBehavior() throws Exception {
final StringWriter outputWriter = new StringWriter();
expect(output.createOutput((String) anyObject(),
anyInt())).andReturn(outputWriter);
replay(output);
- BehaviorModel behavior = new BehaviorModel();
- behavior.setBehaviorId("foo.bar");
+ BehaviorModel behavior = new BehaviorModel("foo.bar");
behavior.setClassNames("org.richfaces.cdk.generate.java.GeneratedBehavior",
"Object");
// TODO add test with types boolean, int, Integer, String, Object
@@ -77,7 +69,7 @@
library.getBehaviors().add(behavior);
generator.visit(behavior, library);
- System.out.println(outputWriter);
+// System.out.println(outputWriter);
verify(output);
compare(outputWriter, "GeneratedBehavior.java");
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -29,11 +29,15 @@
import java.util.Set;
import javax.faces.component.UIOutput;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.MethodBinding;
+import javax.el.ValueExpression;
+import javax.el.MethodExpression;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
@@ -53,44 +57,60 @@
@Inject
private ComponentClassGenerator generator;
- /**
- * Test method for
- * {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}
- * .
- *
- * @throws Exception
- */
@Test
public void testGetOutputFileComponent() throws Exception {
final StringWriter outputWriter = new StringWriter();
expect(output.createOutput((String) anyObject(),
anyInt())).andReturn(outputWriter);
replay(output);
+ ComponentModel component = createComponent();
+
+ library.getComponents().add(component);
+
+ generator.visit(component, library);
+// System.out.println(outputWriter);
+ verify(output);
+
+ compare(outputWriter, "GeneratedComponent.java");
+ }
+
+ public ComponentClassGenerator getGenerator() {
+ return generator;
+ }
+
+ public void setGenerator(ComponentClassGenerator generator) {
+ this.generator = generator;
+ }
+
+ public static ComponentModel createComponent() {
ComponentModel component = new ComponentModel(new
ComponentModel.Type("foo.bar"));
- library.getComponents().add(component);
component.setGenerate(true);
- component.setBaseClass(new ClassDescription(UIOutput.class));
- component.setComponentClass(new
ClassDescription("org.richfaces.cdk.generate.java.GeneratedComponent"));
+
component.setClassNames("org.richfaces.cdk.generate.java.GeneratedComponent",
UIOutput.class.getName());
Property attribute = component.addAttribute("testValue");
+ attribute.setType(new ClassName(Object.class));
+ attribute.setGenerate(true);
- attribute.setType(new ClassDescription(Object.class));
- attribute.setGenerate(true);
attribute = component.addAttribute("testFlag");
- attribute.setType(new ClassDescription(Boolean.class));
+ attribute.setType(new ClassName(Boolean.class));
attribute.setGenerate(true);
+
+ attribute = component.addAttribute("testBinding");
+ attribute.setType(new ClassName(MethodBinding.class));
+ attribute.setGenerate(true);
+
+ attribute = component.addAttribute("testExpr");
+ attribute.setType(new ClassName(MethodExpression.class));
+ attribute.setGenerate(true);
+
attribute = component.addAttribute("id");
- attribute.setType(new ClassDescription(String.class));
+ attribute.setType(new ClassName(String.class));
+ attribute.setGenerate(false);
Set<EventName> eventNames = attribute.getEventNames();
eventNames.add(getEvent("id", false));
eventNames.add(getEvent("action", true));
-
- attribute.setGenerate(false);
- generator.visit(component, library);
- System.out.println(outputWriter);
- verify(output);
-
- compare(outputWriter, "GeneratedComponent.java");
+
+ return component;
}
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -30,10 +30,10 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.freemarker.PropertyModel;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.Property;
import com.google.inject.Inject;
@@ -47,13 +47,6 @@
@Inject
private ConverterClassGenerator generator;
- /**
- * Test method for
- * {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}
- * .
- *
- * @throws Exception
- */
@Test
public void testGetOutputFileValidator() throws Exception {
final StringWriter outputWriter = new StringWriter();
@@ -64,12 +57,14 @@
converter.setConverterId("foo.bar");
converter.setClassNames("org.richfaces.cdk.generate.java.GeneratedConverter",
"Object");
- addAttribute(converter, "testValue", Object.class, true);
- // TODO test with primitiv type 'boolean'
- addAttribute(converter, "testFlag", Boolean.class, true);
- Property attribute = addAttribute(converter, "id", String.class,
false);
+ addAttribute(converter, "myClass", PropertyModel.class, true);
+ addAttribute(converter, "testObject", Object.class, true);
+ addAttribute(converter, "testBoolean", Boolean.class, true);
+ addAttribute(converter, "testInteger", Integer.class, true);
+ addAttribute(converter, "visible", boolean.class, true);
+ addAttribute(converter, "id", String.class, false);
- Set<EventName> eventNames = attribute.getEventNames();
+ Set<EventName> eventNames =
converter.getAttribute("id").getEventNames();
eventNames.add(getEvent("id", false));
eventNames.add(getEvent("action", true));
@@ -77,10 +72,11 @@
library.getConverters().add(converter);
generator.visit(converter, library);
- System.out.println(outputWriter);
-
+// System.out.println(outputWriter);
verify(output);
compare(outputWriter, "GeneratedConverter.java");
}
+
+
}
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java;
+
+import com.google.inject.Inject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.verify;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.generate.java.taghandler.TagHandlerClassGenerator;
+
+import javax.faces.view.facelets.ComponentHandler;
+import java.io.StringWriter;
+
+/**
+ * @author akolonitsky
+ * @since Feb 22, 2010
+ */
+(a)RunWith(CdkTestRunner.class)
+public class TagHandlerClassGeneratorTest extends AbstractClassGeneratorTest {
+
+ @Inject
+ private TagHandlerClassGenerator generator;
+
+ @Test
+ public void testGetOutputFileBehavior() throws Exception {
+ final StringWriter outputWriter = new StringWriter();
+ expect(output.createOutput((String) anyObject(),
anyInt())).andReturn(outputWriter);
+ replay(output);
+
+ ComponentModel model = ComponentClassGeneratorTest.createComponent();
+ library.getComponents().add(model);
+
+ TagModel tagModel = new TagModel();
+ tagModel.setName("mytag");
+ tagModel.setModel(model);
+ tagModel.setHandler(new
ClassDescriptor("org.richfaces.cdk.generate.java.GeneratedTagHandler",
ComponentHandler.class.getName()));
+ generator.process(tagModel);
+
+// System.out.println(outputWriter);
+ verify(output);
+
+ compare(outputWriter, "GeneratedTagHandler.java");
+ }
+
+ public TagHandlerClassGenerator getGenerator() {
+ return generator;
+ }
+
+ public void setGenerator(TagHandlerClassGenerator generator) {
+ this.generator = generator;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -47,13 +47,6 @@
@Inject
private ValidatorClassGenerator generator;
- /**
- * Test method for
- * {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}
- * .
- *
- * @throws Exception
- */
@Test
public void testGetOutputFileValidator() throws Exception {
final StringWriter outputWriter = new StringWriter();
@@ -62,7 +55,7 @@
ValidatorModel validator = new ValidatorModel();
validator.setValidatorId("foo.bar");
-
validator.setClassNames("org.richfaces.cdk.generate.java.GeneratedClass",
"Object");
+
validator.setClassNames("org.richfaces.cdk.generate.java.GeneratedValidator",
"Object");
addAttribute(validator, "testValue", Object.class, true);
// TODO test with primitiv type 'boolean'
@@ -77,11 +70,10 @@
library.getValidators().add(validator);
generator.visit(validator, library);
- System.out.println(outputWriter);
-
+// System.out.println(outputWriter);
verify(output);
- compare(outputWriter, "GeneratedClass.java");
+ compare(outputWriter, "GeneratedValidator.java");
}
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -24,51 +24,21 @@
import static org.easymock.EasyMock.*;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
import java.io.StringWriter;
-import java.net.URISyntaxException;
-import java.util.Set;
-import javax.faces.component.UIOutput;
-
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.Validator;
-import org.easymock.EasyMock;
-import org.junit.Assert;
import org.junit.Test;
+import org.junit.Ignore;
import org.junit.runner.RunWith;
-import org.richfaces.cdk.As;
-import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.Output;
-import org.richfaces.cdk.Outputs;
-import org.richfaces.cdk.freemarker.CdkConfiguration;
-import org.richfaces.cdk.freemarker.LibraryModelWrapper;
-import org.richfaces.cdk.generate.taglib.ValidatorTagGenerator;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.model.Visitable;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.EntityResolver2;
import com.google.inject.Binder;
import com.google.inject.Inject;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.MapBinder;
-import freemarker.template.Configuration;
-import freemarker.template.ObjectWrapper;
-
/**
* @author akolonitsky
* @since Jan 18, 2010
@@ -97,6 +67,7 @@
* @throws Exception
*/
@Test
+ @Ignore
public void testGetOutputFileComponent() throws Exception {
final StringWriter outputWriter = new StringWriter();
expect(output.createOutput(eq("META-INF/test.taglib.xml"),
anyLong())).andReturn(outputWriter);
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -22,22 +22,16 @@
package org.richfaces.cdk.generate.taglib;
-import static org.easymock.EasyMock.*;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URISyntaxException;
-import java.util.Set;
-import javax.faces.component.UIOutput;
-
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.Validator;
import org.junit.Assert;
-import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.As;
import org.richfaces.cdk.CdkTestBase;
@@ -48,12 +42,10 @@
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.freemarker.CdkConfiguration;
import org.richfaces.cdk.freemarker.LibraryModelWrapper;
-import org.richfaces.cdk.generate.taglib.ValidatorTagGenerator;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.ValidatorModel;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;
@@ -98,7 +90,7 @@
protected Property createAttribute( Class<?> type, boolean generate) {
Property attribute = new Property();
- attribute.setType(new ClassDescription(type));
+ attribute.setType(new ClassName(type));
attribute.setGenerate(generate);
return attribute;
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -24,46 +24,25 @@
import static org.easymock.EasyMock.*;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
import java.io.StringWriter;
-import java.net.URISyntaxException;
import java.util.Set;
import javax.faces.component.UIOutput;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.Validator;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.richfaces.cdk.As;
-import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.Output;
-import org.richfaces.cdk.Outputs;
-import org.richfaces.cdk.freemarker.CdkConfiguration;
-import org.richfaces.cdk.freemarker.LibraryModelWrapper;
import org.richfaces.cdk.generate.taglib.ValidatorTagGenerator;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.EntityResolver2;
import com.google.inject.Inject;
-import freemarker.template.Configuration;
-import freemarker.template.ObjectWrapper;
-
/**
+ * TODO ??
+ *
* @author akolonitsky
* @since Jan 18, 2010
*/
@@ -85,7 +64,8 @@
public void testGetOutputFileComponent() throws Exception {
final StringWriter outputWriter = new StringWriter();
- ValidatorModel validator = new ValidatorModel("foo.bar", new
ClassDescription(UIOutput.class));
+ ValidatorModel validator = new ValidatorModel("foo.bar");
+ validator.setGeneratedClass(UIOutput.class);
validator.setGenerate(true);
Property attribute1 = createAttribute( Object.class, true);
@@ -103,7 +83,6 @@
replay(output, resolver);
generator.generate(validator, outputWriter);
- System.out.println(outputWriter);
verify(output, resolver);
checkXmlStructure(outputWriter);
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ClassDescriptionTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -60,11 +60,11 @@
}
/**
- * Test method for {@link
org.richfaces.cdk.model.ClassDescription#ClassDescription(java.lang.String)}.
+ * Test method for {@link ClassName#ClassName(java.lang.String)}.
*/
@Test
public void testClassDescription() {
- ClassDescription description = new ClassDescription(className);
+ ClassName description = new ClassName(className);
assertEquals(className, description.toString());
assertEquals(expectedCanonicalName, description.getName());
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -32,7 +32,6 @@
* @author asmirnov(a)exadel.com
*
*/
-@SuppressWarnings("serial")
public class ModelBean implements ModelElement<ModelBean> {
/**
@@ -40,12 +39,13 @@
* </p>
*/
private static final long serialVersionUID = -4853397197172488116L;
+ String readOnly;
+ String writeOnly;
+
private boolean vizited = false;
private String doNotReplace;
- String readOnly;
private Object result;
private Type type;
- String writeOnly;
public ModelBean() {
}
@@ -172,16 +172,21 @@
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
vizited = true;
- return (R) visitor.visit(this, param);
+ return visitor.visit(this, param);
}
+ public void accept(Visitor visitor) {
+ visitor.visit(this);
+ }
+
@Override
public boolean same(ModelBean other) {
return null != getType() && getType().equals(other.getType());
}
- @SuppressWarnings("serial")
public static final class Type extends Key {
+ private static final long serialVersionUID = 6227413669285563473L;
+
public Type(String type) {
super(type);
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -46,12 +46,8 @@
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.RenderKitModel;
-import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.model.RenderKitModel.Id;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.JAXB;
@@ -109,7 +105,7 @@
}
private void assertNoSignature(Property property) {
- List<ClassDescription> signature = property.getSignature();
+ List<ClassName> signature = property.getSignature();
assertNotNull(signature);
assertTrue(signature.isEmpty());
}
@@ -208,7 +204,7 @@
assertNotNull(actionListenerProperty);
assertNoEventNames(actionListenerProperty);
- assertEquals(Lists.newArrayList(new ClassDescription(ActionEvent.class)),
actionListenerProperty.getSignature());
+ assertEquals(Lists.newArrayList(new ClassName(ActionEvent.class)),
actionListenerProperty.getSignature());
}
/**
@@ -221,9 +217,9 @@
assertNotNull(coolMethodProperty);
assertNoEventNames(coolMethodProperty);
- ArrayList<ClassDescription> expectedSignature =
- Lists.newArrayList(new ClassDescription(int.class), new
ClassDescription(String.class),
- new ClassDescription(Validator.class));
+ ArrayList<ClassName> expectedSignature =
+ Lists.newArrayList(new ClassName(int.class), new ClassName(String.class),
+ new ClassName(Validator.class));
assertEquals(expectedSignature, coolMethodProperty.getSignature());
}
@@ -237,7 +233,7 @@
assertNoSignature(integerAttribute);
assertNotRequired(integerAttribute);
- assertEquals(new ClassDescription(Integer.class), integerAttribute.getType());
+ assertEquals(new ClassName(Integer.class), integerAttribute.getType());
assertEquals("-1", integerAttribute.getDefaultValue());
}
@@ -275,7 +271,7 @@
RenderKitModel renderKit =
getRenderkitFromModel(RenderKitFactory.HTML_BASIC_RENDER_KIT);
RendererModel renderer = getFirstRendererFromRenderkit(renderKit);
- assertEquals(new
ClassDescription("org.richfaces.renderkit.html.BasicRendererImpl"), renderer
+ assertEquals(new
ClassName("org.richfaces.renderkit.html.BasicRendererImpl"), renderer
.getRendererClass());
assertFalse(renderer.isRendersChildren());
}
@@ -296,7 +292,7 @@
RenderKitModel renderKit =
getRenderkitFromModel("org.richfaces.CUSTOM_RENDERKIT");
RendererModel renderer = getFirstRendererFromRenderkit(renderKit);
- assertEquals(new
ClassDescription("org.richfaces.renderkit.html.DummyRendererImpl"), renderer
+ assertEquals(new
ClassName("org.richfaces.renderkit.html.DummyRendererImpl"), renderer
.getRendererClass());
assertTrue(renderer.isRendersChildren());
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -103,7 +103,7 @@
assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
assertEquals("Panel component", component.getDescription());
assertEquals("Panel", component.getDisplayname());
- assertTrue(component.isGenerate());
+ assertFalse(component.isGenerate());
FacetModel facet = Iterables.getOnlyElement(component.getFacets().values());
String key = Iterables.getOnlyElement(component.getFacets().keySet());
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -39,7 +39,7 @@
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.Property;
import org.xml.sax.ext.EntityResolver2;
@@ -133,7 +133,7 @@
assertTrue(property.isPassThrough());
assertTrue(property.isRequired());
- List<ClassDescription> signature = property.getSignature();
+ List<ClassName> signature = property.getSignature();
assertEquals(2, signature.size());
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -5,7 +5,8 @@
import java.util.List;
import org.junit.Test;
-import org.richfaces.cdk.model.ClassDescription;
+import org.junit.Ignore;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.xmlconfig.model.ComponentBean;
import org.richfaces.cdk.xmlconfig.model.PropertyBase;
@@ -19,18 +20,18 @@
private static final String FOO_UI_BAR = "foo.UIBar";
@Test
+ @Ignore
public void testCreateAdapter() throws Exception {
ComponentModel component = new ComponentModel(new ComponentModel.Type(FOO_BAR));
component.setDescription(FOO_DESCTIPTION);
- component.setComponentClass(new ClassDescription(FOO_UI_BAR));
+ component.setGeneratedClass(FOO_UI_BAR);
component.addAttribute(BAZ);
component.setFamily(FOO_FAMILY);
- ComponentBean componentBean = JAXBBinding.createAdapter(ComponentBean.class,
component);
+ ComponentBean componentBean = null;
//JAXBBinding.createAdapter(ComponentBean.class, component);
+ assertEquals(FOO_BAR, componentBean.getType());
- assertEquals(FOO_BAR, componentBean.getType());
-
List<PropertyBase> attributes = componentBean.getAttributes();
assertEquals(0, attributes.size());
Added:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.xmlconfig;
+
+import org.junit.Test;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.generate.taglib.TaglibGeneratorVisitor;
+
+import javax.faces.component.UIOutput;
+import java.util.Set;
+
+/**
+ * @author akolonitsky
+ * @since Feb 3, 2010
+ */
+public class TaglibGeneratorVisitorTest extends XmlTest {
+
+ @Test
+ public void generationTest() throws Exception {
+ ValidatorModel validator = new ValidatorModel("foo.bar");
+ validator.setGeneratedClass(UIOutput.class);
+ validator.setGenerate(true);
+
+ addAttribute(validator, "testValue", Object.class, true);
+ addAttribute(validator, "testFlag", boolean.class, true);
+ Property attribute = addAttribute(validator, "id", String.class,
false);
+
+ Set<EventName> eventNames = attribute.getEventNames();
+ eventNames.add(getEvent("id", false));
+ eventNames.add(getEvent("action", true));
+
+ ComponentLibrary library = new ComponentLibrary();
+ library.getValidators().add(validator);
+
+ TaglibGeneratorVisitor visitor = new TaglibGeneratorVisitor();
+ library.accept(visitor);
+// visitor.generate();
+
+ // TODO validate result
+ }
+
+ private EventName getEvent(String name, boolean defaultEvent) {
+ EventName event = new EventName();
+ event.setName(name);
+ event.setDefaultEvent(defaultEvent);
+ return event;
+ }
+
+ private Property addAttribute(ValidatorModel validator, String attributeName,
Class<?> type, boolean generate) {
+ Property attribute = validator.addAttribute(attributeName);
+ attribute.setType(new ClassName(type));
+ attribute.setGenerate(generate);
+ return attribute;
+ }
+}
Copied:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java
(from rev 16400,
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ModelBeanTest.java)
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/XmlTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,83 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.xmlconfig;
+
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.Validator;
+import org.junit.Assert;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+
+/**
+ * @author akolonitsky
+ * @since Jan 13, 2010
+ */
+public abstract class XmlTest extends JaxbTestBase {
+
+ protected void validateXml(StringWriter facesConfig, String schemaLocation) throws
SAXException, IOException {
+ InputSource is = new InputSource(new StringReader(facesConfig.toString()));
+ Validator validator = new Validator(is);
+ validator.useXMLSchema(true);
+ InputSource source = new CdkEntityResolver()
+ .resolveEntity(null, schemaLocation);
+ validator.setJAXP12SchemaSource(source);
+
+ validator.assertIsValid();
+ }
+
+ protected void validateXml(StringWriter facesConfig) throws SAXException, IOException
{
+ validateXml(facesConfig, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION);
+ }
+
+ protected void validateTaglib(StringWriter facesConfig) throws SAXException,
IOException {
+ validateXml(facesConfig, ComponentLibrary.TAGLIB_SCHEMA_LOCATION);
+ }
+
+ protected void checkXmlStructure(StringWriter writer) throws SAXException,
IOException {
+ Class<?> testClass = this.getClass();
+ InputStream expectedFacesConfigFile =
testClass.getResourceAsStream(testClass.getSimpleName() + ".xml");
+ if (expectedFacesConfigFile == null) {
+ return;
+ }
+
+ Diff xmlDiff = new Diff(
+ new StringReader(writer.toString()),
+ new InputStreamReader(expectedFacesConfigFile));
+
+ Assert.assertTrue("XML was not similar", xmlDiff.similar());
+ }
+
+ protected StringWriter generateFacesConfig(ComponentLibrary library) throws Exception
{
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+
+ JAXBBinding jaxbBinding = new JAXBBinding();
+ jaxbBinding.marshal(result, FacesConfigGenerator.FACES_SCHEMA_LOCATION,
+ new FacesConfigAdapter().marshal(library));
+ return writer;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -26,20 +26,22 @@
import org.junit.Test;
import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.xmlconfig.XmlTest;
/**
* @author akolonitsky
* @since Jan 21, 2010
*/
-public class BehaviorBeanTest extends ModelBeanTest {
+public class BehaviorBeanTest extends XmlTest {
@Test
public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- BehaviorModel behaviorModel = new BehaviorModel("my_behavior", new
ClassDescription(Object.class));
+ BehaviorModel behaviorModel = new BehaviorModel("my_behavior");
+ behaviorModel.setGeneratedClass(Object.class);
library.getBehaviors().add(behaviorModel);
// Jaxb marshaling
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -21,24 +21,26 @@
package org.richfaces.cdk.xmlconfig.testmodel;
-import java.io.StringWriter;
-
import org.junit.Test;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
+import org.richfaces.cdk.xmlconfig.XmlTest;
+import java.io.StringWriter;
+
/**
* @author akolonitsky
* @since Jan 10, 2010
*/
-public class ConverterBeanTest extends ModelBeanTest {
+public class ConverterBeanTest extends XmlTest {
@Test
public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- ConverterModel converterModel = new ConverterModel("my_converter", new
ClassDescription(Object.class));
+ ConverterModel converterModel = new ConverterModel("my_converter");
+ converterModel.setGeneratedClass(Object.class);
library.getConverters().add(converterModel);
// Jaxb marshaling
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -24,21 +24,23 @@
import java.io.StringWriter;
import org.junit.Test;
-import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.xmlconfig.XmlTest;
/**
* @author akolonitsky
* @since Jan 13, 2010
*/
-public class ValidatorBeanTest extends ModelBeanTest {
+public class ValidatorBeanTest extends XmlTest {
@Test
public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- ValidatorModel validatorModel = new ValidatorModel("my_validator", new
ClassDescription(Object.class));
+ ValidatorModel validatorModel = new ValidatorModel("my_validator");
+ validatorModel.setGeneratedClass(Object.class);
library.getValidators().add(validatorModel);
// Jaxb marshaling
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -23,10 +23,10 @@
import javax.annotation.Generated;
import javax.faces.component.PartialStateHolder;
-import javax.faces.component.StateHelper;
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.event.BehaviorEvent;
+import javax.faces.el.ValueBinding;
/**
*
@@ -38,44 +38,52 @@
public void broadcast(BehaviorEvent event) {
}
- protected enum Properties {
- testValue,
- testFlag
- }
- /**
- *
- **/
- public java.lang.Object getTestValue(){
- return (java.lang.Object)getStateHelper().eval(Properties.testValue);
+ private Object testValue;
+
+
+ private Boolean testFlag;
+
+
+
+ public void setTestValue(Object testValue) {
+ this.testValue = testValue;
}
- /**
- * Setter for testValue
- **/
- public void setTestValue(java.lang.Object testValue){
- getStateHelper().put(Properties.testValue,testValue);
+ public Object getTestValue() {
+ if (testValue != null) {
+ return testValue;
+ }
+
+ ValueBinding vb = getValueBinding("testValue");
+ if (null != vb) {
+ return (Object) vb.getValue(getFacesContext());
+ }
+
+ return testValue;
}
- /**
- *
- **/
- public java.lang.Boolean isTestFlag(){
- return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
+ public void setTestFlag(Boolean testFlag) {
+ this.testFlag = testFlag;
}
- /**
- * Setter for testFlag
- **/
- public void setTestFlag(java.lang.Boolean testFlag){
- getStateHelper().put(Properties.testFlag,testFlag);
- }
+ public Boolean isTestFlag() {
+ if (testFlag != null) {
+ return testFlag;
+ }
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
+ ValueBinding vb = getValueBinding("testFlag");
+ if (null != vb) {
+ return (Boolean) vb.getValue(getFacesContext());
+ }
+
+ return testFlag;
}
+ private static FacesContext getFacesContext() {
+ return FacesContext.getCurrentInstance();
+ }
- protected StateHelper getStateHelper(boolean create) {
- return null;
+ private static ValueBinding getValueBinding(String name) {
+ return getFacesContext().getApplication().createValueBinding(name);
}
// ----------------------------------------------------- StateHolder Methods
@@ -86,7 +94,7 @@
}
if (!initialStateMarked()) {
Object values[] = new Object[1];
- values[0] = this.getTestValue();
+ values[0] = this.getTestValue();
values[1] = this.isTestFlag();
return values;
@@ -104,8 +112,8 @@
}
Object values[] = (Object[]) state;
- setTestValue((java.lang.Object) values[0]);
- setTestFlag((java.lang.Boolean) values[1]);
+ setTestValue((Object) values[0]);
+ setTestFlag((Boolean) values[1]);
}
private boolean transientValue = false;
Deleted:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.richfaces.cdk.generate.java;
-
-import javax.annotation.Generated;
-import javax.faces.component.StateHelper;
-import javax.faces.component.UIComponent;
-import javax.faces.component.PartialStateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-
-/**
- *
- **/
-@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
-public class GeneratedClass extends Object implements Validator, PartialStateHolder {
-
- @Override
- public void validate(FacesContext context, UIComponent component, Object value)
throws ValidatorException {
-
- }
-
- protected enum Properties {
- testValue,
- testFlag
- }
-
-
- /**
- *
- **/
- public java.lang.Object getTestValue(){
- return (java.lang.Object)getStateHelper().eval(Properties.testValue);
- }
-
- /**
- * Setter for testValue
- **/
- public void setTestValue(java.lang.Object testValue){
- getStateHelper().put(Properties.testValue,testValue);
- }
- /**
- *
- **/
- public java.lang.Boolean isTestFlag(){
- return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
- }
-
- /**
- * Setter for testFlag
- **/
- public void setTestFlag(java.lang.Boolean testFlag){
- getStateHelper().put(Properties.testFlag,testFlag);
- }
-
-
-
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
- }
-
- protected StateHelper getStateHelper(boolean create) {
- return null;
- }
-
- // ----------------------------------------------------- StateHolder Methods
- @Override
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (!initialStateMarked()) {
- Object values[] = new Object[1];
- values[0] = this.getTestValue();
- values[1] = this.isTestFlag();
-
- return values;
- }
- return null;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- Object values[] = (Object[]) state;
- setTestValue((java.lang.Object) values[0]);
- setTestFlag((java.lang.Boolean) values[1]);
- }
-
- private boolean transientValue = false;
-
- @Override
- public boolean isTransient() {
- return this.transientValue;
- }
-
- @Override
- public void setTransient(boolean transientValue) {
- this.transientValue = transientValue;
- }
-
-
- private boolean initialState;
-
- @Override
- public void markInitialState() {
- initialState = true;
- }
-
- @Override
- public boolean initialStateMarked() {
- return initialState;
- }
-
- @Override
- public void clearInitialState() {
- initialState = false;
- }
-}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -33,12 +33,13 @@
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
+import javax.faces.component.UIOutput;
/**
*
**/
@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
-public class GeneratedComponent extends javax.faces.component.UIOutput implements
ClientBehaviorHolder {
+public class GeneratedComponent extends UIOutput implements ClientBehaviorHolder {
public static final String COMPONENT_TYPE="foo.bar";
@@ -58,7 +59,9 @@
}
protected enum Properties {
testValue,
- testFlag
+ testFlag,
+ testBinding,
+ testExpr
}
@@ -88,5 +91,31 @@
public void setTestFlag(java.lang.Boolean testFlag){
getStateHelper().put(Properties.testFlag,testFlag);
}
+ /**
+ *
+ **/
+ public javax.faces.el.MethodBinding getTestBinding(){
+ return
(javax.faces.el.MethodBinding)getStateHelper().eval(Properties.testBinding);
+ }
-}
+ /**
+ * Setter for testBinding
+ **/
+ public void setTestBinding(javax.faces.el.MethodBinding testBinding){
+ getStateHelper().put(Properties.testBinding,testBinding);
+ }
+ /**
+ *
+ **/
+ public javax.el.MethodExpression getTestExpr(){
+ return (javax.el.MethodExpression)getStateHelper().eval(Properties.testExpr);
+ }
+
+ /**
+ * Setter for testExpr
+ **/
+ public void setTestExpr(javax.el.MethodExpression testExpr){
+ getStateHelper().put(Properties.testExpr,testExpr);
+ }
+
+}
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -22,11 +22,13 @@
package org.richfaces.cdk.generate.java;
import javax.annotation.Generated;
+import javax.faces.component.PartialStateHolder;
import javax.faces.component.StateHelper;
-import javax.faces.component.PartialStateHolder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import org.richfaces.PartialStateHolderHelper;
+import org.richfaces.cdk.freemarker.PropertyModel;
/**
*
@@ -34,84 +36,82 @@
@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
public class GeneratedConverter extends Object implements Converter, PartialStateHolder
{
+ @Override
public Object getAsObject(FacesContext context, UIComponent component, String value)
{
return null;
}
+ @Override
public String getAsString(FacesContext context, UIComponent component, Object value)
{
return null;
}
protected enum Properties {
- testValue,
- testFlag
+ myClass,
+ testObject,
+ testBoolean,
+ testInteger,
+ visible
}
- /**
- *
- **/
- public java.lang.Object getTestValue() {
- return (java.lang.Object)getStateHelper().eval(Properties.testValue);
+
+ public PropertyModel getMyClass() {
+ return (PropertyModel) getStateHelper().eval(Properties.myClass);
}
- /**
- * Setter for testValue
- **/
- public void setTestValue(java.lang.Object testValue) {
- getStateHelper().put(Properties.testValue,testValue);
+ public void setMyClass(PropertyModel myClass) {
+ getStateHelper().put(Properties.myClass, myClass);
}
- /**
- *
- **/
- public java.lang.Boolean isTestFlag() {
- return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
+
+ public Object getTestObject() {
+ return (Object) getStateHelper().eval(Properties.testObject);
}
- /**
- * Setter for testFlag
- **/
- public void setTestFlag(java.lang.Boolean testFlag) {
- getStateHelper().put(Properties.testFlag,testFlag);
+ public void setTestObject(Object testObject) {
+ getStateHelper().put(Properties.testObject, testObject);
}
+ public Boolean isTestBoolean() {
+ return (Boolean) getStateHelper().eval(Properties.testBoolean);
+ }
+ public void setTestBoolean(Boolean testBoolean) {
+ getStateHelper().put(Properties.testBoolean, testBoolean);
+ }
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
+ public Integer getTestInteger() {
+ return (Integer) getStateHelper().eval(Properties.testInteger);
}
- protected StateHelper getStateHelper(boolean create) {
- return null;
+ public void setTestInteger(Integer testInteger) {
+ getStateHelper().put(Properties.testInteger, testInteger);
}
+ public boolean isVisible() {
+ return (Boolean) getStateHelper().eval(Properties.visible);
+ }
+
+ public void setVisible(boolean visible) {
+ getStateHelper().put(Properties.visible, visible);
+ }
+
+ private StateHelper stateHelper = null;
+
+ protected StateHelper getStateHelper() {
+ if (stateHelper == null) {
+ stateHelper = new PartialStateHolderHelper(this);
+ }
+ return stateHelper;
+ }
// ----------------------------------------------------- StateHolder Methods
@Override
public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (!initialStateMarked()) {
- Object values[] = new Object[1];
- values[0] = this.getTestValue();
- values[1] = this.isTestFlag();
-
- return values;
- }
- return null;
+ return stateHelper.saveState(context);
}
@Override
public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- Object values[] = (Object[]) state;
- setTestValue((java.lang.Object) values[0]);
- setTestFlag((java.lang.Boolean) values[1]);
+ stateHelper.restoreState(context, state);
}
private boolean transientValue = false;
@@ -126,7 +126,6 @@
this.transientValue = transientValue;
}
-
private boolean initialState;
@Override
@@ -143,4 +142,5 @@
public void clearInitialState() {
initialState = false;
}
+
}
Added:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedTagHandler.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedTagHandler.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedTagHandler.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.cdk.generate.java;
+
+import javax.faces.view.facelets.*;
+import org.richfaces.MethodMetadata;
+import org.richfaces.cdk.generate.java.GeneratedComponent;
+
+public class GeneratedTagHandler extends ComponentHandler {
+
+ private static final GeneratedTagHandlerMetaRule metaRule = new
GeneratedTagHandlerMetaRule();
+
+
+ public GeneratedTagHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(metaRule);
+ return m;
+ }
+
+ static class GeneratedTagHandlerMetaRule extends MetaRule{
+
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(GeneratedComponent.class)) {
+ if ("testBinding".equals(name)) {
+ return new MethodMetadata(attribute) {
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((GeneratedComponent) instance).setTestBinding(
+ getMethodBinding(ctx));
+ }
+ };
+ }
+
+ if ("testExpr".equals(name)) {
+ return new MethodMetadata(attribute) {
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((GeneratedComponent) instance).setTestExpr(
+ getMethodExpression(ctx));
+ }
+ };
+ }
+
+ }
+ return null;
+ }
+ }
+}
\ No newline at end of file
Copied:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedValidator.java
(from rev 16354,
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java)
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedValidator.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedValidator.java 2010-03-01
13:40:54 UTC (rev 16509)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.cdk.generate.java;
+
+import javax.annotation.Generated;
+import javax.faces.component.UIComponent;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.faces.el.ValueBinding;
+
+/**
+ *
+ **/
+@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
+public class GeneratedValidator extends Object implements Validator, PartialStateHolder
{
+
+ @Override
+ public void validate(FacesContext context, UIComponent component, Object value)
throws ValidatorException {
+
+ }
+
+
+ private Object testValue;
+
+
+ private Boolean testFlag;
+
+
+
+ public void setTestValue(Object testValue) {
+ this.testValue = testValue;
+ }
+
+ public Object getTestValue() {
+ if (testValue != null) {
+ return testValue;
+ }
+
+ ValueBinding vb = getValueBinding("testValue");
+ if (null != vb) {
+ return (Object) vb.getValue(getFacesContext());
+ }
+
+ return testValue;
+ }
+ public void setTestFlag(Boolean testFlag) {
+ this.testFlag = testFlag;
+ }
+
+ public Boolean isTestFlag() {
+ if (testFlag != null) {
+ return testFlag;
+ }
+
+ ValueBinding vb = getValueBinding("testFlag");
+ if (null != vb) {
+ return (Boolean) vb.getValue(getFacesContext());
+ }
+
+ return testFlag;
+ }
+ private static FacesContext getFacesContext() {
+ return FacesContext.getCurrentInstance();
+ }
+
+ private static ValueBinding getValueBinding(String name) {
+ return getFacesContext().getApplication().createValueBinding(name);
+ }
+
+ // ----------------------------------------------------- StateHolder Methods
+ @Override
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (!initialStateMarked()) {
+ Object values[] = new Object[1];
+ values[0] = this.getTestValue();
+ values[1] = this.isTestFlag();
+
+ return values;
+ }
+ return null;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ Object values[] = (Object[]) state;
+ setTestValue((Object) values[0]);
+ setTestFlag((Boolean) values[1]);
+ }
+
+ private boolean transientValue = false;
+
+ @Override
+ public boolean isTransient() {
+ return this.transientValue;
+ }
+
+ @Override
+ public void setTransient(boolean transientValue) {
+ this.transientValue = transientValue;
+ }
+
+
+ private boolean initialState;
+
+ @Override
+ public void markInitialState() {
+ initialState = true;
+ }
+
+ @Override
+ public boolean initialStateMarked() {
+ return initialState;
+ }
+
+ @Override
+ public void clearInitialState() {
+ initialState = false;
+ }
+}
Modified:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml 2010-03-01
13:29:51 UTC (rev 16508)
+++
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/component.xml 2010-03-01
13:40:54 UTC (rev 16509)
@@ -64,9 +64,11 @@
</property>
<component-extension>
<cdk:component-family>javax.faces.Panel</cdk:component-family>
- <cdk:base-class>javax.faces.component.UIComponentBase
- </cdk:base-class>
+ <cdk:base-class>javax.faces.component.UIComponentBase</cdk:base-class>
<cdk:generate>true</cdk:generate>
+ <cdk:renderer>
+
<cdk:renderer-type>org.richfaces.cdk.TestPanelRenderer</cdk:renderer-type>
+ </cdk:renderer>
</component-extension>
</component>
</faces-config>
\ No newline at end of file