Author: alexsmirnov
Date: 2010-05-05 19:22:04 -0400 (Wed, 05 May 2010)
New Revision: 16901
Added:
root/cdk/trunk/plugins/attributes/src/main/resources/
Removed:
root/cdk/trunk/plugins/annotations/src/main/resources/
Modified:
root/cdk/trunk/plugins/attributes/src/main/resources/META-INF/cdk/attributes/javax.faces.component.ValueHolder.xml
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/resources/META-INF/cdk/attributes/html5.xml
Log:
Move xml templates to "attributes" project, fix attributes for @Subcomponent
Copied: root/cdk/trunk/plugins/attributes/src/main/resources (from rev 16897,
root/cdk/trunk/plugins/annotations/src/main/resources)
Modified:
root/cdk/trunk/plugins/attributes/src/main/resources/META-INF/cdk/attributes/javax.faces.component.ValueHolder.xml
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/resources/META-INF/cdk/attributes/javax.faces.component.ValueHolder.xml 2010-05-05
15:40:30 UTC (rev 16897)
+++
root/cdk/trunk/plugins/attributes/src/main/resources/META-INF/cdk/attributes/javax.faces.component.ValueHolder.xml 2010-05-05
23:22:04 UTC (rev 16901)
@@ -44,6 +44,7 @@
<property-name>localValue</property-name>
<property-class>java.lang.Object</property-class>
<property-extension>
+ <cdk:read-only>true</cdk:read-only>
<cdk:hidden>true</cdk:hidden>
</property-extension>
</property>
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2010-05-05
21:45:59 UTC (rev 16900)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2010-05-05
23:22:04 UTC (rev 16901)
@@ -255,7 +255,7 @@
try {
log.debug(" -> visit - " + type.toString());
component.getAttributes().addAll(
- parseProperties(CdkEntityResolver.URN_ATTRIBUTES +
type.toString() + ".xml"));
+ parseProperties(type.toString() + ".xml"));
} catch (CdkException e) {
// TODO - log errors ?
}
@@ -267,7 +267,7 @@
log.debug(" -- Process Java files.");
Set<BeanProperty> properties = Sets.newHashSet();
properties.addAll(sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class,
element));
- properties.addAll(sourceUtils.getAbstractBeanProperties(element));
+// properties.addAll(sourceUtils.getAbstractBeanProperties(element));
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
processAttribute(beanProperty,
component.getOrCreateAttribute(beanProperty.getName()));
@@ -275,7 +275,7 @@
}
private Collection<? extends PropertyBase> parseProperties(String uri) {
- return parser.parseProperties(uri);
+ return parser.parseProperties(CdkEntityResolver.URN_ATTRIBUTES + uri);
}
private SourceUtils getSourceUtils() {
@@ -288,7 +288,7 @@
// Process all files from @Jsf.. attributes property.
for (String attributes : attributesConfig) {
try {
-
component.getAttributes().addAll(parseProperties(CdkEntityResolver.URN_ATTRIBUTES +
attributes));
+ component.getAttributes().addAll(parseProperties(attributes));
} catch (CdkException e) {
// TODO - log errors ?
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-05-05
21:45:59 UTC (rev 16900)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-05-05
23:22:04 UTC (rev 16901)
@@ -38,6 +38,7 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
+import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.util.Strings;
@@ -91,6 +92,13 @@
subcomponentModel.setTargetClass(ClassName.parseName(subcomponent.generate()));
subcomponentModel.setGenerate(!Strings.isEmpty(subcomponent.generate()));
setComponentProperties(null, subcomponentModel, subAnnotation);
+ // Propagate attributes from parent element.
+ for (PropertyBase property : component.getAttributes()) {
+ PropertyBase subcomponentAttribute =
subcomponentModel.getOrCreateAttribute(property.getName());
+ subcomponentAttribute.merge(property);
+ // parent component should be concrete. TODO - move to validator.
+ subcomponentAttribute.setGenerate(false);
+ }
library.getComponents().add(subcomponentModel);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-05-05
21:45:59 UTC (rev 16900)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-05-05
23:22:04 UTC (rev 16901)
@@ -88,7 +88,6 @@
expectLastCall();
BeanProperty beanProperty = createNiceMock(BeanProperty.class);
expect(utils.getBeanPropertiesAnnotatedWith(eq(Attribute.class),
same(element))).andReturn(Collections.singleton(beanProperty));
-
expect(utils.getAbstractBeanProperties(element)).andReturn(Collections.<BeanProperty>emptySet());
expect(beanProperty.getName()).andReturn(FOO);
expect(beanProperty.getType()).andReturn(ClassName.parseName(String.class.getName()));
mockController.replay();replay(element,beanProperty);
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/resources/META-INF/cdk/attributes/html5.xml
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/resources/META-INF/cdk/attributes/html5.xml 2010-05-05
21:45:59 UTC (rev 16900)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/resources/META-INF/cdk/attributes/html5.xml 2010-05-05
23:22:04 UTC (rev 16901)
@@ -29,6 +29,7 @@
<property-class>java.lang.String</property-class>
<property-extension>
<cdk:pass-through>true</cdk:pass-through>
+ <cdk:generate>true</cdk:generate>
</property-extension>
</property>
@@ -42,6 +43,7 @@
<property-class>boolean</property-class>
<property-extension>
<cdk:pass-through>true</cdk:pass-through>
+ <cdk:generate>true</cdk:generate>
</property-extension>
</property>
@@ -58,6 +60,9 @@
<icon />
<property-name>autocomplete</property-name>
<property-class>java.lang.String</property-class>
+ <property-extension>
+ <cdk:generate>true</cdk:generate>
+ </property-extension>
</property>
</cdk:properties>