Author: alexsmirnov
Date: 2010-03-17 20:53:35 -0400 (Wed, 17 Mar 2010)
New Revision: 16592
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/FacesComponentProcessor.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
Log:
CODING IN PROGRESS - issue RF-8523: Refactor CDK annotations
https://jira.jboss.org/jira/browse/RF-8523
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -78,6 +78,16 @@
boolean required() default false;
boolean generate() default true;
+
+ String displayName() default "";
+
+ String defaultValue() default "";
+
+ String suggestedValue() default "";
+
+ Icon icon() default @Icon();
Signature signature() default @Signature();
+
+ EventName[] events() default {};
}
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Event.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -29,6 +29,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.faces.event.FacesEvent;
+
/**
* <p class="changed_added_4_0">
* This annotation tells CDK to generate event-related classes:
@@ -49,6 +51,11 @@
public static final String NAME = "org.richfaces.cdk.annotations.Event";
/**
+ * <p class="changed_added_4_0"></p>
+ * @return
+ */
+ public Class<? extends FacesEvent> value();
+ /**
* <p class="changed_added_4_0">
* Name of the listener interface class.
* </p>
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Facet.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -49,6 +49,12 @@
*
* @return
*/
- String value() default "";
+ String name() default "";
+
+ boolean generate() default true;
+
+ Icon icon() default @Icon;
+
+ String displayName() default "";
}
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -50,7 +50,40 @@
*/
public String id() default "";
- public String behaviorClass() default "";
+ public String generate() default "";
public Tag tag() default @Tag;
+
+
+ /**
+ * <p class="changed_added_4_0">
+ * Icon used by IDE.
+ * </p>
+ *
+ * @return
+ */
+ public Icon icon() default @Icon();
+
+ /**
+ * <p class="changed_added_4_0">
+ * Display name for development tools.
+ * </p>
+ *
+ * @return
+ */
+ public String displayName() default "";
+
+
+ /**
+ * <p class="changed_added_4_0">
+ * defines fragments of faces-config.xml that contain standard attribute definitions.
CDK also tries to read
+ * META-INF/cdk/attributes/[classname].xml file for all component superclasses and
interfaces, therefore it is not
+ * necessary to explicit include definitions for UIComponent and any other standard
JSF classes. CDK defines couple
+ * of its own "urn" namespaces: "urn:resource:" for classpath
resources, "urn:config:" for for project configuration
+ * folder and "urn:attributes:" for META-INF/cdk/attributes/ in the
annotations library.
+ * </p>
+ *
+ * @return
+ */
+ public String[] attributes() default {};
}
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -51,6 +51,10 @@
public static final String NAME =
"org.richfaces.cdk.annotations.JsfComponent";
/**
+ * <p class="changed_added_4_0">Excplicitly disable component
generation</p>
+ */
+ public static final String DISABLED = "##DISABLED";
+ /**
* <p class="changed_added_4_0">
* Type of the component. This is mandatory parameter because CDK uses
<em>component-type</em> as primary key for
* components library model.
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -42,9 +42,44 @@
public String id() default "";
- public Class<?> forClass() default Object.class;
+ public Class<?> forClass() default NONE.class;
- public String converterClass() default "";
+ public String generate() default "";
+
+ /**
+ * <p class="changed_added_4_0">
+ * Icon used by IDE.
+ * </p>
+ *
+ * @return
+ */
+ public Icon icon() default @Icon();
+
+ /**
+ * <p class="changed_added_4_0">
+ * Display name for development tools.
+ * </p>
+ *
+ * @return
+ */
+ public String displayName() default "";
+
public Tag tag() default @Tag;
+
+ public static final class NONE {}
+
+ /**
+ * <p class="changed_added_4_0">
+ * defines fragments of faces-config.xml that contain standard attribute definitions.
CDK also tries to read
+ * META-INF/cdk/attributes/[classname].xml file for all component superclasses and
interfaces, therefore it is not
+ * necessary to explicit include definitions for UIComponent and any other standard
JSF classes. CDK defines couple
+ * of its own "urn" namespaces: "urn:resource:" for classpath
resources, "urn:config:" for for project configuration
+ * folder and "urn:attributes:" for META-INF/cdk/attributes/ in the
annotations library.
+ * </p>
+ *
+ * @return
+ */
+ public String[] attributes() default {};
+
}
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -15,9 +15,40 @@
public static final String NAME =
"org.richfaces.cdk.annotations.JsfValidator";
- public String id() default "";
+ public String id();
- public String validatorClass() default "";
+ public String generate() default "";
public Tag tag() default @Tag;
+ /**
+ * <p class="changed_added_4_0">
+ * Icon used by IDE.
+ * </p>
+ *
+ * @return
+ */
+ public Icon icon() default @Icon();
+
+ /**
+ * <p class="changed_added_4_0">
+ * Display name for development tools.
+ * </p>
+ *
+ * @return
+ */
+ public String displayName() default "";
+
+
+ /**
+ * <p class="changed_added_4_0">
+ * defines fragments of faces-config.xml that contain standard attribute definitions.
CDK also tries to read
+ * META-INF/cdk/attributes/[classname].xml file for all component superclasses and
interfaces, therefore it is not
+ * necessary to explicit include definitions for UIComponent and any other standard
JSF classes. CDK defines couple
+ * of its own "urn" namespaces: "urn:resource:" for classpath
resources, "urn:config:" for for project configuration
+ * folder and "urn:attributes:" for META-INF/cdk/attributes/ in the
annotations library.
+ * </p>
+ *
+ * @return
+ */
+ public String[] attributes() default {};
}
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java
===================================================================
---
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -40,7 +40,7 @@
*
* @return
*/
- public Class<?> returnType() default Object.class;
+ public Class<?> returnType() default NONE.class;
/**
* <p class="changed_added_4_0">
@@ -50,4 +50,6 @@
* @return
*/
public Class<?>[] parameters() default {};
+
+ public static final class NONE {}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -45,7 +45,6 @@
protected void configure() {
Multibinder<CdkAnnotationProcessor> setBinder =
Multibinder.newSetBinder(binder(),CdkAnnotationProcessor.class);
setBinder.addBinding().to(ComponentProcessor.class);
- setBinder.addBinding().to(FacesComponentProcessor.class);
setBinder.addBinding().to(BehaviorProcessor.class);
setBinder.addBinding().to(RendererProcessor.class);
setBinder.addBinding().to(ConverterProcessor.class);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -25,6 +25,7 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.annotations.JsfConverter;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.FacesId;
@@ -49,9 +50,9 @@
setClassNames(element, behaviorModel, behavior);
setTagInfo(behavior.tag(), behaviorModel);
+ processAttributes(element, behaviorModel);
+ setDescription(behaviorModel, behavior.icon(), getDocComment(element),
behavior.displayName());
- setDescription(element, behaviorModel);
-
getLibrary().getBehaviors().add(behaviorModel);
}
@@ -62,11 +63,14 @@
public void setClassNames(TypeElement element, BehaviorModel behaviorModel,
JsfBehavior behavior) {
String baseClass = element.getQualifiedName().toString();
- setClassNames(element, behaviorModel, behavior.behaviorClass(), baseClass);
+ setClassNames(element, behaviorModel, behavior.generate(), baseClass);
}
+
@Override
- protected String getDafaultParentTagHandlerClass() {
- return BehaviorHandler.class.getName();
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
+ return behavior.attributes();
}
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -45,7 +45,6 @@
import javax.lang.model.type.MirroredTypesException;
import javax.lang.model.type.TypeMirror;
import java.lang.annotation.Annotation;
-import java.util.List;
import java.util.Set;
/**
@@ -63,44 +62,29 @@
private Injector injector;
public void process(TypeElement componentElement) {
- ComponentLibrary library = getLibrary();
- // Process class-level annotations.
- ComponentModel component = new ComponentModel();
- component.setType(new FacesId(getComponentType(componentElement)));
- // Should that component be generated ?
- setClassNames(componentElement, component);
- setComponentProperties(componentElement, component);
-
JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
if (null != annotation) {
- component.setGenerate(!"".equals(annotation.generate()));
+ ComponentLibrary library = getLibrary();
+ // Process class-level annotations.
+ ComponentModel component = new ComponentModel();
+ component.setType(FacesId.parseId(annotation.type()));
+ // Should that component be generated ?
+ String baseClass = componentElement.getQualifiedName().toString();
+ setClassNames(componentElement, component, annotation.generate(),
baseClass);
+ setComponentProperties(componentElement, component, annotation);
for (Tag tag : annotation.tag()) {
setTagInfo(tag, component);
}
+ library.getComponents().add(component);
}
- library.getComponents().add(component);
}
- protected String getComponentType(TypeElement componentElement) {
- // Calculate type for base UI component class.
- JsfComponent componentAnnotation =
componentElement.getAnnotation(JsfComponent.class);
- String explicitType = componentAnnotation.type();
-// if (!Strings.isEmpty(explicitType)) {
- return explicitType;
-// }
-
- // Because component type is a primary key for components collection,
- // we have to infer explicit value here.
-// String className = componentElement.getQualifiedName().toString();
-// return getNamingConventions().inferComponentType(new ClassName(className));
- }
-
- private void setComponentProperties(TypeElement componentElement, ComponentModel
component)
+ private void setComponentProperties(TypeElement componentElement, ComponentModel
component, JsfComponent annotation)
throws CdkException {
// JsfComponent family
setComponeneFamily(componentElement, component);
- setDescription(componentElement, component);
+ setDescription(component, annotation.icon(), getDocComment(componentElement),
annotation.displayName());
processFacets(componentElement, component);
// process Events.
@@ -122,51 +106,44 @@
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
- FacetModel facet = component.getOrCreateFacet(beanProperty.getName());
+ Facet facet = beanProperty.getAnnotation(Facet.class);
+ FacetModel facetModel = component.getOrCreateFacet(beanProperty.getName());
// Documentation
- facet.setDescription(beanProperty.getDocComment());
+ facetModel.setDescription(beanProperty.getDocComment());
- Icon icon = beanProperty.getAnnotation(Icon.class);
-
- if (null != icon) {
- setIcon(facet, icon);
+ processFacet(facet, facetModel);
+ if(!beanProperty.isExists()){
+ facetModel.setGenerate(true);
}
-
- DisplayName displayName = beanProperty.getAnnotation(DisplayName.class);
-
- if (null != displayName) {
- facet.setDisplayname(displayName.value());
- }
-
- // Flags.
- facet.setGenerate(beanProperty.isExists());
}
// @Facets annotation.
- Facets facetsAnnotation = componentElement.getAnnotation(Facets.class);
-
- if (null != facetsAnnotation) {
- Facet[] facets = facetsAnnotation.value();
-
- for (Facet facet : facets) {
- if (!Strings.isEmpty(facet.value())) {
- component.getOrCreateFacet(facet.value());
+ JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
+ for (Facet facet : annotation.facets()) {
+ if (!Strings.isEmpty(facet.name())) {
+ FacetModel facetModel = component.getOrCreateFacet(facet.name());
+ processFacet(facet, facetModel);
} else {
-
// TODO - record error.
+ throw new CdkException("Facet name should be set");
}
}
- }
}
+ private void processFacet(Facet facet, FacetModel facetModel) {
+ setIcon(facetModel, facet.icon());
+ facetModel.setDisplayname(facet.displayName());
+ // Flags.
+ facetModel.setGenerate(facet.generate());
+ }
+
private void setComponeneFamily(TypeElement componentElement, ComponentModel
component) {
- Family family = componentElement.getAnnotation(Family.class);
+ JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
- if (null != family) {
-
+ if (!Strings.isEmpty(annotation.family())) {
// @Family annotation
- component.setFamily(family.value());
+ component.setFamily(annotation.family());
} else {
// static final COMPONENT_FAMILY string constant.
Object value =
getSourceUtils().getConstant(asClassDesctiption(componentElement),
"COMPONENT_FAMILY");
@@ -178,167 +155,30 @@
private void setEvents(TypeElement componentElement, ComponentModel component) {
- Fires fires = componentElement.getAnnotation(Fires.class);
+ Event[] fires = componentElement.getAnnotation(JsfComponent.class).fires();
- if (null != fires) {
- try {
- for (Class<? extends FacesEvent> eventClass : fires.value()) {
- component.addEvent(eventClass.getName());
- }
- } catch (MirroredTypesException mirror) {
- for (TypeMirror eventType : mirror.getTypeMirrors()) {
- component.addEvent(eventType.toString());
- // TODO - check does component already implement eventSource
interface
- }
- } catch (MirroredTypeException mirror) {
- component.addEvent(mirror.getTypeMirror().toString());
- }
- }
- }
+ for (Event event : fires) {
+ try {
+ component.addEvent(event.value().getName());
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+ // TODO - check does component already implement eventSource
interface
+ }
+ } catch (MirroredTypeException mirror) {
+ component.addEvent(mirror.getTypeMirror().toString());
+ }
- private void setClassNames(TypeElement componentElement, ComponentModel component) {
- Generate generate = componentElement.getAnnotation(Generate.class);
- String name = generate == null ? null : generate.value();
-
- String baseClass = componentElement.getQualifiedName().toString();
-
- setClassNames(componentElement, component, name, baseClass);
- }
-
- protected void processAttributes(TypeElement componentElement, final ComponentModel
component)
- throws CdkException {
-
- // Process XML files with standard attributes definitions.
- Attributes attributes = componentElement.getAnnotation(Attributes.class);
-
- if (null != attributes) {
- for (String attributesConfig : attributes.value()) {
-
- // process additional properties.
- component.getAttributes().addAll(parseProperties(attributesConfig));
- }
- }
-
- SourceUtils sourceUtils = getSourceUtils();
- sourceUtils.visitSupertypes(asClassDesctiption(componentElement), new
SuperTypeVisitor() {
-
- @Override
- public void visit(ClassName type) {
- try {
- component.getAttributes().addAll(
- parseProperties(CdkEntityResolver.URN_ATTRIBUTES +
type.toString() + ".xml"));
- } catch (CdkException e) {
- // TODO - log errors ?
}
- }
- });
-
- Set<BeanProperty> properties =
sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class,
asClassDesctiption(componentElement));
-
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- if (component.getAttribute(beanProperty.getName()) != null) {
- continue;
- }
-
- Property attribute = component.getOrCreateAttribute(beanProperty.getName());
-
- // Documentation
- attribute.setDescription(beanProperty.getDocComment());
-
- setDescription(componentElement, component);
-
- // type.
- attribute.setType(beanProperty.getType());
-
-
- setAttributePrams(beanProperty, attribute);
-
- // BehaviorModel events.
- EventName eventName = beanProperty.getAnnotation(EventName.class);
- setBehaviorEvent(attribute, eventName);
-
- EventNames eventNames = beanProperty.getAnnotation(EventNames.class);
- if (null != eventNames) {
- for (EventName eventNameInstance : eventNames.value()) {
- setBehaviorEvent(attribute, eventNameInstance);
- }
- }
-
- // DefaultValues
- DefaultValue defaultValue = beanProperty.getAnnotation(DefaultValue.class);
- if (null != defaultValue) {
- attribute.setDefaultValue(defaultValue.value());
- }
-
- SuggestedValue suggestedValue =
beanProperty.getAnnotation(SuggestedValue.class);
- if (null != suggestedValue) {
- attribute.setSuggestedValue(suggestedValue.value());
- }
-
- // Flags.
- attribute.setGenerate(attribute.isGenerate()
- || !beanProperty.isExists()
- || null != beanProperty.getAnnotation(Generate.class));
- }
}
- private void setAttributePrams(BeanProperty beanProperty, Property attribute) {
- // Flags
- Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
- if (attributeAnnotarion == null) {
- return;
- }
-
- attribute.setHidden(attributeAnnotarion.hidden());
- attribute.setLiteral(attributeAnnotarion.literal());
- attribute.setPassThrough(attributeAnnotarion.passThrough());
- attribute.setRequired(attributeAnnotarion.required());
- attribute.setReadOnly(attributeAnnotarion.readOnly());
- attribute.setGenerate(attributeAnnotarion.generate());
-
- // MethodExpression call signature.
- Signature signature = attributeAnnotarion.signature();
- if (null != signature) {
- List<ClassName> parameters = Lists.newArrayList();
-
- try {
- for (Class<?> parameterType : signature.parameters()) {
- parameters.add(new ClassName(parameterType.getName()));
- }
- } catch (MirroredTypeException e) {
- TypeMirror parameterType = e.getTypeMirror();
- parameters.add(new ClassName(parameterType.toString()));
- } catch (MirroredTypesException e) {
- for (TypeMirror parameterType : e.getTypeMirrors()) {
- parameters.add(new ClassName(parameterType.toString()));
- }
- }
-
- // signature parameters always should be replaced.
- attribute.setSignature(parameters);
-
- // TODO - set method return type.
- }
+ @Override
+ protected String[] getAnnotationAttributes(TypeElement componentElement) {
+ return componentElement.getAnnotation(JsfComponent.class).attributes();
}
- private void setBehaviorEvent(Property attribute, EventName eventName) {
- if (null != eventName) {
- org.richfaces.cdk.model.EventName event = new
org.richfaces.cdk.model.EventName();
-
- event.setName(eventName.value());
- event.setDefaultEvent(eventName.defaultEvent());
- attribute.getEventNames().add(event);
- }
- }
-
@Override
public Class<? extends Annotation> getProcessedAnnotation() {
return JsfComponent.class;
}
-
- @Override
- protected String getDafaultParentTagHandlerClass() {
- return ComponentHandler.class.getName();
- }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -48,12 +48,20 @@
converterModel.setId(FacesId.parseId(converter.id()));
try {
- converterModel.setConverterForClass(new
ClassName(converter.forClass().getName()));
+ Class<?> forClass = converter.forClass();
+ if (!JsfConverter.NONE.class.equals(forClass)) {
+ converterModel.setConverterForClass(new ClassName(forClass.getName()));
+ }
} catch (MirroredTypeException e) {
- converterModel.setConverterForClass(new
ClassName(e.getTypeMirror().toString()));
+ String name = e.getTypeMirror().toString();
+ if (!JsfConverter.NONE.class.getName().equals(name)) {
+ converterModel.setConverterForClass(new ClassName(name));
+ }
}
- setDescription(element, converterModel);
+ setDescription(converterModel, converter.icon(), getDocComment(element),
converter.displayName());
+
+ processAttributes(element, converterModel);
setClassNames(element, converterModel, converter);
setTagInfo(converter.tag(), converterModel);
@@ -70,11 +78,12 @@
public void setClassNames(TypeElement componentElement, ConverterModel
converterModel, JsfConverter converter) {
String baseClass = componentElement.getQualifiedName().toString();
- setClassNames(componentElement, converterModel, converter.converterClass(),
baseClass);
+ setClassNames(componentElement, converterModel, converter.generate(),
baseClass);
}
- @Override
- protected String getDafaultParentTagHandlerClass() {
- return ConverterHandler.class.getName();
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfConverter converter = element.getAnnotation(JsfConverter.class);
+
+ return converter.attributes();
}
}
Deleted:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/FacesComponentProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/FacesComponentProcessor.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/FacesComponentProcessor.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -1,48 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.apt;
-
-import java.lang.annotation.Annotation;
-
-import javax.faces.component.FacesComponent;
-import javax.lang.model.element.TypeElement;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class FacesComponentProcessor extends ComponentProcessor {
-
- @Override
- protected String getComponentType(TypeElement componentElement) {
- FacesComponent facesComponent =
componentElement.getAnnotation(FacesComponent.class);
- return facesComponent.value();
- }
- @Override
- public Class<? extends Annotation> getProcessedAnnotation() {
- return FacesComponent.class;
- }
-
-}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -1,18 +1,33 @@
package org.richfaces.cdk.apt;
+import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Provider;
+
+import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.DisplayName;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.Icon;
+import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import org.richfaces.cdk.xmlconfig.FragmentParser;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeMirror;
+
import java.util.Collection;
+import java.util.List;
+import java.util.Set;
public abstract class ProcessorBase {
@@ -57,9 +72,6 @@
protected void setTagInfo(Tag tag, ModelElementBase model) {
String name = tag.name();
-// if (Strings.isEmpty(name)) {
-// name = namingConventions.inferTagName(model.getGeneratedClass());
-// }
TagModel tagModel = new TagModel();
tagModel.setName(name);
@@ -71,9 +83,6 @@
model.setTag(tagModel);
}
- protected String getDafaultParentTagHandlerClass() {
- return null;
- }
/**
* <p class="changed_added_4_0"></p>
@@ -81,17 +90,19 @@
* @param icon
*/
protected void setIcon(DescriptionGroup component, Icon icon) {
- DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
-
- if (icon.small().length() > 0) {
- iconValue.setSmallIcon(icon.small());
+ if (!Strings.isEmpty(icon.small()) || !Strings.isEmpty(icon.large())) {
+ DescriptionGroup.Icon iconValue = new DescriptionGroup.Icon();
+
+ if (!Strings.isEmpty(icon.small())) {
+ iconValue.setSmallIcon(icon.small());
+ }
+
+ if (!Strings.isEmpty(icon.large())) {
+ iconValue.setLargeIcon(icon.large());
+ }
+ component.setIcon(iconValue);
+
}
-
- if (icon.large().length() > 0) {
- iconValue.setLargeIcon(icon.large());
- }
-
- component.setIcon(iconValue);
}
public ComponentLibrary getLibrary() {
@@ -99,33 +110,29 @@
}
-
- protected void setDescription(TypeElement element, DescriptionGroup component) {
+ protected void setDescription(DescriptionGroup component, Icon icon, String
description, String displayName) {
// JavaDoc comments
-
component.setDescription(getSourceUtils().getDocComment(asClassDesctiption(element)));
-
- Icon icon = element.getAnnotation(Icon.class);
-
- if (null != icon) {
+ component.setDescription(description);
+ if (null != icon ) {
setIcon(component, icon);
}
-
- DisplayName displayName = element.getAnnotation(DisplayName.class);
-
- if (null != displayName) {
- component.setDisplayname(displayName.value());
+
+ if (!Strings.isEmpty(displayName)) {
+ component.setDisplayname(displayName);
}
}
protected void setClassNames(TypeElement componentElement, ModelElementBase
modelElement,
String generatedClass, String baseClass) {
- if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
+ if (componentElement.getModifiers().contains(Modifier.ABSTRACT) ||
!Strings.isEmpty(generatedClass)) {
modelElement.setGenerate(true);
+ modelElement.setTargetClass(ClassName.parseName(generatedClass));
+ } else {
+ modelElement.setGenerate(false);
}
modelElement.setBaseClass(ClassName.parseName(baseClass));
- modelElement.setTargetClass(ClassName.parseName(generatedClass));
}
protected Collection<Property> parseProperties(String attributesConfig) {
@@ -135,4 +142,112 @@
protected ClassName asClassDesctiption(TypeElement componentElement) {
return new ClassName(componentElement.getQualifiedName().toString());
}
+
+ protected String getDocComment(TypeElement componentElement) {
+ return getSourceUtils().getDocComment(asClassDesctiption(componentElement));
+ }
+
+ protected abstract String[] getAnnotationAttributes(TypeElement componentElement);
+
+
+ protected void processAttributes(TypeElement componentElement, final BeanModelBase
component) throws CdkException {
+
+ // Process XML files with standard attributes definitions.
+
+ for (String attributesConfig : getAnnotationAttributes(componentElement)) {
+ // process additional properties.
+ component.getAttributes().addAll(parseProperties(attributesConfig));
+ }
+
+ SourceUtils sourceUtils = getSourceUtils();
+ sourceUtils.visitSupertypes(asClassDesctiption(componentElement), new
SuperTypeVisitor() {
+
+ @Override
+ public void visit(ClassName type) {
+ try {
+ component.getAttributes().addAll(
+ parseProperties(CdkEntityResolver.URN_ATTRIBUTES +
type.toString() + ".xml"));
+ } catch (CdkException e) {
+ // TODO - log errors ?
+ }
+ }
+ });
+
+ Set<BeanProperty> properties =
sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class,
asClassDesctiption(componentElement));
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+
+ Property attribute = component.getOrCreateAttribute(beanProperty.getName());
+
+ processAttribute(beanProperty, attribute);
+ }
+ }
+
+ private void processAttribute(BeanProperty beanProperty, Property attribute) {
+ // Flags
+ Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
+ if (attributeAnnotarion == null) {
+ return;
+ }
+
+ attribute.setHidden(attributeAnnotarion.hidden());
+ attribute.setLiteral(attributeAnnotarion.literal());
+ attribute.setPassThrough(attributeAnnotarion.passThrough());
+ attribute.setRequired(attributeAnnotarion.required());
+ attribute.setReadOnly(attributeAnnotarion.readOnly());
+ attribute.setGenerate(attributeAnnotarion.generate()||
!beanProperty.isExists());
+
+ setDescription(attribute, attributeAnnotarion.icon(),
beanProperty.getDocComment(), attributeAnnotarion.displayName());
+
+ // type.
+ attribute.setType(beanProperty.getType());
+
+ // DefaultValues
+ String defaultValue = attributeAnnotarion.defaultValue();
+ if (!Strings.isEmpty(defaultValue)) {
+ attribute.setDefaultValue(defaultValue);
+ }
+
+ String suggestedValue = attributeAnnotarion.suggestedValue();
+ if (!Strings.isEmpty(suggestedValue)) {
+ attribute.setSuggestedValue(suggestedValue);
+ }
+
+ // MethodExpression call signature.
+ Signature signature = attributeAnnotarion.signature();
+ if (null != signature && signature.returnType() != Signature.NONE.class)
{
+ List<ClassName> parameters = Lists.newArrayList();
+
+ try {
+ for (Class<?> parameterType : signature.parameters()) {
+ parameters.add(new ClassName(parameterType.getName()));
+ }
+ } catch (MirroredTypeException e) {
+ TypeMirror parameterType = e.getTypeMirror();
+ parameters.add(new ClassName(parameterType.toString()));
+ } catch (MirroredTypesException e) {
+ for (TypeMirror parameterType : e.getTypeMirrors()) {
+ parameters.add(new ClassName(parameterType.toString()));
+ }
+ }
+
+ // signature parameters always should be replaced.
+ attribute.setSignature(parameters);
+ // TODO - set method return type.
+ }
+ for(EventName event : attributeAnnotarion.events()){
+ setBehaviorEvent(attribute, event);
+ }
+ }
+
+ private void setBehaviorEvent(Property attribute, EventName eventName) {
+ if (null != eventName) {
+ org.richfaces.cdk.model.EventName event = new
org.richfaces.cdk.model.EventName();
+
+ event.setName(eventName.value());
+ event.setDefaultEvent(eventName.defaultEvent());
+ attribute.getEventNames().add(event);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -71,7 +71,7 @@
setRendererType(rendererModel, annotation);
setComponentFamily(rendererModel, annotation);
setTemplate(rendererModel, annotation);
- setDescription(rendererElement, rendererModel);
+ setDescription(rendererModel, annotation.icon(), getDocComment(rendererElement),
annotation.displayName());
String renderKitId = annotation.renderKitId();
if (Strings.isEmpty(renderKitId)) {
@@ -152,37 +152,14 @@
}
-// private void setEvents(TypeElement componentElement,
org.richfaces.cdk.model.Renderer component) {
-// Fires fires = componentElement.getAnnotation(Fires.class);
-//
-// if (null != fires) {
-// try {
-// for (Class<? extends FacesEvent> eventClass : fires.value()) {
-// component.addEvent(eventClass.getName());
-// }
-// } catch (MirroredTypesException mirror) {
-// for (TypeMirror eventType : mirror.getTypeMirrors()) {
-// component.addEvent(eventType.toString());
-// // TODO - check does component already implement eventSource
interface
-// }
-// } catch (MirroredTypeException mirror) {
-// component.addEvent(mirror.getTypeMirror().toString());
-// }
-// }
-// }
- private void setBehaviorEvent(Property attribute, EventName eventName) {
- if (null != eventName) {
- org.richfaces.cdk.model.EventName event = new
org.richfaces.cdk.model.EventName();
-
- event.setName(eventName.value());
- event.setDefaultEvent(eventName.defaultEvent());
- attribute.getEventNames().add(event);
- }
- }
-
@Override
public Class<? extends Annotation> getProcessedAnnotation() {
return JsfRenderer.class;
}
+
+ protected String[] getAnnotationAttributes(TypeElement componentElement) {
+ return null;
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -44,7 +44,7 @@
ValidatorModel validatorModel = new
ValidatorModel(FacesId.parseId((validator.id())));
setClassNames(element, validatorModel, validator);
- setDescription(element, validatorModel);
+ setDescription(validatorModel, validator.icon(), getDocComment(element),
validator.displayName());
setTagInfo(validator.tag(), validatorModel);
@@ -59,11 +59,11 @@
public void setClassNames(TypeElement componentElement, ValidatorModel
validatorModel,
JsfValidator validator) {
String baseClass = componentElement.getQualifiedName().toString();
- setClassNames(componentElement, validatorModel, validator.validatorClass(),
baseClass);
+ setClassNames(componentElement, validatorModel, validator.generate(),
baseClass);
}
- @Override
- protected String getDafaultParentTagHandlerClass() {
- return ValidatorHandler.class.getName();
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfValidator validator = element.getAnnotation(JsfValidator.class);
+ return validator.attributes();
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -25,18 +25,22 @@
package org.richfaces.cdk.freemarker;
-import com.google.inject.Inject;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.LibraryVisitor;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Trackable;
+import org.richfaces.cdk.model.Visitable;
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
/**
* <p class="changed_added_4_0">Base class for all output file buildes
that use FreeMarker as template engine.</p>
@@ -53,7 +57,6 @@
private final FileManager output;
- @Inject
public FreeMarkerRenderer(Configuration configuration, ComponentLibrary library,
FileManager output) {
this.configuration = configuration;
this.library = library;
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -25,22 +25,26 @@
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
-import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Collections;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
import javax.lang.model.element.TypeElement;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.Stub;
+import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.xmlconfig.JAXB;
@@ -68,8 +72,17 @@
@Mock
private TypeElement componentElement;
+
+ @Stub
+ private Name name;
+ @Stub
+ private Tag tag;
+
@Mock
+ private JsfBehavior behaviorAnnotation;
+
+ @Mock
private JAXB jaxb;
@Mock
@@ -77,34 +90,26 @@
@Test
- @Ignore
+
public void testProcess() throws Exception {
- expect(componentElement.getAnnotation(JsfBehavior.class)).andReturn(new
JsfBehavior() {
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return JsfBehavior.class;
- }
-
- @Override
- public Tag tag() {
- return null;
- }
-
- @Override
- public String id() {
- return MY_BEHAVIOR;
- }
-
- @Override
- public String behaviorClass() {
- return "foo.bar.Behavior";
- }
- });
- replay(log, utils, componentElement, jaxb, conventions);
+
expect(componentElement.getAnnotation(JsfBehavior.class)).andStubReturn(behaviorAnnotation);
+ expect(behaviorAnnotation.id()).andReturn(MY_BEHAVIOR);
+ expect(componentElement.getQualifiedName()).andReturn(name);
+
expect(componentElement.getModifiers()).andReturn(Collections.singleton(Modifier.ABSTRACT));
+ expect(componentElement.getQualifiedName()).andReturn(name).atLeastOnce();
+ expect(behaviorAnnotation.generate()).andReturn("foo.Bar");
+ expect(behaviorAnnotation.tag()).andReturn(tag);
+ expect(behaviorAnnotation.attributes()).andReturn(new String[]{});
+ expect(behaviorAnnotation.icon()).andReturn(null);
+ expect(behaviorAnnotation.displayName()).andReturn(null);
+ expect(tag.handlerName()).andStubReturn("");
+ utils.visitSupertypes((ClassName)anyObject(),
(SuperTypeVisitor)anyObject());expectLastCall();
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Attribute.class),
(ClassName)anyObject())).andReturn(Collections.<BeanProperty>emptySet());
+ expect(utils.getDocComment((ClassName) anyObject())).andStubReturn(null);
+ replay(log, utils, componentElement, jaxb,
conventions,behaviorAnnotation,tag,name);
processor.process(componentElement);
- verify(log, utils, componentElement, jaxb, conventions);
+ verify(log, utils, componentElement, jaxb,
conventions,behaviorAnnotation,tag,name);
Collection<BehaviorModel> behaviors = library.getBehaviors();
assertEquals(1, behaviors.size());
Deleted:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -1,28 +0,0 @@
-package org.richfaces.cdk.freemarker;
-
-import static org.junit.Assert.*;
-
-import java.io.StringWriter;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.FacesId;
-
-public class FreeMarkerRendererTest extends CdkTestBase {
- @Test
- public void testRender() {
-
- // fail("Not yet implemented");
- }
-
- @Test
- @Ignore
- public void testProcessComponent() throws Exception {
- final StringWriter output = new StringWriter();
- ComponentModel component = new
ComponentModel(FacesId.parseId("foo.Bar"));
-
- assertEquals("foo.Bar", output.toString());
- }
-}
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-03-18
00:30:57 UTC (rev 16591)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-03-18
00:53:35 UTC (rev 16592)
@@ -56,6 +56,7 @@
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.xmlconfig.JAXB;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import org.xml.sax.InputSource;
import org.xml.sax.ext.EntityResolver2;
import javax.faces.event.ActionEvent;
@@ -288,11 +289,15 @@
}
@Test
- @Ignore
+
// TODO - fix import-attributes.
public void dummyComponentTest() throws Exception {
- expect(resolver.getExternalSubset(eq("cdk:root"),
EasyMock.<String> anyObject())).andReturn(null).atLeastOnce();
- expect(resolver.resolveEntity((String)isNull(),
(String)anyObject())).andReturn(null).atLeastOnce();
+ expect(resolver.getExternalSubset(EasyMock.<String>
eq("cdk:root"), (String)anyObject())).andReturn(null);
+ expect(resolver.resolveEntity((String)isNull(),
(String)eq("urn:resource:org/richfaces/cdk/templatecompiler/dummy-attributes.xml"))).andReturn(new
InputSource(this.getClass().getResourceAsStream("/org/richfaces/cdk/templatecompiler/dummy-attributes.xml")));
+ expect(resolver.getExternalSubset(EasyMock.<String>
eq("cdk:properties"), (String)isNull())).andReturn(null);
+ expect(resolver.resolveEntity((String)isNull(),
(String)eq("urn:attributes:dummy-template-props.xml"))).andReturn(new
InputSource(this.getClass().getResourceAsStream("/META-INF/cdk/attributes/dummy-template-props.xml")));
+
expect(resolver.getExternalSubset(EasyMock.<String>eq("cdk:properties"),
(String)isNull())).andReturn(null);
+
replay(resolver, templatesSource);
Template template =
parser.parseTemplate(getJavaFile("org/richfaces/cdk/templatecompiler/dummy.template.xml"));
assertNotNull(template);