Author: alexsmirnov
Date: 2010-12-16 11:49:29 -0500 (Thu, 16 Dec 2010)
New Revision: 20619
Added:
branches/RF-9323/
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/BehaviorRendererModel.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/FacesComponent.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaImportImpl.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClassImport.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ScriptOptionStatement.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.xml
Log:
create CDK development branch
Copied: branches/RF-9323 (from rev 20592, trunk)
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -24,6 +24,7 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.ElementKindVisitor6;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
@@ -34,12 +35,14 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import com.google.inject.Inject;
public class AptSourceUtils implements SourceUtils {
private static final Set<String> PROPERTIES =
new HashSet<String>(Arrays.asList("getEventNames",
"getDefaultEventName", "getClientBehaviors", "getFamily"));
+ private static final Predicate<Element> BEAN_PROPERTY_PREDICATE = new
BeanPropertyMethodPredicate();
private final ProcessingEnvironment processingEnv;
@Inject
@@ -111,6 +114,55 @@
return properties;
}
+ @Override
+ public BeanProperty getBeanProperty(TypeElement type, String name) {
+ List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(type);
+ return null;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Utility method to get all bean
properties, similar to Introspector</p>
+ * @param type
+ * @return
+ */
+ Map<String,BeanProperty> getBeanProperties(TypeElement type){
+ List<? extends Element> members =
this.processingEnv.getElementUtils().getAllMembers(type);
+ // extract all getters/setters.
+ Iterable<? extends ExecutableElement> gettersAndSetters =
Iterables.filter(Iterables.filter(members,
BEAN_PROPERTY_PREDICATE),ExecutableElement.class);
+ Map<String,BeanProperty> result = Maps.newHashMap();
+ for (Element element : members) {
+ if (ElementKind.METHOD.equals(element.getKind())){
+ ExecutableElement method = (ExecutableElement) element;
+ if(isPublicNonStatic(method)){
+ if(isGetter(method)){
+ String propertyName =
PropertyUtils.methodToName(method.getSimpleName().toString());
+ if(result.containsKey(propertyName)){
+ // Merge property with existed one.
+ BeanProperty beanProperty = result.get(propertyName);
+ processingEnv.getElementUtils().
+ } else {
+
+ }
+ } else if (isBooleanGetter(method)) {
+
+ } else if (isSetter(method)) {
+
+ }
+ }
+ }
+ }
+ // Merge all getter/setter methods.
+ for (ExecutableElement accestor : gettersAndSetters) {
+ String name =
PropertyUtils.methodToName(accestor.getSimpleName().toString());
+ if(result.containsKey(name)){
+
+ } else {
+
+ }
+ }
+ return result;
+ }
+
private void removeNotAbstractGroups(Map<String, List<ExecutableElement>>
props) {
List<String> removeKeys = new ArrayList<String>();
for (Map.Entry<String, List<ExecutableElement>> entry :
props.entrySet()) {
@@ -163,7 +215,7 @@
AptBeanProperty property = new
AptBeanProperty(childElement.getSimpleName().toString());
property.type = asClassDescription(childElement.asType());
- property.element = childElement;
+ property.getter = childElement;
// TODO - find getter/setter, check them for abstract.
property.exists = true;
@@ -197,7 +249,7 @@
AptBeanProperty property = new AptBeanProperty(name);
property.type = asClassDescription(propertyType);
- property.element = childElement;
+ property.getter = childElement;
property.exists = exists;
properties.add(property);
@@ -215,6 +267,26 @@
return method.getModifiers().contains(Modifier.ABSTRACT);
}
+ private boolean isPublicNonStatic(ExecutableElement method){
+ Set<Modifier> modifiers = method.getModifiers();
+ return modifiers.contains(Modifier.PUBLIC) &&
!modifiers.contains(Modifier.STATIC);
+ }
+
+ private boolean isGetter(ExecutableElement e) {
+ String methodName = e.getSimpleName().toString();
+ return methodName.startsWith("get") && methodName.length()>3
&& Character.isUpperCase(methodName.charAt(3)) && 0 ==
e.getParameters().size();
+ }
+
+ private boolean isBooleanGetter(ExecutableElement e) {
+ String methodName = e.getSimpleName().toString();
+ return methodName.startsWith("is") && methodName.length()>2
&& Character.isUpperCase(methodName.charAt(2)) && 0 ==
e.getParameters().size() && TypeKind.BOOLEAN.equals(e.getReturnType().getKind());
+ }
+
+ private boolean isSetter(ExecutableElement e) {
+ String methodName = e.getSimpleName().toString();
+ return methodName.startsWith("set") && methodName.length()>3
&& Character.isUpperCase(methodName.charAt(3)) && 1 ==
e.getParameters().size() && !e.isVarArgs() &&
TypeKind.VOID.equals(e.getReturnType().getKind());
+ }
+
private ClassName asClassDescription(TypeMirror type) {
return new ClassName(type.toString());
}
@@ -378,6 +450,45 @@
}
}
+ private static final class BeanPropertyMethodPredicate extends
ElementKindVisitor6<Boolean, Boolean> implements Predicate<Element> {
+
+ public BeanPropertyMethodPredicate() {
+ super(Boolean.FALSE);
+ }
+
+ @Override
+ public Boolean visitExecutableAsMethod(ExecutableElement e, Boolean p) {
+ Set<Modifier> modifiers = e.getModifiers();
+ // bean accessors have to be publis, non-static.
+ if(modifiers.contains(Modifier.PUBLIC) &&
!modifiers.contains(Modifier.STATIC)){
+ if(isGetter(e)||isBooleanGetter(e)||isSetter(e)){
+ return Boolean.TRUE;
+ }
+ }
+ return DEFAULT_VALUE;
+ }
+
+ private boolean isGetter(ExecutableElement e) {
+ String methodName = e.getSimpleName().toString();
+ return methodName.startsWith("get") &&
methodName.length()>3 && Character.isUpperCase(methodName.charAt(3)) &&
0 == e.getParameters().size();
+ }
+
+ private boolean isBooleanGetter(ExecutableElement e) {
+ String methodName = e.getSimpleName().toString();
+ return methodName.startsWith("is") &&
methodName.length()>2 && Character.isUpperCase(methodName.charAt(2)) &&
0 == e.getParameters().size() &&
TypeKind.BOOLEAN.equals(e.getReturnType().getKind());
+ }
+
+ private boolean isSetter(ExecutableElement e) {
+ String methodName = e.getSimpleName().toString();
+ return methodName.startsWith("set") &&
methodName.length()>3 && Character.isUpperCase(methodName.charAt(3)) &&
1 == e.getParameters().size() && !e.isVarArgs() &&
TypeKind.VOID.equals(e.getReturnType().getKind());
+ }
+
+ @Override
+ public boolean apply(Element input) {
+ return visit(input);
+ }
+ }
+
private static final class AnnotationAttributePredicate implements
Predicate<Map.Entry<? extends ExecutableElement, ? extends
AnnotationValue>> {
private final String propertyName;
@@ -401,7 +512,10 @@
*
*/
protected final class AptBeanProperty implements BeanProperty {
- private Element element;
+ private ExecutableElement getter;
+ private ExecutableElement setter;
+ private String docComment;
+ private Map<Class<? extends Annotation>,AnnotationMirror> annotations
= Maps.newHashMap();
private boolean exists;
private final String name;
private ClassName type;
@@ -481,7 +595,7 @@
* @return
*/
public String getDocComment() {
- return processingEnv.getElementUtils().getDocComment(element);
+ return processingEnv.getElementUtils().getDocComment(getter);
}
public ClassName getType() {
@@ -499,12 +613,9 @@
}
public AnnotationMirror getAnnotationMirror(Class<? extends Annotation>
annotationType) {
- return AptSourceUtils.this.getAnnotationMirror(element, annotationType);
+ return AptSourceUtils.this.getAnnotationMirror(getter, annotationType);
}
- public <T extends Annotation> T getAnnotation(Class<T>
annotationType) {
- return element.getAnnotation(annotationType);
- }
}
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -67,6 +67,12 @@
}
@Override
+ public BeanProperty getBeanProperty(TypeElement type, String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
public Object getConstant(TypeElement element, String name) {
// TODO Auto-generated method stub
return null;
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -97,7 +97,6 @@
AnnotationMirror getAnnotationMirror(Class<? extends Annotation>
annotationType);
- <T extends Annotation> T getAnnotation(Class<T> annotationType);
}
/**
@@ -119,6 +118,15 @@
* @return
*/
Set<BeanProperty> getAbstractBeanProperties(TypeElement type);
+
+
+ /**
+ * <p class="changed_added_4_0">Get bean property descriptor for
particular type.</p>
+ * @param type
+ * @param name
+ * @return
+ */
+ BeanProperty getBeanProperty(TypeElement type, String name);
/**
* <p class="changed_added_4_0">
@@ -172,6 +180,14 @@
<T> List<T> getAnnotationValues(AnnotationMirror annotation, String
propertyName, Class<T> expectedType);
/**
+ * <p class="changed_added_4_0"></p>
+ * @param annotation
+ * @param propertyName
+ * @return
+ */
+ public abstract boolean isAnnotationPropertyPresent(AnnotationMirror annotation,
final String propertyName);
+
+ /**
* <p class="changed_added_4_0">Check annotation proprrty for default
value.</p>
* @param annotation
* @param propertyName
@@ -179,6 +195,23 @@
*/
boolean isDefaultValue(AnnotationMirror annotation, String propertyName);
/**
+ * <p class="changed_added_4_0"></p>
+ * @param model
+ * @param annotation
+ * @param modelProperty
+ * @param annotationAttribute
+ */
+ public abstract void setModelProperty(Object model, AnnotationMirror annotation,
String modelProperty, String annotationAttribute);
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param model
+ * @param annotation
+ * @param modelProperty
+ */
+ public abstract void setModelProperty(Object model, AnnotationMirror annotation,
String modelProperty);
+
+ /**
* <p class="changed_added_4_0">
* </p>
*
@@ -203,7 +236,7 @@
* </p>
*
* @param mirror
- * @return
+ * @return The Element for given type
*/
TypeElement asTypeElement(TypeMirror mirror);
@@ -212,14 +245,8 @@
* </p>
*
* @param type
- * @return
+ * @return TypeElement for given type, or null if corresponding name does not exist.
*/
TypeElement asTypeElement(ClassName type);
- public abstract boolean isAnnotationPropertyPresent(AnnotationMirror annotation,
final String propertyName);
-
- public abstract void setModelProperty(Object model, AnnotationMirror annotation,
String modelProperty, String annotationAttribute);
-
- public abstract void setModelProperty(Object model, AnnotationMirror annotation,
String modelProperty);
-
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -124,7 +124,7 @@
Set<ClassName> result = Sets.newTreeSet();
for (PropertyBase entry : model.getAttributes()) {
- if (entry.isGenerate() && !isPredefined(entry)) {
+ if (entry.getGenerate() && !isPredefined(entry)) {
result.add(entry.getType());
}
}
@@ -244,7 +244,7 @@
@Override
public boolean apply(PropertyBase input) {
- return input.isGenerate();
+ return input.getGenerate();
}
}));
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -52,7 +52,7 @@
public void render(ComponentLibrary library) throws CdkException {
Collection<BehaviorModel> models = library.getBehaviors();
for (BehaviorModel model : models) {
- if (model.isGenerate()) {
+ if (model.getGenerate()) {
this.generate(library, model);
}
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -55,7 +55,7 @@
public void render(ComponentLibrary library) throws CdkException {
Collection<ComponentModel> models = library.getComponents();
for (ComponentModel model : models) {
- if (model.isGenerate()) {
+ if (model.getGenerate()) {
this.generate(library, model);
}
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -52,7 +52,7 @@
public void render(ComponentLibrary library) throws CdkException {
Collection<ConverterModel> models = library.getConverters();
for (ConverterModel model : models) {
- if (model.isGenerate()) {
+ if (model.getGenerate()) {
this.generate(library, model);
}
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -51,7 +51,7 @@
public void render(ComponentLibrary library) throws CdkException {
Collection<ValidatorModel> models = library.getValidators();
for (ValidatorModel model : models) {
- if (model.isGenerate()) {
+ if (model.getGenerate()) {
this.generate(library, model);
}
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/BehaviorRendererModel.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/BehaviorRendererModel.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/BehaviorRendererModel.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -99,7 +99,7 @@
* <p class="changed_added_4_0"></p>
* @return the generate
*/
- public boolean isGenerate() {
+ public Boolean getGenerate() {
return this.generate;
}
@@ -107,7 +107,7 @@
* <p class="changed_added_4_0"></p>
* @param generate the generate to set
*/
- public void setGenerate(boolean generate) {
+ public void setGenerate(Boolean generate) {
this.generate = generate;
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -61,7 +61,7 @@
ComponentLibrary.merge(getFacets(), otherComponent.getFacets());
ComponentLibrary.merge(getEvents(), otherComponent.getEvents());
ComponentLibrary.merge(this, otherComponent);
- this.setGenerate(this.isGenerate() || otherComponent.isGenerate());
+ this.setGenerate(this.getGenerate() || otherComponent.getGenerate());
}
@Override
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -31,7 +31,7 @@
/**
* <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 generate ;
/**
* <p class="changed_added_4_0">
@@ -83,11 +83,11 @@
}
@Merge
- public boolean isGenerate() {
+ public Boolean getGenerate() {
return generate;
}
- public void setGenerate(boolean generate) {
+ public void setGenerate(Boolean generate) {
this.generate = generate;
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/FacesComponent.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/FacesComponent.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/FacesComponent.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -91,12 +91,12 @@
* <p class="changed_added_4_0"></p>
* @return
*/
- public boolean isGenerate();
+ public Boolean getGenerate();
/**
* <p class="changed_added_4_0"></p>
* @param generate
*/
- public void setGenerate(boolean generate);
+ public void setGenerate(Boolean generate);
}
\ No newline at end of file
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -293,9 +293,9 @@
@Override
public void merge(PropertyBase other) {
- boolean generate = isGenerate();
+ boolean generate = getGenerate();
ComponentLibrary.merge(this, other);
- setGenerate(generate || other.isGenerate());
+ setGenerate(generate || other.getGenerate());
}
public <R,D> R accept(Visitor<R,D> visitor, D data) {
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -44,8 +44,6 @@
private FacesId id;
- private boolean generate;
-
public RenderKitModel() {
}
@@ -100,22 +98,6 @@
/**
* <p class="changed_added_4_0"></p>
- * @return the generate
- */
- public boolean isGenerate() {
- return this.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 renderers
*/
public ModelCollection<RendererModel> getRenderers() {
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -361,13 +361,7 @@
try {
// Step one, lookup for parent.
ComponentModel parentComponent =
- Iterables.find(library.getComponents(), new
Predicate<ComponentModel>() {
-
- @Override
- public boolean apply(ComponentModel input) {
- return
component.getBaseClass().equals(input.getTargetClass());
- }
- });
+ findParent(library.getComponents(), component);
// To be sure what all properties for parent component were
propagated.
verifyComponentAttributes(library, parentComponent, verified);
for (PropertyBase parentAttribute : parentComponent.getAttributes())
{
@@ -382,7 +376,7 @@
} // Check attributes.
for (PropertyBase attribute : component.getAttributes()) {
- verifyAttribute(attribute, component.isGenerate());
+ verifyAttribute(attribute, component.getGenerate());
}
// compact(component.getAttributes());
// Check renderers.
@@ -397,6 +391,16 @@
}
}
+ private <T extends FacesComponent> T findParent(Iterable<T> components,
final T component) throws NoSuchElementException {
+ return Iterables.find(components, new Predicate<T>() {
+
+ @Override
+ public boolean apply(T input) {
+ return component.getBaseClass().equals(input.getTargetClass());
+ }
+ });
+ }
+
protected void verifyTag(TagModel tag, FacesId id, ClassName handler) {
if (Strings.isEmpty(tag.getName())) {
String defaultTagName = namingConventions.inferTagName(id);
@@ -457,7 +461,7 @@
}
}
// Check classes.
- if (component.isGenerate()) {
+ if (component.getGenerate()) {
if (null == component.getBaseClass()) {
component.setBaseClass(callback.getDefaultBaseClass());
// return;
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -74,8 +74,8 @@
addImport(new JavaImportImpl(name));
}
- public void addImport(String name, boolean _static) {
- addImport(new JavaImportImpl(name, _static));
+ public void addImport(String name, boolean staticImport) {
+ addImport(new JavaImportImpl(name, staticImport));
}
public void addImport(Class<?> claz) {
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaImportImpl.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaImportImpl.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaImportImpl.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -33,7 +33,7 @@
private String name;
- private boolean _static;
+ private boolean staticImport;
public JavaImportImpl(String name) {
this(name, false);
@@ -43,14 +43,14 @@
this(clazz.getName());
}
- public JavaImportImpl(String name, boolean _static) {
+ public JavaImportImpl(String name, boolean staticImport) {
super();
this.name = name;
- this._static = _static;
+ this.staticImport = staticImport;
}
- public JavaImportImpl(Class<?> clazz, boolean _static) {
- this(clazz.getName(), _static);
+ public JavaImportImpl(Class<?> clazz, boolean staticImport) {
+ this(clazz.getName(), staticImport);
}
public String getName() {
@@ -58,7 +58,7 @@
}
public boolean isStatic() {
- return _static;
+ return staticImport;
}
public boolean isDefault() {
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClassImport.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClassImport.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClassImport.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -32,47 +32,47 @@
*/
public class ClassImport {
- @XmlAttribute(required = true)
- @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
- private String _package;
+ private String packageName;
- @XmlAttribute
- private boolean _static;
+ private boolean staticImport;
- @XmlAttribute
private List<String> names;
/**
* @return the package_
*/
+ @XmlAttribute(required = true)
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
public String getPackage() {
- return _package;
+ return packageName;
}
/**
- * @param _package the package_ to set
+ * @param packageName the package_ to set
*/
- public void setPackage(String _package) {
- this._package = _package;
+ public void setPackage(String packageName) {
+ this.packageName = packageName;
}
/**
* @return the static_
*/
+ @XmlAttribute
public boolean isStatic() {
- return _static;
+ return staticImport;
}
/**
* @param static_ the static_ to set
*/
- public void setStatic(boolean _static) {
- this._static = _static;
+ public void setStatic(boolean staticImport) {
+ this.staticImport = staticImport;
}
/**
* @return the classes
*/
+ @XmlAttribute
public List<String> getNames() {
return names;
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethod.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -80,11 +80,6 @@
}
}
- private static String[] transformClassesToClassNames(Class<?>[] s) {
- Iterator<String> transformed = transform(forArray(s),
CLASS_TO_CLASS_NAME);
- return toArray(transformed, String.class);
- }
-
private HelperMethod(String name, String returnType, String... argumentTypes) {
this.name = name;
this.returnType = returnType;
@@ -95,6 +90,11 @@
this(name, CLASS_TO_CLASS_NAME.apply(returnType),
transformClassesToClassNames(argumentTypes));
}
+ private static String[] transformClassesToClassNames(Class<?>[] s) {
+ Iterator<String> transformed = transform(forArray(s),
CLASS_TO_CLASS_NAME);
+ return toArray(transformed, String.class);
+ }
+
public String getName() {
return name;
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ScriptOptionStatement.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ScriptOptionStatement.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ScriptOptionStatement.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -79,11 +79,12 @@
}
/**
- * @param value the value to set
+ * @param value
+ * the value to set
*/
public void setValueExpression(String valueExpression) {
try {
- this.value = parser.parse(valueExpression, this, TypesFactory.OBJECT_TYPE);
+ this.value = parser.parse(valueExpression, this, TypesFactory.OBJECT_TYPE);
} catch (ParsingException e) {
logger.error("Error parse scriptOption value expression: " +
valueExpression, e);
}
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -27,7 +27,6 @@
import org.richfaces.cdk.generate.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.templatecompiler.TemplateModel;
-import com.google.common.collect.Sets;
import com.google.inject.Inject;
/**
Modified:
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -3,7 +3,6 @@
import static org.junit.Assert.*;
import java.util.List;
-import java.util.Set;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.AnnotationMirror;
@@ -13,9 +12,7 @@
import org.richfaces.cdk.apt.TestAnnotation.TestEnum;
import org.richfaces.cdk.model.ClassName;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
public class AptSourceUtilsAnnotationsTest extends SourceUtilsTestBase {
@@ -163,15 +160,4 @@
protected Iterable<String> sources() {
return ImmutableList.of(CLASS_JAVA, SUB_CLASS_JAVA);
}
-
- private Element findElement(RoundEnvironment roundEnvironment, final String name){
- Set<? extends Element> elements = roundEnvironment.getRootElements();
- return Iterables.find(elements, new Predicate<Element>() {
-
- @Override
- public boolean apply(Element input) {
- return name.equals(input.getSimpleName().toString());
- }
- });
- }
}
Modified:
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/SourceUtilsTestBase.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -33,6 +33,7 @@
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import org.junit.runner.RunWith;
@@ -42,6 +43,8 @@
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import com.google.inject.Binder;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -77,6 +80,17 @@
assertTrue("Compilation error",factory.get().call());
}
+ protected Element findElement(RoundEnvironment roundEnvironment, final String name)
{
+ Set<? extends Element> elements = roundEnvironment.getRootElements();
+ return Iterables.find(elements, new Predicate<Element>() {
+
+ @Override
+ public boolean apply(Element input) {
+ return name.equals(input.getSimpleName().toString());
+ }
+ });
+ }
+
/**
* <p class="changed_added_4_0">Interface to call back test method
from APT</p>
* @author asmirnov(a)exadel.com
Modified:
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -130,7 +130,7 @@
verify(utils, componentElement, jaxb, annotation, property, facet, description);
assertEquals(1, model.getFacets().size());
FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
- assertTrue(facetModel.isGenerate());
+ assertTrue(facetModel.getGenerate());
assertEquals("foo", facetModel.getName());
// assertEquals("my comment", facetModel.getDescription());
// assertEquals("fooFacet", facetModel.getDisplayname());
@@ -160,7 +160,7 @@
verify(utils, componentElement, jaxb, annotation, property, facet, description);
assertEquals(1, model.getFacets().size());
FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
- assertTrue(facetModel.isGenerate());
+ assertTrue(facetModel.getGenerate());
assertEquals("foo", facetModel.getName());
// assertEquals("my comment", facetModel.getDescription());
// assertEquals("fooFacet", facetModel.getDisplayname());
@@ -180,7 +180,7 @@
replay(utils, componentElement, jaxb, annotation);
processor.setClassNames(componentElement, model, "");
verify(utils, componentElement, jaxb, annotation);
- assertFalse(model.isGenerate());
+ assertFalse(model.getGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
assertNull(model.getTargetClass());
}
@@ -200,7 +200,7 @@
processor.setClassNames(componentElement, model, "");
verify(utils, componentElement, jaxb, annotation);
- assertTrue(model.isGenerate());
+ assertTrue(model.getGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
assertNull(model.getTargetClass());
}
@@ -220,7 +220,7 @@
processor.setClassNames(componentElement, model, FOO_HTML_BAR);
verify(utils, componentElement, jaxb, annotation);
- assertTrue(model.isGenerate());
+ assertTrue(model.getGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
assertEquals(FOO_HTML_BAR, model.getTargetClass().toString());
}
Modified:
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -104,12 +104,12 @@
assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
assertEquals("Panel component", component.getDescription());
assertEquals("Panel", component.getDisplayname());
- assertTrue(component.isGenerate());
+ assertTrue(component.getGenerate());
FacetModel facet = Iterables.getOnlyElement(component.getFacets());
assertEquals("header", facet.getName());
assertEquals("Header facet", facet.getDescription());
- assertTrue(facet.isGenerate());
+ assertTrue(facet.getGenerate());
Collection<PropertyBase> attributes = component.getAttributes();
Modified:
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -118,7 +118,7 @@
assertEquals("15", property.getSuggestedValue());
// CDK extensions.
- assertTrue(property.isGenerate());
+ assertTrue(property.getGenerate());
assertTrue(property.isHidden());
assertTrue(property.isLiteral());
assertTrue(property.isPassThrough());
Modified:
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java
===================================================================
--- trunk/cdk/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/apt/TestClass.java 2010-12-16
16:49:29 UTC (rev 20619)
@@ -31,4 +31,13 @@
*
*/
//@TestAnnotation("foo")
-public class TestClass {}
+public class TestClass {
+
+ public Integer getReadOnly(){
+ return null;
+ }
+
+ public void setWriteOnly(){
+
+ }
+}
Modified:
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml
===================================================================
---
trunk/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml 2010-12-16
16:49:29 UTC (rev 20619)
@@ -7,7 +7,6 @@
<attribute-name>attr2</attribute-name>
<attribute-class>java.lang.String</attribute-class>
<attribute-extension>
- <cdk:generate>false</cdk:generate>
<cdk:hidden>false</cdk:hidden>
<cdk:literal>false</cdk:literal>
<cdk:pass-through>false</cdk:pass-through>
@@ -19,7 +18,6 @@
<property-name>attr1</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
- <cdk:generate>false</cdk:generate>
<cdk:hidden>false</cdk:hidden>
<cdk:literal>false</cdk:literal>
<cdk:pass-through>false</cdk:pass-through>
@@ -27,9 +25,7 @@
<cdk:required>false</cdk:required>
</property-extension>
</property>
- <behavior-extension>
- <cdk:generate>false</cdk:generate>
- </behavior-extension>
+ <behavior-extension/>
</behavior>
<faces-config-extension/>
</faces-config>
\ No newline at end of file
Modified:
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml
===================================================================
---
trunk/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.xml 2010-12-16
16:49:29 UTC (rev 20619)
@@ -3,9 +3,7 @@
<converter>
<converter-id>my_converter</converter-id>
<converter-class>java.lang.Object</converter-class>
- <converter-extension>
- <cdk:generate>false</cdk:generate>
- </converter-extension>
+ <converter-extension/>
</converter>
<faces-config-extension/>
</faces-config>
\ No newline at end of file
Modified:
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.xml
===================================================================
---
trunk/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.xml 2010-12-15
17:57:11 UTC (rev 20592)
+++
branches/RF-9323/cdk/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.xml 2010-12-16
16:49:29 UTC (rev 20619)
@@ -3,9 +3,7 @@
<validator>
<validator-id>my_validator</validator-id>
<validator-class>java.lang.Object</validator-class>
- <validator-extension>
- <cdk:generate>false</cdk:generate>
- </validator-extension>
+ <validator-extension/>
</validator>
<faces-config-extension/>
</faces-config>
\ No newline at end of file