Author: Alex.Kolonitsky
Date: 2011-01-10 05:29:55 -0500 (Mon, 10 Jan 2011)
New Revision: 20927
Added:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/JsfSubComponent.java
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfRenderer.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/RendererSpecificComponent.java
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessorImpl.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/EventProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/FunctionProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerWriter.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/EventModel.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
trunk/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
trunk/cdk/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
trunk/ui/core/ui/src/main/java/org/richfaces/component/UIRepeat.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DrowDownMenuRendererTest.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java
Log:
Revert: RESOLVED - issue RF-10093:
https://issues.jboss.org/browse/RF-10093
Modified: trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -23,8 +23,6 @@
package org.richfaces.cdk.annotations;
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
@@ -52,18 +50,13 @@
public static final String NAME = "org.richfaces.cdk.annotations.Event";
/**
- * <p class="changed_added_4_0">Used in the {@link JsfComponent}
only, to define event type.</p>
- * @return
- */
- public Class<? extends FacesEvent> value() default DEFAULT.class;
- /**
* <p class="changed_added_4_0">
- * The listener interface class that process annotated event.
+ * The listener interface class that process annotated event. This is mandatory
parameter.
* </p>
*
* @return name of listener interface
*/
- public Class<? extends FacesListener> listener() default
DEFAULT_LISTENER.class;
+ public Class<? extends FacesListener> listener();
/**
* <p class="changed_added_4_0">Name for the listener interface
method that process annotated event type.</p>
@@ -89,24 +82,4 @@
*/
public Tag[] tag() default {};
- @SuppressWarnings("serial")
- static final class DEFAULT extends FacesEvent {
-
- public DEFAULT(UIComponent component) {
- super(component);
- }
-
- @Override
- public boolean isAppropriateListener(FacesListener listener) {
- return false;
- }
-
- @Override
- public void processListener(FacesListener listener) {
- }
- }
-
- static final class DEFAULT_LISTENER implements FacesListener {
-
- }
}
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -52,7 +52,7 @@
public String generate() default "";
- public Tag[] tag() default {};
+ public Tag tag() default @Tag;
public JsfBehaviorRenderer renderer() default @JsfBehaviorRenderer();
/**
@@ -77,13 +77,4 @@
* @return
*/
public String[] attributes() default {};
-
- /**
- * <p class="changed_added_4_0">
- * Interfaces that should be implemented in the generated class. CDK processes all
{@link Attribute} annotations in these interfaces
- * </p>
- *
- * @return
- */
- public Class<?>[] interfaces() default {};
}
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -134,7 +134,7 @@
*
* @return
*/
- public Event[] fires() default {};
+ public Class<? extends FacesEvent>[] fires() default {};
/**
* <p class="changed_added_4_0">
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -56,7 +56,7 @@
*/
public Description description() default @Description();
- public Tag[] tag() default {};
+ public Tag tag() default @Tag;
public static final class NONE {}
@@ -72,13 +72,5 @@
* @return
*/
public String[] attributes() default {};
- /**
- * <p class="changed_added_4_0">
- * Interfaces that should be implemented in the generated class. CDK processes all
{@link Attribute} annotations in these interfaces
- * </p>
- *
- * @return
- */
- public Class<?>[] interfaces() default {};
}
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfRenderer.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfRenderer.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfRenderer.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -58,13 +58,6 @@
* @return
*/
public String family() default "";
-
-
- /**
- * <p class="changed_added_4_0">Name of generated renderer
class.</p>
- * @return
- */
- public String generate() default "";
/**
* <p class="changed_added_4_0">RenderKit for which this renderer is
belong to</p>
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -19,7 +19,7 @@
public String generate() default "";
- public Tag[] tag() default {};
+ public Tag tag() default @Tag;
/**
* <p class="changed_added_4_0">
* Description used by IDE.
@@ -41,13 +41,4 @@
* @return
*/
public String[] attributes() default {};
- /**
- * <p class="changed_added_4_0">
- * Interfaces that should be implemented in the generated class. CDK processes all
{@link Attribute} annotations in these interfaces
- * </p>
- *
- * @return
- */
- public Class<?>[] interfaces() default {};
-
}
Modified:
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/RendererSpecificComponent.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/RendererSpecificComponent.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/RendererSpecificComponent.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -129,13 +129,5 @@
* @return
*/
public Class<?>[] interfaces() default {};
- /**
- * <p class="changed_added_4_0">
- * Events fired by the component.
- * </p>
- *
- * @return
- */
- public Event[] fires() default {};
}
Modified: trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java
===================================================================
---
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/annotations/src/main/java/org/richfaces/cdk/annotations/TagType.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -28,19 +28,16 @@
*/
public enum TagType {
/**
- * <p class="changed_added_4_0">
- * Defines JSP tag.
- * </p>
- */
+ * <p class="changed_added_4_0">Do not generate any tags, this is
default value for {@link Tag#type()} annotation.</p>
+ */
+ None, /**
+ * <p class="changed_added_4_0">Defines JSP tag.</p>
+ */
Jsp, /**
- * <p class="changed_added_4_0">
- * Defines Facelets tag.
- * </p>
- */
+ * <p class="changed_added_4_0">Defines Facelets tag.</p>
+ */
Facelets, /**
- * <p class="changed_added_4_0">
- * Enforces tag annotation to generate all known tag types
- * </p>
- */
+ * <p class="changed_added_4_0">Enforces tag annotation to generate
all known tag types</p>
+ */
All
}
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2011-01-10
10:14:36 UTC (rev 20926)
+++ trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -25,7 +25,6 @@
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.util.PropertyUtils;
import com.google.common.base.Predicate;
@@ -161,7 +160,7 @@
AptBeanProperty beanProperty = result.get(propertyName);
checkPropertyType(type, propertyName, propertyType, beanProperty);
if (null != (setter?beanProperty.setter:beanProperty.getter)) {
- log.debug("Two " + (setter ? "setter" :
"getter") + " methods for the same bean property "
+ log.warn("Two " + (setter ? "setter" :
"getter") + " methods for the same bean property "
+ propertyName + " in the class " +
type.getQualifiedName());
if(!method.getModifiers().contains(Modifier.ABSTRACT)){
beanProperty.setAccessMethod(method, setter);
@@ -279,11 +278,8 @@
VariableElement variable = (VariableElement) annotationValue.getValue();
return (T) Enum.valueOf((Class<? extends Enum>) expectedType,
variable.getSimpleName().toString());
} else if (ClassName.class.equals(expectedType)) {
- Object value = annotationValue.getValue();
+ TypeMirror value = (TypeMirror) annotationValue.getValue();
return (T) ClassName.get(value.toString());
- } else if (FacesId.class.equals(expectedType)) {
- String value = (String) annotationValue.getValue();
- return (T) FacesId.parseId(value);
} else if (AnnotationMirror.class.isAssignableFrom(expectedType)) {
AnnotationMirror value = (AnnotationMirror) annotationValue.getValue();
return (T) value;
@@ -294,7 +290,7 @@
@SuppressWarnings("unchecked")
@Override
- public <T> Iterable<T> getAnnotationValues(AnnotationMirror annotation,
String propertyName, Class<T> expectedType) {
+ public <T> List<T> getAnnotationValues(AnnotationMirror annotation,
String propertyName, Class<T> expectedType) {
Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>
attributeEntry =
findAnnotationProperty(annotation, propertyName);
List<? extends AnnotationValue> annotationValues =
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -24,6 +24,7 @@
package org.richfaces.cdk.apt;
import java.lang.annotation.Annotation;
+import java.util.List;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
@@ -112,7 +113,7 @@
}
@Override
- public <T> Iterable<T> getAnnotationValues(AnnotationMirror annotation,
String propertyName, Class<T> expectedType) {
+ public <T> List<T> getAnnotationValues(AnnotationMirror annotation,
String propertyName, Class<T> expectedType) {
// TODO Auto-generated method stub
return null;
}
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2011-01-10
10:14:36 UTC (rev 20926)
+++ trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -24,6 +24,7 @@
package org.richfaces.cdk.apt;
import java.lang.annotation.Annotation;
+import java.util.List;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
@@ -199,7 +200,7 @@
* @param propertyName
* @return
*/
- <T> Iterable<T> getAnnotationValues(AnnotationMirror annotation, String
propertyName, Class<T> expectedType);
+ <T> List<T> getAnnotationValues(AnnotationMirror annotation, String
propertyName, Class<T> expectedType);
/**
* <p class="changed_added_4_0"></p>
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -23,7 +23,6 @@
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -84,20 +83,19 @@
}
} else {
SourceUtils utils = utilsProvider.get();
- utils.setModelProperty(attribute, attributeAnnotarion, "hidden");
- utils.setModelProperty(attribute, attributeAnnotarion, "literal");
- utils.setModelProperty(attribute, attributeAnnotarion,
"passThrough");
- utils.setModelProperty(attribute, attributeAnnotarion,
"required");
- utils.setModelProperty(attribute, attributeAnnotarion,
"readOnly");
+ utils.setModelProperty(attribute, attributeAnnotarion, "hidden");
+ utils.setModelProperty(attribute, attributeAnnotarion,
"literal");
+ utils.setModelProperty(attribute, attributeAnnotarion,
"passThrough");
+ utils.setModelProperty(attribute, attributeAnnotarion,
"required");
+ utils.setModelProperty(attribute, attributeAnnotarion,
"readOnly");
if (!utils.isDefaultValue(attributeAnnotarion, "generate")) {
attribute.setGenerate(utils.getAnnotationValue(attributeAnnotarion,
"generate", boolean.class));
} else {
attribute.setGenerate(!beanProperty.isExists());
}
- descriptionProcessor.processDescription(attribute,
- utils.getAnnotationValue(attributeAnnotarion, "description",
AnnotationMirror.class),
- beanProperty.getDocComment());
+ descriptionProcessor.processDescription(attribute,
beanProperty.getAnnotation(Attribute.class).description(), beanProperty
+ .getDocComment());
setDefaultValue(attribute, attributeAnnotarion);
@@ -106,13 +104,13 @@
// MethodExpression call signature.
attribute.setSignature(getSignature(attributeAnnotarion));
- for (AnnotationMirror event : utils.getAnnotationValues(attributeAnnotarion,
"events",
- AnnotationMirror.class)) {
+ for (AnnotationMirror event : utils.getAnnotationValues(attributeAnnotarion,
"events", AnnotationMirror.class)){
setBehaviorEvent(attribute, event);
}
}
}
+
private void setDefaultValue(PropertyBase attribute, AnnotationMirror
attributeAnnotarion) {
SourceUtils utils = utilsProvider.get();
String defaultValue;
@@ -167,8 +165,8 @@
if (!SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
MethodSignature methodSignature = new MethodSignature();
-
methodSignature.setParameters(Lists.newArrayList(utils.getAnnotationValues(signatureAnnotation,
"parameters",
- ClassName.class)));
+
methodSignature.setParameters(utils.getAnnotationValues(signatureAnnotation,
"parameters",
+ ClassName.class));
methodSignature.setReturnType(returnType);
return methodSignature;
}
@@ -176,6 +174,7 @@
return null;
}
+
private void setBehaviorEvent(PropertyBase attribute, AnnotationMirror eventMirror)
{
if (null != eventMirror) {
SourceUtils utils = utilsProvider.get();
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -26,15 +26,14 @@
import java.lang.annotation.Annotation;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
/**
* <p class="changed_added_4_0"></p>
@@ -46,17 +45,17 @@
@Override
public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
- SourceUtils sourceUtils = getSourceUtils();
- AnnotationMirror behavior = sourceUtils.getAnnotationMirror(element,
JsfBehavior.class);
+ JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
- BehaviorModel behaviorModel = new BehaviorModel();
-
- sourceUtils.setModelProperty(behaviorModel, behavior, "id");
- setClassNames((TypeElement) element, behaviorModel, behavior);
+ BehaviorModel behaviorModel = new BehaviorModel(new FacesId(behavior.id()));
+ setClassNames((TypeElement) element, behaviorModel, behavior.generate());
- setTagInfo(behavior, behaviorModel);
- processAttributes((TypeElement) element, behaviorModel, behavior);
- setDescription(behaviorModel, behavior, getDocComment(element));
+ setTagInfo(behavior.tag(), behaviorModel);
+ AttributesProcessor attributesProcessor = getAttributeProcessor();
+ attributesProcessor.processXmlFragment(behaviorModel, behavior.attributes());
+ attributesProcessor.processType(behaviorModel, (TypeElement) element);
+ setDescription(behaviorModel, behavior.description(), getDocComment(element));
+
library.getBehaviors().add(behaviorModel);
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -24,24 +24,36 @@
package org.richfaces.cdk.apt.processors;
import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.List;
import java.util.Set;
-import javax.lang.model.element.AnnotationMirror;
+import javax.faces.event.FacesEvent;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.annotations.Facet;
import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.RendererSpecificComponent;
+import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
+import org.richfaces.cdk.util.Strings;
+import com.google.inject.Inject;
+
/**
* <p class="changed_added_4_0">
* That class process component-related annotations such as {@link
org.richfaces.cdk.annotations.JsfComponent} or
@@ -57,32 +69,32 @@
public static final String COMPONENT_TYPE = "COMPONENT_TYPE";
+ @Inject
+ private Logger log;
+
public void process(Element componentElement, ComponentLibrary library) {
- SourceUtils sourceUtils = getSourceUtils();
- if (sourceUtils.isAnnotationPresent(componentElement, JsfComponent.class)) {
- AnnotationMirror annotation =
sourceUtils.getAnnotationMirror(componentElement, JsfComponent.class);
- // Process class-level annotations.
- ComponentModel component = new ComponentModel();
+ final JsfComponent annotation =
componentElement.getAnnotation(JsfComponent.class);
+ if (annotation == null) {
+ return;
+ }
- // Should that component be generated ?
- setClassNames((TypeElement) componentElement, component, annotation);
- setComponentProperties((TypeElement) componentElement, component,
annotation);
+ // Process class-level annotations.
+ ComponentModel component = new ComponentModel();
- library.getComponents().add(component);
+ // Should that component be generated ?
+ setClassNames((TypeElement) componentElement, component, annotation.generate());
+ setComponentProperties((TypeElement) componentElement, component, annotation);
+ library.getComponents().add(component);
- // Process the second level annotations.
- for (AnnotationMirror subcomponent :
sourceUtils.getAnnotationValues(annotation, "components",
- AnnotationMirror.class)) {
- ComponentModel subcomponentModel = new ComponentModel();
- subcomponentModel.setBaseClass(component.getTargetClass());
- if (!sourceUtils.isDefaultValue(subcomponent, "generate")) {
-
subcomponentModel.setTargetClass(sourceUtils.getAnnotationValue(subcomponent,
"generate",
- ClassName.class));
- subcomponentModel.setGenerate(true);
- }
- setComponentProperties(null, subcomponentModel, subcomponent);
- library.getComponents().add(subcomponentModel);
- }
+ // Process the second level annotations.
+ for (final RendererSpecificComponent subcomponent : annotation.components()) {
+ JsfComponent subAnnotation = new JsfSubComponent(subcomponent, annotation);
+ ComponentModel subcomponentModel = new ComponentModel();
+ subcomponentModel.setBaseClass(component.getTargetClass());
+
subcomponentModel.setTargetClass(ClassName.parseName(subcomponent.generate()));
+ subcomponentModel.setGenerate(!Strings.isEmpty(subcomponent.generate()));
+ setComponentProperties(null, subcomponentModel, subAnnotation);
+ library.getComponents().add(subcomponentModel);
}
}
@@ -96,48 +108,91 @@
* @param annotation
* @throws CdkException
*/
- void setComponentProperties(TypeElement componentElement, ComponentModel component,
AnnotationMirror annotation)
+ void setComponentProperties(TypeElement componentElement, ComponentModel component,
JsfComponent annotation)
throws CdkException {
- SourceUtils sourceUtils = getSourceUtils();
- setComponentType(componentElement, component, annotation);
- setComponeneFamily(componentElement, component, annotation);
- setDescription(component, annotation, getDocComment(componentElement));
- if (!sourceUtils.isDefaultValue(annotation, "renderer")) {
- setRendererType(component, sourceUtils.getAnnotationValue(annotation,
"renderer", AnnotationMirror.class));
- }
+ setComponentType(componentElement, component, annotation.type());
+ setComponeneFamily(componentElement, component, annotation.family());
+ setDescription(component, annotation.description(),
getDocComment(componentElement));
+ setRendererType(component, annotation.renderer());
+
processFacets(componentElement, component, annotation);
processAttributes(componentElement, component, annotation);
processEvents(componentElement, component, annotation);
- setTagInfo(annotation, component);
+ for (Tag tag : annotation.tag()) {
+ setTagInfo(tag, component);
+ }
// TODO - process @Test annotations.
}
- private void setRendererType(ComponentModel component, AnnotationMirror annotation)
{
- SourceUtils sourceUtils = getSourceUtils();
- if (!sourceUtils.isDefaultValue(annotation, "type")) {
- component.setRendererType(sourceUtils.getAnnotationValue(annotation,
"type", FacesId.class));
+ private void setRendererType(ComponentModel component, JsfRenderer jsfRenderer) {
+ if(!Strings.isEmpty(jsfRenderer.type())){
+ component.setRendererType(FacesId.parseId(jsfRenderer.type()));
}
- if (!sourceUtils.isDefaultValue(annotation, "template")) {
- component.setRendererTemplate(sourceUtils.getAnnotationValue(annotation,
"template", String.class));
+ if(!Strings.isEmpty(jsfRenderer.template())){
+ component.setRendererTemplate(jsfRenderer.template());
}
}
- void setComponentType(TypeElement componentElement, ComponentModel component,
AnnotationMirror annotation) {
- component.setId(FacesId.parseId(getAnnotationPropertyOrConstant(componentElement,
annotation,"type",COMPONENT_TYPE)));
+ private void processAttributes(TypeElement componentElement, ComponentModel
component, JsfComponent annotation) {
+ AttributesProcessor attributesProcessor = getAttributeProcessor();
+ attributesProcessor.processXmlFragment(component, annotation.attributes());
+
+ if (componentElement != null) {
+ attributesProcessor.processType(component, componentElement);
+ }
+
+ Collection<ClassName> interfaceNames = component.getInterfaces();
+ try {
+ Class<?>[] interfaces = annotation.interfaces();
+ for (Class<?> clazz : interfaces) {
+ interfaceNames.add(new ClassName(clazz));
+ }
+ } catch (MirroredTypesException e) {
+ List<? extends TypeMirror> typeMirrors = e.getTypeMirrors();
+ for (TypeMirror mirror : typeMirrors) {
+ processInterface(component, attributesProcessor, mirror);
+ }
+ } catch (MirroredTypeException e) {
+ processInterface(component, attributesProcessor, e.getTypeMirror());
+ }
}
- final void processFacets(TypeElement componentElement, ComponentModel component,
AnnotationMirror annotation) {
- SourceUtils sourceUtils = getSourceUtils();
+ private void processInterface(ComponentModel component, AttributesProcessor
attributesProcessor, TypeMirror mirror) {
+ component.getInterfaces().add(ClassName.parseName(mirror.toString()));
+ if (TypeKind.DECLARED.equals(mirror.getKind())) {
+ attributesProcessor.processType(component,
getSourceUtils().asTypeElement(mirror));
+ } else {
+ // TODO - record warning.
+ }
+ }
+
+ void setComponentType(TypeElement componentElement, ComponentModel component, String
type) {
+ if (!Strings.isEmpty(type)) {
+ component.setId(FacesId.parseId(type));
+ } else if (null != componentElement) {
+
+ // static final String COMPONENT_FAMILY = "...";
+ Object value = getSourceUtils().getConstant(componentElement,
COMPONENT_TYPE);
+ if (value != null) {
+ component.setId(FacesId.parseId(value.toString()));
+ }
+ }
+ }
+
+ final void processFacets(TypeElement componentElement, ComponentModel component,
JsfComponent annotation) {
if (null != componentElement) {
+ SourceUtils sourceUtils = getSourceUtils();
Set<BeanProperty> properties =
sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, componentElement);
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
- AnnotationMirror facet = beanProperty.getAnnotationMirror(Facet.class);
+ Facet facet = beanProperty.getAnnotation(Facet.class);
FacetModel facetModel =
component.getOrCreateFacet(beanProperty.getName());
+
facetModel.setDescription(beanProperty.getDocComment());
+
processFacet(facet, facetModel, beanProperty.getDocComment());
if (!beanProperty.isExists()) {
facetModel.setGenerate(true);
@@ -145,42 +200,57 @@
}
}
- for (AnnotationMirror facet : sourceUtils.getAnnotationValues(annotation,
"facets", AnnotationMirror.class)) {
- if (!sourceUtils.isDefaultValue(facet, "name")) {
- String name = sourceUtils.getAnnotationValue(facet, "name",
String.class);
+ for (Facet facet : annotation.facets()) {
+ String name = facet.name();
+ if (!Strings.isEmpty(name)) {
FacetModel facetModel = component.getOrCreateFacet(name);
processFacet(facet, facetModel, null);
} else {
+ // TODO - record error.
throw new CdkException("Facet name should be set");
}
}
}
- final void processFacet(AnnotationMirror facet, FacetModel facetModel, String
docComment) {
- SourceUtils sourceUtils = getSourceUtils();
- if (!sourceUtils.isDefaultValue(facet, "description")) {
- setDescription(facetModel, facet, docComment);
- }
- if (!sourceUtils.isDefaultValue(facet, "generate")) {
- facetModel.setGenerate(sourceUtils.getAnnotationValue(facet,
"generate", Boolean.class));
- }
+ final void processFacet(Facet facet, FacetModel facetModel, String docComment) {
+ setDescription(facetModel, facet.description(), docComment);
+ facetModel.setGenerate(facet.generate());
}
- final void setComponeneFamily(TypeElement componentElement, ComponentModel component,
AnnotationMirror annotation) {
- if(null != componentElement){
-
component.setFamily(FacesId.parseId(getAnnotationPropertyOrConstant(componentElement,
annotation,"family",COMPONENT_FAMILY)));
+ final void setComponeneFamily(TypeElement componentElement, ComponentModel component,
String family) {
+ if (!Strings.isEmpty(family)) {
+ component.setFamily(FacesId.parseId(family));
+ } else if (null != componentElement) {
+ // static final String COMPONENT_FAMILY = "...";
+ Object value = getSourceUtils().getConstant(componentElement,
COMPONENT_FAMILY);
+ if (null != value) {
+ component.setFamily(FacesId.parseId(value.toString()));
+ }
}
}
- final void processEvents(TypeElement componentElement, ComponentModel component,
AnnotationMirror annotation) {
- SourceUtils sourceUtils = getSourceUtils();
- for (AnnotationMirror event : sourceUtils.getAnnotationValues(annotation,
"fires", AnnotationMirror.class)) {
- EventModel model = new EventModel();
- sourceUtils.setModelProperty(model, event, "type",
"value");
- sourceUtils.setModelProperty(model, event, "listenerInterface",
"listener");
- sourceUtils.setModelProperty(model, event, "listenerMethod");
- sourceUtils.setModelProperty(model, event, "sourceInterface",
"source");
- component.getEvents().add(model);
+ final void processEvents(TypeElement componentElement, ComponentModel component,
JsfComponent annotation) {
+ try {
+ Class<? extends FacesEvent>[] fires = annotation.fires();
+
+ for (Class<? extends FacesEvent> event : fires) {
+ try {
+ component.addEvent(event.getName());
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+ }
+ } catch (MirroredTypeException mirror) {
+ component.addEvent(mirror.getTypeMirror().toString());
+ }
+
+ }
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+ }
+ } catch (MirroredTypeException mirror) {
+ component.addEvent(mirror.getTypeMirror().toString());
}
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -24,14 +24,16 @@
import java.lang.annotation.Annotation;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfConverter;
-import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
+import org.richfaces.cdk.model.FacesId;
/**
* @author akolonitsky
@@ -42,16 +44,32 @@
@Override
public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
- SourceUtils sourceUtils = getSourceUtils();
- AnnotationMirror converter = sourceUtils.getAnnotationMirror(element,
JsfConverter.class);
+ JsfConverter converter = element.getAnnotation(JsfConverter.class);
ConverterModel converterModel = new ConverterModel();
- sourceUtils.setModelProperty(converterModel, converter, "id");
- sourceUtils.setModelProperty(converterModel, converter,
"converterForClass","forClass");
+ converterModel.setId(FacesId.parseId(converter.id()));
- setDescription(converterModel, converter, getDocComment(element));
- processAttributes(element, converterModel, converter);
- setTagInfo(converter, converterModel);
+ try {
+ Class<?> forClass = converter.forClass();
+ if (!JsfConverter.NONE.class.equals(forClass)) {
+ converterModel.setConverterForClass(new ClassName(forClass.getName()));
+ }
+ } catch (MirroredTypeException e) {
+ String name = e.getTypeMirror().toString();
+ if (!JsfConverter.NONE.class.getName().equals(name)) {
+ converterModel.setConverterForClass(new ClassName(name));
+ }
+ }
+
+ setDescription(converterModel, converter.description(), getDocComment(element));
+
+ AttributesProcessor attributesProcessor = getAttributeProcessor();
+ attributesProcessor.processXmlFragment(converterModel, converter.attributes());
+ attributesProcessor.processType(converterModel, (TypeElement) element);
+ setClassNames((TypeElement) element, converterModel, converter.generate());
+
+ setTagInfo(converter.tag(), converterModel);
+
library.getConverters().add(converterModel);
}
@@ -59,4 +77,11 @@
public Class<? extends Annotation> getProcessedAnnotation() {
return JsfConverter.class;
}
+
+
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfConverter converter = element.getAnnotation(JsfConverter.class);
+
+ return converter.attributes();
+ }
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -23,8 +23,7 @@
package org.richfaces.cdk.apt.processors;
-import javax.lang.model.element.AnnotationMirror;
-
+import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.model.DescriptionGroup;
/**
@@ -37,15 +36,15 @@
/**
* <p class="changed_added_4_0">process {@link Description}
annotation and set information from it into model. Optional string from the JavaDoc
comment has precedence over {@link Desription#value()} attribute.</p>
* @param model
- * @param annotation
+ * @param description
* @param docComment JavaDoc comment associated with described element.
*/
- public void processDescription(DescriptionGroup model, AnnotationMirror annotation,
String docComment);
+ public void processDescription(DescriptionGroup model, Description description,
String docComment);
/**
* <p class="changed_added_4_0">process {@link Description}
annotation and set information from it into model.</p>
* @param model
* @param description
*/
- public void processDescription(DescriptionGroup model, AnnotationMirror
description);
+ public void processDescription(DescriptionGroup model, Description description);
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessorImpl.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessorImpl.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/DescriptionProcessorImpl.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -23,56 +23,51 @@
package org.richfaces.cdk.apt.processors;
-import javax.lang.model.element.AnnotationMirror;
-
-import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.model.DescriptionGroup;
import org.richfaces.cdk.util.Strings;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
/**
- * <p class="changed_added_4_0">
- * </p>
- *
+ * <p class="changed_added_4_0"></p>
+ *
* @author asmirnov(a)exadel.com
*/
public class DescriptionProcessorImpl implements DescriptionProcessor {
- private final Provider<SourceUtils> utilsProvider;
-
- @Inject
- public DescriptionProcessorImpl(Provider<SourceUtils> utilsProvider) {
- this.utilsProvider = utilsProvider;
- }
-
@Override
- public void processDescription(DescriptionGroup model, AnnotationMirror description,
String docComment) {
+ public void processDescription(DescriptionGroup model, Description description,
String docComment) {
if (!Strings.isEmpty(docComment)) {
model.setDescription(docComment);
}
if (description != null) {
- SourceUtils utils = utilsProvider.get();
setIcon(model, description);
- utils.setModelProperty(model, description, "displayName");
- utils.setModelProperty(model, description,
"description","value");
+ if (!Strings.isEmpty(description.displayName())) {
+ model.setDisplayname(description.displayName());
+ }
+ if (!Strings.isEmpty(description.value())) {
+ model.setDescription(description.value());
+ }
}
}
@Override
- public void processDescription(DescriptionGroup model, AnnotationMirror description)
{
+ public void processDescription(DescriptionGroup model, Description description) {
processDescription(model, description, null);
}
- protected void setIcon(DescriptionGroup component, AnnotationMirror description) {
- SourceUtils utils = utilsProvider.get();
- if (null != description
- && (!utils.isDefaultValue(description, "smallIcon") ||
!utils.isDefaultValue(description, "largeIcon"))) {
+ protected void setIcon(DescriptionGroup component, Description icon) {
+ if (null != icon && (!Strings.isEmpty(icon.smallIcon()) ||
!Strings.isEmpty(icon.largeIcon()))) {
DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
- utils.setModelProperty(iconValue, description, "smallIcon");
- utils.setModelProperty(iconValue, description, "largeIcon");
+
+ if (!Strings.isEmpty(icon.smallIcon())) {
+ iconValue.setSmallIcon(icon.smallIcon());
+ }
+
+ if (!Strings.isEmpty(icon.largeIcon())) {
+ iconValue.setLargeIcon(icon.largeIcon());
+ }
+
component.setIcon(iconValue);
}
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/EventProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/EventProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/EventProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -25,31 +25,28 @@
import java.lang.annotation.Annotation;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.Event;
-import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventModel;
+import org.richfaces.cdk.util.Strings;
/**
- * <p class="changed_added_4_0">
- * This class processes annotations for FacesEvents.
- * </p>
- *
+ * <p class="changed_added_4_0">This class processes annotations for
FacesEvents.</p>
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class EventProcessor extends ProcessorBase implements CdkAnnotationProcessor {
- /*
- * (non-Javadoc)
- *
+ /* (non-Javadoc)
* @see
org.richfaces.cdk.apt.processors.CdkAnnotationProcessor#getProcessedAnnotation()
*/
@Override
@@ -57,24 +54,31 @@
return Event.class;
}
- /*
- * (non-Javadoc)
- *
- * @see
org.richfaces.cdk.apt.processors.CdkAnnotationProcessor#process(javax.lang.model.element.Element,
- * org.richfaces.cdk.model.ComponentLibrary)
+ /* (non-Javadoc)
+ * @see
org.richfaces.cdk.apt.processors.CdkAnnotationProcessor#process(javax.lang.model.element.Element,
org.richfaces.cdk.model.ComponentLibrary)
*/
@Override
public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
if (ElementKind.CLASS.equals(element.getKind())) {
- SourceUtils sourceUtils = getSourceUtils();
TypeElement eventType = (TypeElement) element;
- AnnotationMirror event = sourceUtils.getAnnotationMirror(element,
Event.class);
+ Event event = eventType.getAnnotation(Event.class);
EventModel model = new EventModel();
model.setType(ClassName.parseName(eventType.getQualifiedName().toString()));
- sourceUtils.setModelProperty(model, event, "listenerInterface",
"listener");
- sourceUtils.setModelProperty(model, event, "listenerMethod");
- sourceUtils.setModelProperty(model, event, "sourceInterface",
"source");
- setTagInfo(event, model);
+ try {
+
model.setListenerInterface(ClassName.parseName(event.listener().toString()));
+ } catch (MirroredTypeException mirror) {
+
model.setListenerInterface(ClassName.parseName(mirror.getTypeMirror().toString()));
+ }
+ String listenerMethod = event.listenerMethod();
+ if(!Strings.isEmpty(listenerMethod)){
+ model.setListenerMethod(listenerMethod);
+ }
+ model.setSourceInterface(ClassName.parseName(event.source()));
+ for (Tag tag : event.tag()) {
+ if(!TagType.None.equals(tag.type())){
+ model.getTags().add(processTag(tag));
+ }
+ }
library.getEvents().add(model);
}
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/FunctionProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/FunctionProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/FunctionProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -26,7 +26,6 @@
import java.lang.annotation.Annotation;
import java.util.Set;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
@@ -36,14 +35,11 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.Function;
-import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FunctionModel;
+import org.richfaces.cdk.util.Strings;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Iterables;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -51,14 +47,6 @@
*/
public class FunctionProcessor extends ProcessorBase implements CdkAnnotationProcessor {
- private static final Joiner PARAMETERS_JOINER = Joiner.on(',').skipNulls();
- private static final com.google.common.base.Function<VariableElement,String>
PARAMETER_CONVERTER = new
com.google.common.base.Function<VariableElement,String>(){
-
- @Override
- public String apply(VariableElement var) {
- return var.asType().toString();
- }
- };
/* (non-Javadoc)
* @see
org.richfaces.cdk.apt.processors.CdkAnnotationProcessor#getProcessedAnnotation()
*/
@@ -72,7 +60,6 @@
*/
@Override
public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
- SourceUtils utils = getSourceUtils();
switch (element.getKind()) {
case METHOD:
ExecutableElement methodElement = (ExecutableElement) element;
@@ -85,20 +72,27 @@
if(!modifiers.contains(Modifier.STATIC)){
throw new CdkProcessingException("Only static method can be
registered as EL function "+methodElement.getSimpleName());
}
- AnnotationMirror function = utils.getAnnotationMirror(methodElement,
Function.class);
+ Function function = methodElement.getAnnotation(Function.class);
FunctionModel model = new FunctionModel();
- if(!utils.isDefaultValue(function, "name")){
- utils.setModelProperty(model, function, "name");
+ if(!Strings.isEmpty(function.name())){
+ model.setName(function.name());
} else {
model.setName(methodElement.getSimpleName().toString());
}
- utils.setModelProperty(model, function, "type");
- setDescription(model, function, getDocComment(methodElement));
+ model.setType(function.type());
+ setDescription(model, function.description(),
getDocComment(methodElement));
// Calculate method signature
StringBuilder signature = new StringBuilder();
signature.append(methodElement.getReturnType()).append(" ");
signature.append(methodElement.getSimpleName()).append("(");
- PARAMETERS_JOINER.appendTo(signature,
Iterables.transform(methodElement.getParameters(), PARAMETER_CONVERTER));
+ boolean first = true;
+ for(VariableElement parameter :methodElement.getParameters()){
+ if(!first){
+ signature.append(",");
+ }
+ signature.append(parameter.asType());
+ first = false;
+ }
signature.append(")");
model.setSignature(signature.toString());
Element declaringClass = methodElement.getEnclosingElement();
Added:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/JsfSubComponent.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/JsfSubComponent.java
(rev 0)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/JsfSubComponent.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -0,0 +1,120 @@
+/*
+ * 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.apt.processors;
+
+import java.lang.annotation.Annotation;
+
+import javax.faces.event.FacesEvent;
+
+import org.richfaces.cdk.annotations.Description;
+import org.richfaces.cdk.annotations.Facet;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.RendererSpecificComponent;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.Test;
+
+/**
+ * This calss wraps {@link RendererSpecificComponent} annotation so it would be used by
{@link ComponentProcessor} methods, so they
+ * can be reused for different types of the component annotations.
+ *
+ * @author akolonitsky
+ * @since Mar 31, 2010
+ */
+public class JsfSubComponent implements JsfComponent {
+
+ private final RendererSpecificComponent subcomponent;
+
+ private final JsfComponent parent;
+
+ public JsfSubComponent(RendererSpecificComponent subcomponent, JsfComponent parent)
{
+ this.subcomponent = subcomponent;
+ this.parent = parent;
+ }
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return JsfComponent.class;
+ }
+
+ @Override
+ public String type() {
+ return this.subcomponent.type();
+ }
+
+ @Override
+ public Test test() {
+ return this.subcomponent.test();
+ }
+
+ @Override
+ public Tag[] tag() {
+ return this.subcomponent.tag();
+ }
+
+ @Override
+ public JsfRenderer renderer() {
+ return this.subcomponent.renderer();
+ }
+
+ @Override
+ public Class<?>[] interfaces() {
+ return this.subcomponent.interfaces();
+ }
+
+ @Override
+ public String generate() {
+ return this.subcomponent.generate();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<? extends FacesEvent>[] fires() {
+ return new Class[0];
+ }
+
+ @Override
+ public String family() {
+ return this.parent.family();
+ }
+
+ @Override
+ public Facet[] facets() {
+ return this.subcomponent.facets();
+ }
+
+ @Override
+ public Description description() {
+ return this.subcomponent.description();
+ }
+
+ @Override
+ public RendererSpecificComponent[] components() {
+ return new RendererSpecificComponent[0];
+ }
+
+ @Override
+ public String[] attributes() {
+ return this.subcomponent.attributes();
+ }
+}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -1,33 +1,27 @@
package org.richfaces.cdk.apt.processors;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import org.richfaces.cdk.Logger;
import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.annotations.Description;
+import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.ModelCollection;
import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.TagModel;
-import org.richfaces.cdk.model.ViewElement;
+import org.richfaces.cdk.util.Strings;
import com.google.inject.Inject;
import com.google.inject.Provider;
-public abstract class ProcessorBase {
+public abstract class ProcessorBase {
+
@Inject
- protected Logger log;
-
- @Inject
private Provider<SourceUtils> sourceUtils;
@Inject
@@ -35,7 +29,7 @@
@Inject
private NamingConventions namingConventions;
-
+
@Inject
private DescriptionProcessor descriptionProcessor;
@@ -43,47 +37,46 @@
return this.sourceUtils.get();
}
- protected void setTagInfo(AnnotationMirror annotation, ViewElement model) {
- SourceUtils sourceUtils = getSourceUtils();
- ModelCollection<TagModel> tags = model.getTags();
- for (AnnotationMirror tag : sourceUtils.getAnnotationValues(annotation,
"tag", AnnotationMirror.class)) {
+ protected void setTagInfo(Tag tag, ModelElementBase model) {
+
+ if (!TagType.None.equals(tag.type())) {
TagModel tagModel = processTag(tag);
- tags.add(tagModel);
+
+ model.getTags().add(tagModel);
+
}
}
- protected TagModel processTag(AnnotationMirror tag) {
+ protected TagModel processTag(Tag tag) {
TagModel tagModel = new TagModel();
- SourceUtils sourceUtils = getSourceUtils();
- sourceUtils.setModelProperty(tagModel, tag, "name");
- tagModel.setType(sourceUtils.getAnnotationValue(tag, "type",
TagType.class));
- sourceUtils.setModelProperty(tagModel, tag, "targetClass",
"handler");
- sourceUtils.setModelProperty(tagModel, tag, "baseClass");
- sourceUtils.setModelProperty(tagModel, tag, "generate");
+ String name = tag.name();
+ tagModel.setName(name);
+ tagModel.setType(tag.type());
+ tagModel.setTargetClass(ClassName.parseName(tag.handler()));
+ tagModel.setBaseClass(ClassName.parseName(tag.baseClass()));
+ tagModel.setGenerate(tag.generate());
return tagModel;
}
- protected void setClassNames(TypeElement componentElement, ModelElementBase
modelElement, AnnotationMirror behavior) {
- SourceUtils sourceUtils = getSourceUtils();
- if (componentElement.getModifiers().contains(Modifier.ABSTRACT)
- || !sourceUtils.isDefaultValue(behavior, "generate")) {
+ protected void setClassNames(TypeElement componentElement, ModelElementBase
modelElement,
+ String generatedClass) {
+
+ if (componentElement.getModifiers().contains(Modifier.ABSTRACT) ||
!Strings.isEmpty(generatedClass)) {
modelElement.setGenerate(true);
- sourceUtils.setModelProperty(modelElement, behavior, "targetClass",
"generate");
+ modelElement.setTargetClass(ClassName.parseName(generatedClass));
} else {
modelElement.setGenerate(false);
-
modelElement.setTargetClass(ClassName.parseName(componentElement.getQualifiedName().toString()));
}
modelElement.setBaseClass(ClassName.parseName(componentElement.getQualifiedName().toString()));
}
+
protected String getDocComment(Element element) {
return null != element ? getSourceUtils().getDocComment(element) : null;
}
/**
- * <p class="changed_added_4_0">
- * </p>
- *
+ * <p class="changed_added_4_0"></p>
* @return the attributeProcessor
*/
protected AttributesProcessor getAttributeProcessor() {
@@ -98,44 +91,7 @@
this.namingConventions = namingConventions;
}
- protected void setDescription(DescriptionGroup model, AnnotationMirror annotation,
String docComment) {
- descriptionProcessor.processDescription(model,
- getSourceUtils().getAnnotationValue(annotation, "description",
AnnotationMirror.class), docComment);
+ protected void setDescription(DescriptionGroup model, Description description, String
docComment) {
+ descriptionProcessor.processDescription(model, description, docComment);
}
-
- protected void processAttributes(Element element, ModelElementBase component,
AnnotationMirror annotation) {
- AttributesProcessor attributesProcessor = getAttributeProcessor();
- SourceUtils sourceUtils = getSourceUtils();
- for (String atributesFragment : sourceUtils.getAnnotationValues(annotation,
"attributes", String.class)) {
- attributesProcessor.processXmlFragment(component, atributesFragment);
- }
- if (element != null && ElementKind.CLASS.equals(element.getKind())) {
- attributesProcessor.processType(component, (TypeElement) element);
- }
- for (TypeMirror atributesInterface : sourceUtils
- .getAnnotationValues(annotation, "interfaces", TypeMirror.class))
{
- processInterface(component, attributesProcessor, atributesInterface);
- }
- }
-
- private void processInterface(ModelElementBase component, AttributesProcessor
attributesProcessor, TypeMirror mirror) {
- component.getInterfaces().add(ClassName.parseName(mirror.toString()));
- if (TypeKind.DECLARED.equals(mirror.getKind())) {
- attributesProcessor.processType(component,
getSourceUtils().asTypeElement(mirror));
- } else {
- // TODO - record warning.
- }
- }
-
- protected String getAnnotationPropertyOrConstant(TypeElement element,
AnnotationMirror annotation, String annotationAttribute, String fieldName) {
- SourceUtils utils = getSourceUtils();
- if (!utils.isDefaultValue(annotation, annotationAttribute)) {
- return utils.getAnnotationValue(annotation,
annotationAttribute,String.class);
- }
- Object value = utils.getConstant((TypeElement) element, fieldName);
- if (value != null) {
- return value.toString();
- }
- return null;
- }
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -24,18 +24,23 @@
import java.lang.annotation.Annotation;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.AnnotationMirror;
+import javax.faces.render.RenderKitFactory;
import javax.lang.model.element.Element;
+import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.util.Strings;
+import com.google.inject.Inject;
/**
* @author akolonitsky
@@ -48,29 +53,61 @@
private static final String RENDERER_TYPE = "RENDERER_TYPE";
+ @Inject
+ private Logger log;
+
+
public void process(Element rendererElement, ComponentLibrary library) {
- SourceUtils sourceUtils = getSourceUtils();
- AnnotationMirror annotation = sourceUtils.getAnnotationMirror(rendererElement,
JsfRenderer.class);
+ JsfRenderer annotation = rendererElement.getAnnotation(JsfRenderer.class);
+ RendererModel rendererModel = process((TypeElement) rendererElement, annotation,
library);
+
+ addToRenderKit(annotation, library, rendererModel);
+
+ }
+
+ public RendererModel process(TypeElement rendererElement, JsfRenderer annotation,
ComponentLibrary library) {
RendererModel rendererModel = new RendererModel();
- TypeElement rendererTypeElement = (TypeElement) rendererElement;
- setClassNames(rendererTypeElement, rendererModel, annotation);
+ setClassNames(rendererElement, rendererModel, null);
- setRendererType(rendererTypeElement, rendererModel, annotation);
-
- setComponentFamily(rendererTypeElement, rendererModel, annotation);
- setDescription(rendererModel, annotation, getDocComment(rendererElement));
+ setRendererType(rendererElement, rendererModel, annotation);
+ setComponentFamily(rendererElement, rendererModel, annotation);
+ setDescription(rendererModel, annotation.description(),
getDocComment(rendererElement));
- sourceUtils.setModelProperty(rendererModel, annotation,
"templatePath","template");
+ setTemplate(rendererModel, annotation);
- String renderKitId = sourceUtils.getAnnotationValue(annotation,
"renderKitId", String.class);
- library.addRenderer(renderKitId, rendererModel);
+ // TODO - process @Test annotations.
+ return rendererModel;
+ }
+ protected void setClassNames(TypeElement componentElement, RendererModel
modelElement, String generatedClass) {
+
+ if (componentElement.getModifiers().contains(Modifier.ABSTRACT) ||
!Strings.isEmpty(generatedClass)) {
+ modelElement.setGenerate(true);
+ modelElement.setRendererClass(ClassName.parseName(generatedClass));
+
modelElement.setBaseClass(ClassName.parseName(componentElement.getQualifiedName().toString()));
+ } else {
+ modelElement.setGenerate(false);
+
modelElement.setRendererClass(ClassName.parseName(componentElement.getQualifiedName().toString()));
+
+ TypeMirror superclass = componentElement.getSuperclass();
+ if (superclass.getKind() == TypeKind.DECLARED) {
+ TypeElement typeElement = getSourceUtils().asTypeElement(superclass);
+
modelElement.setBaseClass(ClassName.parseName(typeElement.getQualifiedName().toString()));
+ }
+ }
+
}
+ private void addToRenderKit(JsfRenderer annotation, ComponentLibrary library,
RendererModel rendererModel) {
+ String renderKitId = annotation.renderKitId();
+ if (Strings.isEmpty(renderKitId)) {
+ renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT; // TODO ???
+ }
+ library.addRenderer(renderKitId, rendererModel);
+ }
-
private void setTemplate(RendererModel rendererModel, JsfRenderer annotation) {
String template = annotation.template();
if (!Strings.isEmpty(template)) {
@@ -79,14 +116,39 @@
}
- private void setComponentFamily(TypeElement rendererElement, RendererModel
rendererModel, AnnotationMirror annotation) {
-
rendererModel.setFamily(FacesId.parseId(getAnnotationPropertyOrConstant(rendererElement,
annotation,"family",COMPONENT_FAMILY)));
+ private void setComponentFamily(TypeElement rendererElement, RendererModel
rendererModel, JsfRenderer annotation) {
+ String family = annotation.family();
+ if (!Strings.isEmpty(family)) {
+ rendererModel.setFamily(FacesId.parseId(family));
+ return;
+ } else {
+
+ Object value = getSourceUtils().getConstant(rendererElement,
COMPONENT_FAMILY);
+ if (value != null) {
+ rendererModel.setFamily(FacesId.parseId(value.toString()));
+ return;
+ }
+ }
}
- private void setRendererType(TypeElement rendererElement, RendererModel
rendererModel, AnnotationMirror annotation) {
-
rendererModel.setId(FacesId.parseId(getAnnotationPropertyOrConstant(rendererElement,
annotation,"type",RENDERER_TYPE)));
+ private String getRendererType(TypeElement rendererElement, JsfRenderer annotation)
{
+ String type = annotation.type();
+ if (!Strings.isEmpty(type)) {
+ return type;
+ }
+
+ Object value = getSourceUtils().getConstant(rendererElement, RENDERER_TYPE);
+ if (value != null) {
+ return value.toString();
+ }
+
+ return null;
}
+ private void setRendererType(TypeElement rendererElement, RendererModel
rendererModel, JsfRenderer annotation) {
+ rendererModel.setId(FacesId.parseId(getRendererType(rendererElement,
annotation)));
+ }
+
protected String getComponentType(TypeElement componentElement) {
JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
if (annotation != null) {
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -24,14 +24,13 @@
import java.lang.annotation.Annotation;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfValidator;
-import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.ValidatorModel;
/**
@@ -43,15 +42,13 @@
@Override
public void process(Element element, ComponentLibrary library) throws
CdkProcessingException {
- SourceUtils utils = getSourceUtils();
- AnnotationMirror validator =
utils.getAnnotationMirror(element,JsfValidator.class);
+ JsfValidator validator = element.getAnnotation(JsfValidator.class);
- ValidatorModel validatorModel = new ValidatorModel();
- utils.setModelProperty(validatorModel, validator, "id");
- setClassNames((TypeElement) element, validatorModel, validator);
- setDescription(validatorModel, validator, getDocComment(element));
+ ValidatorModel validatorModel = new
ValidatorModel(FacesId.parseId(validator.id()));
+ setClassNames((TypeElement) element, validatorModel, validator.generate());
+ setDescription(validatorModel, validator.description(), getDocComment(element));
- setTagInfo(validator, validatorModel);
+ setTagInfo(validator.tag(), validatorModel);
library.getValidators().add(validatorModel);
}
@@ -60,4 +57,10 @@
public Class<? extends Annotation> getProcessedAnnotation() {
return JsfValidator.class;
}
+
+
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfValidator validator = element.getAnnotation(JsfValidator.class);
+ return validator.attributes();
+ }
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerWriter.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerWriter.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMarkerWriter.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -36,7 +36,6 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.Trackable;
-import org.richfaces.cdk.model.ViewElement;
import freemarker.template.TemplateException;
@@ -87,7 +86,7 @@
}
protected String getOutputFileName(C c) throws CdkException {
- if (c instanceof ViewElement) {
+ if (c instanceof ModelElementBase) {
ModelElementBase modelElement = (ModelElementBase) c;
return modelElement.getTargetClass().getName().replace('.',
File.separatorChar) + ".java";
} else {
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -26,9 +26,9 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.TagModel;
-import org.richfaces.cdk.model.ViewElement;
import freemarker.ext.beans.BeansWrapper;
import freemarker.ext.beans.StringModel;
@@ -72,7 +72,7 @@
return create(obj, EventTemplateModel.FACTORY);
} else if (obj instanceof TagModel) {
return create(obj, TagTemplateModel.FACTORY);
- } else if (obj instanceof ViewElement) {
+ } else if (obj instanceof ModelElementBase) {
return create(obj, ModelElementBaseTemplateModel.FACTORY);
} else {
return super.wrap(obj);
Modified:
trunk/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 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -122,46 +122,39 @@
public TemplateModel getImportClasses() throws TemplateModelException {
Set<ClassName> result = Sets.newTreeSet();
- String targetPackage = model.getTargetClass().getPackage();
+
for (PropertyBase entry : model.getAttributes()) {
- if (entry.getGenerate()) {
- addIfNecessary(targetPackage, result, entry.getType());
+ if (entry.getGenerate() && !isPredefined(entry)) {
+ result.add(entry.getType());
}
}
// Import all interfaces implemented by the generated class.
result.addAll(model.getInterfaces());
if (model instanceof ComponentModel) {
ComponentModel component = (ComponentModel) model;
- for (EventModel event : component.getEvents()) {
- addIfNecessary(targetPackage, result, event.getSourceInterface());
- addIfNecessary(targetPackage, result, event.getListenerInterface());
+ for(EventModel event :component.getEvents()){
+ result.add(event.getSourceInterface());
+ result.add(event.getListenerInterface());
}
}
// Collection<String> list = new ArrayList<String>(result);
return this.wrapper.wrap(result);
}
-
- private void addIfNecessary(String pkg, Set<ClassName> classNames, ClassName
toadd) {
- if (null != toadd && !isPredefined(toadd) &&
!pkg.equals(toadd.getPackage())) {
- classNames.add(toadd);
- }
- }
-
public TemplateModel getTagImports() throws TemplateModelException {
Set<ClassName> result = Sets.newTreeSet();
for (PropertyBase entry : model.getAttributes()) {
- if (!(entry.isHidden() || entry.isReadOnly() || null ==
entry.getSignature())) {
+ if (!(entry.isHidden()||entry.isReadOnly()||null == entry.getSignature())) {
MethodSignature methodSignature = entry.getSignature();
- if (!isPredefined(methodSignature.getReturnType())) {
+ if(!isPredefined(methodSignature.getReturnType())){
result.add(methodSignature.getReturnType());
}
for (ClassName className : methodSignature.getParameters()) {
- if (!isPredefined(className)) {
+ if(!isPredefined(className)){
result.add(className);
}
-
+
}
}
}
@@ -180,18 +173,15 @@
public TemplateModel getImplementedInterfaces() throws TemplateModelException {
Set<ClassName> result = Sets.newTreeSet();
- if (getEventNames().size() > 0) {
+ if(getEventNames().size()>0){
result.add(ClassName.parseName("javax.faces.component.behavior.ClientBehaviorHolder"));
}
// Import all interfaces implemented by the generated class.
result.addAll(model.getInterfaces());
if (model instanceof ComponentModel) {
ComponentModel component = (ComponentModel) model;
- for (EventModel event : component.getEvents()) {
- ClassName sourceInterface = event.getSourceInterface();
- if (null != sourceInterface) {
- result.add(sourceInterface);
- }
+ for(EventModel event :component.getEvents()){
+ result.add(event.getSourceInterface());
}
}
// Collection<String> list = new ArrayList<String>(result);
@@ -203,7 +193,7 @@
}
public boolean isPredefined(ClassName type) {
- return type.isPrimitive() || "java.lang".equals(type.getPackage());
+ return type.isPrimitive() ||"java.lang".equals(type.getPackage());
}
private TemplateModel eventNames() throws TemplateModelException {
@@ -264,7 +254,7 @@
@Override
public boolean apply(PropertyBase input) {
- return !(input.isHidden() || input.isReadOnly());
+ return !(input.isHidden()||input.isReadOnly());
}
}));
}
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -288,8 +288,8 @@
if (!Strings.isEmpty(model.getDescription())) {
parent.addElement("description").addText(model.getDescription());
}
- if (!Strings.isEmpty(model.getDisplayName())) {
- parent.addElement("display-name").addText(model.getDisplayName());
+ if (!Strings.isEmpty(model.getDisplayname())) {
+ parent.addElement("display-name").addText(model.getDisplayname());
}
if (null != model.getIcon()) {
Element iconElement = parent.addElement("icon");
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -159,18 +159,15 @@
return events;
}
- public EventModel addEvent(ClassName className) {
+ public EventModel addEvent(String className) {
+ // TODO - use a single events collection from library.
EventModel event = new EventModel();
- event.setType(className);
+ event.setType(new ClassName(className));
events.add(event);
return event;
}
- public EventModel addEvent(String className) {
- return addEvent(ClassName.get(className));
- }
-
@Override
public String toString() {
return "Component {type: " + getId() + ", family: " +
getFamily() + "}";
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -36,7 +36,7 @@
*/
@XmlElement(name = "display-name")
@Merge
- public String getDisplayName();
+ public String getDisplayname();
/**
* <p class="changed_added_4_0">
@@ -44,7 +44,7 @@
*
* @param displayname the displayname to set
*/
- public void setDisplayName(String displayname);
+ public void setDisplayname(String displayname);
/**
* <p class="changed_added_4_0">
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroupBase.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -65,11 +65,11 @@
}
@Merge
- public final String getDisplayName() {
+ public final String getDisplayname() {
return displayname;
}
- public final void setDisplayName(String displayname) {
+ public final void setDisplayname(String displayname) {
this.displayname = displayname;
}
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/EventModel.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/EventModel.java 2011-01-10
10:14:36 UTC (rev 20926)
+++ trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/EventModel.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -41,7 +41,7 @@
@SuppressWarnings("serial")
@XmlType(name = "event-configType", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
-public class EventModel implements ModelElement<EventModel>, ViewElement {
+public class EventModel implements ModelElement<EventModel> {
private String description;
private ClassName listenerInterface;
private String listenerMethod;
Modified: trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -10,7 +10,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ModelElementBase extends BeanModelBase implements FacesComponent,
ViewElement {
+public class ModelElementBase extends BeanModelBase implements FacesComponent {
private FacesId id;
@@ -23,10 +23,10 @@
private final Collection<ClassName> interfaces = Lists.newArrayList();
- /* (non-Javadoc)
- * @see org.richfaces.cdk.model.ViewElement#getTags()
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tags
*/
- @Override
public ModelCollection<TagModel> getTags() {
return this.tags;
}
Modified:
trunk/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 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -319,19 +319,22 @@
protected void verifyEvents(ComponentLibrary library) {
for (EventModel event : library.getEvents()) {
ClassName listenerInterface = event.getListenerInterface();
+ if (null == listenerInterface) {
+ // TODO - infer listener interface name.
+ }
SourceUtils sourceUtils = sourceUtilsProvider.get();
- if (null != listenerInterface) {
-
event.setGenerateListener(!sourceUtils.isClassExists(listenerInterface));
- }
+ event.setGenerateListener(!sourceUtils.isClassExists(listenerInterface));
String methodName = event.getListenerMethod();
if (null == methodName) {
+ // TODO infer listener method name.
methodName = "process";
event.setListenerMethod(methodName);
}
ClassName sourceInterface = event.getSourceInterface();
- if (null != sourceInterface) {
- event.setGenerateSource(!sourceUtils.isClassExists(sourceInterface));
+ if (null == sourceInterface) {
+ // TODO - infer source interface.
}
+ event.setGenerateSource(!sourceUtils.isClassExists(sourceInterface));
// Propagate event to corresponding components.
for (ComponentModel component : library.getComponents()) {
for (EventModel componentEvent : component.getEvents()) {
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -246,7 +246,7 @@
// TODO is it the right one?
rendererProperty.setDescription(templateAttribute.getShortDescription());
- rendererProperty.setDisplayName(templateAttribute.getDisplayName());
+ rendererProperty.setDisplayname(templateAttribute.getDisplayName());
Set<EventName> eventNamesSet =
convert(templateAttribute.getClientBehaviors());
if (eventNamesSet != null) {
Modified:
trunk/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -7,7 +7,7 @@
import org.richfaces.cdk.model.DescriptionGroup;
@XmlType(name = "descriptionType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder = {"description", "displayName",
"icon"})
+ propOrder = {"description", "displayname",
"icon"})
public class DescriptionGroupBean implements DescriptionGroup {
private String description;
private String displayname;
@@ -61,7 +61,7 @@
* @return the displayname
*/
@XmlElement(name = "display-name", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public final String getDisplayName() {
+ public final String getDisplayname() {
return displayname;
}
@@ -70,7 +70,7 @@
*
* @param displayname the displayname to set
*/
- public final void setDisplayName(String displayname) {
+ public final void setDisplayname(String displayname) {
this.displayname = displayname;
}
}
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsAnnotationsTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -13,7 +13,6 @@
import org.richfaces.cdk.model.ClassName;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
public class AptSourceUtilsAnnotationsTest extends SourceUtilsTestBase {
@@ -137,11 +136,11 @@
public void process(SourceUtils utils, RoundEnvironment roundEnv) {
Element element = findElement(roundEnv, ANNOTATIONS_TEST_CLASS);
AnnotationMirror annotationMirror = utils.getAnnotationMirror(element,
TestAnnotation.class);
- Iterable<T> annotationValues =
utils.getAnnotationValues(annotationMirror, propertyName, type);
- assertEquals("Annotation values size is different from
expected",expected.length, Iterables.size(annotationValues));
+ List<T> annotationValues =
utils.getAnnotationValues(annotationMirror, propertyName, type);
+ assertEquals("Annotation values size is different from
expected",expected.length, annotationValues.size());
for (int i = 0; i < expected.length; i++) {
Object expectedValue = expected[i];
- assertEquals("Annotation value at position "+i+" is
different from expected",expectedValue, Iterables.get(annotationValues, i));
+ assertEquals("Annotation value at position "+i+" is
different from expected",expectedValue, annotationValues.get(i));
}
}
});
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -104,7 +104,7 @@
expect(componentElement.getModifiers()).andReturn(Collections.singleton(Modifier.ABSTRACT));
expect(componentElement.getQualifiedName()).andReturn(name).atLeastOnce();
expect(behaviorAnnotation.generate()).andReturn("foo.Bar");
- expect(behaviorAnnotation.tag()).andReturn(new Tag[]{tag});
+ expect(behaviorAnnotation.tag()).andReturn(tag);
expect(behaviorAnnotation.attributes()).andReturn(new String[] {});
expect(behaviorAnnotation.description()).andReturn(this.description);
expect(tag.handler()).andStubReturn("");
Modified:
trunk/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 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -28,7 +28,6 @@
import java.util.Collections;
-import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
@@ -72,7 +71,7 @@
private static final String FOO_HTML_BAR = "foo.HtmlBar";
@Mock
- private AnnotationMirror annotation;
+ private JsfComponent annotation;
@Mock
private AttributesProcessor attributesProcessor;
@@ -113,19 +112,13 @@
@Test
public void testProcessFacetsFromAnnotation() throws Exception {
- AnnotationMirror facet = createMock(AnnotationMirror.class);
+ Facet facet = createMock(Facet.class);
expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),
same(componentElement))).andReturn(
Collections.<BeanProperty> emptySet());
-// expect(annotation.facets()).andReturn(new Facet[] { facet });
- expect(utils.getAnnotationValues(annotation,
"facets",AnnotationMirror.class)).andReturn(Collections.singleton(facet));
- expect(utils.isDefaultValue(same(facet),
eq("name"))).andReturn(false);
- expect(utils.getAnnotationValue(facet,
"name",String.class)).andReturn("foo");
- expect(utils.isDefaultValue(same(facet),
eq("description"))).andReturn(true);
- expect(utils.isDefaultValue(same(facet),
eq("generate"))).andReturn(false);
- expect(utils.getAnnotationValue(facet,
"generate",Boolean.class)).andReturn(true);
-// expect(facet.name()).andReturn("foo");
-// expect(facet.description()).andReturn(this.description);
-// expect(facet.generate()).andReturn(true);
+ expect(annotation.facets()).andReturn(new Facet[] { facet });
+ expect(facet.name()).andReturn("foo");
+ expect(facet.description()).andReturn(this.description);
+ expect(facet.generate()).andReturn(true);
// expect(this.description.smallIcon()).andReturn("");
// expect(this.description.largeIcon()).andReturn("");
//
expect(this.description.displayName()).andReturn("fooFacet").times(2);
@@ -146,17 +139,20 @@
@Test
public void testProcessFacetsFromProperty() throws Exception {
- AnnotationMirror facet = createMock(AnnotationMirror.class);
+ Facet facet = createMock(Facet.class);
expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),
same(componentElement))).andReturn(
Collections.singleton(property));
- expect(property.getAnnotationMirror(Facet.class)).andReturn(facet);
+ expect(annotation.facets()).andReturn(new Facet[0]);
+ expect(property.getAnnotation(Facet.class)).andReturn(facet);
expect(property.getName()).andReturn("foo");
expect(property.getDocComment()).andReturn("my comment").times(2);
expect(property.isExists()).andReturn(true);
- expect(utils.isDefaultValue(same(facet),
eq("description"))).andReturn(true);
- expect(utils.isDefaultValue(same(facet),
eq("generate"))).andReturn(false);
- expect(utils.getAnnotationValue(facet,
"generate",Boolean.class)).andReturn(true);
- expect(utils.getAnnotationValues(annotation,
"facets",AnnotationMirror.class)).andReturn(Collections.<AnnotationMirror>emptySet());
+ expect(facet.description()).andReturn(description);
+ expect(facet.generate()).andReturn(true);
+ // expect(this.description.smallIcon()).andReturn("");
+ // expect(this.description.largeIcon()).andReturn("");
+ //
expect(this.description.displayName()).andReturn("fooFacet").times(2);
+ // expect(this.description.value()).andReturn("");
replay(utils, componentElement, jaxb, annotation, property, facet, description);
processor.processFacets(componentElement, model, annotation);
@@ -166,6 +162,9 @@
FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
assertTrue(facetModel.getGenerate());
assertEquals("foo", facetModel.getName());
+ // assertEquals("my comment", facetModel.getDescription());
+ // assertEquals("fooFacet", facetModel.getDisplayname());
+ // assertNull(facetModel.getIcon());
}
/**
@@ -178,14 +177,12 @@
public void testSetClassNames() throws Exception {
expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>
emptySet());
expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
- expect(utils.isDefaultValue(annotation, "generate")).andReturn(true);
- expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
replay(utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model, annotation);
+ processor.setClassNames(componentElement, model, "");
verify(utils, componentElement, jaxb, annotation);
assertFalse(model.getGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
- assertEquals(FOO_BAR, model.getTargetClass().toString());
+ assertNull(model.getTargetClass());
}
/**
@@ -197,11 +194,10 @@
@Test
public void testSetClassNames1() throws Exception {
expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>
singleton(Modifier.ABSTRACT));
- utils.setModelProperty(model, annotation,
"targetClass","generate");expectLastCall();
expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
replay(utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model, annotation);
+ processor.setClassNames(componentElement, model, "");
verify(utils, componentElement, jaxb, annotation);
assertTrue(model.getGenerate());
@@ -218,18 +214,50 @@
@Test
public void testSetClassNames2() throws Exception {
expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>
emptySet());
- expect(utils.isDefaultValue(annotation, "generate")).andReturn(false);
- utils.setModelProperty(model, annotation,
"targetClass","generate");expectLastCall();
expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
replay(utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model, annotation);
+ processor.setClassNames(componentElement, model, FOO_HTML_BAR);
verify(utils, componentElement, jaxb, annotation);
assertTrue(model.getGenerate());
assertEquals(FOO_BAR, model.getBaseClass().toString());
+ assertEquals(FOO_HTML_BAR, model.getTargetClass().toString());
}
+ @Test
+ public void testSetFamily() throws Exception {
+ replay(utils, componentElement, jaxb, annotation);
+
+ processor.setComponeneFamily(componentElement, model, FOO_HTML_BAR);
+
+ verify(utils, componentElement, jaxb, annotation);
+ assertEquals(FacesId.parseId(FOO_HTML_BAR), model.getFamily());
+ }
+
+ @Test
+ public void testSetFamily1() throws Exception {
+ expect(utils.getConstant(same(componentElement),
eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(
+ FOO_HTML_BAR);
+ replay(utils, componentElement, jaxb, annotation);
+
+ processor.setComponeneFamily(componentElement, model, "");
+
+ verify(utils, componentElement, jaxb, annotation);
+ assertEquals(FacesId.parseId(FOO_HTML_BAR), model.getFamily());
+ }
+
+ @Test
+ public void testSetFamily2() throws Exception {
+ expect(utils.getConstant(same(componentElement),
eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(null);
+ replay(utils, componentElement, jaxb, annotation);
+
+ processor.setComponeneFamily(componentElement, model, "");
+
+ verify(utils, componentElement, jaxb, annotation);
+ assertNull(model.getFamily());
+ }
+
@Override
protected Iterable<String> sources() {
return Collections.singleton(COMPONENT_CLASS_JAVA);
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/apt/processors/DescriptionProcessorTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -27,15 +27,12 @@
import java.util.Collections;
-import javax.lang.model.element.AnnotationMirror;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.annotations.Description;
import org.richfaces.cdk.apt.AnnotationProcessorTestBase;
-import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.DescriptionGroup;
import com.google.inject.Inject;
@@ -58,14 +55,12 @@
private DescriptionGroup bean;
@Mock
- private AnnotationMirror description;
+ private Description description;
@Inject
private DescriptionProcessorImpl descriptionProcessor;
- @Mock
- private SourceUtils utils;
- /**
+ /**
* Test method for
* {@link
org.richfaces.cdk.apt.processors.DescriptionProcessorImpl#processDescription(org.richfaces.cdk.model.DescriptionGroup,
org.richfaces.cdk.annotations.Description, java.lang.String)}
* .
@@ -74,14 +69,12 @@
public void testProcessDescription() {
bean.setDescription(FOO_BAR_ELEMENT);
expectLastCall();
- expect(utils.isDefaultValue(description,
"smallIcon")).andStubReturn(true);
- expect(utils.isDefaultValue(description,
"largeIcon")).andStubReturn(true);
- utils.setModelProperty(bean, description,
"displayName");expectLastCall();
- utils.setModelProperty(bean, description,
"description","value");expectLastCall();
-// expect(this.description.smallIcon()).andReturn("");
-// expect(this.description.largeIcon()).andReturn("");
-// expect(this.description.displayName()).andReturn(FOO_FACET).times(2);
-// expect(this.description.value()).andReturn("");
+ bean.setDisplayname(FOO_FACET);
+ expectLastCall();
+ expect(this.description.smallIcon()).andReturn("");
+ expect(this.description.largeIcon()).andReturn("");
+ expect(this.description.displayName()).andReturn(FOO_FACET).times(2);
+ expect(this.description.value()).andReturn("");
mockController.replay();
descriptionProcessor.processDescription(bean, description, FOO_BAR_ELEMENT);
mockController.verify();
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -252,7 +252,7 @@
assertTrue(requiredAttribute.isRequired());
assertEquals("That's a required attribute",
requiredAttribute.getDescription());
- assertEquals("Required Attribute",
requiredAttribute.getDisplayName());
+ assertEquals("Required Attribute",
requiredAttribute.getDisplayname());
}
@Test
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -103,7 +103,7 @@
assertEquals("panel.gif", component.getIcon().getSmallIcon());
assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
assertEquals("Panel component", component.getDescription());
- assertEquals("Panel", component.getDisplayName());
+ assertEquals("Panel", component.getDisplayname());
assertTrue(component.getGenerate());
FacetModel facet = Iterables.getOnlyElement(component.getFacets());
Modified:
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
---
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -113,7 +113,7 @@
assertEquals("int", property.getType().getName());
assertEquals("test2 property", property.getDescription());
assertEquals("ontest2.png", property.getIcon().getSmallIcon());
- assertEquals("test2 event property", property.getDisplayName());
+ assertEquals("test2 event property", property.getDisplayname());
assertEquals("3", property.getDefaultValue());
assertEquals("15", property.getSuggestedValue());
Modified:
trunk/cdk/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/cdk/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -31,12 +31,9 @@
import javax.faces.component.ValueHolder;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.event.ValueChangeListener;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Description;
-import org.richfaces.cdk.annotations.Event;
import org.richfaces.cdk.annotations.Facet;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
@@ -59,7 +56,7 @@
description=@Description(displayName="Test
Component",largeIcon="large.gif",smallIcon="spall.png"),
generate="org.richfaces.cdk.test.component.UITestComponent",
facets=@Facet(name="caption",generate=true,description=@Description("Caption
Facet")),
-
fires={@Event(TestEvent.class),(a)Event(value=ValueChangeEvent.class,listener=ValueChangeListener.class)},
+ fires=TestEvent.class,
interfaces=ValueHolder.class,
components={
@RendererSpecificComponent(type =
"org.richfaces.cdk.test.TestHtmlAbbr",
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/component/UIRepeat.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/component/UIRepeat.java 2011-01-10
10:14:36 UTC (rev 20926)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/component/UIRepeat.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -30,7 +30,7 @@
* @author Nick Belaevski
*
*/
-@JsfComponent(tag = @Tag(name = "repeat", type = TagType.Facelets), renderer =
@JsfRenderer(type = "org.richfaces.RepeatRenderer"))
+@JsfComponent(generate = "", tag = @Tag(name = "repeat", type =
TagType.Facelets), renderer = @JsfRenderer(type =
"org.richfaces.RepeatRenderer"))
public class UIRepeat extends UISequence {
public static final String COMPONENT_TYPE = "org.richfaces.Repeat";
Modified:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DrowDownMenuRendererTest.java
===================================================================
---
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DrowDownMenuRendererTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DrowDownMenuRendererTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -29,6 +29,7 @@
import java.net.URISyntaxException;
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.Ignore;
import org.junit.Test;
import org.richfaces.component.DropDownMenuBean;
import org.xml.sax.SAXException;
@@ -36,6 +37,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
+@Ignore
public class DrowDownMenuRendererTest extends RendererTestBase {
@Override
Modified:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java
===================================================================
---
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java 2011-01-10
10:14:36 UTC (rev 20926)
+++
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java 2011-01-10
10:29:55 UTC (rev 20927)
@@ -29,6 +29,7 @@
import java.net.URISyntaxException;
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.Ignore;
import org.junit.Test;
import org.richfaces.component.DropDownMenuBean;
import org.xml.sax.SAXException;
@@ -36,6 +37,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
+@Ignore
public class MenuItemRendererTest extends RendererTestBase {
@Override