JBoss Rich Faces SVN: r16680 - in root: cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-29 05:25:57 -0400 (Mon, 29 Mar 2010)
New Revision: 16680
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
Log:
Fix checkstyle
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2010-03-29 07:05:29 UTC (rev 16679)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2010-03-29 09:25:57 UTC (rev 16680)
@@ -23,14 +23,9 @@
package org.richfaces.cdk.annotations;
-import java.io.IOException;
-import java.lang.annotation.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
-import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.TagConfig;
-import javax.faces.view.facelets.TagHandler;
-
/**
* <p class="changed_added_4_0">
* </p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-29 07:05:29 UTC (rev 16679)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-29 09:25:57 UTC (rev 16680)
@@ -36,7 +36,6 @@
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.ListenerModel;
import org.richfaces.cdk.model.ModelElement;
-import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-29 07:05:29 UTC (rev 16679)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-29 09:25:57 UTC (rev 16680)
@@ -28,8 +28,6 @@
import org.richfaces.cdk.annotations.TagType;
import org.richfaces.cdk.util.ComparatorUtils;
-import java.io.Serializable;
-
/**
* <p class="changed_added_4_0">That bean represents VDL tag</p>
* @author asmirnov(a)exadel.com
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-03-29 07:05:29 UTC (rev 16679)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-03-29 09:25:57 UTC (rev 16680)
@@ -1,22 +1,20 @@
package org.ajax4jsf.component.behavior;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
+import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.component.UIComponentBase;
import javax.faces.component.behavior.FacesBehavior;
import javax.faces.context.FacesContext;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
-import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.facelets.tag.AjaxHandler;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
-
/**
* @author Anton Belevich
*/
14 years, 5 months
JBoss Rich Faces SVN: r16679 - root/docs/trunk/Developer_Guide/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-03-29 03:05:29 -0400 (Mon, 29 Mar 2010)
New Revision: 16679
Modified:
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml
Log:
Worked on Advanced_features
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml 2010-03-27 00:35:13 UTC (rev 16678)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Advanced_features.xml 2010-03-29 07:05:29 UTC (rev 16679)
@@ -4,34 +4,50 @@
<chapter id="chap-Developer_Guide-Advanced_features">
<title>Advanced features</title>
<para>
- Incomplete
+ Read this chapter for details on some of the advanced features and configuration possibilities for the RichFaces framework.
</para>
- <section id="sect-Developer_Guide-Advanced_features-Additions_to_JSF2">
- <title>Additions to JSF2</title>
+ <section id="sect-Developer_Guide-Advanced_features-JSF2_integration">
+ <title>JSF2 integration</title>
<para>
- Incomplete
+ JavaServer Faces (<acronym>JSF</acronym>) is the Java-based web application framework upon which the RichFaces framework has been built. RichFaces is now integrated with JSF2, which features several improvements to the framework.
</para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ The standard display technology used by JSF1 was JavaServer Pages (<acronym>JSP</acronym>). With JSP2, the standard display technology has been changed to Facelets, which is a more powerful and more efficient View Declaration Language (<acronym>VLD</acronym>) than JSP.
+ </para>
+ </listitem>
+ </itemizedlist>
</section>
<section id="sect-Developer_Guide-Advanced_features-Performance_optimization">
<title>Performance optimization</title>
<para>
- Incomplete
+ The RichFaces framework includes several components designed to improve application performance. Script and style management can be optimized with resource-loading components such as <sgmltag><a4j:loadBundle></sgmltag>, <sgmltag><a4j:loadScript></sgmltag>, and <sgmltag><a4j:loadStyle></sgmltag>.
</para>
+ <para>
+ For further details on optimizing the performance of RichFaces applications, refer to the <citetitle pubwork="chapter">Resources</citetitle> and <citetitle pubwork="chapter">Processing management</citetitle> chapters in the <citetitle>Component Reference Guide</citetitle>.
+ </para>
</section>
<section id="sect-Developer_Guide-Advanced_features-Traffic_control_and_queues">
<title>Traffic control and queues</title>
<para>
- Incomplete
+ The RichFaces framework allows for queues to manage traffic from Ajax requests, events, and page updates. Controlling the message processing with a queue can make applications more efficient and avoid problems with data corruption. Basic queuing is available with all RichFaces components, and the <sgmltag><a4j:queue></sgmltag> component adds advanced queuing to standard JSF components.
</para>
+ <para>
+ For further details on RichFaces queue management, refer to the queuing details in the <citetitle pubwork="chapter">Common Ajax attributes</citetitle> chapter and the <citetitle pubwork="chapter">Processing management</citetitle> chapter in the <citetitle>Component Reference Guide</citetitle>.
+ </para>
</section>
<section id="sect-Developer_Guide-Advanced_features-Validation">
<title>Validation</title>
<para>
- Incomplete
+ The RichFaces framework features several validation components. These components can validate Ajax actions, or validate data against model-based constraints defined using <application>Hibernate Validator</application>.
</para>
+ <para>
+ For further details on RichFaces validation components, refer to the <citetitle pubwork="chapter">Validation</citetitle> chapter of the <citetitle>Component Reference Guide</citetitle>.
+ </para>
</section>
<section id="sect-Developer_Guide-Advanced_features-Filters">
14 years, 5 months
JBoss Rich Faces SVN: r16678 - root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-26 20:35:13 -0400 (Fri, 26 Mar 2010)
New Revision: 16678
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
Log:
fix integration test
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2010-03-26 23:48:22 UTC (rev 16677)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2010-03-27 00:35:13 UTC (rev 16678)
@@ -26,14 +26,13 @@
import java.util.List;
import javax.faces.component.UIComponentBase;
-import javax.faces.component.ValueHolder;
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.annotations.Family;
import org.richfaces.cdk.annotations.Fires;
import org.richfaces.cdk.annotations.Generate;
import org.richfaces.cdk.annotations.Icon;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.test.event.TestEvent;
@@ -44,13 +43,9 @@
* @author asmirnov(a)exadel.com
*
*/
-@Component(type = "org.richfaces.cdk.test.TestComponent")
-@Generate("org.richfaces.cdk.test.UITestComponent")
-@Family("org.richfaces.cdk.test.Test")
-(a)Fires(TestEvent.class)
-@Tag(name = "test")
-@Icon(large="large.jpg",small="small.gif")
+@JsfComponent(type = "org.richfaces.cdk.test.TestComponent")
public abstract class AbstractTestComponent extends UIComponentBase /*implements ValueHolder */{
+
@Attribute
private int foo;
14 years, 5 months
JBoss Rich Faces SVN: r16677 - in root: cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-26 19:48:22 -0400 (Fri, 26 Mar 2010)
New Revision: 16677
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.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/Tag.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Tag.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -53,24 +53,10 @@
public TagType type() default TagType.All;
- public String handlerName() default "";
+ public String handler() default "";
- public Class<? extends TagHandler> handler() default DEFAULT.class;
+ public String baseClass() default "";
- public Class<? extends TagHandler> baseHandler() default DEFAULT.class;
-
- /**
- * Used in {@link Tag} to signal that tag uses the default handler.
- */
- public static final class DEFAULT extends TagHandler {
-
- public DEFAULT(TagConfig config) {
- super(config);
- }
-
- @Override
- public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
- // do nothing
- }
- }
+ public boolean generate() default false;
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -27,7 +27,6 @@
public abstract class ProcessorBase {
- private static final String TAG_HANDLER_DEFULT_CLASS = Tag.DEFAULT.class.getName().replace('$', '.');
@Inject
private Provider<SourceUtils> sourceUtils;
@@ -53,12 +52,12 @@
TagModel tagModel = new TagModel();
tagModel.setName(name);
- tagModel.setTargetClass(ClassName.parseName(tag.handlerName()));
+ tagModel.setTargetClass(ClassName.parseName(tag.handler()));
tagModel.setType(tag.type());
- // TODO - set base class name,
+ tagModel.setBaseClass(ClassName.parseName(tag.baseClass()));
// TODO - move refference integrity to model.
tagModel.setModel(model);
- model.setTag(tagModel);
+ model.getTags().add(tagModel);
}
protected void setIcon(DescriptionGroup component, Icon icon) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -56,12 +56,11 @@
}
private void generateTagHandler(ModelElementBase model) {
- TagModel tag = model.getTag();
- if (tag == null || !tag.isGenerate()) {
- return;
+ for (TagModel tag : model.getTags()) {
+ if (tag.isGenerate()) {
+ generateTagHandler(tag);
+ }
}
-
- generateTagHandler(tag);
}
private void generateTagHandler(TagModel model) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -25,6 +25,7 @@
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
+import org.richfaces.cdk.annotations.TagType;
import org.richfaces.cdk.model.BeanModelBase;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.BehaviorRenderer;
@@ -74,13 +75,19 @@
}
public void visitComponent(ComponentModel model) {
- Element tag = createTag(getComponentTagName(model)); // TODO change to tag name!
- Element component = tag.addElement(COMPONENT);
- component.addElement(COMPONENT_TYPE).addText(model.getType().getType());
- component.addElement("renderer-type").addText(model.getType().getType() + "JsfRenderer");
-
- addTagHandler(component, model.getTag());
- appendAttributs(tag, model);
+ for (TagModel tagModel : model.getTags()) {
+ if (TagType.Facelets.equals(tagModel.getType())) {
+ Element tag = createTag(tagModel.getName());
+ Element component = tag.addElement(COMPONENT);
+ component.addElement(COMPONENT_TYPE).addText(model.getType().getType());
+ RendererModel renderer = model.getRenderer();
+ if (null != renderer) {
+ component.addElement("renderer-type").addText(renderer.getType().getType());
+ }
+ addTagHandler(component, tagModel);
+ appendAttributs(tag, model);
+ }
+ }
}
private void addTagHandler(Element parent, TagModel tag) {
@@ -89,30 +96,19 @@
}
}
- private String getComponentTagName(ComponentModel model) {
- return getTagName(model);
- }
- private String getTagName(ModelElementBase model) {
- TagModel tag = model.getTag();
- if (tag != null) {
- return tag.getName();
- }
- return "";
- }
-
public void visitConverter(ConverterModel model) {
- TagModel tagModel = model.getTag();
- if (null != tagModel) {
- Element tag = createTag(tagModel.getName());
- Element converter = tag.addElement("converter");
- converter.addElement("converter-id", model.getId().toString());
-
- addTagHandler(converter, model.getTag());
- appendAttributs(tag, model);
- }
+ for (TagModel tagModel : model.getTags()) {
+ if (TagType.Facelets.equals(tagModel.getType())) {
+ Element tag = createTag(tagModel.getName());
+ Element converter = tag.addElement("converter");
+ converter.addElement("converter-id", model.getId().toString());
+ addTagHandler(converter, tagModel);
+ appendAttributs(tag, model);
+ }
+ }
}
/**
@@ -132,12 +128,15 @@
*
* */
public void visitValidator(ValidatorModel model) {
- Element tag = createTag(getTagName(model));
- Element validator = tag.addElement("validator");
- validator.addElement("validator-id", model.getId().toString());
-
- addTagHandler(validator, model.getTag());
- appendAttributs(tag, model);
+ for (TagModel tagModel : model.getTags()) {
+ if (TagType.Facelets.equals(tagModel.getType())) {
+ Element tag = createTag(tagModel.getName());
+ Element validator = tag.addElement("validator");
+ validator.addElement("validator-id", model.getId().toString());
+ addTagHandler(validator, tagModel);
+ appendAttributs(tag, model);
+ }
+ }
}
@@ -179,12 +178,15 @@
}
public void visitBehavior(BehaviorModel model) {
- Element tag = createTag(getTagName(model));
- Element validator = tag.addElement("behavior");
- validator.addElement("behavior-id").addText(model.getId().toString());
-
- addTagHandler(validator, model.getTag());
- appendAttributs(tag, model);
+ for (TagModel tagModel : model.getTags()) {
+ if (TagType.Facelets.equals(tagModel.getType())) {
+ Element tag = createTag(tagModel.getName());
+ Element behavior = tag.addElement("behavior");
+ behavior.addElement("behavior-id").addText(model.getId().toString());
+ addTagHandler(behavior, tagModel);
+ appendAttributs(tag, model);
+ }
+ }
}
public void visitFacet(FacetModel model) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -36,6 +36,8 @@
private String family;
+ private RendererModel renderer;
+
public ComponentModel(FacesId key) {
this.setId(key);
}
@@ -59,7 +61,6 @@
ComponentLibrary.merge(getAttributes(), otherComponent.getAttributes());
ComponentLibrary.merge(getFacets(), otherComponent.getFacets());
ComponentLibrary.merge(getEvents(), otherComponent.getEvents());
-// ComponentLibrary.merge(getRenderers(), otherComponent.getRenderers());
ComponentLibrary.merge(this, otherComponent);
this.setGenerate(this.isGenerate() || otherComponent.isGenerate());
}
@@ -176,7 +177,15 @@
* TODO - synchronize renderers collection with library ?
* @return the renderers
*/
-// public Collection<RendererModel> getRenderers() {
-// return renderers;
-// }
+ public RendererModel getRenderer() {
+ return renderer;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderer the renderer to set
+ */
+ public void setRenderer(RendererModel renderer) {
+ this.renderer = renderer;
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -14,14 +14,15 @@
private ClassName baseClass;
- private TagModel tag;
+ private final ModelCollection<TagModel> tags = ModelCollection.<TagModel>create();
- public TagModel getTag() {
- return tag;
- }
- public void setTag(TagModel tag) {
- this.tag = tag;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tags
+ */
+ public ModelCollection<TagModel> getTags() {
+ return this.tags;
}
public FacesId getId() {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -26,6 +26,7 @@
package org.richfaces.cdk.model;
import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.cdk.util.ComparatorUtils;
import java.io.Serializable;
@@ -34,7 +35,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class TagModel implements Named , Serializable {
+public class TagModel implements Named , ModelElement<TagModel> {
private static final long serialVersionUID = 3875718626199223087L;
@@ -98,6 +99,7 @@
* <p class="changed_added_4_0"></p>
* @return the targetClass
*/
+ @Merge
public ClassName getTargetClass() {
return this.targetClass;
}
@@ -116,6 +118,7 @@
* <p class="changed_added_4_0"></p>
* @return the baseClass
*/
+ @Merge
public ClassName getBaseClass() {
return this.baseClass;
}
@@ -146,5 +149,20 @@
public void setGenerate(boolean generate) {
this.generate = generate;
}
+
+ @Override
+ public void merge(TagModel other) {
+ ComponentLibrary.merge(this, other);
+ }
+
+ @Override
+ public boolean same(TagModel other) {
+ return ComparatorUtils.nullSafeEquals(this.getName(), other.getName()) && ComparatorUtils.nullSafeEquals(this.getType(), other.getType());
+ }
+
+ @Override
+ public void accept(Visitor visitor) {
+ visitor.visit(this);
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -37,6 +37,7 @@
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.model.RendererModel.Type;
import org.richfaces.cdk.templatecompiler.builder.model.JavaClass;
import org.richfaces.cdk.templatecompiler.model.Template;
@@ -78,19 +79,14 @@
}
private ComponentModel findComponentByRenderer(RendererModel renderer) {
- String rendererFamily = renderer.getFamily();
- if (rendererFamily == null) {
- return null;
- }
-
+ Type rendererType = renderer.getType();
Collection<ComponentModel> components = library.getComponents();
- if (components == null) {
- return null;
- }
-
- for (ComponentModel component : components) {
- if (rendererFamily.equals(component.getFamily())) {
- return component;
+ if (components != null) {
+ for (ComponentModel component : components) {
+ RendererModel rendererModel = component.getRenderer();
+ if (rendererModel != null && rendererType.equals(rendererModel.getType())) {
+ return component;
+ }
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -48,20 +48,17 @@
return ComponentModel.class;
}
+ @Override
+ protected void postMarshal(ComponentModel model, ComponentBean bean) {
+ super.postMarshal(model, bean);
+ if(null != model.getRenderer()){
+ bean.getExtension().setRendererType(model.getRenderer().getType().getType());
+ }
+ }
@Override
protected void postUnmarshal(ComponentBean bean, ComponentModel model) {
super.postUnmarshal(bean, model);
- // Copy properties/attributes
-
-/*
- Collection<RendererModel> renderers = model.getRenderers();
- ComponentBean.ComponentExtension extension = bean.getExtension();
- if (renderers != null && extension != null) {
- for (String renderType : extension.getRendererTypes()) {
- renderers.add(new RendererModel(new RendererModel.Type(renderType)));
- }
- }
-*/
+ // TODO set renderer from type.
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -31,6 +31,7 @@
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.AttributeModel;
+import org.richfaces.cdk.model.TagModel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@@ -141,8 +142,9 @@
}
public static class ComponentExtension extends ExtensionBeanBase {
- private List<String> rendererTypes = Lists.newArrayList();
+ private String rendererType ;
private List<EventModel> events = Lists.newArrayList();
+ private List<TagModel> tags = Lists.newArrayList();
private String family;
/**
* <p class="changed_added_4_0"></p>
@@ -166,11 +168,11 @@
/**
* <p class="changed_added_4_0"></p>
*
- * @param rendererTypes the rendererTypes to set
+ * @param rendererType the rendererTypes to set
*/
@XmlElement(name = "renderer-type", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public void setRendererTypes(List<String> rendererTypes) {
- this.rendererTypes = rendererTypes;
+ public void setRendererType(String rendererType) {
+ this.rendererType = rendererType;
}
/**
@@ -178,8 +180,8 @@
*
* @return the rendererTypes
*/
- public List<String> getRendererTypes() {
- return rendererTypes;
+ public String getRendererType() {
+ return rendererType;
}
/**
@@ -201,6 +203,23 @@
public void setEvents(List<EventModel> events) {
this.events = events;
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the tags
+ */
+ @XmlElement(name = "tag", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public List<TagModel> getTags() {
+ return this.tags;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param tags the tags to set
+ */
+ public void setTags(List<TagModel> tags) {
+ this.tags = tags;
+ }
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -109,7 +109,7 @@
expect(behaviorAnnotation.attributes()).andReturn(new String[]{});
expect(behaviorAnnotation.icon()).andReturn(null);
expect(behaviorAnnotation.displayName()).andReturn(null);
- expect(tag.handlerName()).andStubReturn("");
+ expect(tag.handler()).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);
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -15,13 +15,14 @@
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
/**
* @author Anton Belevich
*/
@JsfBehavior(
id = "org.ajax4jsf.behavior.Ajax",
- tag = @Tag(name = "ajax", handler = AjaxHandler.class)
+ tag = @Tag(name = "ajax", handler = "org.ajax4jsf.facelets.tag.AjaxHandler",type=TagType.Facelets)
)
@FacesBehavior(value = "org.ajax4jsf.behavior.Ajax")
public class AjaxBehavior extends javax.faces.component.behavior.AjaxBehavior implements AjaxClientBehavior {
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -47,7 +47,9 @@
*
*/
@JsfComponent(
- tag = @Tag(name = "mediaOutput", handlerName = "org.richfaces.taghandler.html.PushMediaOutput")
+ type = "org.richfaces.MediaOutput",
+ tag = @Tag(name = "mediaOutput", handler = "org.richfaces.taghandler.html.PushMediaOutput"),
+ generate = ""
)
public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent2 {
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -37,7 +37,7 @@
*
*/
@JsfComponent(
- tag = @Tag(handlerName = "org.richfaces.taghandler.html.OutputPanelTagHandler"),
+ tag = @Tag(handler = "org.richfaces.taghandler.html.OutputPanelTagHandler"),
generate = "org.richfaces.component.html.HtmlOutputPanel"
)
public abstract class AbstractOutputPanel extends UIPanel implements AjaxOutput {
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java 2010-03-26 20:32:24 UTC (rev 16676)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java 2010-03-26 23:48:22 UTC (rev 16677)
@@ -46,7 +46,8 @@
*/
@JsfComponent(
type = "org.richfaces.Push",
- tag = @Tag(name = "push", handlerName = "org.richfaces.taghandler.html.PushTagHandler")
+ tag = @Tag(name = "push", handler = "org.richfaces.taghandler.html.PushTagHandler"),
+ generate = ""
)
public abstract class AbstractPush extends UICommand {
14 years, 5 months
JBoss Rich Faces SVN: r16676 - in root: cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-26 16:32:24 -0400 (Fri, 26 Mar 2010)
New Revision: 16676
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributeProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandButton.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandLink.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.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/CdkAnnotationProcessor.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/apt/VirtualFileManager.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.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/apt/ComponentProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxOutputPanel.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Outputs.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Sources.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/AptSourceUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxFunction.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxLog.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxStatus.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractQueue.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
Log:
RF-8232 Tags support
generate Html<Component> classes for core-ui components
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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -65,7 +65,7 @@
*
* @return component type.
*/
- public String type();
+ public String type() default "";
/**
* <p class="changed_added_4_0">
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,12 +0,0 @@
-package org.richfaces.cdk;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface OutputType {
- String getName();
-
- OutputType getFolderType();
-}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Outputs.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Outputs.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Outputs.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -31,16 +31,6 @@
* @author asmirnov(a)exadel.com
*
*/
-public enum Outputs implements OutputType {
- JAVA_CLASSES, RESOURCES, TEST_JAVA_CLASSES, TEST_RESOURCES, DOCUMENTATION;
-
- @Override
- public OutputType getFolderType() {
- return null;
- }
-
- @Override
- public String getName() {
- return name();
- }
+public enum Outputs {
+ JAVA_CLASSES, RESOURCES, TEST_JAVA_CLASSES, TEST_RESOURCES, DOCUMENTATION
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -99,7 +99,7 @@
if (null == componentType) {
throw new IllegalArgumentException();
}
- return componentType.toString();
+ return componentType.toString();
}
@Override
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,11 +0,0 @@
-package org.richfaces.cdk;
-
-/**
- * <p class="changed_added_4_0">Id of source files e.g. Java classes, faces-configs, renderer templates</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface SourceType {
-
- String getName();
-}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Sources.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Sources.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Sources.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -29,11 +29,6 @@
*
* @author asmirnov(a)exadel.com
*/
-public enum Sources implements SourceType {
- JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES;
-
- @Override
- public String getName() {
- return name();
- }
+public enum Sources {
+ JAVA_SOURCES, FACES_CONFIGS, RENDERER_TEMPLATES
}
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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -27,6 +27,12 @@
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.apt.processors.ComponentProcessor;
+import org.richfaces.cdk.apt.processors.ValidatorProcessor;
+import org.richfaces.cdk.apt.processors.RendererProcessor;
+import org.richfaces.cdk.apt.processors.ConverterProcessor;
+import org.richfaces.cdk.apt.processors.BehaviorProcessor;
+import org.richfaces.cdk.apt.processors.CdkAnnotationProcessor;
import javax.annotation.processing.Processor;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,6 +1,5 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.Sets;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
@@ -16,14 +15,20 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
public class AptSourceUtils implements SourceUtils {
+ private static final Set<String> PROPERTIES = new HashSet<String>(Arrays.asList(
+ "getEventNames", "getDefaultEventName", "getClientBehaviors", "getFamily"));
+ private final ProcessingEnvironment processingEnv;
- private final ProcessingEnvironment processingEnv;
-
/**
* <p class="changed_added_4_0"></p>
@@ -45,7 +50,7 @@
*/
public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation,
ClassName type) {
- Set<BeanProperty> properties = Sets.newHashSet();
+ Set<BeanProperty> properties = new HashSet<BeanProperty>();
List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(asTypeElement(type));
// Get all methods and fields annotated by annotation.
@@ -69,12 +74,21 @@
}
public Set<BeanProperty> getAbstractBeanProperties(ClassName type) {
- Set<BeanProperty> properties = Sets.newHashSet();
+ System.out.println("AptSourceUtils.getAbstractBeanProperties");
+ System.out.println(" - type = " + type);
+
+ Set<BeanProperty> properties = new HashSet<BeanProperty>();
List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(asTypeElement(type));
- for (Element childElement : members) {
- if (ElementKind.METHOD.equals(childElement.getKind())) {
- processMethod(properties, childElement, false);
+ Map<String, List<ExecutableElement>> props = groupMethodsBySignature(members);
+ removeNotAbstractGroups(props);
+
+ for (List<ExecutableElement> methods : props.values()) {
+ ExecutableElement method = methods.get(0);
+
+ if (ElementKind.METHOD.equals(method.getKind())
+ && !PROPERTIES.contains(method.getSimpleName().toString())) {
+ processMethod(properties, method, false);
}
// TODO - merge properties with same name ?
@@ -83,6 +97,54 @@
return properties;
}
+ private void removeNotAbstractGroups(Map<String, List<ExecutableElement>> props) {
+ List<String> removeKeys = new ArrayList<String>();
+ for (Map.Entry<String,List<ExecutableElement>> entry : props.entrySet()) {
+ List<ExecutableElement> value = entry.getValue();
+ for (ExecutableElement element : value) {
+ if (!isAbstract(element)) {
+ removeKeys.add(entry.getKey());
+ }
+ }
+ }
+
+ for (String removeKey : removeKeys) {
+ props.remove(removeKey);
+ }
+ }
+
+ private Map<String, List<ExecutableElement>> groupMethodsBySignature(List<? extends Element> members) {
+ Map<String, List<ExecutableElement>> props = new HashMap<String, List<ExecutableElement>>();
+ for (Element element : members) {
+ if (ElementKind.METHOD.equals(element.getKind())
+ && !PROPERTIES.contains(element.getSimpleName().toString())) {
+
+ ExecutableElement method = (ExecutableElement) element;
+
+ String signature = getSignature(method);
+
+ List<ExecutableElement> methods = props.get(signature);
+ if (methods == null) {
+ methods = new ArrayList<ExecutableElement>(5);
+ props.put(signature, methods);
+ }
+
+ methods.add(method);
+ }
+ }
+ return props;
+ }
+
+ private String getSignature(ExecutableElement method) {
+ String name = method.getSimpleName().toString();
+ List<? extends VariableElement> methodParams = method.getParameters();
+ StringBuilder builder = new StringBuilder(name);
+ for (VariableElement methodParam : methodParams) {
+ builder.append(":").append(methodParam.getKind().name());
+ }
+ return builder.toString();
+ }
+
private void processFiled(Set<BeanProperty> properties, Element childElement) {
AptBeanProperty property = new AptBeanProperty(childElement.getSimpleName().toString());
@@ -97,8 +159,9 @@
private void processMethod(Set<BeanProperty> properties, Element childElement, boolean annotated) {
ExecutableElement method = (ExecutableElement) childElement;
- boolean exists = !method.getModifiers().contains(Modifier.ABSTRACT);
+ boolean exists = !isAbstract(method);
if (!annotated && exists) {
+ System.out.println(" - " + childElement.getSimpleName() + " : didn't annotated and didn't abstract.");
return;
}
@@ -111,6 +174,7 @@
} else if (!parameters.isEmpty()) {
// TODO Invalid method signature for a bean property,
// throw exception ?
+ System.out.println(" - " + childElement.getSimpleName() + " : Invalid method signature for a bean property.");
return;
}
@@ -123,12 +187,20 @@
property.exists = exists;
properties.add(property);
+ System.out.println(" - " + childElement.getSimpleName() + " : was added.");
+
} catch (InvalidNameException e) {
+ System.out.println(" - " + childElement.getSimpleName() + " : Invalid method name for a bean property, throw.");
+
// TODO Invalid method name for a bean property, throw
// exception ?
}
}
+ private boolean isAbstract(ExecutableElement method) {
+ return method.getModifiers().contains(Modifier.ABSTRACT);
+ }
+
private ClassName asClassDescription(TypeMirror type) {
return new ClassName(type.toString());
}
@@ -146,7 +218,7 @@
Set<Modifier> modifiers = field.getModifiers();
if (modifiers.contains(Modifier.FINAL) && modifiers.contains(Modifier.STATIC)
- && field.getSimpleName().equals(name)) {
+ && field.getSimpleName().toString().equals(name)) {
value = field.getConstantValue();
}
}
Deleted: 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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,71 +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 org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.FacesId;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-import java.lang.annotation.Annotation;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfBehavior.NAME})
-public class BehaviorProcessor extends ProcessorBase implements CdkAnnotationProcessor {
-
- @Override
- public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException {
- JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
-
- BehaviorModel behaviorModel = new BehaviorModel(new FacesId(behavior.id()));
- setClassNames(element, behaviorModel, behavior.generate());
-
- setTagInfo(behavior.tag(), behaviorModel);
- processAttributes(element, behaviorModel);
- setDescription(behaviorModel, behavior.icon(), getDocComment(element), behavior.displayName());
-
- library.getBehaviors().add(behaviorModel);
- }
-
- @Override
- public Class<? extends Annotation> getProcessedAnnotation() {
- return JsfBehavior.class;
- }
-
-
-
- @Override
- protected String[] getAnnotationAttributes(TypeElement element) {
- JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
- return behavior.attributes();
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,50 +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 org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.model.ComponentLibrary;
-
-import javax.lang.model.element.TypeElement;
-import java.lang.annotation.Annotation;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface CdkAnnotationProcessor {
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param element
- * @param library TODO
- * @throws CdkProcessingException
- */
- public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException;
-
- public Class<? extends Annotation> getProcessedAnnotation();
-
-}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.ModelValidator;
+import org.richfaces.cdk.apt.processors.CdkAnnotationProcessor;
import org.richfaces.cdk.model.ComponentLibrary;
import javax.annotation.processing.AbstractProcessor;
Deleted: 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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,182 +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 java.util.Set;
-
-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 org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Event;
-import org.richfaces.cdk.annotations.Facet;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-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.util.Strings;
-
-import com.google.inject.Inject;
-
-/**
- * <p class="changed_added_4_0">That class process component-related annotations such as {@link org.richfaces.cdk.annotations.JsfComponent} or
- * {@link javax.faces.component.FacesComponent} and stores information in model.
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class ComponentProcessor extends ProcessorBase implements CdkAnnotationProcessor {
-
- public static final String COMPONENT_FAMILY = "COMPONENT_FAMILY";
- @Inject
- private RendererProcessor rendererProcessor;
-
- public void process(TypeElement componentElement, ComponentLibrary library) {
- JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
- if (null != annotation) {
- // Process class-level annotations.
- ComponentModel component = new ComponentModel();
- // Should that component be generated ?
- setClassNames(componentElement, component, annotation.generate());
- setComponentProperties(componentElement, component, annotation);
- for (Tag tag : annotation.tag()) {
- setTagInfo(tag, component);
- }
- library.getComponents().add(component);
- }
- }
-
- private void setComponentProperties(TypeElement componentElement, ComponentModel component, JsfComponent annotation)
- throws CdkException {
- // type
- component.setType(FacesId.parseId(annotation.type()));
-
- // JsfComponent family
- setComponeneFamily(componentElement, component, annotation.family());
- setDescription(component, annotation.icon(), getDocComment(componentElement), annotation.displayName());
- processFacets(componentElement, component, annotation);
-
- // process Events.
- processEvents(componentElement, component, annotation);
-
- // TODO Use @Inject directly, componentElement is wrong here.
- JsfRenderer renderer = annotation.renderer();
- rendererProcessor.process(componentElement, renderer);
-
- // TODO - process @Test annotations.
- // Process attributes.
- processAttributes(componentElement, component);
- }
-
- final void processFacets(TypeElement componentElement, ComponentModel component, JsfComponent annotation) {
- SourceUtils sourceUtils = getSourceUtils();
- Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, asClassDesctiption(componentElement));
-
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
- Facet facet = beanProperty.getAnnotation(Facet.class);
- FacetModel facetModel = component.getOrCreateFacet(beanProperty.getName());
-
- // Documentation
- facetModel.setDescription(beanProperty.getDocComment());
-
- processFacet(facet, facetModel);
- if (!beanProperty.isExists()) {
- facetModel.setGenerate(true);
- }
- }
-
- // @Facets annotation.
- for (Facet facet : annotation.facets()) {
- String name = facet.name();
- if (!Strings.isEmpty(name)) {
- FacetModel facetModel = component.getOrCreateFacet(name);
- processFacet(facet, facetModel);
- } else {
- // TODO - record error.
- throw new CdkException("Facet name should be set");
- }
- }
- }
-
- final void processFacet(Facet facet, FacetModel facetModel) {
- setIcon(facetModel, facet.icon());
- facetModel.setDisplayname(facet.displayName());
- // Flags.
- facetModel.setGenerate(facet.generate());
- }
-
- final void setComponeneFamily(TypeElement componentElement, ComponentModel component, String family) {
-
- if (!Strings.isEmpty(family)) {
- // @Family annotation
- component.setFamily(family);
- } else {
- // static final COMPONENT_FAMILY string constant.
- Object value = getSourceUtils().getConstant(asClassDesctiption(componentElement), COMPONENT_FAMILY);
- if (null != value) {
- component.setFamily(value.toString());
- }
- }
- }
-
-
- final void processEvents(TypeElement componentElement, ComponentModel component, JsfComponent annotation) {
- Event[] fires = annotation.fires();
-
- 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());
- }
-
- }
- }
-
- @Override
- protected final String[] getAnnotationAttributes(TypeElement componentElement) {
- return componentElement.getAnnotation(JsfComponent.class).attributes();
- }
-
- @Override
- public final Class<? extends Annotation> getProcessedAnnotation() {
- return JsfComponent.class;
- }
-}
Deleted: 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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,83 +0,0 @@
-/**
- * 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 org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.annotations.JsfConverter;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ConverterModel;
-import org.richfaces.cdk.model.FacesId;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.MirroredTypeException;
-import java.lang.annotation.Annotation;
-
-/**
- * @author akolonitsky
- * @since Jan 4, 2010
- */
-@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfConverter.NAME})
-public class ConverterProcessor extends ProcessorBase implements CdkAnnotationProcessor {
-
- @Override
- public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException {
- JsfConverter converter = element.getAnnotation(JsfConverter.class);
-
- ConverterModel converterModel = new ConverterModel();
- converterModel.setId(FacesId.parseId(converter.id()));
-
- try {
- Class<?> forClass = converter.forClass();
- if (!JsfConverter.NONE.class.equals(forClass)) {
- converterModel.setConverterForClass(new ClassName(forClass.getName()));
- }
- } catch (MirroredTypeException e) {
- String name = e.getTypeMirror().toString();
- if (!JsfConverter.NONE.class.getName().equals(name)) {
- converterModel.setConverterForClass(new ClassName(name));
- }
- }
-
- setDescription(converterModel, converter.icon(), getDocComment(element), converter.displayName());
-
- processAttributes(element, converterModel);
- setClassNames(element, converterModel, converter.generate());
-
- setTagInfo(converter.tag(), converterModel);
-
- library.getConverters().add(converterModel);
- }
-
- @Override
- public Class<? extends Annotation> getProcessedAnnotation() {
- return JsfConverter.class;
- }
-
-
- 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/ProcessorBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,269 +0,0 @@
-package org.richfaces.cdk.apt;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-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 org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Attribute;
-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.BeanModelBase;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.PropertyBase;
-import org.richfaces.cdk.model.TagModel;
-import org.richfaces.cdk.util.Strings;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
-import org.richfaces.cdk.xmlconfig.FragmentParser;
-
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-public abstract class ProcessorBase {
-
- private static final String TAG_HANDLER_DEFULT_CLASS = Tag.DEFAULT.class.getName().replace('$', '.');
-
- private static final String SIGNATURE_NONE_CLASS_NAME = Signature.NONE.class.getName().replace('$', '.');
-
-
- @Inject
- private Provider<SourceUtils> sourceUtils;
-
-
- @Inject
- private FragmentParser fragmentParser;
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the fragmentParser
- */
- public FragmentParser getFragmentParser() {
- return this.fragmentParser;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the sourceUtils
- */
- public SourceUtils getSourceUtils() {
- return this.sourceUtils.get();
- }
-
-
- protected void setTagInfo(Tag tag, ModelElementBase model) {
-
- String name = tag.name();
-
- TagModel tagModel = new TagModel();
- tagModel.setName(name);
- tagModel.setTargetClass(ClassName.parseName(tag.handlerName()));
- tagModel.setType(tag.type());
- // TODO - set base class name,
- // TODO - move refference integrity to model.
- tagModel.setModel(model);
- model.setTag(tagModel);
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param component
- * @param icon
- */
- protected void setIcon(DescriptionGroup component, Icon icon) {
- if (null != icon && (!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);
-
- }
- }
-
-
-
- protected void setDescription(DescriptionGroup component, Icon icon, String description, String displayName) {
-
- // JavaDoc comments
- component.setDescription(description);
- if (null != icon) {
- setIcon(component, icon);
- }
-
- if (!Strings.isEmpty(displayName)) {
- component.setDisplayname(displayName);
- }
- }
-
- protected void setClassNames(TypeElement componentElement, ModelElementBase modelElement,
- String generatedClass) {
-
- 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(componentElement.getQualifiedName().toString()));
- }
-
- protected Collection<PropertyBase> parseProperties(String attributesConfig) {
- return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES + attributesConfig + ".xml");
- }
-
- 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.
-
- SourceUtils sourceUtils = getSourceUtils();
- // Read xml configuration associated with all superclasses and interfaces
- 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 ?
- }
- }
- });
- // Process all files from @Jsf.. attributes property.
- for(String annotationAttributes : getAnnotationAttributes(componentElement)){
- try {
- component.getAttributes().addAll(
- parseProperties(CdkEntityResolver.URN_ATTRIBUTES + annotationAttributes));
- } catch (CdkException e) {
- // TODO - log errors ?
- }
- }
- ClassName componentClassName = asClassDesctiption(componentElement);
- Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class, componentClassName);
- // Check all abstract properties, they should be generated. TODO - move it to the validator ???
- properties.addAll(sourceUtils.getAbstractBeanProperties(componentClassName));
-
- // TODO - encapsulate attribute builder into utility class.
- for (BeanProperty beanProperty : properties) {
-
- PropertyBase attribute = component.getOrCreateAttribute(beanProperty.getName());
-
- processAttribute(beanProperty, attribute);
- }
- }
-
- protected void processAttribute(BeanProperty beanProperty, PropertyBase attribute) {
- attribute.setType(beanProperty.getType());
-
- Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
- if (attributeAnnotarion == null) {
- attribute.setGenerate(!beanProperty.isExists());
- setDescription(attribute, null, beanProperty.getDocComment(), null);
-
- } else {
- 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());
-
- // 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.
- attribute.setSignature(getSignature(attributeAnnotarion.signature()));
-
- for (EventName event : attributeAnnotarion.events()) {
- setBehaviorEvent(attribute, event);
- }
- }
- }
-
- protected List<ClassName> getSignature(Signature signature) {
- if (signature == null) {
- return null;
- }
- // TODO - where return type can be used ?
- String returnType;
- try {
- returnType = signature.returnType().getName();
- } catch (MirroredTypeException e) {
- TypeMirror returnTypeMirror = e.getTypeMirror();
- returnType = returnTypeMirror.toString();
- }
-
- if (signature != null && SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
- 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()));
- }
- }
-
- return parameters;
- // signature parameters always should be replaced.
- // TODO - set method return type.
- }
-
- return null;
- }
-
- protected void setBehaviorEvent(PropertyBase 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);
- }
- }
-}
Deleted: 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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,157 +0,0 @@
-/**
- * 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.annotation.processing.SupportedAnnotationTypes;
-import javax.faces.render.RenderKitFactory;
-import javax.lang.model.element.TypeElement;
-
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.RendererModel;
-import org.richfaces.cdk.util.Strings;
-
-/**
- * @author akolonitsky
- * @since Dec 30, 2009
- */
-@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfRenderer.NAME})
-public class RendererProcessor extends ProcessorBase implements CdkAnnotationProcessor {
-
-
- public void process(TypeElement rendererElement, ComponentLibrary library) {
- JsfRenderer annotation = rendererElement.getAnnotation(JsfRenderer.class);
-
- RendererModel rendererModel = process(rendererElement, annotation);
-
- ComponentModel componentModel = library.getComponentModel(rendererModel.getFamily());
- if (componentModel != null) {
- componentModel.getRenderers().add(rendererModel);
- } else {
- System.out.println("For renderer with type (" + rendererModel.getType() + ") and family ("
- + rendererModel.getFamily() + ") comopnent was not found");
- }
- }
-
- public RendererModel process(TypeElement rendererElement, JsfRenderer annotation) {
- RendererModel rendererModel = new RendererModel();
- rendererModel.setRendererClass(new ClassName(rendererElement.getQualifiedName().toString()));
-
- setRendererType(rendererModel, annotation);
- setComponentFamily(rendererModel, annotation);
- setTemplate(rendererModel, annotation);
- setDescription(rendererModel, annotation.icon(), getDocComment(rendererElement), annotation.displayName());
-
- String renderKitId = annotation.renderKitId();
- if (Strings.isEmpty(renderKitId)) {
- renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT; // TODO ???
- }
-
- setRendererProperties(rendererElement, rendererModel);
- return rendererModel;
- }
-
- private void setTemplate(RendererModel rendererModel, JsfRenderer annotation) {
- String template = annotation.template();
- if (!Strings.isEmpty(template)) {
- rendererModel.setTemplatePath(template);
- // TODO - add template to source list to process it in appropriate builder.
- processRendererTemplate(rendererModel);
- }
- }
-
- private void processRendererTemplate(RendererModel renderer) {
-// RendererTemplateParser templateParser = injector.getInstance(RendererTemplateParser.class);
-// templateParser.
- }
-
- private void setComponentFamily(RendererModel rendererModel, JsfRenderer annotation) {
- String family = annotation.family();
- if (!Strings.isEmpty(family)) {
- rendererModel.setFamily(family);
- }
- }
-
- private void setRendererType(RendererModel rendererModel, JsfRenderer annotation) {
- String type = annotation.type();
- if (Strings.isEmpty(type)) {
- rendererModel.setType(new RendererModel.Type(type));
- }
- }
-
- protected String getComponentType(TypeElement componentElement) {
- JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
- if (annotation != null) {
- return annotation.type();
- }
-
- return null;
- }
-
- private void setRendererProperties(TypeElement componentElement, RendererModel renderer)
- throws CdkException {
-
- // JsfComponent family
- setRendererFamily(componentElement, renderer);
-// processFacets(componentElement, renderer);
-
- // process Events.
-// setEvents(componentElement, renderer);
- // TODO - process renderers ( @JsfRenderer and @RendererTemplate attribute.
- // TODO - process @Test annotations.
- // Process attributes.
-// processAttributes(componentElement, component);
- }
-
- private void setRendererFamily(TypeElement rendererElement, RendererModel renderer) {
- Family family = rendererElement.getAnnotation(Family.class);
-
- if (null != family) {
- renderer.setFamily(family.value());
- } else {
- // static final COMPONENT_FAMILY string constant.
- Object value = getSourceUtils().getConstant(asClassDesctiption(rendererElement), "COMPONENT_FAMILY");
- if (null != value) {
- renderer.setFamily(value.toString());
- }
- }
- }
-
-
-
- @Override
- public Class<? extends Annotation> getProcessedAnnotation() {
- return JsfRenderer.class;
- }
-
- protected String[] getAnnotationAttributes(TypeElement componentElement) {
- return null;
- }
-
-}
Deleted: 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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,64 +0,0 @@
-/**
- * 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 org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.annotations.JsfValidator;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.FacesId;
-import org.richfaces.cdk.model.ValidatorModel;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-import java.lang.annotation.Annotation;
-
-/**
- * @author akolonitsky
- * @since Jan 13, 2010
- */
-@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfValidator.NAME})
-public class ValidatorProcessor extends ProcessorBase implements CdkAnnotationProcessor {
-
- @Override
- public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException {
- JsfValidator validator = element.getAnnotation(JsfValidator.class);
-
- ValidatorModel validatorModel = new ValidatorModel(FacesId.parseId(validator.id()));
- setClassNames(element, validatorModel, validator.generate());
- setDescription(validatorModel, validator.icon(), getDocComment(element), validator.displayName());
-
- setTagInfo(validator.tag(), validatorModel);
-
- library.getValidators().add(validatorModel);
- }
-
- @Override
- public Class<? extends Annotation> getProcessedAnnotation() {
- return JsfValidator.class;
- }
-
-
- protected String[] getAnnotationAttributes(TypeElement element) {
- JsfValidator validator = element.getAnnotation(JsfValidator.class);
- return validator.attributes();
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,574 +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 com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Lists;
-import com.google.inject.Inject;
-import org.richfaces.cdk.Logger;
-
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.StandardLocation;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * <p class="changed_added_4_0">
- * That class wraps {@link javax.tools.StandardJavaFileManager}
- * </p>
- *
- * @author asmirnov(a)exadel.com
- */
-final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager> {
- @Inject
- private Logger log;
-
-// private final BiMap<FileObjectKey, FileObject> classPathFiles;
- // private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
- private final ClassLoader classPathLoader;
- private final BiMap<FileObject, FileObjectKey> inversedSources;
- private final BiMap<FileObjectKey, FileObject> sources;
-
- private File javaSourceDirectory;
- private File outputDirectory;
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param fileManager
- */
- public VirtualFileManager(JavaFileManager fileManager, ClassLoader classPathLoader) {
- super(fileManager);
- this.classPathLoader = classPathLoader;
- this.sources = HashBiMap.create(128);
- inversedSources = this.sources.inverse();
-
-// this.classPathFiles = HashBiMap.create(128);
-// inversedClassPathFiles = this.classPathFiles.inverse();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#getJavaFileForInput(javax.tools
- * .JavaFileManager.Location, java.lang.String,
- * javax.tools.JavaFileObject.Kind)
- */
- @Override
- public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getJavaFileForInput(" + String.valueOf(location) + "," + className + ","
- + String.valueOf(kind) + ")");
- }
-
- FileObjectKey key = new FileObjectKey(className, kind);
-
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- JavaFileObject fileObject = (JavaFileObject) sources.get(key);
-
- if (null == fileObject && null != javaSourceDirectory) {
- String fileName = className.replace('.', File.separatorChar) + kind.extension;
- File resource = new File(javaSourceDirectory, fileName);
-
- if (resource.exists()) {
- fileObject = new VirtualJavaFileSystemObject(resource, kind);
- sources.put(key, fileObject);
- }
- }
-
- return fileObject;
- }
-
- return super.getJavaFileForInput(location, className, kind);
- }
-
- @Override
- public ClassLoader getClassLoader(Location location) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getClassLoader(" + String.valueOf(location) + ")");
- }
-
- if (StandardLocation.CLASS_OUTPUT.equals(location) || StandardLocation.SOURCE_PATH.equals(location)
- || StandardLocation.SOURCE_OUTPUT.equals(location)) {
- return getClassPathLoader();
- } else {
- return super.getClassLoader(location);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#getJavaFileForOutput(javax.tools
- * .JavaFileManager.Location, java.lang.String,
- * javax.tools.JavaFileObject.Kind, javax.tools.FileObject)
- */
- @Override
- public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getJavaFileForOutput(" + String.valueOf(location) + "," + className + ","
- + String.valueOf(kind) + "," + String.valueOf(sibling) + ")");
- }
-
- JavaFileObject fileForOutput = null;
-
- if (StandardLocation.CLASS_OUTPUT.equals(location) && null != getOutputDirectory()) {
- String fileName = className.replace('.', '/') + kind.extension;
- File outputFile = new File(getOutputDirectory(), fileName);
-
- fileForOutput = new VirtualJavaFileSystemObject(outputFile, kind);
- }
-
- return fileForOutput;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#hasLocation(javax.tools.JavaFileManager
- * .Location)
- */
- @Override
- public boolean hasLocation(Location location) {
- boolean hasLocation;
-
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.hasLocation(" + String.valueOf(location) + ")");
- }
-
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- hasLocation = null != getJavaSourceDirectory() || !sources.isEmpty();
- } else if (StandardLocation.CLASS_OUTPUT.equals(location)) {
- hasLocation = null != getOutputDirectory();
- } else {
- hasLocation = super.hasLocation(location);
- }
-
- return hasLocation;
- }
-
- @Override
- public Iterable<JavaFileObject> list(final Location location, final String packageName, final Set<Kind> kinds,
- final boolean recurse) throws IOException {
-
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.list(" + String.valueOf(location) + "," + packageName + ","
- + String.valueOf(kinds) + "," + String.valueOf(recurse) + ")");
- }
-
- Iterable<JavaFileObject> list;
-
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- if (null != getJavaSourceDirectory()) {
- String fileName = packageName.replace('.', File.separatorChar);
- File packageDirectory = new File(getJavaSourceDirectory(), fileName);
-
- if (packageDirectory.exists()) {
- final List<JavaFileObject> fileslist = Lists.newArrayList();
- File[] files = packageDirectory.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- File child = new File(dir, name);
-
- if (child.isDirectory() && recurse) {
-
- // Recursive add directory content.
- try {
- Iterable<JavaFileObject> childList = list(location, packageName + '.' + name,
- kinds, recurse);
-
- for (JavaFileObject javaFileObject : childList) {
- fileslist.add(javaFileObject);
- }
- } catch (IOException e) {
- return false;
- }
- } else {
- for (Kind kind : kinds) {
- if (name.endsWith(kind.extension)) {
- return true;
- }
- }
- }
-
- return false;
- }
- });
-
- for (File file : files) {
- String name = file.getName();
- Kind kind = Kind.SOURCE;
- int indexOfPeriod = name.lastIndexOf('.');
-
- if (indexOfPeriod > 0) {
- name = name.substring(0, indexOfPeriod);
-
- String ext = name.substring(indexOfPeriod);
-
- for (Kind requestedKind : kinds) {
- if (ext.equals(requestedKind.extension)) {
- kind = requestedKind;
- }
- }
- }
-
- String className = packageName + '.' + name;
- FileObjectKey key = new FileObjectKey(className, kind);
- JavaFileObject javaFileObject = (JavaFileObject) sources.get(key);
-
- if (null == javaFileObject) {
- javaFileObject = new VirtualJavaFileSystemObject(file, kind);
- sources.put(key, javaFileObject);
- }
-
- fileslist.add(javaFileObject);
- }
-
- list = fileslist;
- } else {
- list = Collections.emptyList();
- }
- } else {
- list = Collections.emptyList();
- }
- } else {
- list = super.list(location, packageName, kinds, recurse);
- }
-
- return list;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#close()
- */
- @Override
- public void close() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.close()");
- }
-
- super.close();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#flush()
- */
- @Override
- public void flush() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.flush()");
- }
-
- super.flush();
- }
-
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#getFileForInput(javax.tools.
- * JavaFileManager.Location, java.lang.String, java.lang.String)
- */
- @Override
- public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getFileForInput(" + String.valueOf(location) + "," + packageName + ","
- + relativeName + ")");
- }
-
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- String fileName = packageName.replace('.', File.separatorChar) + File.separator + relativeName;
-
- if (null != javaSourceDirectory) {
- File resource = new File(javaSourceDirectory, fileName);
-
- if (resource.exists()) {
- return new VirtualJavaFileSystemObject(resource, Kind.OTHER);
- }
- }
-
- return null;
- }
-
- return super.getFileForInput(location, packageName, relativeName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#getFileForOutput(javax.tools.
- * JavaFileManager.Location, java.lang.String, java.lang.String,
- * javax.tools.FileObject)
- */
- @Override
- public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling)
- throws IOException {
-
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.getFileForOutput(" + String.valueOf(location) + "," + packageName + ","
- + relativeName + "," + String.valueOf(sibling) + ")");
- }
-
- return super.getFileForOutput(location, packageName, relativeName, sibling);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.tools.ForwardingJavaFileManager#handleOption(java.lang.String,
- * java.util.Iterator)
- */
- @Override
- public boolean handleOption(String current, Iterator<String> remaining) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.handleOption(" + current + ",remaining)");
- }
-
- return super.handleOption(current, remaining);
- }
-
- /*
- * (non-Javadoc)
- *
- * @seejavax.tools.ForwardingJavaFileManager#inferBinaryName(javax.tools.
- * JavaFileManager.Location, javax.tools.JavaFileObject)
- */
- @Override
- public String inferBinaryName(Location location, JavaFileObject file) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.inferBinaryName(" + String.valueOf(location) + "," + String.valueOf(file)
- + ")");
- }
-
- if (StandardLocation.SOURCE_PATH.equals(location)) {
- FileObjectKey fileObjectKey = inversedSources.get(file);
-
- if (null != fileObjectKey) {
- return fileObjectKey.getBinaryName();
- } else {
- return null;
- }
- } else {
- return super.inferBinaryName(location, file);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#isSameFile(javax.tools.FileObject,
- * javax.tools.FileObject)
- */
- @Override
- public boolean isSameFile(FileObject a, FileObject b) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.isSameFile(" + String.valueOf(a) + "," + String.valueOf(b) + ")");
- }
-
- if (a instanceof VirtualJavaFileObject) {
- return a.equals(b);
- }
-
- return super.isSameFile(a, b);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * javax.tools.ForwardingJavaFileManager#isSupportedOption(java.lang.String)
- */
- @Override
- public int isSupportedOption(String option) {
- if (log.isDebugEnabled()) {
- log.debug("VirtualFileManager.isSupportedOption(" + option + ")");
- }
-
- return super.isSupportedOption(option);
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the classPathLoader
- */
- private ClassLoader getClassPathLoader() {
- return classPathLoader;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the outputDirectory
- */
- public File getOutputDirectory() {
- return outputDirectory;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param outputDirectory the outputDirectory to set
- */
- public void setOutputDirectory(File outputDirectory) {
- this.outputDirectory = outputDirectory;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaSourceDirectory
- */
- public File getJavaSourceDirectory() {
- return javaSourceDirectory;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param javaSourceDirectory the javaSourceDirectory to set
- */
- public void setJavaSourceDirectory(File javaSourceDirectory) {
- this.javaSourceDirectory = javaSourceDirectory;
- }
-
- @SuppressWarnings("serial")
- private static class FileObjectKey implements Serializable {
- private final String binaryName;
- private final Kind kind;
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param binaryName
- * @param kind
- */
- public FileObjectKey(String binaryName, Kind kind) {
- super();
- this.binaryName = binaryName;
- this.kind = kind;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the binaryName
- */
- public String getBinaryName() {
- return binaryName;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the kind
- */
- public Kind getKind() {
- return kind;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((binaryName == null) ? 0 : binaryName.hashCode());
- result = prime * result + ((kind == null) ? 0 : kind.hashCode());
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- FileObjectKey other = (FileObjectKey) obj;
-
- if (binaryName == null) {
- if (other.binaryName != null) {
- return false;
- }
- } else if (!binaryName.equals(other.binaryName)) {
- return false;
- }
-
- if (kind == null) {
- if (other.kind != null) {
- return false;
- }
- } else if (!kind.equals(other.kind)) {
- return false;
- }
-
- return true;
- }
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaClassPathObject.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,130 +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.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created
- * from {@link java.io.File} or {@link URL}</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class VirtualJavaClassPathObject extends VirtualJavaFileObject {
- private final URL url;
-
- /**
- * <p class="changed_added_4_0">Create file object from URL</p>
- *
- * @param url
- * @param kind
- * @throws URISyntaxException
- */
- public VirtualJavaClassPathObject(URL url, Kind kind) throws URISyntaxException {
- super(url.toURI(), kind);
- this.url = url;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- return url.openStream();
- }
-
- /*
- * (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- try {
- URLConnection connection = url.openConnection();
-
- return connection.getLastModified();
- } catch (IOException e) {
- return super.getLastModified();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((url == null) ? 0 : url.hashCode());
- result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (!(obj instanceof VirtualJavaClassPathObject)) {
- return false;
- }
-
- VirtualJavaClassPathObject other = (VirtualJavaClassPathObject) obj;
-
- if (url == null) {
- if (other.uri != null) {
- return false;
- }
- } else if (!url.equals(other.uri)) {
- return false;
- }
-
- if (getKind() == null) {
- if (other.getKind() != null) {
- return false;
- }
- } else if (!getKind().equals(other.getKind())) {
- return false;
- }
-
- return true;
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileObject.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,110 +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 javax.tools.SimpleJavaFileObject;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.charset.Charset;
-
-/**
- * <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created
- * from {@link java.io.File} or {@link java.net.URL}</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class VirtualJavaFileObject extends SimpleJavaFileObject {
-
- /**
- * <p class="changed_added_4_0">base file object. One of {@link file} or {@link url} fields should be set</p>
- */
- private Charset charset = Charset.defaultCharset();
-
- /**
- * <p class="changed_added_4_0">Cached content</p>
- */
- private CharSequence content;
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param classFile
- * @param kind
- */
- protected VirtualJavaFileObject(URI classFile, Kind kind) {
- super(classFile, kind);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getCharContent(boolean)
- */
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- if (null == content) {
- StringBuilder builder = new StringBuilder((int) (4096f * getCharset().newDecoder().averageCharsPerByte()));
- InputStream inputStream = openInputStream();
-
- if (null != inputStream) {
- ReadableByteChannel channel = Channels.newChannel(inputStream);
-
- for (ByteBuffer buff = ByteBuffer.allocate(4096); channel.read(buff) >= 0; buff.clear()) {
- buff.flip();
- builder.append(getCharset().decode(buff));
- }
-
- channel.close();
- inputStream.close();
- content = builder.toString();
- }
- }
-
- return content;
- }
-
- /**
- * <p class="changed_added_4_0">Set {@link Charset} for read operations</p>
- *
- * @param charset the charset to set
- */
- public void setCharset(Charset charset) {
- this.charset = charset;
-
- // Reset cached content
- this.content = null;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the charset
- */
- public Charset getCharset() {
- return charset;
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualJavaFileSystemObject.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,129 +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.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * <p class="changed_added_4_0">This class represents read-only {@link javax.tools.JavaFileObject} created from
- * {@link File} or {@link java.net.URL}</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class VirtualJavaFileSystemObject extends VirtualJavaFileObject {
-
- /**
- * <p class="changed_added_4_0">base file object. One of {@link file} or {@link url} fields should be set</p>
- */
- private final File classFile;
-
- /**
- * <p class="changed_added_4_0">Create source from {@link File}</p>
- *
- * @param classFile
- */
- public VirtualJavaFileSystemObject(File classFile) {
- this(classFile, Kind.SOURCE);
- }
-
- public VirtualJavaFileSystemObject(File classFile, Kind kind) {
- super(classFile.toURI(), kind);
- this.classFile = classFile;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#openInputStream()
- */
- @Override
- public InputStream openInputStream() throws IOException {
- return new FileInputStream(classFile);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.tools.SimpleJavaFileObject#getLastModified()
- */
- @Override
- public long getLastModified() {
- return classFile.lastModified();
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((classFile == null) ? 0 : classFile.hashCode());
- result = prime * result + ((getKind() == null) ? 0 : getKind().hashCode());
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (!(obj instanceof VirtualJavaFileSystemObject)) {
- return false;
- }
-
- VirtualJavaFileSystemObject other = (VirtualJavaFileSystemObject) obj;
-
- if (classFile == null) {
- if (other.classFile != null) {
- return false;
- }
- } else if (!classFile.equals(other.classFile)) {
- return false;
- }
-
- if (getKind() == null) {
- if (other.getKind() != null) {
- return false;
- }
- } else if (!getKind().equals(other.getKind())) {
- return false;
- }
-
- return true;
- }
-}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributeProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributeProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributeProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.apt.processors;
+
+import com.google.common.collect.Lists;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.Signature;
+import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.util.Strings;
+
+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.List;
+
+/**
+ * @author akolonitsky
+ * @since Mar 23, 2010
+ */
+public class AttributeProcessor extends ProcessorBase {
+
+ private static final String SIGNATURE_NONE_CLASS_NAME = Signature.NONE.class.getName().replace('$', '.');
+
+ public void process(SourceUtils.BeanProperty beanProperty, PropertyBase attribute) {
+
+ attribute.setType(beanProperty.getType());
+
+ Attribute attributeAnnotarion = beanProperty.getAnnotation(Attribute.class);
+ if (attributeAnnotarion == null) {
+ attribute.setGenerate(!beanProperty.isExists());
+ setDescription(attribute, null, beanProperty.getDocComment(), null);
+
+ } else {
+ 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());
+
+ 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.
+ attribute.setSignature(getSignature(attributeAnnotarion.signature()));
+
+ for (EventName event : attributeAnnotarion.events()) {
+ setBehaviorEvent(attribute, event);
+ }
+ }
+ }
+
+ private List<ClassName> getSignature(Signature signature) {
+ if (signature == null) {
+ return null;
+ }
+
+ String returnType;
+ try {
+ returnType = signature.returnType().getName();
+ } catch (MirroredTypeException e) {
+ TypeMirror returnTypeMirror = e.getTypeMirror();
+ returnType = returnTypeMirror.toString();
+ }
+
+ if (signature != null && SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
+ 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()));
+ }
+ }
+
+ return parameters;
+ // signature parameters always should be replaced.
+ // TODO - set method return type.
+ }
+
+ return null;
+ }
+
+ private void setBehaviorEvent(PropertyBase 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
+ protected String[] getAnnotationAttributes(TypeElement componentElement) {
+ throw new UnsupportedOperationException();
+ }
+}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java (from rev 16654, 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/processors/BehaviorProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,71 @@
+/*
+ * $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.processors;
+
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfBehavior.NAME})
+public class BehaviorProcessor extends ProcessorBase implements CdkAnnotationProcessor {
+
+ @Override
+ public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException {
+ JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
+
+ BehaviorModel behaviorModel = new BehaviorModel(new FacesId(behavior.id()));
+ setClassNames(element, behaviorModel, behavior.generate());
+
+ setTagInfo(behavior.tag(), behaviorModel);
+ processAttributes(element, behaviorModel);
+ setDescription(behaviorModel, behavior.icon(), getDocComment(element), behavior.displayName());
+
+ library.getBehaviors().add(behaviorModel);
+ }
+
+ @Override
+ public Class<? extends Annotation> getProcessedAnnotation() {
+ return JsfBehavior.class;
+ }
+
+
+
+ @Override
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
+ return behavior.attributes();
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/BehaviorProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java (from rev 16654, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkAnnotationProcessor.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,50 @@
+/*
+ * $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.processors;
+
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface CdkAnnotationProcessor {
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param element
+ * @param library TODO
+ * @throws CdkProcessingException
+ */
+ public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException;
+
+ public Class<? extends Annotation> getProcessedAnnotation();
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/CdkAnnotationProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java (from rev 16654, 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/processors/ComponentProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,206 @@
+/*
+ * $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.processors;
+
+import com.google.inject.Inject;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.NamingConventions;
+import org.richfaces.cdk.annotations.Event;
+import org.richfaces.cdk.annotations.Facet;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.apt.SourceUtils;
+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.util.Strings;
+
+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.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * <p class="changed_added_4_0">That class process component-related annotations such as {@link org.richfaces.cdk.annotations.JsfComponent} or
+ * {@link javax.faces.component.FacesComponent} and stores information in model.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentProcessor extends ProcessorBase implements CdkAnnotationProcessor {
+
+ public static final String COMPONENT_FAMILY = "COMPONENT_FAMILY";
+
+ public static final String COMPONENT_TYPE = "COMPONENT_TYPE";
+
+ @Inject
+ private RendererProcessor rendererProcessor;
+
+ @Inject
+ private NamingConventions namingConventions;
+
+ public void process(TypeElement componentElement, ComponentLibrary library) {
+ JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
+ if (annotation == null) {
+ return;
+ }
+
+ // Process class-level annotations.
+ ComponentModel component = new ComponentModel();
+ // Should that component be generated ?
+ setClassNames(componentElement, component, annotation.generate());
+ setComponentProperties(componentElement, component, annotation, library);
+ for (Tag tag : annotation.tag()) {
+ setTagInfo(tag, component);
+ }
+ library.getComponents().add(component);
+ }
+
+ private void setComponentProperties(TypeElement componentElement, ComponentModel component, JsfComponent annotation, ComponentLibrary library)
+ throws CdkException {
+
+ setComponentType(componentElement, component, annotation.type());
+ setComponeneFamily(componentElement, component, annotation.family());
+ setDescription(component, annotation.icon(), getDocComment(componentElement), annotation.displayName());
+
+ processFacets(componentElement, component, annotation);
+ processEvents(componentElement, component, annotation);
+
+ processAttributes(componentElement, component);
+
+ rendererProcessor.process(componentElement, annotation.renderer(), library);
+
+ // TODO - process @Test annotations.
+ }
+
+ private void setComponentType(TypeElement componentElement, ComponentModel component, String type) {
+ if (!Strings.isEmpty(type)) {
+ component.setType(FacesId.parseId(type));
+ return;
+ }
+
+ // static final String COMPONENT_FAMILY = "...";
+ Object value = getSourceUtils().getConstant(asClassDesctiption(componentElement), COMPONENT_TYPE);
+ if (value != null) {
+ component.setType(FacesId.parseId(value.toString()));
+ return;
+ }
+
+ component.setType(this.getNamingConventions().inferComponentType(asClassDesctiption(componentElement)));
+ }
+
+ final void processFacets(TypeElement componentElement, ComponentModel component, JsfComponent annotation) {
+ SourceUtils sourceUtils = getSourceUtils();
+ Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, asClassDesctiption(componentElement));
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ Facet facet = beanProperty.getAnnotation(Facet.class);
+ FacetModel facetModel = component.getOrCreateFacet(beanProperty.getName());
+
+ facetModel.setDescription(beanProperty.getDocComment());
+
+ processFacet(facet, facetModel);
+ if (!beanProperty.isExists()) {
+ facetModel.setGenerate(true);
+ }
+ }
+
+ for (Facet facet : annotation.facets()) {
+ String name = facet.name();
+ if (!Strings.isEmpty(name)) {
+ FacetModel facetModel = component.getOrCreateFacet(name);
+ processFacet(facet, facetModel);
+ } else {
+ // TODO - record error.
+ throw new CdkException("Facet name should be set");
+ }
+ }
+ }
+
+ final void processFacet(Facet facet, FacetModel facetModel) {
+ setIcon(facetModel, facet.icon());
+ facetModel.setDisplayname(facet.displayName());
+ facetModel.setGenerate(facet.generate());
+ }
+
+ final void setComponeneFamily(TypeElement componentElement, ComponentModel component, String family) {
+ if (!Strings.isEmpty(family)) {
+ component.setFamily(family);
+ return;
+ }
+
+ // static final String COMPONENT_FAMILY = "...";
+ Object value = getSourceUtils().getConstant(asClassDesctiption(componentElement), COMPONENT_FAMILY);
+ if (null != value) {
+ component.setFamily(value.toString());
+ return;
+ }
+
+ component.setFamily(getNamingConventions().inferUIComponentFamily(component.getType()));
+ }
+
+
+ final void processEvents(TypeElement componentElement, ComponentModel component, JsfComponent annotation) {
+ Event[] fires = annotation.fires();
+
+ 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());
+ }
+
+ }
+ }
+
+ @Override
+ protected final String[] getAnnotationAttributes(TypeElement componentElement) {
+ return componentElement.getAnnotation(JsfComponent.class).attributes();
+ }
+
+ @Override
+ public final Class<? extends Annotation> getProcessedAnnotation() {
+ return JsfComponent.class;
+ }
+
+ public NamingConventions getNamingConventions() {
+ return namingConventions;
+ }
+
+ public void setNamingConventions(NamingConventions namingConventions) {
+ this.namingConventions = namingConventions;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java (from rev 16654, 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/processors/ConverterProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,83 @@
+/**
+ * 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.processors;
+
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.annotations.JsfConverter;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConverterModel;
+import org.richfaces.cdk.model.FacesId;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.MirroredTypeException;
+import java.lang.annotation.Annotation;
+
+/**
+ * @author akolonitsky
+ * @since Jan 4, 2010
+ */
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfConverter.NAME})
+public class ConverterProcessor extends ProcessorBase implements CdkAnnotationProcessor {
+
+ @Override
+ public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException {
+ JsfConverter converter = element.getAnnotation(JsfConverter.class);
+
+ ConverterModel converterModel = new ConverterModel();
+ converterModel.setId(FacesId.parseId(converter.id()));
+
+ try {
+ Class<?> forClass = converter.forClass();
+ if (!JsfConverter.NONE.class.equals(forClass)) {
+ converterModel.setConverterForClass(new ClassName(forClass.getName()));
+ }
+ } catch (MirroredTypeException e) {
+ String name = e.getTypeMirror().toString();
+ if (!JsfConverter.NONE.class.getName().equals(name)) {
+ converterModel.setConverterForClass(new ClassName(name));
+ }
+ }
+
+ setDescription(converterModel, converter.icon(), getDocComment(element), converter.displayName());
+
+ processAttributes(element, converterModel);
+ setClassNames(element, converterModel, converter.generate());
+
+ setTagInfo(converter.tag(), converterModel);
+
+ library.getConverters().add(converterModel);
+ }
+
+ @Override
+ public Class<? extends Annotation> getProcessedAnnotation() {
+ return JsfConverter.class;
+ }
+
+
+ protected String[] getAnnotationAttributes(TypeElement element) {
+ JsfConverter converter = element.getAnnotation(JsfConverter.class);
+
+ return converter.attributes();
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ConverterProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java (from rev 16654, 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/processors/ProcessorBase.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,156 @@
+package org.richfaces.cdk.apt.processors;
+
+import com.google.common.collect.Sets;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.Icon;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
+import org.richfaces.cdk.model.BeanModelBase;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.DescriptionGroup;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.model.TagModel;
+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 java.util.Collection;
+import java.util.Set;
+
+public abstract class ProcessorBase {
+
+ private static final String TAG_HANDLER_DEFULT_CLASS = Tag.DEFAULT.class.getName().replace('$', '.');
+
+ @Inject
+ private Provider<SourceUtils> sourceUtils;
+
+
+ @Inject
+ private FragmentParser fragmentParser;
+
+ @Inject
+ private AttributeProcessor attributeProcessor;
+
+ public FragmentParser getFragmentParser() {
+ return this.fragmentParser;
+ }
+
+ public SourceUtils getSourceUtils() {
+ return this.sourceUtils.get();
+ }
+
+ protected void setTagInfo(Tag tag, ModelElementBase model) {
+
+ String name = tag.name();
+
+ TagModel tagModel = new TagModel();
+ tagModel.setName(name);
+ tagModel.setTargetClass(ClassName.parseName(tag.handlerName()));
+ tagModel.setType(tag.type());
+ // TODO - set base class name,
+ // TODO - move refference integrity to model.
+ tagModel.setModel(model);
+ model.setTag(tagModel);
+ }
+
+ protected void setIcon(DescriptionGroup component, Icon icon) {
+ if (null != icon && (!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);
+ }
+ }
+
+ protected void setDescription(DescriptionGroup component, Icon icon, String description, String displayName) {
+ component.setDescription(description);
+
+ if (icon != null) {
+ setIcon(component, icon);
+ }
+
+ if (!Strings.isEmpty(displayName)) {
+ component.setDisplayname(displayName);
+ }
+ }
+
+ protected void setClassNames(TypeElement componentElement, ModelElementBase modelElement,
+ String generatedClass) {
+
+ 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(componentElement.getQualifiedName().toString()));
+ }
+
+ protected Collection<PropertyBase> parseProperties(String attributesConfig) {
+ return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES + attributesConfig + ".xml");
+ }
+
+ 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.
+ SourceUtils sourceUtils = getSourceUtils();
+ ClassName componentClassName = asClassDesctiption(componentElement);
+ sourceUtils.visitSupertypes(componentClassName, 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 ?
+ }
+ }
+ });
+
+ // Process all files from @Jsf.. attributes property.
+ for(String annotationAttributes : getAnnotationAttributes(componentElement)){
+ try {
+ component.getAttributes().addAll(parseProperties(
+ CdkEntityResolver.URN_ATTRIBUTES + annotationAttributes));
+ } catch (CdkException e) {
+ // TODO - log errors ?
+ }
+ }
+
+ Set<BeanProperty> properties = Sets.newHashSet();
+ properties.addAll(sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class, componentClassName));
+ properties.addAll(sourceUtils.getAbstractBeanProperties(componentClassName));
+
+ // TODO - encapsulate attribute builder into utility class.
+ for (BeanProperty beanProperty : properties) {
+ attributeProcessor.process(beanProperty, component.getOrCreateAttribute(beanProperty.getName()));
+ }
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ProcessorBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java (from rev 16654, 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/processors/RendererProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,168 @@
+/**
+ * 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.processors;
+
+import com.google.inject.Inject;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.annotations.Family;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.templatecompiler.RendererTemplateParser;
+import org.richfaces.cdk.util.Strings;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.faces.render.RenderKitFactory;
+import javax.lang.model.element.TypeElement;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.lang.annotation.Annotation;
+
+/**
+ * @author akolonitsky
+ * @since Dec 30, 2009
+ */
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfRenderer.NAME})
+public class RendererProcessor extends ProcessorBase implements CdkAnnotationProcessor {
+
+ @Inject
+ @Source(Sources.RENDERER_TEMPLATES)
+ private FileManager sources;
+
+ @Inject
+ private RendererTemplateParser templateParser;
+
+ public void process(TypeElement rendererElement, ComponentLibrary library) {
+ JsfRenderer annotation = rendererElement.getAnnotation(JsfRenderer.class);
+
+ RendererModel rendererModel = process(rendererElement, annotation, library);
+
+ addToRenderKit(annotation, library, rendererModel);
+
+/* ComponentModel componentModel = library.getComponentModel(rendererModel.getFamily());
+ if (componentModel != null) {
+ componentModel.getRenderers().add(rendererModel);
+ } else {
+ System.out.println("For renderer with type (" + rendererModel.getType() + ") and family ("
+ + rendererModel.getFamily() + ") comopnent was not found");
+ }*/
+ }
+
+ public RendererModel process(TypeElement rendererElement, JsfRenderer annotation, ComponentLibrary library) {
+ RendererModel rendererModel = new RendererModel();
+ rendererModel.setRendererClass(new ClassName(rendererElement.getQualifiedName().toString()));
+
+ setRendererType(rendererModel, annotation);
+ setComponentFamily(rendererModel, annotation);
+ setDescription(rendererModel, annotation.icon(), getDocComment(rendererElement), annotation.displayName());
+
+ setTemplate(rendererModel, annotation);
+
+// processFacets(componentElement, renderer);
+// processEvents(componentElement, renderer);
+ // TODO - process renderers ( @JsfRenderer and @RendererTemplate attribute.
+ // TODO - process @Test annotations.
+// processAttributes(componentElement, component);
+ return rendererModel;
+ }
+
+ private void addToRenderKit(JsfRenderer annotation, ComponentLibrary library, RendererModel rendererModel) {
+ String renderKitId = annotation.renderKitId();
+ if (Strings.isEmpty(renderKitId)) {
+ renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT; // TODO ???
+ }
+ library.addRenderer(renderKitId, rendererModel);
+ }
+
+ private void setTemplate(RendererModel rendererModel, JsfRenderer annotation) {
+ String template = annotation.template();
+ if (!Strings.isEmpty(template)) {
+ rendererModel.setTemplatePath(template);
+
+ // TODO - add template to source list to process it in appropriate builder.
+ processRendererTemplate(rendererModel);
+ }
+ }
+
+ private void processRendererTemplate(RendererModel renderer) {
+ String templatePath = renderer.getTemplatePath();
+ try {
+
+ File file = sources.getFile(templatePath);
+ templateParser.build(file, renderer);
+ } catch (FileNotFoundException e) {
+ // TODO log
+ e.printStackTrace();
+ }
+ }
+
+ private void setComponentFamily(RendererModel rendererModel, JsfRenderer annotation) {
+ String family = annotation.family();
+ if (!Strings.isEmpty(family)) {
+ rendererModel.setFamily(family);
+ }
+ }
+
+ private void setRendererType(RendererModel rendererModel, JsfRenderer annotation) {
+ String type = annotation.type();
+ if (!Strings.isEmpty(type)) {
+ rendererModel.setType(new RendererModel.Type(type));
+ }
+ }
+
+ protected String getComponentType(TypeElement componentElement) {
+ JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
+ if (annotation != null) {
+ return annotation.type();
+ }
+
+ return null;
+ }
+
+ private void setRendererFamily(TypeElement rendererElement, RendererModel renderer) {
+ Family family = rendererElement.getAnnotation(Family.class);
+
+ if (null != family) {
+ renderer.setFamily(family.value());
+ } else {
+ // static final COMPONENT_FAMILY string constant.
+ Object value = getSourceUtils().getConstant(asClassDesctiption(rendererElement), "COMPONENT_FAMILY");
+ if (null != value) {
+ renderer.setFamily(value.toString());
+ }
+ }
+ }
+
+ @Override
+ public Class<? extends Annotation> getProcessedAnnotation() {
+ return JsfRenderer.class;
+ }
+
+ protected String[] getAnnotationAttributes(TypeElement componentElement) {
+ return null;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/RendererProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java (from rev 16654, 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/processors/ValidatorProcessor.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ValidatorProcessor.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,64 @@
+/**
+ * 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.processors;
+
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.annotations.JsfValidator;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.ValidatorModel;
+
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
+
+/**
+ * @author akolonitsky
+ * @since Jan 13, 2010
+ */
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfValidator.NAME})
+public class ValidatorProcessor extends ProcessorBase implements CdkAnnotationProcessor {
+
+ @Override
+ public void process(TypeElement element, ComponentLibrary library) throws CdkProcessingException {
+ JsfValidator validator = element.getAnnotation(JsfValidator.class);
+
+ ValidatorModel validatorModel = new ValidatorModel(FacesId.parseId(validator.id()));
+ setClassNames(element, validatorModel, validator.generate());
+ setDescription(validatorModel, validator.icon(), getDocComment(element), validator.displayName());
+
+ setTagInfo(validator.tag(), validatorModel);
+
+ library.getValidators().add(validatorModel);
+ }
+
+ @Override
+ public Class<? extends Annotation> getProcessedAnnotation() {
+ return JsfValidator.class;
+ }
+
+
+ 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/generate/java/ClassGeneratorModule.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -41,7 +41,7 @@
@Override
protected void configure() {
Multibinder<CdkWriter> setBinder = Multibinder.newSetBinder(binder(), CdkWriter.class);
-// setBinder.addBinding().to(ComponentClassGenerator.class);
+ setBinder.addBinding().to(ComponentClassGenerator.class);
setBinder.addBinding().to(ConverterClassGenerator.class);
setBinder.addBinding().to(ValidatorClassGenerator.class);
setBinder.addBinding().to(BehaviorClassGenerator.class);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -179,6 +179,20 @@
return renderKits.get(id);
}
+ public void addRenderer(RenderKitModel.Id renderKitId, RendererModel rendererModel) {
+ RenderKitModel renderKit = this.renderKits.get(renderKitId);
+ if (renderKit == null) {
+ renderKit = new RenderKitModel();
+ this.renderKits.put(renderKitId, renderKit);
+ }
+
+ renderKit.getRenderers().add(rendererModel);
+ }
+
+ public void addRenderer(String renderKitId, RendererModel rendererModel) {
+ this.addRenderer(new RenderKitModel.Id(renderKitId), rendererModel);
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -32,7 +32,7 @@
* relation.
* </p>
*/
- private final ModelCollection<RendererModel> renderers = ModelCollection.<RendererModel>create();
+// private final ModelCollection<RendererModel> renderers = ModelCollection.<RendererModel>create();
private String family;
@@ -47,10 +47,10 @@
public void accept(Visitor visitor) {
visitor.visitComponent(this);
- // TODO ??? see at render kit
- for (RendererModel renderer : renderers) {
- renderer.accept(visitor);
- }
+// TODO ??? see at render kit
+// for (RendererModel renderer : renderers) {
+// renderer.accept(visitor);
+// }
}
@Override
@@ -59,7 +59,7 @@
ComponentLibrary.merge(getAttributes(), otherComponent.getAttributes());
ComponentLibrary.merge(getFacets(), otherComponent.getFacets());
ComponentLibrary.merge(getEvents(), otherComponent.getEvents());
- ComponentLibrary.merge(getRenderers(), otherComponent.getRenderers());
+// ComponentLibrary.merge(getRenderers(), otherComponent.getRenderers());
ComponentLibrary.merge(this, otherComponent);
this.setGenerate(this.isGenerate() || otherComponent.isGenerate());
}
@@ -176,7 +176,7 @@
* TODO - synchronize renderers collection with library ?
* @return the renderers
*/
- public Collection<RendererModel> getRenderers() {
- return renderers;
- }
+// public Collection<RendererModel> getRenderers() {
+// return renderers;
+// }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -41,6 +41,7 @@
private String templatePath;
private Template template;
private Type type;
+ private RenderKitModel.Id renderKitId;
private boolean rendersChildren;
@@ -188,6 +189,14 @@
return false;
}
+ public RenderKitModel.Id getRenderKitId() {
+ return renderKitId;
+ }
+
+ public void setRenderKitId(RenderKitModel.Id renderKitId) {
+ this.renderKitId = renderKitId;
+ }
+
/**
* <p class="changed_added_4_0">FacesId for lookup renderer in the model.</p>
* @author asmirnov(a)exadel.com
@@ -206,4 +215,9 @@
super(type);
}
}
+
+ @Override
+ public String toString() {
+ return "Renderer {type: " + getType() + ", family: " + getFamily() + "}";
+ }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -25,10 +25,19 @@
import com.google.inject.Inject;
import freemarker.template.TemplateException;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Output;
+import org.richfaces.cdk.Outputs;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.ModelCollection;
+import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.model.RenderKitModel;
+import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.templatecompiler.builder.model.JavaClass;
-import org.richfaces.cdk.*;
-import org.richfaces.cdk.model.*;
-import org.richfaces.cdk.model.RendererModel.Type;
import org.richfaces.cdk.templatecompiler.model.Template;
import java.io.IOException;
@@ -70,24 +79,18 @@
private ComponentModel findComponentByRenderer(RendererModel renderer) {
String rendererFamily = renderer.getFamily();
- Type rendererType = renderer.getType();
+ if (rendererFamily == null) {
+ return null;
+ }
+
+ Collection<ComponentModel> components = library.getComponents();
+ if (components == null) {
+ return null;
+ }
- Collection<ComponentModel> components = library.getComponents();
- if (components != null) {
- for (ComponentModel component : components) {
- if (!rendererFamily.equals(component.getFamily())) {
- continue;
- }
-
- //TODO - compare renderkit Id?
- Collection<RendererModel> renderers = component.getRenderers();
- if (renderers != null) {
- for (RendererModel rendererModel : renderers) {
- if (rendererType.equals(rendererModel.getType())) {
- return component;
- }
- }
- }
+ for (ComponentModel component : components) {
+ if (rendererFamily.equals(component.getFamily())) {
+ return component;
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -53,7 +53,9 @@
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;
@@ -71,6 +73,9 @@
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;
@@ -108,14 +113,11 @@
}
Set<EventName> result = Sets.newLinkedHashSet();
-
- if (clientBehaviors != null) {
- for (ClientBehavior clientBehavior : clientBehaviors) {
- EventName eventName = new EventName();
- eventName.setName(clientBehavior.getEvent());
- eventName.setDefaultEvent(clientBehavior.isDefaultEvent());
- result.add(eventName);
- }
+ for (ClientBehavior clientBehavior : clientBehaviors) {
+ EventName eventName = new EventName();
+ eventName.setName(clientBehavior.getEvent());
+ eventName.setDefaultEvent(clientBehavior.isDefaultEvent());
+ result.add(eventName);
}
return result;
@@ -127,23 +129,20 @@
}
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 (signatureString != null) {
- 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).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));
- }
- }
}
return result;
@@ -164,8 +163,18 @@
}
}
- private void build(File file, RendererModel rendererModel) {
+ public void build(File file, RendererModel rendererModel) {
+ System.out.println("RendererTemplateParser.build");
+ System.out.println(" - file = " + file.getAbsolutePath());
+ System.out.println(" - renderer = " + rendererModel);
+
+ if (PROCESSED_TEMPLATES.containsKey(file.getAbsolutePath())) {
+ System.out.println(" - Template was already processed.");
+ return;
+ }
+
Template template = parseTemplate(file);
+ PROCESSED_TEMPLATES.put(file.getAbsolutePath(), template);
// TODO rewrite it
final String defaultTemplate = "src\\main\\templates";
@@ -178,7 +187,6 @@
protected void mergeTemplateIntoModel(Template template, RendererModel renderer) throws CdkException {
CompositeInterface compositeInterface = template.getInterface();
- // TODO - infer values ?
if (renderer == null) {
renderer = new RendererModel();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -25,11 +25,8 @@
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.RendererModel;
-import java.util.Collection;
-
/**
* <p class="changed_added_4_0"></p>
*
@@ -57,6 +54,7 @@
super.postUnmarshal(bean, model);
// Copy properties/attributes
+/*
Collection<RendererModel> renderers = model.getRenderers();
ComponentBean.ComponentExtension extension = bean.getExtension();
if (renderers != null && extension != null) {
@@ -64,5 +62,6 @@
renderers.add(new RendererModel(new RendererModel.Type(renderType)));
}
}
+*/
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-03-26 20:32:24 UTC (rev 16676)
@@ -31,33 +31,37 @@
public class ${componentClass.simpleName} extends ${baseClass.simpleName} <#if (eventNames?size > 0)>implements ClientBehaviorHolder</#if> {
public static final String COMPONENT_TYPE="${type}";
+
<#if family?exists>
public static final String COMPONENT_FAMILY="${family}";
@Override
public String getFamily() {
- return (COMPONENT_FAMILY);
+ return COMPONENT_FAMILY;
}</#if>
+
<#if (eventNames?size > 0)>
private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
- <@concat seq=eventNames ; event>"${event.name}"</@concat>
+ <#list eventNames as event>"${event.name}"<#if event_has_next>${",\n "}</#if></#list>
));
+
public Collection<String> getEventNames() {
- return EVENT_NAMES; }
+ return EVENT_NAMES;
+ }
public String getDefaultEventName() {
return <#if defaultEvent?exists>"${defaultEvent.name}"<#else>null</#if>;
}</#if>
- protected enum Properties {
+ protected static enum Properties {
<#list generatedAttributes as attribute>${attribute.name}<#if attribute_has_next>${",\n "}</#if></#list>
}
<#list generatedAttributes as attribute>
public ${attribute.simpleTypeName} ${attribute.getterName}() {
- return (${attribute.typeForCasting}) getStateHelper().eval(Properties.${attribute.name});
+ return (${attribute.typeForCasting}) getStateHelper().eval(Properties.${attribute.name}<#if attribute.defaultValue?exists>, ${attribute.defaultValue}</#if>);
}
public void ${attribute.setterName}(${attribute.simpleTypeName} ${attribute.name}) {
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,144 +0,0 @@
-/**
- * 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 com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Generator;
-import org.richfaces.cdk.LibraryBuilder;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.Source;
-import org.richfaces.cdk.SourceFileManager;
-import org.richfaces.cdk.SourceImpl;
-import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.model.ComponentModel;
-
-import javax.el.ELContext;
-import javax.faces.component.UIComponent;
-import javax.lang.model.element.Name;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author akolonitsky
- * @since Jan 14, 2010
- */
-public abstract class AnnotationProcessorTest extends CdkTestBase {
-
- protected static final class TestName implements Name {
-
- private final String name;
-
- public TestName(String name) {
- this.name = name;
- }
- @Override
- public boolean contentEquals(CharSequence cs) {
- // TODO Auto-generated method stub
- return name.equals(cs);
- }
-
- @Override
- public char charAt(int index) {
- return name.charAt(index);
- }
-
- @Override
- public int length() {
- return name.length();
- }
-
- @Override
- public CharSequence subSequence(int start, int end) {
- return name.substring(start, end);
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-
- protected static final String FOO_BAR = "foo.Bar";
-
- @Inject
- @Source(Sources.JAVA_SOURCES)
- protected FileManager sources;
-
- @Mock
- protected Logger log;
-
- @Inject
- private Injector injector;
-
- protected void process(String javaFilePath) throws Exception {
- Generator generator = new Generator();
- generator.setLoader(createClassLoader());
- generator.addSources(Sources.JAVA_SOURCES, ImmutableList.of(getJavaFile(javaFilePath)), null);
-
- generator.init();
- injector.injectMembers(new ComponentProcessor());
-
- LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
- builder.build();
- }
-
- @Override
- public void configure(Binder binder) {
- super.configure(binder);
- try {
- CdkClassLoader cdkClassLoader = createClassLoader();
- binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
- List<File> sourceFiles = new ArrayList<File>();
- for (String src : sources()) {
- sourceFiles.add(getJavaFile(src));
- }
- binder.bind(FileManager.class).annotatedWith(new SourceImpl(Sources.JAVA_SOURCES)).toInstance(
- new SourceFileManager(sourceFiles, this.testSourceDirectory));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
-
- protected abstract Iterable<String> sources();
-
- @Override
- protected CdkClassLoader createClassLoader() {
- try {
- return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class), getLibraryFile(Family.class),
- getLibraryFile(UIComponent.class)), this.getClass().getClassLoader());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
Deleted: 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-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.cdk.apt;
-
-import com.google.inject.Inject;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-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.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;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * @author akolonitsky
- * @since Jan 21, 2010
- */
-(a)RunWith(CdkTestRunner.class)
-public class BehaviorProcessorTest extends AnnotationProcessorTest {
- private static final String MY_BEHAVIOR = "my_behavior";
-
- private static final String BEHAVIOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyBehavior.java";
-
- @Inject
- private BehaviorProcessor processor;
-
- @Inject
- private ComponentLibrary library;
-
- @Mock
- private SourceUtils utils;
-
- @Mock
- private TypeElement componentElement;
-
- @Stub
- private Name name;
-
- @Stub
- private Tag tag;
-
- @Mock
- private JsfBehavior behaviorAnnotation;
-
- @Mock
- private JAXB jaxb;
-
- @Mock
- private NamingConventions conventions;
-
-
- @Test
- @Ignore
- public void testProcess() throws Exception {
-
- 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, library);
- verify(log, utils, componentElement, jaxb, conventions,behaviorAnnotation,tag,name);
- Collection<BehaviorModel> behaviors = library.getBehaviors();
-
- assertEquals(1, behaviors.size());
-
- for (BehaviorModel model : behaviors) {
- FacesId id = model.getId();
- if (id != null ) {
- assertEquals(MY_BEHAVIOR, id.toString());
- }
- }
- }
-
- @Override
- protected Iterable<String> sources() {
- return Collections.singleton(BEHAVIOR_CLASS_JAVA);
- }
-
-}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -45,6 +45,8 @@
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
+import org.richfaces.cdk.apt.processors.CdkAnnotationProcessor;
+import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import org.richfaces.cdk.model.ComponentLibrary;
import javax.annotation.processing.Processor;
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,285 +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 static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-
-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.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.Facet;
-import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
-import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.FacetModel;
-import org.richfaces.cdk.model.PropertyBase;
-import org.richfaces.cdk.xmlconfig.JAXB;
-
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-
-/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-(a)RunWith(CdkTestRunner.class)
-public class ComponentProcessorTest extends AnnotationProcessorTest {
- public static final String SMALL_JPG = "/icons/Small.jpg";
- public static final String LARGE_GIF = "/icons/Large.gif";
- private static final String FOO_HTML_BAR = "foo.HtmlBar";
- private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
- private static final String FACES_COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/UITestCommand.java";
-
- @Inject
- private ComponentProcessor processor;
-
- @Inject
- private ComponentLibrary library;
-
- @Inject
- private ComponentModel model;
-
- @Mock
- private SourceUtils utils;
-
- @Mock
- private TypeElement componentElement;
-
- @Mock
- private JsfComponent annotation;
-
- @Mock
- private JAXB jaxb;
-
- @Mock
- private BeanProperty property;
-
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
- *
- * @throws Exception
- */
- @Test
- public void testSetClassNames() throws Exception {
- expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>emptySet());
- expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
- replay(log, utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model,"");
- verify(log, utils, componentElement, jaxb,annotation );
- assertFalse(model.isGenerate());
- assertEquals(FOO_BAR, model.getBaseClass().toString());
- assertNull(model.getTargetClass());
- }
-
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
- *
- * @throws Exception
- */
- @Test
- public void testSetClassNames1() throws Exception {
- expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>singleton(Modifier.ABSTRACT));
- expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
- replay(log, utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model,"");
- verify(log, utils, componentElement, jaxb,annotation );
- assertTrue(model.isGenerate());
- assertEquals(FOO_BAR, model.getBaseClass().toString());
- assertNull(model.getTargetClass());
- }
- /**
- * Test method for
- * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
- *
- * @throws Exception
- */
- @Test
- public void testSetClassNames2() throws Exception {
- expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>emptySet());
- expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
- replay(log, utils, componentElement, jaxb, annotation);
- processor.setClassNames(componentElement, model,FOO_HTML_BAR);
- verify(log, utils, componentElement, jaxb,annotation );
- assertTrue(model.isGenerate());
- assertEquals(FOO_BAR, model.getBaseClass().toString());
- assertEquals(FOO_HTML_BAR,model.getTargetClass().toString());
- }
-
- @Test
- public void testSetFamily() throws Exception {
- replay(log, utils, componentElement, jaxb, annotation);
- processor.setComponeneFamily(componentElement, model,FOO_HTML_BAR);
- verify(log, utils, componentElement, jaxb,annotation );
- assertEquals(FOO_HTML_BAR, model.getFamily());
- }
-
- @Test
- public void testSetFamily1() throws Exception {
- TestName fooBar = new TestName(FOO_BAR);
- expect(componentElement.getQualifiedName()).andReturn(fooBar);
- expect(utils.getConstant(eq(ClassName.parseName(FOO_BAR)), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(FOO_HTML_BAR);
- replay(log, utils, componentElement, jaxb, annotation);
- processor.setComponeneFamily(componentElement, model,"");
- verify(log, utils, componentElement, jaxb,annotation );
- assertEquals(FOO_HTML_BAR, model.getFamily());
- }
-
- @Test
- public void testSetFamily2() throws Exception {
- TestName fooBar = new TestName(FOO_BAR);
- expect(componentElement.getQualifiedName()).andReturn(fooBar);
- expect(utils.getConstant(eq(ClassName.parseName(FOO_BAR)), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(null);
- replay(log, utils, componentElement, jaxb, annotation);
- processor.setComponeneFamily(componentElement, model,"");
- verify(log, utils, componentElement, jaxb,annotation );
- assertNull( model.getFamily());
- }
-
- @Test
- public void testSetIcon() throws Exception {
- Icon icon = createMock(Icon.class);
- expect(icon.large()).andReturn(LARGE_GIF).atLeastOnce();
- expect(icon.small()).andReturn(SMALL_JPG).atLeastOnce();
- replay(log, utils, componentElement, jaxb, annotation,icon);
- processor.setIcon(model, icon);
- verify(log, utils, componentElement, jaxb,annotation,icon );
- assertNotNull(model.getIcon());
- assertEquals(LARGE_GIF, model.getIcon().getLargeIcon());
- assertEquals(SMALL_JPG, model.getIcon().getSmallIcon());
- }
-
- @Test
- public void testSetIcon1() throws Exception {
- Icon icon = createMock(Icon.class);
- expect(icon.large()).andReturn("").atLeastOnce();
- expect(icon.small()).andReturn("").atLeastOnce();
- replay(log, utils, componentElement, jaxb, annotation,icon);
- processor.setIcon(model, icon);
- verify(log, utils, componentElement, jaxb,annotation,icon );
- assertNull(model.getIcon());
- }
-
- @Test
- public void testProcessFacetsFromProperty() throws Exception {
- Facet facet = createMock(Facet.class);
- expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
- expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.singleton(property));
- expect(annotation.facets()).andReturn(new Facet[0]);
- expect(property.getAnnotation(Facet.class)).andReturn(facet);
- expect(property.getName()).andReturn("foo");
- expect(property.getDocComment()).andReturn("my comment");
- expect(property.isExists()).andReturn(true);
- expect(facet.icon()).andReturn(null);
- expect(facet.displayName()).andReturn("fooFacet");
- expect(facet.generate()).andReturn(true);
- replay(log, utils, componentElement, jaxb, annotation,property,facet);
- processor.processFacets(componentElement, model, annotation);
- verify(log, utils, componentElement, jaxb,annotation,property,facet);
- assertEquals(1, model.getFacets().size());
- FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
- assertTrue(facetModel.isGenerate());
- assertEquals("foo", facetModel.getName());
- assertEquals("my comment", facetModel.getDescription());
- assertEquals("fooFacet", facetModel.getDisplayname());
- assertNull(facetModel.getIcon());
- }
- @Test
- public void testProcessFacetsFromAnnotation() throws Exception {
- Facet facet = createMock(Facet.class);
- expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
- expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.<BeanProperty>emptySet());
- expect(annotation.facets()).andReturn(new Facet[]{facet});
- expect(facet.name()).andReturn("foo");
- expect(facet.icon()).andReturn(null);
- expect(facet.displayName()).andReturn("fooFacet");
- expect(facet.generate()).andReturn(true);
- replay(log, utils, componentElement, jaxb, annotation,property,facet);
- processor.processFacets(componentElement, model, annotation);
- verify(log, utils, componentElement, jaxb,annotation,property,facet);
- assertEquals(1, model.getFacets().size());
- FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
- assertTrue(facetModel.isGenerate());
- assertEquals("foo", facetModel.getName());
-// assertEquals("my comment", facetModel.getDescription());
- assertEquals("fooFacet", facetModel.getDisplayname());
- assertNull(facetModel.getIcon());
- }
-
- @Test
- public void testProcessAttributesFromProperty() throws Exception {
- Attribute attribute = createNiceMock(Attribute.class);
- expect(componentElement.getQualifiedName()).andStubReturn(new TestName(FOO_BAR));
- expect(componentElement.getAnnotation(JsfComponent.class)).andReturn(annotation);
- expect(annotation.attributes()).andReturn(new String[0]);
- utils.visitSupertypes(eq(ClassName.parseName(FOO_BAR)), (SuperTypeVisitor) anyObject());expectLastCall();
- expect(utils.getBeanPropertiesAnnotatedWith(eq(Attribute.class),eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.singleton(property));
- expect(utils.getAbstractBeanProperties(eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.<BeanProperty>emptySet());
- expect(property.getName()).andReturn("foo");
- expect(property.getType()).andReturn(ClassName.parseName("java.lang.Integer"));
- expect(property.getAnnotation(Attribute.class)).andReturn(attribute);
- expect(property.getDocComment()).andReturn("my comment");
-// expect(property.isExists()).andReturn(true);
- expect(attribute.icon()).andReturn(null);
- expect(attribute.displayName()).andReturn("fooFacet");
- expect(attribute.generate()).andReturn(true);
- expect(attribute.events()).andReturn(new EventName[]{});
- replay(log, utils, componentElement, jaxb, annotation,property,attribute);
- processor.processAttributes(componentElement, model);
- verify(log, utils, componentElement, jaxb,annotation,property,attribute);
- assertEquals(1, model.getAttributes().size());
- PropertyBase propertyModel = Iterables.getOnlyElement(model.getAttributes());
- assertTrue(propertyModel.isGenerate());
- assertEquals("foo", propertyModel.getName());
- assertEquals("my comment", propertyModel.getDescription());
- assertEquals("fooFacet", propertyModel.getDisplayname());
- assertEquals(ClassName.parseName("java.lang.Integer"), propertyModel.getType());
- assertNull(propertyModel.getIcon());
- }
-
- @Override
- protected Iterable<String> sources() {
- return Collections.singleton(COMPONENT_CLASS_JAVA);
- }
-
-}
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,67 +0,0 @@
-/**
- * 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 com.google.common.collect.Iterables;
-import com.google.inject.Inject;
-import static org.junit.Assert.assertEquals;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ConverterModel;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * @author akolonitsky
- * @since Jan 14, 2010
- */
-(a)RunWith(CdkTestRunner.class)
-public class ConverterProcessorTest extends AnnotationProcessorTest {
- private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/MyConverter.java";
-
- @Inject
- private ComponentLibrary library;
-
- @Test
- @Ignore
- public void testProcess() throws Exception {
- Collection<ConverterModel> converters = library.getConverters();
-
- assertEquals(3, converters.size());
-
- ConverterModel converterModel = Iterables.get(converters, 0);
- ClassName forClass = converterModel.getConverterForClass();
- if (forClass != null && !Object.class.getName().equals(forClass.getName())) {
- assertEquals(Integer.class.getName(), forClass.getName());
- }
- }
-
- @Override
- protected Iterable<String> sources() {
- return Collections.singleton(COMPONENT_CLASS_JAVA);
- }
-}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/TaskFactoryTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -46,6 +46,7 @@
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
import org.richfaces.cdk.Stub;
+import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
Deleted: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,192 +0,0 @@
-/**
- * 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 com.google.inject.Inject;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.annotations.JsfValidator;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.FacesId;
-import org.richfaces.cdk.model.ValidatorModel;
-
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Name;
-import javax.lang.model.element.TypeElement;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author akolonitsky
- * @since Jan 14, 2010
- */
-(a)RunWith(CdkTestRunner.class)
-public class ValidatorProcessorTest extends AnnotationProcessorTest {
- private static final String VALIDATOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyValidator.java";
- @Inject
- private ComponentLibrary library;
-
- @Override
- protected Iterable<String> sources() {
- return Collections.singleton(VALIDATOR_CLASS_JAVA);
- }
-
- @Test
- @Ignore
- public void testProcess() throws Exception {
- Collection<ValidatorModel> validators = library.getValidators();
-
- assertEquals(2, validators.size());
-
- for (ValidatorModel model : validators) {
- FacesId id = model.getId();
- if (id != null ) {
- assertEquals("my_validator", id.toString());
- }
- }
- }
-
- // TODO create Test for ProcessorBase
- @Test
-
- public void testSetNames() {
- ValidatorModel model;
-
- // @JsfValidator public class BaseClass { ...
- model = getValidatorModelForSetNames(true, null, "BaseClass", false);
- check("BaseClass", null, false, model);
-
- // @JsfValidator(validatorClass = "") public class BaseClass { ...
- model = getValidatorModelForSetNames(true, "", "BaseClass", false);
- check("BaseClass", null, false, model);
-
- // @JsfValidator(validatorClass = BaseClass) public class BaseClass { ...
- model = getValidatorModelForSetNames(true, "BaseClass", "BaseClass", false);
- check("BaseClass", null, false, model);
-
- // @JsfValidator(validatorClass = GeneratedClass) public class BaseClass { ...
- model = getValidatorModelForSetNames(true, "GeneratedClass", "BaseClass", false);
- check("GeneratedClass", "BaseClass", true, model);
-
- // /////////////////////////////// ABSTRACT ///////////////////////////////////////
- // @JsfValidator public abstract class BaseClass { ...
-// checkAbstractWithException(null);
-
- // @JsfValidator(validatorClass = "") public abstract class BaseClass { ...
-// checkAbstractWithException("");
-
- // @JsfValidator(validatorClass = BaseClass) public abstract class BaseClass { ...
-// checkAbstractWithException("BaseClass");
-
- // @JsfValidator(validatorClass = GeneratedClass) public abstract class BaseClass { ...
- model = getValidatorModelForSetNames(true, "GeneratedClass", "BaseClass", true);
- check("GeneratedClass", "BaseClass", true, model);
- }
-
- private void checkAbstractWithException(String validatorClass) {
- try {
- getValidatorModelForSetNames(true, validatorClass, "BaseClass", true);
- Assert.fail("Abstract class can't be a validator.");
- } catch (IllegalStateException e) {
- // Do nothing.
- }
- }
-
- private void check(String validatorClass, String baseClass, boolean generate, ValidatorModel model) {
- if (baseClass != null) {
-// assertEquals(model.getBaseClass().toString(), baseClass);
- } else {
- assertNull(model.getBaseClass());
- }
-
-
-// assertEquals(generate, model.isGenerate());
- }
-
- private ValidatorModel getValidatorModelForSetNames(boolean isAnnotationDefined, String validatorClass,
- final String baseClass, boolean isAbstractPresent) {
- Name name = new MyName(baseClass);
-
- TypeElement element = EasyMock.createMock(TypeElement.class);
- EasyMock.expect(element.getQualifiedName()).andReturn(name);
-
- Set<Modifier> set = new HashSet<Modifier>(1);
- if (isAbstractPresent) {
- set.add(Modifier.ABSTRACT);
- }
- EasyMock.expect(element.getModifiers()).andReturn(set);
- EasyMock.replay(element);
-
- ValidatorModel validatorModel = new ValidatorModel();
- JsfValidator validator = null;
- if (isAnnotationDefined) {
- validator = EasyMock.createMock(JsfValidator.class);
- EasyMock.expect(validator.generate()).andReturn(validatorClass);
- EasyMock.replay(validator);
- }
-
- EasyMock.verify();
-// ValidatorProcessor.setClassNames(element, validatorModel, validator);
- return validatorModel;
- }
-
- private static class MyName implements Name {
- private final String toString;
-
- MyName(String toString) {
- this.toString = toString;
- }
-
- @Override
- public int length() {
- return 0;
- }
-
- @Override
- public char charAt(int index) {
- return 0;
- }
-
- @Override
- public CharSequence subSequence(int start, int end) {
- return null;
- }
-
- @Override
- public String toString() {
- return toString;
- }
-
- @Override
- public boolean contentEquals(CharSequence cs) {
- return false;
- }
- }
-}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java (from rev 16654, root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/AnnotationProcessorTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AnnotationProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,145 @@
+/**
+ * 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.processors;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Generator;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.SourceFileManager;
+import org.richfaces.cdk.SourceImpl;
+import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.apt.processors.ComponentProcessor;
+import org.richfaces.cdk.annotations.Family;
+import org.richfaces.cdk.model.ComponentModel;
+
+import javax.el.ELContext;
+import javax.faces.component.UIComponent;
+import javax.lang.model.element.Name;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author akolonitsky
+ * @since Jan 14, 2010
+ */
+public abstract class AnnotationProcessorTest extends CdkTestBase {
+
+ protected static final class TestName implements Name {
+
+ private final String name;
+
+ public TestName(String name) {
+ this.name = name;
+ }
+ @Override
+ public boolean contentEquals(CharSequence cs) {
+ // TODO Auto-generated method stub
+ return name.equals(cs);
+ }
+
+ @Override
+ public char charAt(int index) {
+ return name.charAt(index);
+ }
+
+ @Override
+ public int length() {
+ return name.length();
+ }
+
+ @Override
+ public CharSequence subSequence(int start, int end) {
+ return name.substring(start, end);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
+ protected static final String FOO_BAR = "foo.Bar";
+
+ @Inject
+ @Source(Sources.JAVA_SOURCES)
+ protected FileManager sources;
+
+ @Mock
+ protected Logger log;
+
+ @Inject
+ private Injector injector;
+
+ protected void process(String javaFilePath) throws Exception {
+ Generator generator = new Generator();
+ generator.setLoader(createClassLoader());
+ generator.addSources(Sources.JAVA_SOURCES, ImmutableList.of(getJavaFile(javaFilePath)), null);
+
+ generator.init();
+ injector.injectMembers(new ComponentProcessor());
+
+ LibraryBuilder builder = injector.getInstance(LibraryBuilder.class);
+ builder.build();
+ }
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ try {
+ CdkClassLoader cdkClassLoader = createClassLoader();
+ binder.bind(CdkClassLoader.class).toInstance(cdkClassLoader);
+ List<File> sourceFiles = new ArrayList<File>();
+ for (String src : sources()) {
+ sourceFiles.add(getJavaFile(src));
+ }
+ binder.bind(FileManager.class).annotatedWith(new SourceImpl(Sources.JAVA_SOURCES)).toInstance(
+ new SourceFileManager(sourceFiles, this.testSourceDirectory));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ protected abstract Iterable<String> sources();
+
+ @Override
+ protected CdkClassLoader createClassLoader() {
+ try {
+ return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
+ getLibraryFile(ComponentModel.class), getLibraryFile(ELContext.class), getLibraryFile(Family.class),
+ getLibraryFile(UIComponent.class)), this.getClass().getClassLoader());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java (from rev 16654, 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/processors/BehaviorProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/BehaviorProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.apt.processors;
+
+import com.google.inject.Inject;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+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.Tag;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
+import org.richfaces.cdk.apt.processors.BehaviorProcessor;
+import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
+import org.richfaces.cdk.apt.SourceUtils;
+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;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+(a)RunWith(CdkTestRunner.class)
+public class BehaviorProcessorTest extends AnnotationProcessorTest {
+ private static final String MY_BEHAVIOR = "my_behavior";
+
+ private static final String BEHAVIOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyBehavior.java";
+
+ @Inject
+ private BehaviorProcessor processor;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Mock
+ private SourceUtils utils;
+
+ @Mock
+ private TypeElement componentElement;
+
+ @Stub
+ private Name name;
+
+ @Stub
+ private Tag tag;
+
+ @Mock
+ private JsfBehavior behaviorAnnotation;
+
+ @Mock
+ private JAXB jaxb;
+
+ @Mock
+ private NamingConventions conventions;
+
+
+ @Test
+ @Ignore
+ public void testProcess() throws Exception {
+
+ 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, library);
+ verify(log, utils, componentElement, jaxb, conventions,behaviorAnnotation,tag,name);
+ Collection<BehaviorModel> behaviors = library.getBehaviors();
+
+ assertEquals(1, behaviors.size());
+
+ for (BehaviorModel model : behaviors) {
+ FacesId id = model.getId();
+ if (id != null ) {
+ assertEquals(MY_BEHAVIOR, id.toString());
+ }
+ }
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(BEHAVIOR_CLASS_JAVA);
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java (from rev 16654, root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,304 @@
+/*
+ * $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.processors;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+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.Source;
+import org.richfaces.cdk.Sources;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.Facet;
+import org.richfaces.cdk.annotations.Icon;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.apt.SourceUtils;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacetModel;
+import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.xmlconfig.JAXB;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import java.util.Collections;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(CdkTestRunner.class)
+public class ComponentProcessorTest extends AnnotationProcessorTest {
+ public static final String SMALL_JPG = "/icons/Small.jpg";
+ public static final String LARGE_GIF = "/icons/Large.gif";
+ private static final String FOO_HTML_BAR = "foo.HtmlBar";
+ private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/AbstractTestComponent.java";
+ private static final String FACES_COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/UITestCommand.java";
+
+ @Inject
+ private ComponentProcessor processor;
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Inject
+ private ComponentModel model;
+
+ @Mock
+ private SourceUtils utils;
+
+ @Mock
+ private TypeElement componentElement;
+
+ @Mock
+ private JsfComponent annotation;
+
+ @Mock
+ private JAXB jaxb;
+
+ @Mock
+ private BeanProperty property;
+
+ @Mock
+ private NamingConventions conventions;
+
+ @Stub
+ @Source(Sources.RENDERER_TEMPLATES)
+ FileManager sources;
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetClassNames() throws Exception {
+ expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>emptySet());
+ expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
+ replay(log, utils, componentElement, jaxb, annotation);
+ processor.setClassNames(componentElement, model,"");
+ verify(log, utils, componentElement, jaxb,annotation );
+ assertFalse(model.isGenerate());
+ assertEquals(FOO_BAR, model.getBaseClass().toString());
+ assertNull(model.getTargetClass());
+ }
+
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetClassNames1() throws Exception {
+ expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>singleton(Modifier.ABSTRACT));
+ expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
+ replay(log, utils, componentElement, jaxb, annotation);
+ processor.setClassNames(componentElement, model,"");
+ verify(log, utils, componentElement, jaxb,annotation );
+ assertTrue(model.isGenerate());
+ assertEquals(FOO_BAR, model.getBaseClass().toString());
+ assertNull(model.getTargetClass());
+ }
+ /**
+ * Test method for
+ * {@link org.richfaces.cdk.apt.CdkProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)} .
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSetClassNames2() throws Exception {
+ expect(componentElement.getModifiers()).andReturn(Collections.<Modifier>emptySet());
+ expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
+ replay(log, utils, componentElement, jaxb, annotation);
+ processor.setClassNames(componentElement, model,FOO_HTML_BAR);
+ verify(log, utils, componentElement, jaxb,annotation );
+ assertTrue(model.isGenerate());
+ assertEquals(FOO_BAR, model.getBaseClass().toString());
+ assertEquals(FOO_HTML_BAR,model.getTargetClass().toString());
+ }
+
+ @Test
+ public void testSetFamily() throws Exception {
+ replay(log, utils, componentElement, jaxb, annotation);
+ processor.setComponeneFamily(componentElement, model,FOO_HTML_BAR);
+ verify(log, utils, componentElement, jaxb,annotation );
+ assertEquals(FOO_HTML_BAR, model.getFamily());
+ }
+
+ @Test
+ public void testSetFamily1() throws Exception {
+ TestName fooBar = new TestName(FOO_BAR);
+ expect(componentElement.getQualifiedName()).andReturn(fooBar);
+ expect(utils.getConstant(eq(ClassName.parseName(FOO_BAR)), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(FOO_HTML_BAR);
+ replay(log, utils, componentElement, jaxb, annotation);
+ processor.setComponeneFamily(componentElement, model,"");
+ verify(log, utils, componentElement, jaxb,annotation );
+ assertEquals(FOO_HTML_BAR, model.getFamily());
+ }
+
+ @Test
+ public void testSetFamily2() throws Exception {
+ TestName fooBar = new TestName(FOO_BAR);
+ expect(componentElement.getQualifiedName()).andReturn(fooBar);
+ expect(utils.getConstant(eq(ClassName.parseName(FOO_BAR)), eq(ComponentProcessor.COMPONENT_FAMILY))).andReturn(null);
+ replay(log, utils, componentElement, jaxb, annotation);
+ processor.setComponeneFamily(componentElement, model,"");
+ verify(log, utils, componentElement, jaxb,annotation );
+ assertNull( model.getFamily());
+ }
+
+ @Test
+ public void testSetIcon() throws Exception {
+ Icon icon = createMock(Icon.class);
+ expect(icon.large()).andReturn(LARGE_GIF).atLeastOnce();
+ expect(icon.small()).andReturn(SMALL_JPG).atLeastOnce();
+ replay(log, utils, componentElement, jaxb, annotation,icon);
+ processor.setIcon(model, icon);
+ verify(log, utils, componentElement, jaxb,annotation,icon );
+ assertNotNull(model.getIcon());
+ assertEquals(LARGE_GIF, model.getIcon().getLargeIcon());
+ assertEquals(SMALL_JPG, model.getIcon().getSmallIcon());
+ }
+
+ @Test
+ public void testSetIcon1() throws Exception {
+ Icon icon = createMock(Icon.class);
+ expect(icon.large()).andReturn("").atLeastOnce();
+ expect(icon.small()).andReturn("").atLeastOnce();
+ replay(log, utils, componentElement, jaxb, annotation,icon);
+ processor.setIcon(model, icon);
+ verify(log, utils, componentElement, jaxb,annotation,icon );
+ assertNull(model.getIcon());
+ }
+
+ @Test
+ public void testProcessFacetsFromProperty() throws Exception {
+ Facet facet = createMock(Facet.class);
+ expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.singleton(property));
+ expect(annotation.facets()).andReturn(new Facet[0]);
+ expect(property.getAnnotation(Facet.class)).andReturn(facet);
+ expect(property.getName()).andReturn("foo");
+ expect(property.getDocComment()).andReturn("my comment");
+ expect(property.isExists()).andReturn(true);
+ expect(facet.icon()).andReturn(null);
+ expect(facet.displayName()).andReturn("fooFacet");
+ expect(facet.generate()).andReturn(true);
+ replay(log, utils, componentElement, jaxb, annotation,property,facet);
+ processor.processFacets(componentElement, model, annotation);
+ verify(log, utils, componentElement, jaxb,annotation,property,facet);
+ assertEquals(1, model.getFacets().size());
+ FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
+ assertTrue(facetModel.isGenerate());
+ assertEquals("foo", facetModel.getName());
+ assertEquals("my comment", facetModel.getDescription());
+ assertEquals("fooFacet", facetModel.getDisplayname());
+ assertNull(facetModel.getIcon());
+ }
+ @Test
+ public void testProcessFacetsFromAnnotation() throws Exception {
+ Facet facet = createMock(Facet.class);
+ expect(componentElement.getQualifiedName()).andReturn(new TestName(FOO_BAR));
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Facet.class),eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.<BeanProperty>emptySet());
+ expect(annotation.facets()).andReturn(new Facet[]{facet});
+ expect(facet.name()).andReturn("foo");
+ expect(facet.icon()).andReturn(null);
+ expect(facet.displayName()).andReturn("fooFacet");
+ expect(facet.generate()).andReturn(true);
+ replay(log, utils, componentElement, jaxb, annotation,property,facet);
+ processor.processFacets(componentElement, model, annotation);
+ verify(log, utils, componentElement, jaxb,annotation,property,facet);
+ assertEquals(1, model.getFacets().size());
+ FacetModel facetModel = Iterables.getOnlyElement(model.getFacets());
+ assertTrue(facetModel.isGenerate());
+ assertEquals("foo", facetModel.getName());
+// assertEquals("my comment", facetModel.getDescription());
+ assertEquals("fooFacet", facetModel.getDisplayname());
+ assertNull(facetModel.getIcon());
+ }
+
+ @Test
+ public void testProcessAttributesFromProperty() throws Exception {
+ Attribute attribute = createNiceMock(Attribute.class);
+ expect(componentElement.getQualifiedName()).andStubReturn(new TestName(FOO_BAR));
+ expect(componentElement.getAnnotation(JsfComponent.class)).andReturn(annotation);
+ expect(annotation.attributes()).andReturn(new String[0]);
+ utils.visitSupertypes(eq(ClassName.parseName(FOO_BAR)), (SuperTypeVisitor) anyObject());expectLastCall();
+ expect(utils.getBeanPropertiesAnnotatedWith(eq(Attribute.class),eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.singleton(property));
+ expect(utils.getAbstractBeanProperties(eq(ClassName.parseName(FOO_BAR)))).andReturn(Collections.<BeanProperty>emptySet());
+ expect(property.getName()).andReturn("foo");
+ expect(property.getType()).andReturn(ClassName.parseName("java.lang.Integer"));
+ expect(property.getAnnotation(Attribute.class)).andReturn(attribute);
+ expect(property.getDocComment()).andReturn("my comment");
+// expect(property.isExists()).andReturn(true);
+ expect(attribute.icon()).andReturn(null);
+ expect(attribute.displayName()).andReturn("fooFacet");
+ expect(attribute.generate()).andReturn(true);
+ expect(attribute.events()).andReturn(new EventName[]{});
+ replay(log, utils, componentElement, jaxb, annotation,property,attribute);
+ processor.processAttributes(componentElement, model);
+ verify(log, utils, componentElement, jaxb,annotation,property,attribute);
+ assertEquals(1, model.getAttributes().size());
+ PropertyBase propertyModel = Iterables.getOnlyElement(model.getAttributes());
+ assertTrue(propertyModel.isGenerate());
+ assertEquals("foo", propertyModel.getName());
+ assertEquals("my comment", propertyModel.getDescription());
+ assertEquals("fooFacet", propertyModel.getDisplayname());
+ assertEquals(ClassName.parseName("java.lang.Integer"), propertyModel.getType());
+ assertNull(propertyModel.getIcon());
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(COMPONENT_CLASS_JAVA);
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ComponentProcessorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java (from rev 16654, root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ConverterProcessorTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ConverterProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,68 @@
+/**
+ * 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.processors;
+
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import static org.junit.Assert.assertEquals;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConverterModel;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author akolonitsky
+ * @since Jan 14, 2010
+ */
+(a)RunWith(CdkTestRunner.class)
+public class ConverterProcessorTest extends AnnotationProcessorTest {
+ private static final String COMPONENT_CLASS_JAVA = "org/richfaces/cdk/test/component/MyConverter.java";
+
+ @Inject
+ private ComponentLibrary library;
+
+ @Test
+ @Ignore
+ public void testProcess() throws Exception {
+ Collection<ConverterModel> converters = library.getConverters();
+
+ assertEquals(3, converters.size());
+
+ ConverterModel converterModel = Iterables.get(converters, 0);
+ ClassName forClass = converterModel.getConverterForClass();
+ if (forClass != null && !Object.class.getName().equals(forClass.getName())) {
+ assertEquals(Integer.class.getName(), forClass.getName());
+ }
+ }
+
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(COMPONENT_CLASS_JAVA);
+ }
+}
Copied: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java (from rev 16654, root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/ValidatorProcessorTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,193 @@
+/**
+ * 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.processors;
+
+import com.google.inject.Inject;
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.apt.processors.AnnotationProcessorTest;
+import org.richfaces.cdk.annotations.JsfValidator;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.ValidatorModel;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author akolonitsky
+ * @since Jan 14, 2010
+ */
+(a)RunWith(CdkTestRunner.class)
+public class ValidatorProcessorTest extends AnnotationProcessorTest {
+ private static final String VALIDATOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyValidator.java";
+ @Inject
+ private ComponentLibrary library;
+
+ @Override
+ protected Iterable<String> sources() {
+ return Collections.singleton(VALIDATOR_CLASS_JAVA);
+ }
+
+ @Test
+ @Ignore
+ public void testProcess() throws Exception {
+ Collection<ValidatorModel> validators = library.getValidators();
+
+ assertEquals(2, validators.size());
+
+ for (ValidatorModel model : validators) {
+ FacesId id = model.getId();
+ if (id != null ) {
+ assertEquals("my_validator", id.toString());
+ }
+ }
+ }
+
+ // TODO create Test for ProcessorBase
+ @Test
+
+ public void testSetNames() {
+ ValidatorModel model;
+
+ // @JsfValidator public class BaseClass { ...
+ model = getValidatorModelForSetNames(true, null, "BaseClass", false);
+ check("BaseClass", null, false, model);
+
+ // @JsfValidator(validatorClass = "") public class BaseClass { ...
+ model = getValidatorModelForSetNames(true, "", "BaseClass", false);
+ check("BaseClass", null, false, model);
+
+ // @JsfValidator(validatorClass = BaseClass) public class BaseClass { ...
+ model = getValidatorModelForSetNames(true, "BaseClass", "BaseClass", false);
+ check("BaseClass", null, false, model);
+
+ // @JsfValidator(validatorClass = GeneratedClass) public class BaseClass { ...
+ model = getValidatorModelForSetNames(true, "GeneratedClass", "BaseClass", false);
+ check("GeneratedClass", "BaseClass", true, model);
+
+ // /////////////////////////////// ABSTRACT ///////////////////////////////////////
+ // @JsfValidator public abstract class BaseClass { ...
+// checkAbstractWithException(null);
+
+ // @JsfValidator(validatorClass = "") public abstract class BaseClass { ...
+// checkAbstractWithException("");
+
+ // @JsfValidator(validatorClass = BaseClass) public abstract class BaseClass { ...
+// checkAbstractWithException("BaseClass");
+
+ // @JsfValidator(validatorClass = GeneratedClass) public abstract class BaseClass { ...
+ model = getValidatorModelForSetNames(true, "GeneratedClass", "BaseClass", true);
+ check("GeneratedClass", "BaseClass", true, model);
+ }
+
+ private void checkAbstractWithException(String validatorClass) {
+ try {
+ getValidatorModelForSetNames(true, validatorClass, "BaseClass", true);
+ Assert.fail("Abstract class can't be a validator.");
+ } catch (IllegalStateException e) {
+ // Do nothing.
+ }
+ }
+
+ private void check(String validatorClass, String baseClass, boolean generate, ValidatorModel model) {
+ if (baseClass != null) {
+// assertEquals(model.getBaseClass().toString(), baseClass);
+ } else {
+ assertNull(model.getBaseClass());
+ }
+
+
+// assertEquals(generate, model.isGenerate());
+ }
+
+ private ValidatorModel getValidatorModelForSetNames(boolean isAnnotationDefined, String validatorClass,
+ final String baseClass, boolean isAbstractPresent) {
+ Name name = new MyName(baseClass);
+
+ TypeElement element = EasyMock.createMock(TypeElement.class);
+ EasyMock.expect(element.getQualifiedName()).andReturn(name);
+
+ Set<Modifier> set = new HashSet<Modifier>(1);
+ if (isAbstractPresent) {
+ set.add(Modifier.ABSTRACT);
+ }
+ EasyMock.expect(element.getModifiers()).andReturn(set);
+ EasyMock.replay(element);
+
+ ValidatorModel validatorModel = new ValidatorModel();
+ JsfValidator validator = null;
+ if (isAnnotationDefined) {
+ validator = EasyMock.createMock(JsfValidator.class);
+ EasyMock.expect(validator.generate()).andReturn(validatorClass);
+ EasyMock.replay(validator);
+ }
+
+ EasyMock.verify();
+// ValidatorProcessor.setClassNames(element, validatorModel, validator);
+ return validatorModel;
+ }
+
+ private static class MyName implements Name {
+ private final String toString;
+
+ MyName(String toString) {
+ this.toString = toString;
+ }
+
+ @Override
+ public int length() {
+ return 0;
+ }
+
+ @Override
+ public char charAt(int index) {
+ return 0;
+ }
+
+ @Override
+ public CharSequence subSequence(int start, int end) {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return toString;
+ }
+
+ @Override
+ public boolean contentEquals(CharSequence cs) {
+ return false;
+ }
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -122,7 +122,11 @@
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
List<RenderKitBean> renderKits = library.getRenderKits();
assertEquals(2, renderKits.size());
- assertEquals(new RenderKitModel.Id("HTML_BASIC"), renderKits.get(0).getKey());
+
+ RenderKitBean renderKit = renderKits.get(0);
+ assertEquals(new RenderKitModel.Id("HTML_BASIC"), renderKit.getKey());
+ assertEquals(1, renderKit.getRenderers().size());
+
assertEquals(new RenderKitModel.Id("RDFa"), renderKits.get(1).getKey());
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -48,20 +48,23 @@
public static final String COMPONENT_TYPE="foo.bar";
+
+
private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
- "id",
- "action"
+ "id",
+ "action"
+ ));
- ));
public Collection<String> getEventNames() {
- return EVENT_NAMES; }
+ return EVENT_NAMES;
+ }
public String getDefaultEventName() {
return "action";
}
- protected enum Properties {
+ protected static enum Properties {
testValue,
testFlag,
testBinding,
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandButton.java (from rev 16661, root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandButton.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandButton.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,69 @@
+/**
+ * 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.component;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent
+public abstract class AbstractAjaxCommandButton extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.CommandButton";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.AjaxCommandButton";
+
+ public AbstractAjaxCommandButton() {
+ setRendererType("org.richfaces.CommandButtonRenderer");
+ }
+
+ @Attribute(
+ defaultValue = "\"\"",
+ events = {
+ @EventName("click"),
+ @EventName("mousemove"),
+ @EventName("dblclick"),
+ @EventName("keydown"),
+ @EventName("keypress"),
+ @EventName("keyup"),
+ @EventName("mousedown"),
+ @EventName("mouseout"),
+ @EventName("mouseover"),
+ @EventName("mouseup"),
+ @EventName(value = "action", defaultEvent = true)}
+ )
+ public abstract String getStyle();
+
+ @Attribute(defaultValue = "\"\"")
+ public abstract String getStyleClass();
+
+ @Attribute(defaultValue = "Boolean.FALSE")
+ public abstract boolean isLimitRender();
+}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandLink.java (from rev 16661, root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandLink.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxCommandLink.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,71 @@
+/**
+ * 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.component;
+
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent(
+ generate = "org.richfaces.component.html.HtmlCommandLink"
+)
+public abstract class AbstractAjaxCommandLink extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.CommandLink";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.AjaxCommandLink";
+
+ public AbstractAjaxCommandLink() {
+ setRendererType("org.richfaces.CommandLinkRenderer");
+ }
+
+ @Attribute(
+ defaultValue = "\"\"",
+ events = {
+ @EventName("click"),
+ @EventName("mousemove"),
+ @EventName("dblclick"),
+ @EventName("keydown"),
+ @EventName("keypress"),
+ @EventName("keyup"),
+ @EventName("mousedown"),
+ @EventName("mouseout"),
+ @EventName("mouseover"),
+ @EventName("mouseup"),
+ @EventName(value = "action", defaultEvent = true)}
+ )
+ public abstract String getStyle();
+
+ @Attribute(defaultValue = "\"\"")
+ public abstract String getStyleClass();
+
+ @Attribute(defaultValue = "Boolean.FALSE")
+ public abstract boolean isLimitRender();
+}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxFunction.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxFunction.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxFunction.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -23,24 +23,49 @@
package org.richfaces.component;
-import org.ajax4jsf.component.AjaxActionComponent;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
+import javax.faces.component.UICommand;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:04 $
*
*/
@JsfComponent(
- type = "org.richfaces.Function",
- tag = @Tag(name = "jsFunction"),
- generate = ""
+ tag = @Tag(name = "jsFunction")
)
-public abstract class AbstractAjaxFunction extends AjaxActionComponent {
+public abstract class AbstractAjaxFunction extends UICommand implements ClientBehaviorHolder {
+
+ public static final String COMPONENT_FAMILY = "javax.faces.Command";
+
public static final String COMPONENT_TYPE = "org.richfaces.Function";
+ public AbstractAjaxFunction() {
+ setRendererType("org.richfaces.FunctionRenderer");
+ }
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isLimitRender();
+
public abstract String getName();
- public abstract void setName(String name);
+ public abstract Object getExecute();
+
+ public abstract Object getRender();
+
+ public abstract String getStatus();
+
+ @Attribute(events = @EventName("begin"))
+ public abstract String getOnbegin();
+
+ @Attribute(events = @EventName("beforedomupdate"))
+ public abstract String getOnbeforedomupdate();
+
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxLog.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -23,7 +23,9 @@
package org.richfaces.component;
+import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
import javax.faces.application.ResourceDependencies;
@@ -39,26 +41,32 @@
@ResourceDependency(name = "richfaces-jsf-log.js") , @ResourceDependency(name = "richfaces.css")
})
@JsfComponent(
- type = "org.richfaces.AjaxLog",
tag = @Tag(name = "log"),
- generate = ""
+ renderer = @JsfRenderer(template = "/org/ajax4jsf/renderkit/html/log.template.xml")
)
public abstract class AbstractAjaxLog extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE="org.richfaces.AjaxLog";
+
public static final String COMPONENT_FAMILY = "org.richfaces.AjaxLog";
+
+ public AbstractAjaxLog() {
+ setRendererType("org.richfaces.AjaxLogRenderer");
+ }
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
}
-// public HtmlAjaxLog() {
-// setRendererType("org.richfaces.AjaxLogRenderer");
-// }
-
+ @Attribute(defaultValue = "\"\"")
public abstract String getStyle();
+ @Attribute(defaultValue = "\"\"")
public abstract String getLevel();
+ @Attribute(defaultValue = "\"\"")
public abstract String getStyleClass();
// public abstract String getHotkey();
Deleted: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxOutputPanel.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxOutputPanel.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxOutputPanel.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,67 +0,0 @@
-/**
- * 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.component;
-
-import org.ajax4jsf.component.AjaxOutput;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.Tag;
-
-import javax.faces.component.UIPanel;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
- *
- */
-@JsfComponent(
- type = "org.richfaces.AjaxOutputPanel",
- tag = @Tag(name = "outputPanel", handlerName = "org.richfaces.taghandler.html.OutputPanelTagHandler"),
- generate = ""
-)
-public class AbstractAjaxOutputPanel extends UIPanel implements AjaxOutput {
- public static final String COMPONENT_TYPE = "org.richfaces.AjaxOutputPanel";
-
- private static enum PropertyKeys {ajaxRendered, keepTransient}
-
- public AbstractAjaxOutputPanel() {
- super();
- setRendererType("org.richfaces.OutputPanelRenderer");
- }
-
- public boolean isAjaxRendered() {
- return Boolean.valueOf(getStateHelper().eval(PropertyKeys.ajaxRendered, Boolean.FALSE).toString());
- }
-
- public boolean isKeepTransient() {
- return Boolean.valueOf(getStateHelper().eval(PropertyKeys.keepTransient, Boolean.FALSE).toString());
- }
-
- public void setAjaxRendered(boolean ajaxRendered) {
- getStateHelper().put(PropertyKeys.ajaxRendered, ajaxRendered);
- }
-
- public void setKeepTransient(boolean keepTransient) {
- getStateHelper().put(PropertyKeys.keepTransient, keepTransient);
- }
-}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxStatus.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxStatus.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxStatus.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -23,16 +23,36 @@
package org.richfaces.component;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+
import javax.faces.component.UIOutput;
/**
* @author Nick Belaevski
*
*/
-public class AbstractAjaxStatus extends UIOutput {
+@JsfComponent
+public abstract class AbstractAjaxStatus extends UIOutput {
+
public static final String COMPONENT_TYPE = "org.richfaces.Status";
- public static String getComponentType() {
- return COMPONENT_TYPE;
+ public static final String COMPONENT_FAMILY = "org.richfaces.Status";
+
+ public AbstractAjaxStatus() {
+ setRendererType("org.richfaces.StatusRenderer");
}
+
+ @Attribute(events = @EventName("start"))
+ public abstract String getOnstart();
+
+ @Attribute(events = @EventName("stop"))
+ public abstract String getOnstop();
+
+ @Attribute(events = @EventName("error"))
+ public abstract String getOnerror();
+
+ @Attribute(events = @EventName("success"))
+ public abstract String getOnsuccess();
}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -28,6 +28,7 @@
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.EventName;
import org.richfaces.resource.MediaOutputResource;
import org.richfaces.webapp.taglib.MethodBindingMethodExpressionAdaptor;
import org.richfaces.webapp.taglib.MethodExpressionMethodBindingAdaptor;
@@ -39,19 +40,21 @@
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import java.io.OutputStream;
+import java.util.Date;
/**
* @author shura
*
*/
@JsfComponent(
- type = "org.richfaces.MediaOutput",
- tag = @Tag(name = "mediaOutput", handlerName = "org.richfaces.taghandler.html.PushMediaOutput"),
- generate = ""
+ tag = @Tag(name = "mediaOutput", handlerName = "org.richfaces.taghandler.html.PushMediaOutput")
)
public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent2 {
+
public static final String COMPONENT_TYPE = "org.richfaces.MediaOutput";
+ public static final String COMPONENT_FAMILY = "org.richfaces.MediaOutput";
+
/**
* Get URI attribute for resource ( src for images, href for links etc ).
* @return
@@ -83,7 +86,9 @@
*
* @return MethodBinding to createContent
*/
- @Attribute(signature = @Signature(parameters = {OutputStream.class, Object.class}))
+ @Attribute(
+ generate = false,
+ signature = @Signature(parameters = {OutputStream.class, Object.class}))
public MethodBinding getCreateContent() {
MethodBinding result = null;
MethodExpression me = getCreateContentExpression();
@@ -133,4 +138,120 @@
return resource;
}
+
+ public abstract String getAccesskey();
+
+ public abstract String getAlign();
+
+ public abstract String getArchive();
+
+ public abstract String getBorder();
+
+ @Attribute(defaultValue = "Boolean.FALSE")
+ public abstract boolean isCacheable();
+
+ public abstract String getCharset();
+
+ public abstract String getClassid();
+
+ public abstract String getCodebase();
+
+ public abstract String getCodetype();
+
+ public abstract String getCoords();
+
+ public abstract void setCoords(String coords);
+
+ public abstract MethodExpression getCreateContentExpression();
+
+ public abstract String getDeclare();
+
+ public abstract String getDir();
+
+ public abstract Date getExpires();
+
+ public abstract String getHreflang();
+
+ public abstract String getHspace();
+
+ @Attribute(defaultValue = "Boolean.FALSE")
+ public abstract boolean isIsmap();
+
+ public abstract String getLang();
+
+ public abstract Date getLastModified();
+
+ public abstract String getMimeType();
+
+ public abstract String getRel();
+
+ public abstract String getRev();
+
+ public abstract String getShape();
+
+ public abstract String getStandby();
+
+ public abstract String getStyle();
+
+ public abstract String getStyleClass();
+
+ public abstract String getTabindex();
+
+ public abstract String getTarget();
+
+ public abstract String getTitle();
+
+ public abstract String getType();
+
+ public abstract String getUsemap();
+
+ public abstract String getVspace();
+
+// todo @Attribute(events = @EventName("blur"))
+ public abstract String getOnblur();
+
+ @Attribute(events = @EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events = @EventName("dblclick"))
+ public abstract String getOndblclick();
+
+// todo @Attribute(events = @EventName("focus"))
+ public abstract String getOnfocus();
+
+ @Attribute(events = @EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events = @EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events = @EventName("keyup"))
+ public abstract String getOnkeyup();
+
+ @Attribute(events = @EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events = @EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events = @EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events = @EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events = @EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ @Deprecated
+ public boolean isSession() {
+ return true;
+ }
+
+ @Deprecated
+ public void setSession(boolean session) {
+ if (!session) {
+ // TODO: log
+ }
+ }
}
Copied: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java (from rev 16670, root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxOutputPanel.java)
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractOutputPanel.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -0,0 +1,101 @@
+/**
+ * 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.component;
+
+import org.ajax4jsf.component.AjaxOutput;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+
+import javax.faces.component.UIPanel;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
+ *
+ */
+@JsfComponent(
+ tag = @Tag(handlerName = "org.richfaces.taghandler.html.OutputPanelTagHandler"),
+ generate = "org.richfaces.component.html.HtmlOutputPanel"
+)
+public abstract class AbstractOutputPanel extends UIPanel implements AjaxOutput {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.OutputPanel";
+
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+
+ public AbstractOutputPanel() {
+ setRendererType("org.richfaces.OutputPanelRenderer");
+ }
+
+ @Attribute(defaultValue = "Boolean.FALSE")
+ public abstract boolean isAjaxRendered();
+
+ @Attribute(defaultValue = "Boolean.FALSE")
+ public abstract boolean isKeepTransient();
+
+ @Attribute(defaultValue = "\"inline\"")
+ public abstract String getLayout();
+
+ @Attribute(events = @EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events = @EventName("dblclick"))
+ public abstract String getOndblclick();
+
+ @Attribute(events = @EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events = @EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events = @EventName("keyup"))
+ public abstract String getOnkeyup();
+
+ @Attribute(events = @EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events = @EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events = @EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events = @EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events = @EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ public abstract String getStyle();
+
+ public abstract String getStyleClass();
+
+ public abstract String getTitle();
+
+ public abstract String getDir();
+
+ public abstract String getLang();
+}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -27,6 +27,7 @@
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.EventName;
import javax.el.MethodExpression;
import javax.faces.component.NamingContainer;
@@ -45,20 +46,20 @@
*/
@JsfComponent(
type = "org.richfaces.Push",
- tag = @Tag(name = "push", handlerName = "org.richfaces.taghandler.html.PushTagHandler"),
- generate = ""
+ tag = @Tag(name = "push", handlerName = "org.richfaces.taghandler.html.PushTagHandler")
)
-public class AbstractPush extends UICommand {
- public static final String COMPONENT_FAMILY = "org.richfaces.Push";
+public abstract class AbstractPush extends UICommand {
+
public static final String COMPONENT_TYPE = "org.richfaces.Push";
- private transient boolean hasActiveBehavior = false;
- private static enum PropertyKeys {
- eventProducer,
- enabled,
- interval
- }
+ public static final String COMPONENT_FAMILY = "org.richfaces.Push";
+
+ public static final String DATA_AVAILABLE = "dataAvailable";
+ public static final String ON_DATA_AVAILABLE = "ondataavailable";
+
+ private transient boolean hasActiveBehavior = false;
+
@Override
public void encodeBegin(FacesContext context) throws IOException {
MethodExpression producer = getEventProducer();
@@ -94,43 +95,7 @@
return id.toString();
}
- @Attribute(signature = @Signature(parameters = EventListener.class))
- public MethodExpression getEventProducer() {
- return (MethodExpression) getStateHelper().get(PropertyKeys.eventProducer);
- }
-
- public void setEventProducer(MethodExpression producer) {
- getStateHelper().put(PropertyKeys.eventProducer, producer);
- }
-
- /**
- * @return time in mc for polling interval.
- */
- public int getInterval() {
- return (Integer) getStateHelper().eval(PropertyKeys.interval, 1000);
- }
-
- /**
- * @param interval time in mc for polling interval.
- */
- public void setInterval(int interval) {
- getStateHelper().put(PropertyKeys.interval, interval);
- }
-
- public boolean isEnabled() {
- return Boolean.valueOf(getStateHelper().eval(PropertyKeys.enabled, Boolean.TRUE).toString());
- }
-
- public void setEnabled(boolean enable) {
- getStateHelper().put(PropertyKeys.enabled, enable);
- }
-
@Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- @Override
public void queueEvent(FacesEvent e) {
if (e instanceof BehaviorEvent) {
hasActiveBehavior = true;
@@ -145,4 +110,32 @@
public boolean isHasActiveBehavior() {
return hasActiveBehavior;
}
+
+ // ---------------------------------------
+ @Attribute(signature = @Signature(parameters = EventListener.class))
+ public abstract MethodExpression getEventProducer();
+
+ public abstract void setEventProducer(MethodExpression producer);
+
+ /**
+ * @return time in mc for polling interval.
+ */
+ @Attribute(defaultValue = "1000")
+ public abstract int getInterval();
+
+ @Attribute(defaultValue = "Boolean.TRUE")
+ public abstract boolean isEnabled();
+
+ // TODO what wrong with that name?
+ @Attribute(events = @EventName(value = DATA_AVAILABLE, defaultEvent = true))
+ public abstract String getOndataavailable();
+
+ @Attribute(events = @EventName("begin"))
+ public abstract String getOnbegin();
+
+ @Attribute(events = @EventName("beforedomupdate"))
+ public abstract String getOnbeforedomupdate();
+
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractQueue.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractQueue.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractQueue.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -21,13 +21,17 @@
*/
package org.richfaces.component;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.JsfComponent;
+
import javax.faces.component.UIComponentBase;
/**
* @author Nick Belaevski
*
*/
-public class AbstractQueue extends UIComponentBase {
+@JsfComponent
+public abstract class AbstractQueue extends UIComponentBase {
public static final String GLOBAL_QUEUE_NAME = "org.richfaces.queue.global";
@@ -35,33 +39,26 @@
public static final String COMPONENT_FAMILY = "org.richfaces.Queue";
- private enum PropertyKeys {
- requestDelay, status
- }
-
public AbstractQueue() {
setRendererType("org.richfaces.QueueRenderer");
}
- public int getRequestDelay() {
- return (Integer) getStateHelper().eval(PropertyKeys.requestDelay, Integer.MIN_VALUE);
- }
+ @Attribute(defaultValue = "Integer.MIN_VALUE")
+ public abstract int getRequestDelay();
- public void setRequestDelay(int requestDelay) {
- getStateHelper().put(PropertyKeys.requestDelay, requestDelay);
- }
-
- public String getStatus() {
- return (String) getStateHelper().eval(PropertyKeys.status);
- }
-
- public void setStatus(String status) {
- getStateHelper().put(PropertyKeys.status, status);
- }
+ public abstract String getStatus();
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ public abstract String getOnsubmit();
+ public abstract String getOncomplete();
+
+ public abstract String getOnbeforedomupdate();
+
+ public abstract String getOnerror();
+
+ public abstract String getOnevent();
+
+ public abstract String getOnrequestqueue();
+
+ public abstract String getOnrequestdequeue();
}
Deleted: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandButton.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,39 +0,0 @@
-/**
- * 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.component;
-
-import javax.faces.component.UIComponentBase;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class UIAjaxCommandButton extends UIComponentBase {
- public static final String COMPONENT_FAMILY = "org.richfaces.AjaxCommandButton";
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-}
Deleted: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxCommandLink.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -1,39 +0,0 @@
-/**
- * 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.component;
-
-import javax.faces.component.UIComponentBase;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class UIAjaxCommandLink extends UIComponentBase {
- public static final String COMPONENT_FAMILY = "org.richfaces.AjaxCommandLink";
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -21,19 +21,18 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Set;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.AbstractOutputPanel;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.AbstractAjaxOutputPanel;
-
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:27 $
@@ -54,7 +53,7 @@
@Override
public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
//
- AbstractAjaxOutputPanel panel = (AbstractAjaxOutputPanel) component;
+ AbstractOutputPanel panel = (AbstractOutputPanel) component;
if (hasNoneLayout(panel)) {
if (component.getChildCount() > 0) {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
@@ -96,7 +95,7 @@
*/
@Override
protected Class<? extends UIComponent> getComponentClass() {
- return AbstractAjaxOutputPanel.class;
+ return AbstractOutputPanel.class;
}
/* (non-Javadoc)
@@ -107,7 +106,7 @@
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component)
throws IOException {
- AbstractAjaxOutputPanel panel = (AbstractAjaxOutputPanel) component;
+ AbstractOutputPanel panel = (AbstractOutputPanel) component;
if (!hasNoneLayout(component)) {
writer.startElement(getTag(panel), panel);
getUtils().encodeId(context, component);
@@ -120,7 +119,7 @@
* @param panel
* @return
*/
- private String getTag(AbstractAjaxOutputPanel panel) {
+ private String getTag(AbstractOutputPanel panel) {
Object layout = panel.getAttributes().get("layout");
return "block".equals(layout) ? HTML.DIV_ELEM : HTML.SPAN_ELEM;
}
@@ -131,7 +130,7 @@
*/
@Override
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- AbstractAjaxOutputPanel panel = (AbstractAjaxOutputPanel) component;
+ AbstractOutputPanel panel = (AbstractOutputPanel) component;
if (!hasNoneLayout(component)) {
writer.endElement(getTag(panel));
}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-03-26 16:49:59 UTC (rev 16675)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-03-26 20:32:24 UTC (rev 16676)
@@ -30,7 +30,6 @@
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractPush;
-import org.richfaces.component.html.HtmlPush;
import org.richfaces.resource.PushResource;
import org.richfaces.cdk.annotations.JsfRenderer;
@@ -99,14 +98,14 @@
}
}
- options.put("interval", new Integer(interval));
+ options.put("interval", interval);
options.put("pushResourceUrl", new PushResource().getRequestPath());
options.put("pushId", push.getListenerId(context));
options.put("clientId", component.getClientId(context));
HandlersChain handlersChain = new HandlersChain(push);
- handlersChain.addInlineHandlerFromAttribute(context, HtmlPush.ON_DATA_AVAILABLE);
- handlersChain.addBehaviors(context, HtmlPush.DATA_AVAILABLE);
+ handlersChain.addInlineHandlerFromAttribute(context, AbstractPush.ON_DATA_AVAILABLE);
+ handlersChain.addBehaviors(context, AbstractPush.DATA_AVAILABLE);
if (!handlersChain.hasSubmittingBehavior()) {
JSFunction ajaxFunction = AjaxRendererUtils
@@ -123,7 +122,7 @@
if (handler != null) {
JSFunctionDefinition dataAvailableHandler = new JSFunctionDefinition(JSReference.EVENT);
dataAvailableHandler.addToBody(handler);
- options.put(HtmlPush.ON_DATA_AVAILABLE, dataAvailableHandler);
+ options.put(AbstractPush.ON_DATA_AVAILABLE, dataAvailableHandler);
}
function.addParameter(options);
script.append(function.toScript());
14 years, 5 months
JBoss Rich Faces SVN: r16675 - root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-26 12:49:59 -0400 (Fri, 26 Mar 2010)
New Revision: 16675
Modified:
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java
Log:
Modified: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java 2010-03-26 14:37:17 UTC (rev 16674)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/utils/EmployeeUtils.java 2010-03-26 16:49:59 UTC (rev 16675)
@@ -1,6 +1,7 @@
package org.richfaces.demo.utils;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.richfaces.demo.model.Company;
@@ -1345,20 +1346,33 @@
addEmployeeToCollection(employeeList, "Derrik Khoo Sin Huat", "CTO", "aksinhuat(a)aes.com", "The AES Corporation", "864-233-4064", "Sydney, Australia");
addEmployeeToCollection(employeeList, "Rick Kelsven", "Network Analyst", "rkelsven(a)rudny.com", "Rudny's Inc", "208-356-4991", "Bangkok, Thailand");
-
-
return employeeList;
}
private static void addEmployeeToCollection(List<Employee> collection, String employeeName, String employeeTitle,
String employeeEmail, String companyName, String companyPhone,
String companyState) {
- Company company = new Company(companyName);
- company.setPhone(companyPhone);
- company.setState(companyState);
+ Company company1 = new Company(companyName);
+ company1.setPhone(companyPhone);
+ company1.setState(companyState);
+
+ Company company2 = new Company("stubName1");
+ company2.setPhone("stubPhone1");
+ company2.setState("stubState1");
+
+ Company company3 = new Company("stubName2");
+ company3.setPhone("stubPhone2");
+ company3.setState("stubState2");
+
+ List<Company> companies = new ArrayList<Company>();
+ companies.add(company1);
+ companies.add(company2);
+ companies.add(company3);
+
Employee employee = new Employee(employeeName, employeeTitle);
employee.setEMail(employeeEmail);
- employee.setCompany(company);
+ employee.setCompanies(companies);
collection.add(employee);
}
+
}
14 years, 5 months
JBoss Rich Faces SVN: r16674 - in root/examples-sandbox/trunk/components/tables/src/main: java/org/richfaces/demo/model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-26 10:37:17 -0400 (Fri, 26 Mar 2010)
New Revision: 16674
Modified:
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java
root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Employee.java
root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml
Log:
insert dataScrollers into subTables
Modified: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java 2010-03-26 14:35:49 UTC (rev 16673)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/DataBean.java 2010-03-26 14:37:17 UTC (rev 16674)
@@ -5,6 +5,7 @@
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
+import org.ajax4jsf.model.DataComponentState;
import org.richfaces.demo.model.Employee;
import org.richfaces.demo.utils.EmployeeUtils;
import org.richfaces.event.SortingEvent;
@@ -12,13 +13,21 @@
@ManagedBean(name="dataBean")
@SessionScoped
public class DataBean {
-
- private List<Employee> employeeList;
+
+ DataComponentState componentState;
+
+ public DataComponentState getComponentState() {
+ return componentState;
+ }
+
+ public void setComponentState(DataComponentState componentState) {
+ this.componentState = componentState;
+ }
+
+ private List<Employee> employeeList;
private boolean state = true;
-
-
- public void setEmployeeList(List<Employee> employeeList) {
+ public void setEmployeeList(List<Employee> employeeList) {
this.employeeList = employeeList;
}
Modified: root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Employee.java
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Employee.java 2010-03-26 14:35:49 UTC (rev 16673)
+++ root/examples-sandbox/trunk/components/tables/src/main/java/org/richfaces/demo/model/Employee.java 2010-03-26 14:37:17 UTC (rev 16674)
@@ -12,7 +12,7 @@
private String title;
- private Company company;
+ private List <Company> companies;
private String eMail;
@@ -53,12 +53,12 @@
this.name = name;
}
- public Company getCompany() {
- return company;
+ public List <Company> getCompanies() {
+ return companies;
}
- public void setCompany(Company company) {
- this.company = company;
+ public void setCompanies(List<Company> companies) {
+ this.companies = companies;
}
public String getEMail() {
@@ -88,8 +88,8 @@
Employee employee = (Employee) obj;
return name.equals(employee.getName())
&& title.equals(employee.getTitle())
- && (company == null ? employee.getCompany() == null : company
- .equals(employee.getCompany()));
+ && (companies == null ? employee.getCompanies() == null : companies
+ .equals(employee.getCompanies()));
}
@Override
@@ -97,7 +97,7 @@
int hash = 1;
hash = hash * 17 + name.hashCode();
hash = hash * 17 + title.hashCode();
- hash = hash * 17 + (company == null ? 0 : company.hashCode());
+ hash = hash * 17 + (companies == null ? 0 : companies.hashCode());
return hash;
}
Modified: root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml
===================================================================
--- root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml 2010-03-26 14:35:49 UTC (rev 16673)
+++ root/examples-sandbox/trunk/components/tables/src/main/webapp/home.xhtml 2010-03-26 14:37:17 UTC (rev 16674)
@@ -21,9 +21,9 @@
</f:facet>
<f:facet name="header">
<rich:colGroup id="headerFacet1">
- <rich:column colspan="3"><h:outputText id="headerFacet12" value="header column 1"> </h:outputText></rich:column>
- <rich:column breakBefore="true"><h:outputText id="headerFacet13" value="header column 2"></h:outputText></rich:column>
- <rich:column colspan="2"><h:outputText id="headerFacet14" value="header column 3"></h:outputText></rich:column>
+ <rich:column><h:outputText id="headerFacet12" value="header column 1"> </h:outputText></rich:column>
+ <rich:column><h:outputText id="headerFacet13" value="header column 2"></h:outputText></rich:column>
+ <rich:column><h:outputText id="headerFacet14" value="header column 3"></h:outputText></rich:column>
</rich:colGroup>
</f:facet>
<rich:column id="column_name" sortBy="#{record.name}" sortIconAsc="resources/images/asc.gif" sortIconDesc="resources/images/desc.gif" sortIconUnsort="resources/images/unsort.gif">
@@ -48,17 +48,13 @@
<h:outputText value="#{record.EMail}" />
</rich:column>
- <rich:subTable id="expandedSubTable" var="company" value="#{record.company}" rows="20" switchType="ajax" expanded="true">
+ <rich:subTable id="expandedSubTable" var="company" value="#{record.companies}" rows="1" switchType="ajax" expanded="true">
<f:facet name="header">
- <rich:colGroup id="headerFacet1" >
- <rich:column><h:outputText id="headerFacet12" value="company"> </h:outputText></rich:column>
- <rich:column><h:outputText id="headerFacet13" value="office location"></h:outputText></rich:column>
- <rich:column><h:outputText id="headerFacet14" value="phone"></h:outputText></rich:column>
- </rich:colGroup>
+ <ds:dataScroller id="subscroller" for="expandedSubTable" maxPages="3"></ds:dataScroller >
</f:facet>
<f:facet name="footer">
- <h:outputText value="SubTable Footer facet" />
+ <h:outputText value="footer"/>
</f:facet>
<rich:column id="column_company_name">
@@ -79,8 +75,8 @@
</f:facet>
</rich:dataTable>
-
- <ds:dataScroller id="ds" for="richTable" maxPages="7"></ds:dataScroller>
+ <ds:dataScroller id="scroller" for="richTable" maxPages="7"></ds:dataScroller >
+
<br/>
<h:commandButton value="submit" />
</h:form>
14 years, 5 months
JBoss Rich Faces SVN: r16673 - root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-26 10:35:49 -0400 (Fri, 26 Mar 2010)
New Revision: 16673
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
Log:
add support for the PartiallyEncodedComponent
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-03-26 14:29:20 UTC (rev 16672)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-03-26 14:35:49 UTC (rev 16673)
@@ -91,11 +91,13 @@
facesContext.getPartialViewContext().getRenderIds().add(dataScrollerEvent.getComponent().getClientId(facesContext));
- String dataTableId = getDataTable().getClientId(facesContext);
-
+ UIComponent dataTable = getDataTable();
+ String dataTableId = dataTable.getClientId(facesContext);
+ if(dataTable instanceof PartiallyEncodedComponent) {
+ dataTableId += "@body";
+ }
+
facesContext.getPartialViewContext().getRenderIds().add(dataTableId);
- facesContext.getPartialViewContext().getExecuteIds().add(dataTableId);
-
}
}
14 years, 5 months
JBoss Rich Faces SVN: r16672 - in root/ui-sandbox/trunk/components/datascroller/ui/src/main: java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-26 10:29:20 -0400 (Fri, 26 Mar 2010)
New Revision: 16672
Modified:
root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java
root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
Log:
refactoring
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml 2010-03-26 14:27:21 UTC (rev 16671)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/config/faces-config.xml 2010-03-26 14:29:20 UTC (rev 16672)
@@ -33,4 +33,5 @@
<cdk:generate xmlns:cdk="http://richfaces.org/cdk/extensions">false</cdk:generate>
</component-extension>
</component>
+
</faces-config>
\ No newline at end of file
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-03-26 14:27:21 UTC (rev 16671)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/UIDataScroller.java 2010-03-26 14:29:20 UTC (rev 16672)
@@ -1,7 +1,5 @@
package org.richfaces.component;
-import java.util.Collection;
-import java.util.LinkedHashSet;
import java.util.Map;
import javax.el.ELException;
@@ -15,9 +13,11 @@
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.FacesEvent;
import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.IterationStateHolder;
import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.util.MessageUtil;
import org.richfaces.event.DataScrollerEvent;
@@ -26,25 +26,18 @@
import org.richfaces.log.RichfacesLogger;
import org.slf4j.Logger;
-
-public class UIDataScroller extends UIComponentBase implements DataScrollerSource {
+public class UIDataScroller extends UIComponentBase implements DataScrollerSource, IterationStateHolder {
public static final String COMPONENT_TYPE = "org.richfaces.DataScroller";
public static final String COMPONENT_FAMILY = "org.richfaces.DataScroller";
+
+ public static final String SCROLLER_STATE_ATTRIBUTE = COMPONENT_TYPE + ":page";
private static final Logger log = RichfacesLogger.COMPONENTS.getLogger();
+
+ private Integer page;
- protected enum PropertyKeys {
- boundaryControls, data, fastControls, fastStep, forComponent, handleValue, inactiveStyle, selectStyle,
- inactiveStyleClass, selectStyleClass, scrollerListener, lastPageMode, maxPages, pageIndexVar, pagesVar, renderIfSinglePage,
- style, styleClass, stepControls
- }
-
- protected enum PageMode {
- full, part //part - prev short
- }
-
public static final String FIRST_FACET_NAME = "first";
public static final String LAST_FACET_NAME = "last";
@@ -58,11 +51,16 @@
public static final String LAST_DISABLED_FACET_NAME = "last_disabled";
-
-//TODO: anton - fix
- private Integer page;
-
-
+ protected enum PropertyKeys {
+ boundaryControls, data, fastControls, fastStep, forComponent, handleValue, inactiveStyle, selectStyle,
+ inactiveStyleClass, selectStyleClass, scrollerListener, lastPageMode, maxPages, pageIndexVar, pagesVar, renderIfSinglePage,
+ style, styleClass, stepControls
+ }
+
+ protected enum PageMode {
+ full, part //part - prev short
+ }
+
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
}
@@ -84,15 +82,20 @@
updateModel(dataScrollerEvent.getPage());
- FacesContext context = getFacesContext();
+ FacesContext facesContext = getFacesContext();
MethodExpression scrollerListener = (MethodExpression)getStateHelper().eval(PropertyKeys.scrollerListener);
if (scrollerListener != null) {
- scrollerListener.invoke(context.getELContext(), new Object[]{event});
+ scrollerListener.invoke(facesContext.getELContext(), new Object[]{event});
}
- context.getPartialViewContext().getRenderIds().add(dataScrollerEvent.getComponent().getClientId(context));
- context.getPartialViewContext().getRenderIds().add(getDataTable().getClientId(context));
+ facesContext.getPartialViewContext().getRenderIds().add(dataScrollerEvent.getComponent().getClientId(facesContext));
+
+ String dataTableId = getDataTable().getClientId(facesContext);
+
+ facesContext.getPartialViewContext().getRenderIds().add(dataTableId);
+ facesContext.getPartialViewContext().getExecuteIds().add(dataTableId);
+
}
}
@@ -261,9 +264,6 @@
return true;
}
-
-
-
public void setupFirstRowValue() {
UIComponent dataTable = getDataTable();
if (isRendered()) {
@@ -281,15 +281,15 @@
}
if (newPage != -1) {
- FacesContext context = getFacesContext();
- Object label = MessageUtil.getLabel(context, this);
+ FacesContext facesContext = getFacesContext();
+ Object label = MessageUtil.getLabel(facesContext, this);
String formattedMessage = Messages.getMessage(Messages.DATASCROLLER_PAGE_MISSING,
new Object[] {label, page, pageCount, newPage});
log.warn(formattedMessage);
page = newPage;
- dataTable.getAttributes().put(SCROLLER_STATE_ATTRIBUTE, page);
+ dataTable.getAttributes().put(dataTable.getClientId(facesContext)+ SCROLLER_STATE_ATTRIBUTE, page);
}
if (isRendered(dataTable)) {
@@ -322,8 +322,12 @@
}
public int getPage() {
- Map<String, Object> attributes = getDataTable().getAttributes();
- Integer state = (Integer) attributes.get(SCROLLER_STATE_ATTRIBUTE);
+ UIComponent dataTable = getDataTable();
+ Map<String, Object> attributes = getDataTable().getAttributes();
+
+ FacesContext facesContext = getFacesContext();
+ Integer state = (Integer) attributes.get(dataTable.getClientId(facesContext)+ SCROLLER_STATE_ATTRIBUTE);
+
if (state != null) {
return state;
}
@@ -335,37 +339,36 @@
ValueExpression ve = getValueExpression("page");
if (ve != null) {
try {
- Integer pageObject = (Integer) ve.getValue(getFacesContext().getELContext());
+ Integer pageObject = (Integer) ve.getValue(facesContext.getELContext());
if (pageObject != null) {
return pageObject;
- } else {
- return 1;
}
} catch (ELException e) {
throw new FacesException(e);
}
- } else {
- return 1;
- }
+ }
+
+ return 1;
}
private void updateModel(int newPage) {
- UIComponent dataTable = getDataTable();
-
- if (isRendered(dataTable)) {
+
+ FacesContext facesContext = getFacesContext();
+ UIComponent dataTable = getDataTable();
+
+ if (isRendered(dataTable)) {
dataTable.getAttributes().put("first", (newPage - 1) * getRows(dataTable));
}
-
+
Map<String, Object> attributes = dataTable.getAttributes();
- attributes.put(SCROLLER_STATE_ATTRIBUTE, newPage);
+ attributes.put(dataTable.getClientId(facesContext) + SCROLLER_STATE_ATTRIBUTE, newPage);
- FacesContext context = getFacesContext();
ValueExpression ve = getValueExpression("page");
if (ve != null) {
try {
- ve.setValue(context.getELContext(), newPage);
- attributes.remove(SCROLLER_STATE_ATTRIBUTE);
+ ve.setValue(facesContext.getELContext(), newPage);
+ attributes.remove(dataTable.getClientId(facesContext) + SCROLLER_STATE_ATTRIBUTE);
} catch (ELException e) {
String messageStr = e.getMessage();
Throwable result = e.getCause();
@@ -377,33 +380,33 @@
FacesMessage message;
if (null == messageStr) {
message =
- MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID,
+ MessageUtil.getMessage(facesContext, UIInput.UPDATE_MESSAGE_ID,
new Object[] { MessageUtil.getLabel(
- context, this) });
+ facesContext, this) });
} else {
message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
messageStr,
messageStr);
}
- context.getExternalContext().log(message.getSummary(), result);
- context.addMessage(getClientId(context), message);
- context.renderResponse();
+ facesContext.getExternalContext().log(message.getSummary(), result);
+ facesContext.addMessage(getClientId(facesContext), message);
+ facesContext.renderResponse();
} catch (IllegalArgumentException e) {
FacesMessage message =
- MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID,
+ MessageUtil.getMessage(facesContext, UIInput.UPDATE_MESSAGE_ID,
new Object[] { MessageUtil.getLabel(
- context, this) });
- context.getExternalContext().log(message.getSummary(), e);
- context.addMessage(getClientId(context), message);
- context.renderResponse();
+ facesContext, this) });
+ facesContext.getExternalContext().log(message.getSummary(), e);
+ facesContext.addMessage(getClientId(facesContext), message);
+ facesContext.renderResponse();
} catch (Exception e) {
FacesMessage message =
- MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID,
+ MessageUtil.getMessage(facesContext, UIInput.UPDATE_MESSAGE_ID,
new Object[] { MessageUtil.getLabel(
- context, this) });
- context.getExternalContext().log(message.getSummary(), e);
- context.addMessage(getClientId(context), message);
- context.renderResponse();
+ facesContext, this) });
+ facesContext.getExternalContext().log(message.getSummary(), e);
+ facesContext.addMessage(getClientId(facesContext), message);
+ facesContext.renderResponse();
}
}
}
@@ -446,24 +449,17 @@
}
}
}
-
- public Object saveState(FacesContext context) {
- return new Object[] {
- super.saveState(context),
- page
- };
-
+
+ public Object saveState(FacesContext facesContext) {
+ return new Object[] { super.saveState(facesContext), page };
}
- public void restoreState(FacesContext context, Object object) {
+ public void restoreState(FacesContext facesContext, Object object) {
Object[] state = (Object[]) object;
-
- super.restoreState(context, state[0]);
+ super.restoreState(facesContext, state[0]);
page = (Integer) state[1];
}
- public static final String SCROLLER_STATE_ATTRIBUTE = COMPONENT_TYPE + ":page";
-
public boolean isLocalPageSet() {
return page != null;
}
@@ -471,9 +467,34 @@
public void resetLocalPage() {
page = null;
}
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+ super.processEvent(event);
+ }
@Override
- public String getFamily() {
- return COMPONENT_FAMILY;
+ public Object getIterationState() {
+ FacesContext facesContext = getFacesContext();
+ UIComponent dataTable = getDataTable();
+ Integer page = (Integer)dataTable.getAttributes().get(dataTable.getClientId(facesContext) + SCROLLER_STATE_ATTRIBUTE);
+ Object [] stateObject = page != null ? new Object[]{page} : null;
+ return stateObject;
}
+
+ @Override
+ public void setIterationState(Object stateObject) {
+ if (stateObject != null) {
+ Object[] state = (Object[]) stateObject;
+ FacesContext facesContext = getFacesContext();
+ UIComponent dataTable = getDataTable();
+ dataTable.getAttributes().put(dataTable.getClientId(facesContext) + SCROLLER_STATE_ATTRIBUTE, state[0]);
+ }
+ }
+
}
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java 2010-03-26 14:27:21 UTC (rev 16671)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/component/html/HtmlDataScroller.java 2010-03-26 14:29:20 UTC (rev 16672)
@@ -13,15 +13,15 @@
public String getFastControls() {
return (String)getStateHelper().eval(PropertyKeys.fastControls, "show");
}
+
+ public String getFor() {
+ return (String)getStateHelper().eval(PropertyKeys.forComponent);
+ }
public int getFastStep() {
return (Integer)getStateHelper().eval(PropertyKeys.fastStep, 0);
}
- public String getFor() {
- return (String)getStateHelper().eval(PropertyKeys.forComponent);
- }
-
public String getInactiveStyle() {
return (String)getStateHelper().eval(PropertyKeys.inactiveStyle);
}
Modified: root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-03-26 14:27:21 UTC (rev 16671)
+++ root/ui-sandbox/trunk/components/datascroller/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-03-26 14:29:20 UTC (rev 16672)
@@ -23,13 +23,11 @@
import java.io.IOException;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -53,6 +51,7 @@
@ResourceDependency(name = "css/datascroller.css")
})
+
public class DataScrollerBaseRenderer extends RendererBase {
public void doDecode(FacesContext context, UIComponent component) {
@@ -75,7 +74,6 @@
public ControlsState getControlsState(FacesContext context, UIComponent component) {
-
int fastStep = (Integer)component.getAttributes().get("fastStep");
int pageIndex = (Integer)component.getAttributes().get("page");
int pageCount = (Integer)component.getAttributes().get("pageCount");
@@ -207,9 +205,9 @@
out.startElement(HTML.SPAN_ELEM, component);
if (isCurrentPage) {
- out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital ds_current "+styleClass, null);
+ out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital ds_current " + styleClass, null);
} else {
- out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital "+styleClass, null);
+ out.writeAttribute(HTML.CLASS_ATTRIBUTE, "ds_digital " + styleClass, null);
}
if (null != style) {
@@ -218,10 +216,12 @@
String page = Integer.toString(i + 1);
String id = clientId+ "_ds_" + page;
+
out.writeAttribute(HTML.ID_ATTRIBUTE,id, null);
+
digital.put(id, page);
- out.writeText(page, null);
+ out.writeText(page, null);
out.endElement(HTML.SPAN_ELEM);
}
@@ -271,6 +271,7 @@
options.put("buttons", buttons);
options.put("digitals", digitals);
options.put("currentPage", (Integer)component.getAttributes().get("page"));
+
function.addParameter(getSubmitFunction(context, component));
function.addParameter(options);
@@ -295,47 +296,6 @@
return definition;
}
- public void renderPages(FacesContext context, UIComponent component, int pageIndex, int count) throws IOException {
- int currentPage = pageIndex;
-
- int pageCount = count;
- if (pageCount <= 1) {
- pageCount = 1;
- }
- String varName = (String) component.getAttributes().get("pageIndexVar");
- if (varName != null && varName.length() > 0) {
- //TODO: anton - fix
- context.getExternalContext().getRequestMap().put(varName, new Integer(currentPage));
- }
- varName = (String) component.getAttributes().get("pagesVar");
- if (varName != null && varName.length() > 0) {
- //TODO: anton - fix
- context.getExternalContext().getRequestMap().put(varName, new Integer(pageCount));
- }
- }
-
- //get UIParameter's Map
- protected Map <String, Object> getParameters(FacesContext context, UIComponent component){
- Map <String,Object> parameters = new HashMap<String, Object>();
-
- if(component instanceof UIDataScroller){
-
- UIDataScroller datascroller = (UIDataScroller)component;
- List <UIComponent> children = datascroller.getChildren();
-
- for (UIComponent child: children) {
- if(child instanceof UIParameter) {
- UIParameter param = (UIParameter)child;
- String name = param.getName();
- if (name != null) {
- parameters.put(name, param.getValue());
- }
- }
- }
- }
- return parameters;
- }
-
public boolean getRendersChildren() {
return true;
}
14 years, 5 months
JBoss Rich Faces SVN: r16671 - in root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces: component/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-03-26 10:27:21 -0400 (Fri, 26 Mar 2010)
New Revision: 16671
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
Log:
paging support, refactoring
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTable.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -7,8 +7,6 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
-import org.ajax4jsf.model.DataComponentState;
-import org.richfaces.component.state.DataTableState;
import org.richfaces.event.SortingEvent;
/**
@@ -32,15 +30,6 @@
return (MethodExpression) getStateHelper().eval(PropertyKeys.sortingExpression);
}
- public DataTableState getCurrentComponentState() {
- return (DataTableState) getComponentState();
- }
-
- @Override
- protected DataComponentState createComponentState() {
- return new DataTableState(getFirst(), getRows());
- }
-
public UIComponent getCaption() {
return getFacet("caption");
}
@@ -50,22 +39,16 @@
super.broadcast(event);
if(event instanceof SortingEvent) {
SortingEvent sortingEvent = (SortingEvent)event;
-
- DataTableState state = getCurrentComponentState();
- if(event.isAppropriateListener(state)) {
- sortingEvent.processListener(state);
- }
-
- MethodExpression expression = getSortingListener();
+
FacesContext context = getFacesContext();
+ MethodExpression expression = getSortingListener();
if (expression != null) {
expression.invoke(context.getELContext(), new Object[] { sortingEvent });
}
-
+
}
}
-
@Override
public void queueEvent(FacesEvent event) {
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -29,22 +29,23 @@
import java.util.List;
import java.util.Map;
+import javax.faces.component.StateHelper;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.ajax4jsf.model.ExtendedDataModel;
-import org.richfaces.model.FilterField;
import org.richfaces.model.Arrangeable;
import org.richfaces.model.ArrangeableModel;
import org.richfaces.model.ArrangeableState;
import org.richfaces.model.ArrangeableStateDefaultImpl;
+import org.richfaces.model.FilterField;
import org.richfaces.model.SortField;
import org.richfaces.model.SortMode;
public class UIDataTableBase extends UISequence implements Row {
protected enum PropertyKeys {
- filterVar, sortPriority, sortMode
+ filterVar, sortPriority, sortMode, first, rows
}
public Iterator<UIComponent> columns() {
@@ -164,4 +165,22 @@
public void setSortMode(SortMode sortMode) {
getStateHelper().put(PropertyKeys.sortMode, sortMode);
}
+
+ @Override
+ public Object getIterationState() {
+ Object stateObject = super.getIterationState();
+ StateHelper stateHelper = getStateHelper();
+ return new Object []{stateObject, stateHelper.get(PropertyKeys.first), stateHelper.get(PropertyKeys.rows)};
+ }
+
+ @Override
+ public void setIterationState(Object stateObject) {
+ StateHelper stateHelper = getStateHelper();
+ if (stateObject != null) {
+ Object[] state = (Object[]) stateObject;
+ super.setIterationState(state[0]);
+ stateHelper.put(PropertyKeys.first, state[1]);
+ stateHelper.put(PropertyKeys.rows, state[2]);
+ }
+ }
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -23,15 +23,11 @@
import javax.el.MethodExpression;
import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.RepeatState;
import org.richfaces.component.state.DataTableState;
-import org.richfaces.component.state.SubTableState;
-import org.richfaces.event.ToggleEvent;
import org.richfaces.event.ToggleListener;
/**
@@ -40,17 +36,22 @@
*/
-public abstract class UISubTable extends UIDataTableBase implements Row, Column, Expandable {
+public class UISubTable extends UIDataTableBase implements Column {
- public static final String SWITCH_TYPE_SERVER = "server";
-
- public static final String SWITCH_TYPE_AJAX = "ajax";
-
-
enum PropertyKeys {
switchType, expanded, toggleExpression
}
+
+
+ public boolean isExpanded() {
+ return (Boolean)getStateHelper().eval(PropertyKeys.expanded, false);
+ }
+
+ public void setExpanded(boolean expanded) {
+ getStateHelper().put(PropertyKeys.expanded, expanded);
+ }
+
public boolean isBreakBefore() {
return true;
}
@@ -67,67 +68,6 @@
public void setSortExpression(String sortExpression) {
throw new IllegalArgumentException("subtable is not sortable element");
}
-
- public String getSwichType() {
- return (String) getStateHelper().eval(PropertyKeys.switchType, SWITCH_TYPE_SERVER);
- }
-
- public void setSwitchType(String switchType) {
- getStateHelper().put(PropertyKeys.switchType, switchType);
- }
-
- public SubTableState getCurrentComponentState() {
- DataComponentState dataComponentState = (SubTableState)getComponentState();
-
- DataTableState parentState = getParentState();
- parentState.addSubTableState((SubTableState) dataComponentState);
-
- return (SubTableState) dataComponentState;
- }
-
- public DataTableState getParentState() {
- DataTableState dataTableState = null;
-
- UIComponent parent = getParent();
- while(parent != null && !(parent instanceof UIDataTable)) {
- parent = parent.getParent();
- }
-
- if(parent == null) {
- throw new AbortProcessingException("UISubTable should have a UIDataTable parent");
- }
-
- UIDataTable dataTable = (UIDataTable) parent;
- DataComponentState state = dataTable.getComponentState();
-
- if (state instanceof DataTableState) {
- dataTableState = (DataTableState) state;
- }
-
- return dataTableState;
- }
-
- @Override
- protected DataComponentState createComponentState() {
- DataComponentState state = null;
- DataTableState parentState = getParentState();
-
- if (parentState != null) {
- //TODO nick - use getClientId(FacesContext)
- //what's wrong with getClientId()???
- state = parentState.getChildState(getClientId());
- }
-
- if (state == null) {
- state = new SubTableState(getClientId(), getFirst(), getRows());
- }
-
- return state;
- }
-
- public abstract void setExpanded(boolean expanded);
-
- public abstract boolean isExpanded();
public void setToggleListener(MethodExpression toggleExpression) {
//TODO nick - use addToggleListener() & MethodExpression wrapper in tag
@@ -138,42 +78,6 @@
return (MethodExpression) getStateHelper().eval(PropertyKeys.toggleExpression);
}
- @Override
- public void queueEvent(FacesEvent event) {
- //TODO nick - what if event comes from the nested subTable?
- if (event instanceof ToggleEvent) {
- //TODO nick - "immediate" support?
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
- super.queueEvent(event);
- }
-
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
-
- if (event instanceof ToggleEvent) {
- ToggleEvent toggleEvent = (ToggleEvent) event;
-
- // not sure that this is right ... need to discuss
- SubTableState state = getCurrentComponentState();
- if (event.isAppropriateListener(state)) {
- toggleEvent.processListener(state);
- }
-
- MethodExpression expression = getToggleListener();
- FacesContext context = getFacesContext();
-
- if (expression != null) {
- expression.invoke(context.getELContext(), new Object[] { toggleEvent });
- }
-
- UIToggleControl toggle = (UIToggleControl)toggleEvent.getSource();
-// toggle.addExecuteId((String)getAttributes().get("clientId"));
- toggle.addRenderId(getClientId(context));
- }
- }
-
public void addToggleListener(ToggleListener listener) {
addFacesListener(listener);
}
@@ -185,6 +89,7 @@
public ToggleListener[] getToggleListeners() {
return (ToggleListener[]) getFacesListeners(ToggleListener.class);
}
+
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/html/HtmlSubTable.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -6,19 +6,5 @@
public static final String COMPONENT_TYPE = "org.richfaces.SubTable";
-
-
- protected enum PropertyKeys {
- expand
- }
-
- @Override
- public boolean isExpanded() {
- return (Boolean)getStateHelper().eval(PropertyKeys.expand, false);
- }
-
- @Override
- public void setExpanded(boolean expanded) {
- getStateHelper().put(PropertyKeys.expand, expanded);
- }
+
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/DataTableState.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -1,28 +1,17 @@
package org.richfaces.component.state;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.RepeatState;
-import org.richfaces.event.SortingEvent;
-import org.richfaces.event.SortingListener;
/**
* @author Anton Belevich
*
*/
-public class DataTableState extends RepeatState implements StateHolder, SortingListener {
+public class DataTableState extends RepeatState {
- private Map<String, SubTableState> subTableStates = new HashMap<String, SubTableState>();
+ private Integer first;
- private int first;
+ private Integer rows;
- private int rows;
-
public DataTableState(int first, int rows) {
this.first = first;
this.rows = rows;
@@ -37,48 +26,5 @@
public int getRows() {
return this.rows;
}
-
- //TODO nick - save/restore first/rows/visualModel
- public void restoreState(FacesContext context, Object state) {
- Object[] newState = (Object[]) state;
- if (newState != null) {
- //TODO nick - do we need to support SubTableState that are StateHolder?
- subTableStates = (Map<String, SubTableState>) newState[0];
- }
- }
-
- public Object saveState(FacesContext context) {
- return new Object[] { subTableStates };
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void setTransient(boolean newTransientValue) {
- }
-
- public void addSubTableState(SubTableState state) {
- if (state != null) {
- this.subTableStates.put(state.getId(), state);
- }
- }
-
- public SubTableState getSubTableState(String id) {
- return this.subTableStates.get(id);
- }
-
- public void addChildState(DataComponentState childState) {
- if (childState instanceof SubTableState) {
- addSubTableState((SubTableState) childState);
- }
- }
-
- public DataComponentState getChildState(String id) {
- DataComponentState state = getSubTableState(id);
- return state;
- }
-
- public void processSorting(SortingEvent sortingEvent) {
- }
+
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/state/SubTableState.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -1,65 +1,12 @@
package org.richfaces.component.state;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.RepeatState;
-import org.richfaces.event.ToggleEvent;
-import org.richfaces.event.ToggleListener;
-
/**
+ *
* @author Anton Belevich
- *
*/
-public class SubTableState extends RepeatState implements StateHolder, ToggleListener {
+public class SubTableState extends DataTableState {
- private String id;
-
- private int first;
-
- private int rows;
-
- public SubTableState(String id, int first, int rows) {
- this.id = id;
- this.first = first;
- this.rows = rows;
+ public SubTableState(int first, int rows) {
+ super(first, rows);
}
-
- public String getId() {
- return this.id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public int getFirst() {
- return this.first;
- }
-
- @Override
- public int getRows() {
- return this.rows;
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void setTransient(boolean newTransientValue) {
- }
-
- public void processToggle(ToggleEvent event) {
- }
-
- @Override
- public void restoreState(FacesContext arg0, Object arg1) {
- }
-
- @Override
- public Object saveState(FacesContext arg0) {
- return null;
- }
-
}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2010-03-26 10:43:08 UTC (rev 16670)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ToggleControlRendererBase.java 2010-03-26 14:27:21 UTC (rev 16671)
@@ -89,11 +89,11 @@
String toggleId = toggleControl.getClientId(context);
String options = encodeOptions(context, toggleControl, subTable);
- String switchType = subTable.getSwichType();
- boolean expanded = subTable.isExpanded();
+ String switchType = null;//subTable.getSwichType();
+// boolean expanded = subTable.isExpanded();
- encodeControl(context, writer, toggleControl, switchType, expanded, false);
- encodeControl(context, writer, toggleControl, switchType, !expanded, true);
+// encodeControl(context, writer, toggleControl, switchType, expanded, false);
+// encodeControl(context, writer, toggleControl, switchType, !expanded, true);
encodeHiddenInput(context, writer, toggleControl);
@@ -153,11 +153,11 @@
HashMap<String, Object> options = new HashMap<String, Object>();
options.put("formId", formId);
options.put("forId", forId);
- options.put("initialState", (Boolean) subTable.isExpanded());
+// options.put("initialState", (Boolean) subTable.isExpanded());
options.put("eventName", toggleControl.getEvent());
- if(subTable.getSwichType().equals(UISubTable.SWITCH_TYPE_AJAX)) {
- options.put("ajax", AjaxRendererUtils.buildEventOptions(context, subTable));
- }
+// if(subTable.getSwichType().equals(UISubTable.SWITCH_TYPE_AJAX)) {
+// options.put("ajax", AjaxRendererUtils.buildEventOptions(context, subTable));
+// }
return ScriptUtils.toScript(options);
}
14 years, 5 months