Author: alexsmirnov
Date: 2010-06-22 15:08:34 -0400 (Tue, 22 Jun 2010)
New Revision: 17659
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/NormalizedStringAdapter.java
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClientBehavior.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
Log:
refactor models to use actual classes for id's and types
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -27,7 +27,6 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.InvalidNameException;
-import org.richfaces.cdk.model.RendererModel;
/**
* <p class="changed_added_4_0">
@@ -75,7 +74,7 @@
* @return
* @throws InvalidNameException
*/
- public String inferUIComponentFamily(FacesId componentType) throws
InvalidNameException;
+ public FacesId inferUIComponentFamily(FacesId componentType) throws
InvalidNameException;
/**
* <p class="changed_added_4_0"></p>
@@ -92,19 +91,19 @@
public String inferRendererTypeByComponentType(FacesId componentType);
- public String inferComponentFamily(RendererModel.Type type);
+ public String inferComponentFamily(FacesId type);
- public String inferTemplate(RendererModel.Type type);
+ public String inferTemplate(FacesId type);
public String inferRendererTypeByTemplatePath(String templateName);
- public String inferRendererName(RendererModel.Type type);
+ public String inferRendererName(FacesId type);
public String inferComponentTypeByRendererClass(String s);
public String inferComponentFamilyByRendererClass(String s);
- public String inferRendererBaseName(RendererModel.Type type);
+ public String inferRendererBaseName(FacesId type);
public FacesId inferBehaviorType(ClassName targetClass);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -9,7 +9,6 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Name;
-import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.model.Name.Classifier;
import org.richfaces.cdk.util.Strings;
@@ -96,11 +95,11 @@
}
@Override
- public String inferUIComponentFamily(FacesId componentType) {
+ public FacesId inferUIComponentFamily(FacesId componentType) {
if (null == componentType) {
throw new IllegalArgumentException();
}
- return componentType.toString();
+ return componentType;
}
@Override
@@ -148,11 +147,11 @@
return componentType + "Renderer";
}
- public String inferComponentFamily(RendererModel.Type type) {
+ public String inferComponentFamily(FacesId type) {
return null;
}
- public String inferTemplate(RendererModel.Type type) {
+ public String inferTemplate(FacesId type) {
return null;
}
@@ -160,11 +159,11 @@
return null;
}
- public String inferRendererName(RendererModel.Type type) {
+ public String inferRendererName(FacesId type) {
return null;
}
- public String inferRendererBaseName(RendererModel.Type type) {
+ public String inferRendererBaseName(FacesId type) {
return null;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -49,7 +49,6 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
-import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.util.Strings;
import com.google.inject.Inject;
@@ -127,15 +126,7 @@
}
private void setRendererType(ComponentModel component, JsfRenderer jsfRenderer) {
- // TODO if jsfRenderer.empty set by naming convention
-
- String type;
- if (jsfRenderer != null && !Strings.isEmpty(jsfRenderer.type())) {
- type = jsfRenderer.type();
- } else {
- type =
getNamingConventions().inferRendererTypeByComponentType(component.getType());
- }
- component.setRendererType(new RendererModel.Type(type));
+ component.setRendererType(FacesId.parseId(jsfRenderer.type()));
}
private void processAttributes(TypeElement componentElement, ComponentModel
component, JsfComponent annotation) {
@@ -173,13 +164,13 @@
void setComponentType(TypeElement componentElement, ComponentModel component, String
type) {
if (!Strings.isEmpty(type)) {
- component.setType(FacesId.parseId(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.setType(FacesId.parseId(value.toString()));
+ component.setId(FacesId.parseId(value.toString()));
}
}
}
@@ -222,12 +213,12 @@
final void setComponeneFamily(TypeElement componentElement, ComponentModel component,
String family) {
if (!Strings.isEmpty(family)) {
- component.setFamily(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(value.toString());
+ component.setFamily(FacesId.parseId(value.toString()));
}
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -38,6 +38,7 @@
import org.richfaces.cdk.annotations.JsfRenderer;
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.templatecompiler.RendererTemplateParser;
import org.richfaces.cdk.util.Strings;
@@ -152,18 +153,16 @@
private void setComponentFamily(TypeElement rendererElement, RendererModel
rendererModel, JsfRenderer annotation) {
String family = annotation.family();
if (!Strings.isEmpty(family)) {
- rendererModel.setFamily(family);
+ rendererModel.setFamily(FacesId.parseId(family));
return;
- }
+ } else {
- Object value = getSourceUtils().getConstant(rendererElement, COMPONENT_FAMILY);
- if (value != null) {
- rendererModel.setFamily(value.toString());
- return;
+ Object value = getSourceUtils().getConstant(rendererElement,
COMPONENT_FAMILY);
+ if (value != null) {
+ rendererModel.setFamily(FacesId.parseId(value.toString()));
+ return;
+ }
}
-
-// rendererModel.setFamily(getNamingConventions()
-//
.inferComponentFamilyByRendererClass(rendererElement.getQualifiedName().toString()));
}
private String getRendererType(TypeElement rendererElement, JsfRenderer annotation)
{
@@ -177,11 +176,11 @@
return value.toString();
}
- return null;
//getNamingConventions().inferRendererTypeByRendererClass(asClassDesctiption(rendererElement));
+ return null;
}
private void setRendererType(TypeElement rendererElement, RendererModel
rendererModel, JsfRenderer annotation) {
- rendererModel.setType(new RendererModel.Type(getRendererType(rendererElement,
annotation)));
+ rendererModel.setId(FacesId.parseId(getRendererType(rendererElement,
annotation)));
}
protected String getComponentType(TypeElement componentElement) {
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -33,12 +33,12 @@
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.DescriptionGroup;
import org.richfaces.cdk.model.EventModel;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FunctionModel;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.SimpleVisitor;
import org.richfaces.cdk.model.TagModel;
import org.richfaces.cdk.model.ValidatorModel;
-import org.richfaces.cdk.model.RendererModel.Type;
import org.richfaces.cdk.util.Strings;
/**
@@ -111,10 +111,10 @@
// Most libraries use <handler-class> INSTEAD of <component>
Element component = tag.addElement(COMPONENT);
component.addElement(COMPONENT_TYPE).addText(model.getId().getType());
- Type rendererType = model.getRendererType();
+ FacesId rendererType = model.getRendererType();
// RendererModel renderer = componentLibrary.getRenderer(model.getFamily(),
model.getId().getType());
if (null != rendererType) {
- component.addElement(RENDERER_TYPE).addText(rendererType.getType());
+ component.addElement(RENDERER_TYPE).addText(rendererType.toString());
}
addTagHandler(component, tagModel);
appendAttributs(tag, model);
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -152,19 +152,23 @@
return components;
}
- public ComponentModel getComponentModel(String componentFamily) {
- if (componentFamily == null) {
+ public ComponentModel getComponentByFamily(FacesId family) {
+ if (family == null) {
return null;
}
for (ComponentModel component : components) {
- if (componentFamily.equals(component.getFamily())) {
+ if (family.equals(component.getFamily())) {
return component;
}
}
return null;
}
+ public ComponentModel getComponentByFamily(String componentFamily) {
+ return getComponentByFamily(FacesId.parseId(componentFamily));
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -217,14 +221,8 @@
if (res.size() > 1) {
for (RendererModel renderer : res) {
String rendererComponentType = renderer.getComponentType();
- if (rendererComponentType == null) {
- if (renderer.getType().getType().startsWith(componentType)) {
- return renderer; // TODO do it throw naming convention
- }
- } else {
- if (rendererComponentType.equals(componentType)) {
- return renderer;
- }
+ if (componentType.equals(rendererComponentType)) {
+ return renderer;
}
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -1,6 +1,5 @@
package org.richfaces.cdk.model;
-import org.richfaces.cdk.model.RendererModel.Type;
/**
* That class represents JSF component in the CDK.
@@ -32,9 +31,9 @@
* relation.
* </p>
*/
- private String family;
+ private FacesId family;
- private RendererModel.Type rendererType;
+ private FacesId rendererType;
public ComponentModel(FacesId key) {
this.setId(key);
@@ -65,39 +64,20 @@
@Override
public boolean same(ComponentModel other) {
- if (null != getType() && null != other.getType()) {
+ if (null != getId() && null != other.getId()) {
// Both types not null, compare them.
- return getType().equals(other.getType());
+ return getId().equals(other.getId());
}
// one or both types are null, compare classes.
return null != getTargetClass() &&
getTargetClass().equals(other.getTargetClass());
}
/**
- * <p class="changed_added_4_0">Delegeted to setId</p>
- * @param type the type to set
- * @deprecated Use {@link ModelElementBase#setId(FacesId)} instead.
- */
- public void setType(FacesId type) {
- setId(type);
- }
-
- /**
* <p class="changed_added_4_0"></p>
- * @return
- * @deprecated Use {@link ModelElementBase#getId()} instead.
- */
- public FacesId getType() {
- return getId();
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
* @return the rendererType
*/
@Merge
- public Type getRendererType() {
+ public FacesId getRendererType() {
return this.rendererType;
}
@@ -105,7 +85,7 @@
* <p class="changed_added_4_0"></p>
* @param renderer the rendererType to set
*/
- public void setRendererType(Type renderer) {
+ public void setRendererType(FacesId renderer) {
this.rendererType = renderer;
}
@@ -118,7 +98,7 @@
* @return the family
*/
@Merge
- public String getFamily() {
+ public FacesId getFamily() {
return family;
}
@@ -129,33 +109,12 @@
* @param family
* the family to set
*/
- public void setFamily(String family) {
+ public void setFamily(FacesId family) {
this.family = family;
}
/**
- * <p class="changed_added_4_0">Alias for TargetClass.
- * </p>
- *
- * @return the componentClass
- * @deprecated
- */
- @Merge
- public ClassName getComponentClass() {
- return getTargetClass();
- }
-
- /**
* <p class="changed_added_4_0"></p>
- * @param name
- * @deprecated
- */
- public void setComponentClass(ClassName name) {
- setTargetClass(name);
- }
-
- /**
- * <p class="changed_added_4_0"></p>
* @return the facets
*/
public ModelCollection<FacetModel> getFacets() {
@@ -195,6 +154,6 @@
@Override
public String toString() {
- return "Component {type: " + getType() + ", family: " +
getFamily() + "}";
+ return "Component {type: " + getId() + ", family: " +
getFamily() + "}";
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -36,10 +36,10 @@
/**
* <p class="changed_added_4_0"></p>
*/
- private Type type;
+ private FacesId id;
- public ListenerModel(Type type) {
- this.type = type;
+ public ListenerModel(FacesId type) {
+ this.id = type;
}
public ListenerModel() {
@@ -53,16 +53,16 @@
* (non-Javadoc)
* @see org.richfaces.cdk.model.ModelElement#getType()
*/
- public Type getType() {
- return type;
+ public FacesId getId() {
+ return id;
}
/**
* <p class="changed_added_4_0"></p>
- * @param type the type to set
+ * @param id the id to set
*/
- public void setType(Type type) {
- this.type = type;
+ public void setId(FacesId type) {
+ this.id = type;
}
@Override
@@ -75,11 +75,5 @@
public boolean same(ListenerModel other) {
return equals(other);
}
-
- public static final class Type extends FacesId {
- public Type(String name) {
- super(name);
- }
- }
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -37,7 +37,7 @@
private static final long serialVersionUID = -5802466539382148578L;
- private String family;
+ private FacesId family;
private String componentType;
@@ -51,22 +51,10 @@
public RendererModel() { }
- public RendererModel(Type type) {
- setType(type);
+ public RendererModel(FacesId type) {
+ setId(type);
}
- public Type getKey() {
- return getType();
- }
-
- public void setType(Type type) {
- this.setId(type);
- }
-
- public Type getType() {
- return (Type) getId();
- }
-
@Merge
public Template getTemplate() {
return template;
@@ -77,11 +65,11 @@
}
@Merge
- public String getFamily() {
+ public FacesId getFamily() {
return family;
}
- public void setFamily(String family) {
+ public void setFamily(FacesId family) {
this.family = family;
}
@@ -143,13 +131,13 @@
@Override
public boolean same(RendererModel other) {
- if (null != getType() && null != other.getType()) {
+ if (null != getId() && null != other.getId()) {
// compare families ?
if (null != getFamily() && null != other.getFamily() &&
!getFamily().equals(other.getFamily())) {
return false;
}
// Both types not null, compare them.
- return getType().equals(other.getType());
+ return getId().equals(other.getId());
}
// one or both types are null, compare classes.
if (null != getRendererClass() &&
getRendererClass().equals(other.getRendererClass())) {
@@ -171,27 +159,8 @@
return new AttributeModel();
}
- /**
- * <p class="changed_added_4_0">FacesId for lookup renderer in the
model.</p>
- * @author asmirnov(a)exadel.com
- *
- */
- public static class Type extends FacesId {
-
- private static final long serialVersionUID = -7819560321446149642L;
-
- /**
- * <p class="changed_added_4_0"></p>
- * TODO - use family as part of key ?
- * @param type
- */
- public Type(String type) {
- super(type);
- }
- }
-
@Override
public String toString() {
- return "Renderer {type: " + getType() + ", family: " +
getFamily() + "}";
+ return "Renderer {type: " + getId() + ", family: " +
getFamily() + "}";
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -77,7 +77,7 @@
}
private ComponentModel findComponentByRenderer(RendererModel renderer,
ComponentLibrary library) {
- return library.getComponentModel(renderer.getFamily());
+ return library.getComponentByFamily(renderer.getFamily());
}
/*
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -26,9 +26,7 @@
import java.io.File;
import java.text.MessageFormat;
import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -70,29 +68,28 @@
*/
public class RendererTemplateParser implements ModelBuilder {
- private static final Pattern PARAMETERS_STRING_PATTERN = Pattern.compile("\\( (
[^\\)]* ) \\) \\s*$",
- Pattern.COMMENTS);
+ private static final Pattern PARAMETERS_STRING_PATTERN =
+ Pattern.compile("\\( ( [^\\)]* ) \\) \\s*$", Pattern.COMMENTS);
private static final Pattern COMMA_SEPARATED_PATTERN =
Pattern.compile("\\s*,\\s*", Pattern.COMMENTS);
- // todo cahche
- private static final Map<String, Template> PROCESSED_TEMPLATES = new
HashMap<String, Template>();
-
private ComponentLibrary library;
-
+
private JAXB jaxbBinding;
-
+
private Logger log;
-
+
private FileManager sources;
-
+
private FragmentParser fragmentParser;
-// @Inject
+ // @Inject
private NamingConventions namingConventions;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param library
* @param jaxbBinding
* @param log
@@ -100,8 +97,7 @@
*/
@Inject
public RendererTemplateParser(ComponentLibrary library, JAXB jaxbBinding, Logger
log,
- @Source(Sources.RENDERER_TEMPLATES) FileManager
sources,
- FragmentParser fragmentParser) {
+ @Source(Sources.RENDERER_TEMPLATES) FileManager sources, FragmentParser
fragmentParser) {
this.library = library;
this.jaxbBinding = jaxbBinding;
this.log = log;
@@ -126,27 +122,26 @@
}
private List<ClassName> parseSignature(String signatureString) {
- if (signatureString == null || signatureString.trim().length() == 0) {
- return null;
- }
List<ClassName> result = Lists.newArrayList();
- Matcher parametersStringMatcher =
PARAMETERS_STRING_PATTERN.matcher(signatureString);
- if (!parametersStringMatcher.find()) {
- // TODO - handle exception
- throw new IllegalArgumentException(MessageFormat.format("Signature
string {0} cannot be parsed!",
- signatureString));
- }
+ if (!Strings.isEmpty(signatureString)) {
+ Matcher parametersStringMatcher =
PARAMETERS_STRING_PATTERN.matcher(signatureString);
+ if (!parametersStringMatcher.find()) {
+ // TODO - handle exception
+ throw new IllegalArgumentException(MessageFormat.format("Signature
string {0} cannot be parsed!",
+ signatureString));
+ }
- String parametersString = parametersStringMatcher.group(1).trim();
- if (parametersString.length() != 0) {
- String[] parameters = COMMA_SEPARATED_PATTERN.split(parametersString);
- for (String parameter : parameters) {
- String trimmedParameter = parameter.trim();
- result.add(new ClassName(trimmedParameter));
+ String parametersString = parametersStringMatcher.group(1);
+ if (parametersString.trim().length() != 0) {
+ String[] parameters = COMMA_SEPARATED_PATTERN.split(parametersString);
+ for (String parameter : parameters) {
+ String trimmedParameter = parameter.trim();
+ result.add(ClassName.parseName(trimmedParameter));
+ }
}
- }
+ }
return result;
}
@@ -171,17 +166,17 @@
log.debug(" - file = " + absolutePath);
log.debug(" - renderer = " + rendererModel);
- RendererModel existedModel = library.accept(new
SimpleVisitor<RendererModel,String>() {
+ RendererModel existedModel = library.accept(new SimpleVisitor<RendererModel,
String>() {
@Override
- public RendererModel visitRender(RendererModel model,String absolutePath) {
+ public RendererModel visitRender(RendererModel model, String absolutePath) {
Template template = model.getTemplate();
- if(null != template &&
absolutePath.equals(template.getTemplatePath())){
+ if (null != template &&
absolutePath.equals(template.getTemplatePath())) {
return model;
} else {
return null;
}
}
- },absolutePath);
+ }, absolutePath);
if (null != existedModel) {
log.debug(" - Template was already processed.");
return;
@@ -204,16 +199,15 @@
}
renderer.setTemplate(template);
setRendererType(template, compositeInterface, renderer);
- setFamily(compositeInterface, renderer); //TODO set default values according to
template name
+ setFamily(compositeInterface, renderer); // TODO set default values according to
template name
setRendererClass(compositeInterface, renderer);
setRendererBaseClass(compositeInterface, renderer);
-
Boolean rendersChildren = compositeInterface.getRendersChildren();
if (rendersChildren != null) {
renderer.setRendersChildren(rendersChildren);
}
-
+
List<ImportAttributes> attributesImports =
compositeInterface.getAttributesImports();
if (attributesImports != null) {
for (ImportAttributes attributesImport : attributesImports) {
@@ -224,7 +218,7 @@
}
}
}
-
+
List<Attribute> templateAttributes = compositeInterface.getAttributes();
if (templateAttributes != null) {
for (Attribute templateAttribute : templateAttributes) {
@@ -260,47 +254,26 @@
rendererProperty.setRequired(templateAttribute.isRequired());
List<ClassName> parsedSignature =
parseSignature(templateAttribute.getMethodSignature());
- if (parsedSignature != null) {
- rendererProperty.getSignature().addAll(parsedSignature);
- }
+ rendererProperty.getSignature().addAll(parsedSignature);
- String templateAttributeType = templateAttribute.getType();
- if (templateAttributeType != null) {
- rendererProperty.setType(new ClassName(templateAttributeType));
- }
+ rendererProperty.setType(templateAttribute.getType());
return rendererProperty;
}
private void setRendererClass(CompositeInterface compositeInterface, RendererModel
renderer) {
- String javaClass = compositeInterface.getJavaClass();
- if (javaClass == null) {
- javaClass = getNamingConventions().inferRendererName(renderer.getType());
- }
- renderer.setRendererClass(new ClassName(javaClass));
+ renderer.setRendererClass(compositeInterface.getJavaClass());
}
private void setRendererBaseClass(CompositeInterface compositeInterface,
RendererModel renderer) {
- String baseClass = compositeInterface.getBaseClass();
- if (baseClass == null) {
- baseClass =
getNamingConventions().inferRendererBaseName(renderer.getType());
- }
- renderer.setBaseClass(new ClassName(baseClass));
+ renderer.setBaseClass(compositeInterface.getBaseClass());
}
private void setFamily(CompositeInterface compositeInterface, RendererModel renderer)
{
- String family = compositeInterface.getComponentFamily();
- if (family == null) {
- family = getNamingConventions().inferComponentFamily(renderer.getType());
- }
- renderer.setFamily(family);
+ renderer.setFamily(compositeInterface.getComponentFamily());
}
private void setRendererType(Template template, CompositeInterface
compositeInterface, RendererModel renderer) {
- String type = compositeInterface.getRendererType();
- if (Strings.isEmpty(type)) {
- type =
getNamingConventions().inferRendererTypeByTemplatePath(template.getTemplatePath());
- }
- renderer.setType(new RendererModel.Type(type));
+ renderer.setId(compositeInterface.getRendererType());
}
protected Template parseTemplate(File file) throws CdkException {
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -27,6 +27,8 @@
import java.util.Set;
import java.util.TreeSet;
+import org.richfaces.cdk.model.ClassName;
+
/**
* Java Class model.
* Intended for building java classes.
@@ -70,6 +72,10 @@
setSuperClass(new JavaClass(superClass));
}
+ public JavaClass(ClassName javaClass) {
+ this(javaClass.getSimpleName(), new JavaPackage(javaClass.getPackage()));
+ }
+
private static String getFullName(JavaPackage javaPackage, String className) {
StringBuilder fullName = new StringBuilder();
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -28,7 +28,11 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.xmlconfig.model.ClassAdapter;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -38,6 +42,7 @@
private static final long serialVersionUID = -8183353368681247171L;
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlAttribute(required = true)
private String name;
@@ -47,9 +52,11 @@
@XmlAttribute
private String shortDescription;
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlAttribute(name = "default")
private String defaultValue;
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlAttribute(name = "method-signature")
private String methodSignature;
@@ -66,7 +73,8 @@
private boolean expert;
@XmlAttribute
- private String type = Object.class.getName();
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ private ClassName type = new ClassName(Object.class);
@XmlElement(name = "clientBehavior", namespace =
Template.COMPOSITE_NAMESPACE)
private List<ClientBehavior> clientBehaviors;
@@ -238,7 +246,7 @@
*
* @return the type
*/
- public String getType() {
+ public ClassName getType() {
return type;
}
@@ -247,7 +255,7 @@
*
* @param type the type to set
*/
- public void setType(String type) {
+ public void setType(ClassName type) {
this.type = type;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkObjectElement.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -24,6 +24,7 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.richfaces.cdk.CdkException;
@@ -35,6 +36,7 @@
public class CdkObjectElement implements ModelElement {
@XmlAttribute(required = true)
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
private String name;
@XmlAttribute
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClientBehavior.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClientBehavior.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ClientBehavior.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -22,6 +22,7 @@
package org.richfaces.cdk.templatecompiler.model;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* @author Nick Belaevski
@@ -39,6 +40,7 @@
* @return the event
*/
@XmlAttribute
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
public String getEvent() {
return event;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -27,10 +27,16 @@
import java.util.List;
import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.xmlconfig.model.ClassAdapter;
+import org.richfaces.cdk.xmlconfig.model.FacesIdAdapter;
+
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -41,7 +47,7 @@
private static final long serialVersionUID = -5578359507253872500L;
- private String componentFamily;
+ private FacesId componentFamily;
private List<Attribute> attributes;
@@ -51,11 +57,11 @@
private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- private String javaClass;
+ private ClassName javaClass;
- private String baseClass = Renderer.class.getName();
+ private ClassName baseClass;
- private String rendererType;
+ private FacesId rendererType;
private Boolean rendersChildren = null;
@@ -64,8 +70,9 @@
*
* @return the family
*/
+ @XmlJavaTypeAdapter(FacesIdAdapter.class)
@XmlElement(name = "component-family", namespace = Template.CDK_NAMESPACE)
- public String getComponentFamily() {
+ public FacesId getComponentFamily() {
return this.componentFamily;
}
@@ -74,7 +81,7 @@
*
* @param family the family to set
*/
- public void setComponentFamily(String family) {
+ public void setComponentFamily(FacesId family) {
this.componentFamily = family;
}
@@ -123,6 +130,7 @@
*
* @return the renderKitId
*/
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlElement(name = "renderkit-id", namespace = Template.CDK_NAMESPACE)
public String getRenderKitId() {
return this.renderKitId;
@@ -142,8 +150,9 @@
*
* @return the javaClass
*/
+ @XmlJavaTypeAdapter(ClassAdapter.class)
@XmlElement(name = "class", namespace = Template.CDK_NAMESPACE)
- public String getJavaClass() {
+ public ClassName getJavaClass() {
return this.javaClass;
}
@@ -152,7 +161,7 @@
*
* @param javaClass the javaClass to set
*/
- public void setJavaClass(String javaClass) {
+ public void setJavaClass(ClassName javaClass) {
this.javaClass = javaClass;
}
@@ -161,8 +170,9 @@
*
* @return the rendererType
*/
+ @XmlJavaTypeAdapter(FacesIdAdapter.class)
@XmlElement(name = "renderer-type", namespace = Template.CDK_NAMESPACE)
- public String getRendererType() {
+ public FacesId getRendererType() {
return this.rendererType;
}
@@ -171,7 +181,7 @@
*
* @param rendererType the rendererType to set
*/
- public void setRendererType(String rendererType) {
+ public void setRendererType(FacesId rendererType) {
this.rendererType = rendererType;
}
@@ -180,8 +190,9 @@
*
* @return the baseClass
*/
+ @XmlJavaTypeAdapter(ClassAdapter.class)
@XmlElement(name = "superclass", namespace = Template.CDK_NAMESPACE)
- public String getBaseClass() {
+ public ClassName getBaseClass() {
return this.baseClass;
}
@@ -190,7 +201,7 @@
*
* @param baseClass the baseClass to set
*/
- public void setBaseClass(String baseClass) {
+ public void setBaseClass(ClassName baseClass) {
this.baseClass = baseClass;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ImportAttributes.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -22,6 +22,7 @@
package org.richfaces.cdk.templatecompiler.model;
import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* @author Nick Belaevski
@@ -34,6 +35,7 @@
/**
* @return the source
*/
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlAttribute(name = "src")
public String getSource() {
return source;
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/NormalizedStringAdapter.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/NormalizedStringAdapter.java
(rev 0)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/NormalizedStringAdapter.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -0,0 +1,18 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.util.Strings;
+
+public class NormalizedStringAdapter extends XmlAdapter<String, String> {
+
+ @Override
+ public String marshal(String text) {
+ return Strings.isEmpty(text)?null:text.trim();
+ }
+
+ @Override
+ public String unmarshal(String v) throws Exception {
+ return Strings.isEmpty(v)?null:v.trim();
+ }
+}
\ No newline at end of file
Property changes on:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/NormalizedStringAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ResourceDependency.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -26,6 +26,7 @@
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/**
* @author Nick Belaevski
@@ -48,6 +49,7 @@
* @return the name
*/
@XmlAttribute(name = "name", required = true)
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
public String getName() {
return name;
}
@@ -67,6 +69,7 @@
* @return the libraryName
*/
@XmlAttribute(name = "library")
+ @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
public String getLibrary() {
return library;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ClassAdapter.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -40,6 +40,7 @@
@Override
public ClassName unmarshal(String v) throws Exception {
- return new ClassName(v);
+
+ return new ClassName(v.trim());
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -47,31 +47,31 @@
* @author asmirnov(a)exadel.com
*/
@XmlType(name = "faces-config-componentType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder = {"type", "targetClass", "facets",
"facesAttributes", "properties", "extension"})
+ propOrder = {"id", "targetClass", "facets",
"facesAttributes", "properties", "extension"})
@XmlJavaTypeAdapter(ComponentAdapter.class)
public class ComponentBean extends
ElementBeanBase<ComponentBean.ComponentExtension> {
private List<FacetModel> facets = Lists.newArrayList();
private ClassName targetClass;
- private FacesId type;
+ private FacesId id;
/**
* <p class="changed_added_4_0"></p>
*
- * @return the type
+ * @return the id
*/
@XmlElement(name = "component-type", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE, required = true)
- public FacesId getType() {
- return type;
+ public FacesId getId() {
+ return id;
}
/**
* <p class="changed_added_4_0"></p>
*
- * @param type the type to set
+ * @param id the id to set
*/
- public void setType(FacesId type) {
- this.type = type;
+ public void setId(FacesId type) {
+ this.id = type;
}
@Override
@@ -148,14 +148,14 @@
private String rendererType;
private List<EventModel> events = Lists.newArrayList();
private List<TagModel> tags = Lists.newArrayList();
- private String family;
+ private FacesId family;
/**
* <p class="changed_added_4_0"></p>
*
* @param family the family to set
*/
- public void setFamily(String family) {
+ public void setFamily(FacesId family) {
this.family = family;
}
@@ -165,7 +165,7 @@
* @return the family
*/
@XmlElement(name = "component-family", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public String getFamily() {
+ public FacesId getFamily() {
return family;
}
@@ -174,7 +174,7 @@
*
* @param rendererType the rendererTypes to set
*/
- @XmlElement(name = "renderer-type", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ @XmlElement(name = "renderer-id", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
public void setRendererType(String rendererType) {
this.rendererType = rendererType;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -41,6 +41,6 @@
@Override
public FacesId unmarshal(String v) throws Exception {
- return new FacesId(v);
+ return new FacesId(v.trim());
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -23,10 +23,7 @@
package org.richfaces.cdk.xmlconfig.model;
-import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.RendererModel;
-import org.richfaces.cdk.model.RendererModel.Type;
-import org.richfaces.cdk.util.Strings;
/**
* <p class="changed_added_4_0">
@@ -46,25 +43,4 @@
return RendererModel.class;
}
- @Override
- protected void postMarshal(RendererModel model, RendererBean bean) {
- ClassName baseClass = model.getBaseClass();
- ClassName rendererClass = model.getRendererClass();
- if (!model.isGenerate() && !isEmpty(baseClass) &&
isEmpty(rendererClass)) {
- bean.setRendererClass(baseClass);
- }
- }
-
- private static boolean isEmpty(ClassName className) {
- return className == null || Strings.isEmpty(className.getName());
- }
-
- @Override
- protected void postUnmarshal(RendererBean bean, RendererModel model) {
- // Copy type.
- String type = bean.getType();
- if (null != type) {
- model.setType(new Type(type.trim()));
- }
- }
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -33,6 +33,7 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.TagModel;
/**
@@ -42,33 +43,33 @@
* @author asmirnov(a)exadel.com
*/
@XmlType(name = "faces-config-rendererType", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder = {"family", "type", "rendererClass",
/*"facet",*/"facesAttributes", "extension"})
+ propOrder = {"family", "id", "rendererClass",
/*"facet",*/"facesAttributes", "extension"})
public class RendererBean extends
ElementBeanBase<RendererBean.RendererExtension> {
- private String family;
+ private FacesId family;
private ClassName rendererClass;
- private String type;
+ private String id;
/**
* <p class="changed_added_4_0">
* </p>
*
- * @return the type
+ * @return the id
*/
@XmlElement(name = "renderer-type", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getType() {
- return type;
+ public String getId() {
+ return id;
}
/**
* <p class="changed_added_4_0">
* </p>
*
- * @param type the type to set
+ * @param id the id to set
*/
- public void setType(String type) {
- this.type = type;
+ public void setId(String type) {
+ this.id = type;
}
/**
@@ -78,7 +79,7 @@
* @return the family
*/
@XmlElement(name = "component-family", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getFamily() {
+ public FacesId getFamily() {
return family;
}
@@ -88,7 +89,7 @@
*
* @param family the family to set
*/
- public void setFamily(String family) {
+ public void setFamily(FacesId family) {
this.family = family;
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-06-22
19:08:34 UTC (rev 17659)
@@ -29,7 +29,7 @@
public class ${targetClass.simpleName} extends ${baseClass.simpleName}
<#if (implemented?size > 0)>implements <@concat seq=implemented ;
interface>${interface.simpleName}</@concat></#if> {
- public static final String COMPONENT_TYPE="${type}";
+ public static final String COMPONENT_TYPE="${id}";
<#if family?exists>
public static final String COMPONENT_FAMILY="${family}";
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -47,6 +47,7 @@
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.xmlconfig.JAXB;
@@ -230,7 +231,7 @@
processor.setComponeneFamily(componentElement, model, FOO_HTML_BAR);
verify(utils, componentElement, jaxb, annotation);
- assertEquals(FOO_HTML_BAR, model.getFamily());
+ assertEquals(FacesId.parseId(FOO_HTML_BAR), model.getFamily());
}
@Test
@@ -242,7 +243,7 @@
processor.setComponeneFamily(componentElement, model, "");
verify(utils, componentElement, jaxb, annotation);
- assertEquals(FOO_HTML_BAR, model.getFamily());
+ assertEquals(FacesId.parseId(FOO_HTML_BAR), model.getFamily());
}
@Test
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -44,7 +44,6 @@
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.PropertyBase;
-import org.richfaces.cdk.model.RendererModel;
import com.google.inject.Inject;
@@ -66,7 +65,7 @@
component.setGenerate(true);
component.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedComponent"));
component.setBaseClass(ClassName.parseName(UIOutput.class.getName()));
- component.setRendererType(new RendererModel.Type("foo.barRenderer"));
+ component.setRendererType(FacesId.parseId("foo.barRenderer"));
PropertyBase attribute = component.getOrCreateAttribute("testValue");
attribute.setType(new ClassName(Object.class));
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -48,6 +48,8 @@
@RunWith(CdkTestRunner.class)
public class ModelValidatorTest extends CdkTestBase {
+ private static final FacesId FOO_BAZ = FacesId.parseId("foo.baz");
+
@Mock
protected Logger log;
@@ -84,13 +86,13 @@
FacesId type = FacesId.parseId("foo.Bar");
component.setTargetClass(className);
expect(namiingConventions.inferComponentType(className)).andReturn(type);
-
expect(namiingConventions.inferUIComponentFamily(type)).andReturn("foo.baz");
+ expect(namiingConventions.inferUIComponentFamily(type)).andReturn(FOO_BAZ);
replay(log, utils, namiingConventions);
// Validator should set component type from base class.
validator.verifyComponentType(component);
verify(log, utils, namiingConventions);
- assertEquals(type, component.getType());
- assertEquals("foo.baz", component.getFamily());
+ assertEquals(type, component.getId());
+ assertEquals(FOO_BAZ, component.getFamily());
}
}
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -127,7 +127,7 @@
assertNotNull(actionProperty);
assertNoEventNames(actionProperty);
- assertEquals(Lists.newArrayList(), actionProperty.getSignature());
+ assertEquals(0, actionProperty.getSignature().size());
}
/**
@@ -281,7 +281,7 @@
assertEquals(new
ClassName("org.richfaces.renderkit.html.DummyRendererImpl"),
renderer.getRendererClass());
assertTrue(renderer.isRendersChildren());
- assertEquals("org.richfaces.Dummy", renderer.getFamily());
+ assertEquals(FacesId.parseId("org.richfaces.Dummy"),
renderer.getFamily());
assertSame(template, renderer.getTemplate());
Collection<PropertyBase> attributes = renderer.getAttributes();
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -28,6 +28,8 @@
import java.util.List;
import org.junit.Test;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.xmlconfig.JaxbTestBase;
/**
@@ -41,7 +43,7 @@
public static final String TEMPLATE_PROLOG =
"<cdk:root
xmlns=\"http://www.w3.org/1999/xhtml\"
xmlns:cdk=\"http://richfaces.org/cdk/core\"
xmlns:c=\"http://richfaces.org/cdk/jstl/core\"
xmlns:cc=\"http://richfaces.org/cdk/jsf/composite\"><cc:i...;
- private static final Object DEFAULT_ATTRIBUTE_TYPE = Object.class.getName();
+ private static final Object DEFAULT_ATTRIBUTE_TYPE = new ClassName(Object.class);
private static final String TEMPLATE_EPILOG =
"</cc:implementation></cdk:root>";
private static final String TEMPLATE_MIDDLE =
"</cc:interface><cc:implementation>";
@@ -123,7 +125,7 @@
assertEquals("disabled", attribute.getName());
assertNull(attribute.getDefaultValue());
assertNull(attribute.getMethodSignature());
- assertEquals("boolean", attribute.getType());
+ assertEquals(ClassName.parseName("boolean"), attribute.getType());
assertNull(attribute.getTargets());
assertFalse(attribute.isRequired());
assertFalse(attribute.isExpert());
@@ -134,7 +136,7 @@
assertEquals("delay", attribute.getName());
assertNull(attribute.getDefaultValue());
assertNull(attribute.getMethodSignature());
- assertEquals("java.lang.Integer", attribute.getType());
+ assertEquals(ClassName.parseName("java.lang.Integer"),
attribute.getType());
assertNull(attribute.getTargets());
assertFalse(attribute.isRequired());
assertFalse(attribute.isExpert());
@@ -233,10 +235,10 @@
CompositeInterface interfaceSection = template.getInterface();
assertNotNull(interfaceSection);
- assertEquals("org.richfaces.renderkit.html.TreeRenderer",
interfaceSection.getJavaClass());
- assertEquals("org.richfaces.renderkit.TreeRendererBase",
interfaceSection.getBaseClass());
- assertEquals("org.richfaces.TreeFamily",
interfaceSection.getComponentFamily());
- assertEquals("org.richfaces.TreeRenderer",
interfaceSection.getRendererType());
+
assertEquals(ClassName.parseName("org.richfaces.renderkit.html.TreeRenderer"),
interfaceSection.getJavaClass());
+
assertEquals(ClassName.parseName("org.richfaces.renderkit.TreeRendererBase"),
interfaceSection.getBaseClass());
+ assertEquals(FacesId.parseId("org.richfaces.TreeFamily"),
interfaceSection.getComponentFamily());
+ assertEquals(FacesId.parseId("org.richfaces.TreeRenderer"),
interfaceSection.getRendererType());
assertEquals("RF4_XHTML", interfaceSection.getRenderKitId());
assertEquals(Boolean.FALSE, interfaceSection.getRendersChildren());
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/ComponentAdapterTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -19,7 +19,7 @@
private static final String BAZ = "baz";
private static final String FOO_BAR = "foo.Bar";
private static final String FOO_DESCTIPTION = "foo.Desctiption";
- private static final String FOO_FAMILY = "foo.Family";
+ private static final FacesId FOO_FAMILY = FacesId.parseId("foo.Family");
private static final String FOO_UI_BAR = "foo.UIBar";
@Test
@@ -32,7 +32,7 @@
component.setFamily(FOO_FAMILY);
ComponentAdapter componentAdapter = new ComponentAdapter();
ComponentBean componentBean = componentAdapter.marshal(component);
- assertEquals(FOO_BAR, componentBean.getType().toString());
+ assertEquals(FOO_BAR, componentBean.getId().toString());
Collection<PropertyBase> attributes = componentBean.getAttributes();
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -38,6 +38,7 @@
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.FacesId;
@@ -96,9 +97,9 @@
ComponentModel component = library.getComponents().get(0);
- assertEquals("javax.faces.Panel", component.getType().toString());
- assertEquals("javax.faces.Panel", component.getFamily());
- assertEquals("javax.faces.component.UIPanel",
component.getTargetClass().getName());
+ assertEquals(FacesId.parseId("javax.faces.Panel"), component.getId());
+ assertEquals(FacesId.parseId("javax.faces.Panel"),
component.getFamily());
+ assertEquals(ClassName.parseName("javax.faces.component.UIPanel"),
component.getTargetClass());
assertEquals("panel.gif", component.getIcon().getSmallIcon());
assertEquals("panel-large.gif", component.getIcon().getLargeIcon());
assertEquals("Panel component", component.getDescription());
Modified:
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
===================================================================
---
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-06-22
15:36:05 UTC (rev 17658)
+++
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-06-22
19:08:34 UTC (rev 17659)
@@ -31,7 +31,7 @@
ComponentModel component = new
ComponentModel(FacesId.parseId("foo.bar"));
library.getComponents().add(component);
RenderKitModel renderKit = library.addRenderKit("HTML");
- RendererModel renderer = new RendererModel(new
RendererModel.Type("foo.Renderer"));
+ RendererModel renderer = new
RendererModel(FacesId.parseId("foo.Renderer"));
renderKit.getRenderers().add(renderer);
StringWriter writer = new StringWriter();