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
- *
- */
-(a)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
- */
-(a)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
- */
-(a)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
- */
-(a)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
+ *
+ */
+(a)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
+ */
+(a)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
+ */
+(a)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
+ */
+(a)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());