JBoss Rich Faces SVN: r16539 - in root: cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-09 09:24:55 -0500 (Tue, 09 Mar 2010)
New Revision: 16539
Added:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
Removed:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.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/apt/ComponentProcessor.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/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.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/xmlconfig/CdkResolverTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/AbstractPoll.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/AbstractAjaxOutputPanel.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/UIRepeat.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxLog.java
Log:
fix core ui build
rename Component to JsfComponent
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Alias.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -39,7 +38,6 @@
*/
@Retention(RetentionPolicy.CLASS)
@Target( { ElementType.METHOD, ElementType.FIELD })
-@Inherited
public @interface Alias {
public static final String NAME = "org.richfaces.cdk.annotations.Alias";
Deleted: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -1,70 +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.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p class="changed_added_4_0">
- * That annotation marks class as JSF component. The difference with JSF 2.0 @
- * {@link javax.faces.component.FacesComponent} annotation is what this one could marks abstaract class from which a
- * real UI-component implementation will be generated. The value of default {@link #value()} attribute is taken to be
- * <em>component type</em>. The fully qualified class name becomes a component class unless that class is abstract or
- * final component class is defined by the {@link Generate} annotation value.
- * </p>
- *
- * @author asmirnov(a)exadel.com
- */
-(a)Retention(RetentionPolicy.SOURCE)
-(a)Target(ElementType.TYPE)
-public @interface Component {
-
- /**
- * <p class="changed_added_4_0">
- * Annotation class name to use as key for annotation processor class.
- * </p>
- */
- public static final String NAME = "org.richfaces.cdk.annotations.Component";
-
- /**
- * <p class="changed_added_4_0">
- * Type of the component. Currently this is mandatory parameter because CDK uses <em>component-type</em> as primary
- * key for components library model.
- * </p>
- * <p class="todo">
- * TODO if this value is an empty, component type will be inferred from class name.
- * </p>
- *
- * @return component type.
- */
- public String value() default "";
-
- public boolean generate() default true;
-
- public Tag tag() default @Tag();
-
-}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -37,7 +36,6 @@
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
-@Inherited
public @interface JsfBehavior {
public static final String NAME = "org.richfaces.cdk.annotations.JsfBehavior";
Copied: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java (from rev 16537, root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Component.java)
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java (rev 0)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -0,0 +1,70 @@
+/*
+ * $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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * <p class="changed_added_4_0">
+ * That annotation marks class as JSF component. The difference with JSF 2.0 @
+ * {@link javax.faces.component.FacesComponent} annotation is what this one could marks abstaract class from which a
+ * real UI-component implementation will be generated. The value of default {@link #value()} attribute is taken to be
+ * <em>component type</em>. The fully qualified class name becomes a component class unless that class is abstract or
+ * final component class is defined by the {@link Generate} annotation value.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ */
+(a)Retention(RetentionPolicy.SOURCE)
+(a)Target(ElementType.TYPE)
+public @interface JsfComponent {
+
+ /**
+ * <p class="changed_added_4_0">
+ * Annotation class name to use as key for annotation processor class.
+ * </p>
+ */
+ public static final String NAME = "org.richfaces.cdk.annotations.JsfComponent";
+
+ /**
+ * <p class="changed_added_4_0">
+ * Type of the component. Currently this is mandatory parameter because CDK uses <em>component-type</em> as primary
+ * key for components library model.
+ * </p>
+ * <p class="todo">
+ * TODO if this value is an empty, component type will be inferred from class name.
+ * </p>
+ *
+ * @return component type.
+ */
+ public String value() default "";
+
+ public boolean generate() default true;
+
+ public Tag tag() default @Tag();
+
+}
Property changes on: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfComponent.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfConverter.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -35,9 +34,8 @@
*
* @author asmirnov(a)exadel.com
*/
-(a)Retention(RetentionPolicy.CLASS)
+(a)Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
-@Inherited
public @interface JsfConverter {
public static final String NAME = "org.richfaces.cdk.annotations.JsfConverter";
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfValidator.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -1,18 +1,16 @@
package org.richfaces.cdk.annotations;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
/**
* @author akolonitsky
* @since Jan 13, 2010
*/
-(a)Retention(RetentionPolicy.CLASS)
+(a)Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
-@Inherited
public @interface JsfValidator {
public static final String NAME = "org.richfaces.cdk.annotations.JsfValidator";
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Renderer.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -36,9 +35,8 @@
*
* @author asmirnov(a)exadel.com
*/
-(a)Retention(RetentionPolicy.CLASS)
+(a)Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
-@Inherited
public @interface Renderer {
public static final String NAME = "org.richfaces.cdk.annotations.Renderer";
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplate.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,11 +23,8 @@
package org.richfaces.cdk.annotations;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
/**
* <p class="changed_added_4_0">
@@ -35,9 +32,7 @@
*
* @author asmirnov(a)exadel.com
*/
-(a)Retention(RetentionPolicy.CLASS)
-(a)Target(ElementType.TYPE)
-@Inherited
+(a)Retention(RetentionPolicy.SOURCE)
public @interface RendererTemplate {
public static final String NAME = "org.richfaces.cdk.annotations.RendererTemplate";
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/RendererTemplates.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,11 +23,8 @@
package org.richfaces.cdk.annotations;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
/**
* <p class="changed_added_4_0">
@@ -35,9 +32,7 @@
*
* @author asmirnov(a)exadel.com
*/
-(a)Retention(RetentionPolicy.CLASS)
-(a)Target(ElementType.TYPE)
-@Inherited
+(a)Retention(RetentionPolicy.SOURCE)
public @interface RendererTemplates {
public static final String NAME = "org.richfaces.cdk.annotations.RendererTemplates";
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/SuggestedValue.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,6 @@
package org.richfaces.cdk.annotations;
import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -36,9 +35,8 @@
* @author asmirnov(a)exadel.com
*
*/
-(a)Retention(RetentionPolicy.CLASS)
+(a)Retention(RetentionPolicy.SOURCE)
@Target( { ElementType.METHOD, ElementType.FIELD })
-@Inherited
public @interface SuggestedValue {
String value();
}
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/package-info.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -2,7 +2,7 @@
* <h1>Java annotations used by the CDK.</h1>
* <h2>Class-level annotations:</h2>
* <p>Mandatory:</p>
- * <p>@{@link Component}("component.Type") or @{@link javax.faces.component.FacesComponent}("component.Type").</p>
+ * <p>@{@link JsfComponent}("component.Type") or @{@link javax.faces.component.FacesComponent}("component.Type").</p>
* <p>Optional:</p>
* <ul>
* <li>@{@link Family}("component.Family") defines component family used in the generated class.<br /></li>
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-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -44,7 +44,7 @@
name.setPrefix(baseName);
}
- // Component type does not contain class or markup parts.
+ // JsfComponent type does not contain class or markup parts.
name.setClassifier(null);
name.setMarkup(null);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -25,9 +25,15 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Set;
+import com.google.common.collect.Lists;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.annotations.*;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.util.Strings;
+import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.faces.event.FacesEvent;
@@ -36,46 +42,19 @@
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.List;
+import java.util.Set;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Attributes;
-import org.richfaces.cdk.annotations.Component;
-import org.richfaces.cdk.annotations.DefaultValue;
-import org.richfaces.cdk.annotations.DisplayName;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.EventNames;
-import org.richfaces.cdk.annotations.Facet;
-import org.richfaces.cdk.annotations.Facets;
-import org.richfaces.cdk.annotations.Family;
-import org.richfaces.cdk.annotations.Fires;
-import org.richfaces.cdk.annotations.Generate;
-import org.richfaces.cdk.annotations.Icon;
-import org.richfaces.cdk.annotations.Signature;
-import org.richfaces.cdk.annotations.SuggestedValue;
-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.ClassName;
-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.model.Property;
-import org.richfaces.cdk.util.Strings;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
-
-import com.google.common.collect.Lists;
-
/**
- * <p class="changed_added_4_0">That class process component-related annotations such as {@link Component} or
+ * <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
*
*/
-@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", Component.NAME})
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfComponent.NAME})
public class ComponentProcessor extends ProcessorBase implements CdkAnnotationProcessor {
public void process(TypeElement componentElement) {
@@ -87,7 +66,7 @@
setClassNames(componentElement, component);
setComponentProperties(componentElement, component);
- Component annotation = componentElement.getAnnotation(Component.class);
+ JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
if (null != annotation) {
component.setGenerate(annotation.generate());
setTagInfo(annotation.tag(), component);
@@ -101,7 +80,7 @@
protected String getComponentType(TypeElement componentElement) {
// Calculate type for base UI component class.
- Component componentAnnotation = componentElement.getAnnotation(Component.class);
+ JsfComponent componentAnnotation = componentElement.getAnnotation(JsfComponent.class);
String explicitType = componentAnnotation.value();
// if (!Strings.isEmpty(explicitType)) {
return explicitType;
@@ -116,7 +95,7 @@
private void setComponentProperties(TypeElement componentElement, ComponentModel component)
throws CdkException {
- // Component family
+ // JsfComponent family
setComponeneFamily(componentElement, component);
setDescription(componentElement, component);
processFacets(componentElement, component);
@@ -347,7 +326,7 @@
@Override
public Class<? extends Annotation> getProcessedAnnotation() {
- return Component.class;
+ return JsfComponent.class;
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/RendererProcessor.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -21,20 +21,19 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
-
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
-
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.Family;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Renderer;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RendererModel;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
+
/**
* @author akolonitsky
* @since Dec 30, 2009
@@ -64,7 +63,7 @@
}
protected String getComponentType(TypeElement componentElement) {
- Component annotation = componentElement.getAnnotation(Component.class);
+ JsfComponent annotation = componentElement.getAnnotation(JsfComponent.class);
if (annotation != null) {
return annotation.value();
}
@@ -75,7 +74,7 @@
private void setRendererProperties(TypeElement componentElement, RendererModel renderer)
throws CdkException {
- // Component family
+ // JsfComponent family
setRendererFamily(componentElement, renderer);
setDescription(componentElement, renderer);
// processFacets(componentElement, renderer);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -78,7 +78,12 @@
}
private String getTagName(ModelElementBase model) {
- return model.getTag().getName();
+ TagModel tag = model.getTag();
+ if (tag != null) {
+ return tag.getName();
+ }
+
+ return "";
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -99,7 +99,7 @@
}
}
protected void verifyComponent(ComponentModel component) {
- // Check Component type.
+ // Check JsfComponent type.
if (null == component.getType()) {
if (null != component.getComponentClass()) {
component.setType(namingConventions.inferComponentType(component.getComponentClass()));
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/CdkTestBase.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,6 +23,13 @@
package org.richfaces.cdk;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import org.junit.After;
+import org.junit.Before;
+import org.richfaces.cdk.annotations.JsfComponent;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -34,14 +41,6 @@
import java.util.Locale;
import java.util.logging.LogManager;
-import org.junit.After;
-import org.junit.Before;
-import org.richfaces.cdk.annotations.Component;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Module;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -129,7 +128,7 @@
protected CdkClassLoader createClassLoader() {
try {
return new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(Component.class)), null);
+ getLibraryFile(JsfComponent.class)), null);
} catch (Exception e) {
throw new RuntimeException(e);
}
Modified: 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-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,31 +23,27 @@
package org.richfaces.cdk.apt;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import javax.lang.model.element.TypeElement;
-
+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.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.JAXB;
-import com.google.common.collect.Iterables;
-import com.google.inject.Inject;
+import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.Collections;
/**
* <p class="changed_added_4_0">
@@ -88,11 +84,11 @@
@Test
@Ignore
public void testProcess() throws Exception {
- expect(componentElement.getAnnotation(Component.class)).andReturn(new Component() {
+ expect(componentElement.getAnnotation(JsfComponent.class)).andReturn(new JsfComponent() {
@Override
public Class<? extends Annotation> annotationType() {
- return Component.class;
+ return JsfComponent.class;
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -1,26 +1,18 @@
package org.richfaces.cdk.xmlconfig;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
+import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkTestBase;
-import org.richfaces.cdk.CdkTestRunner;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Mock;
-import org.richfaces.cdk.Source;
-import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.*;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.xml.sax.InputSource;
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Binder;
-import com.google.inject.Inject;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
@RunWith(CdkTestRunner.class)
public class CdkResolverTest extends CdkTestBase {
@@ -44,7 +36,7 @@
try {
CdkClassLoader classLoader =
new CdkClassLoader(ImmutableList.of(getLibraryFile("test.source.properties"),
- getLibraryFile(Component.class)), null) {
+ getLibraryFile(JsfComponent.class)), null) {
@Override
public InputStream getResourceAsStream(String name) {
if ("foo/bar.xml".equals(name)) {
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/AbstractTestComponent.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -26,19 +26,18 @@
package org.richfaces.cdk.test.component;
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
-import java.util.List;
-
import javax.faces.component.UIComponent;
import javax.faces.component.ValueHolder;
+import java.util.List;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-@Component("org.richfaces.cdk.test.TestComponent")
+@JsfComponent("org.richfaces.cdk.test.TestComponent")
public abstract class AbstractTestComponent extends UIComponent implements ValueHolder {
private static final String COMPONENT_FAMILY = "org.richfaces.Test";
@Attribute
Modified: root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/AbstractPoll.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/AbstractPoll.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/AbstractPoll.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,16 +23,16 @@
package org.ajax4jsf.component;
+import org.ajax4jsf.context.AjaxContext;
+
import javax.faces.context.FacesContext;
-import org.ajax4jsf.context.AjaxContext;
-
/**
* Component for periodically call AJAX events on server ( poll actions )
* @author shura
*
*/
-//@Component
+//@JsfComponent
public abstract class AbstractPoll extends AjaxActionComponent {
public static final String COMPONENT_TYPE = "org.ajax4jsf.Poll";
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-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxFunction.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,7 @@
package org.richfaces.component;
import org.ajax4jsf.component.AjaxActionComponent;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
/**
@@ -32,9 +32,10 @@
* @version $Revision: 1.1.2.2 $ $Date: 2007/01/23 20:01:04 $
*
*/
-@Component(
+@JsfComponent(
value = "org.richfaces.Function",
- tag = @Tag(name = "jsFunction")
+ tag = @Tag(name = "jsFunction"),
+ generate = false
)
public abstract class AbstractAjaxFunction extends AjaxActionComponent {
public static final String COMPONENT_TYPE = "org.richfaces.Function";
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-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,7 +23,7 @@
package org.richfaces.component;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
import javax.faces.application.ResourceDependencies;
@@ -38,9 +38,10 @@
@ResourceDependency(name = "jquery.js") , @ResourceDependency(name = "richfaces.js") ,
@ResourceDependency(name = "richfaces-jsf-log.js") , @ResourceDependency(name = "richfaces.css")
})
-@Component (
+@JsfComponent(
value = "org.richfaces.AjaxLog",
- tag = @Tag(name = "log")
+ tag = @Tag(name = "log"),
+ generate = false
)
public abstract class AbstractAjaxLog extends UIComponentBase {
public static final String COMPONENT_FAMILY = "org.richfaces.AjaxLog";
Modified: 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-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAjaxOutputPanel.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -23,15 +23,22 @@
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;
-import org.ajax4jsf.component.AjaxOutput;
-
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:26 $
*
*/
+@JsfComponent(
+ value = "org.richfaces.AjaxOutputPanel",
+ tag = @Tag(name = "outputPanel", handlerName = "org.richfaces.taghandler.html.OutputPanelTagHandler"),
+ generate = false
+)
public class AbstractAjaxOutputPanel extends UIPanel implements AjaxOutput {
public static final String COMPONENT_TYPE = "org.richfaces.AjaxOutputPanel";
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-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -25,7 +25,7 @@
import org.ajax4jsf.resource.ResourceComponent2;
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.resource.MediaOutputResource;
@@ -44,9 +44,10 @@
* @author shura
*
*/
-@Component(
+@JsfComponent(
value = "org.richfaces.MediaOutput",
- tag = @Tag(name = "mediaOutput", handlerName = "org.richfaces.taghandler.html.PushMediaOutput")
+ tag = @Tag(name = "mediaOutput", handlerName = "org.richfaces.taghandler.html.PushMediaOutput"),
+ generate = false
)
public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent2 {
public static final String COMPONENT_TYPE = "org.richfaces.MediaOutput";
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-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractPush.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -24,7 +24,7 @@
package org.richfaces.component;
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
@@ -43,7 +43,7 @@
* @author shura
*
*/
-@Component(
+@JsfComponent(
value = "org.richfaces.Push",
tag = @Tag(name = "push", handlerName = "org.richfaces.taghandler.html.PushTagHandler"),
generate = false
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIRepeat.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIRepeat.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIRepeat.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -21,14 +21,14 @@
*/
package org.richfaces.component;
-import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
/**
* @author Nick Belaevski
*
*/
-@Component(generate = false, tag = @Tag(name = "repeat"))
+@JsfComponent(generate = false, tag = @Tag(name = "repeat"))
public class UIRepeat extends UISequence {
public static final String COMPONENT_TYPE = "org.richfaces.Repeat";
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxLog.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxLog.java 2010-03-09 11:07:41 UTC (rev 16538)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxLog.java 2010-03-09 14:24:55 UTC (rev 16539)
@@ -29,7 +29,7 @@
*/
import org.richfaces.component.AbstractAjaxLog;
-//@Component(value = "org.richfaces.AjaxLog", generate = false)
+//@JsfComponent(value = "org.richfaces.AjaxLog", generate = false)
public class HtmlAjaxLog extends AbstractAjaxLog {
public static final String COMPONENT_TYPE = "org.richfaces.AjaxLog";
14 years, 7 months
JBoss Rich Faces SVN: r16538 - in root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk: freemarker and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-03-09 06:07:41 -0500 (Tue, 09 Mar 2010)
New Revision: 16538
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.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/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.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/ConverterModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.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/model/validator/ValidatorImpl.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/RendererClassVisitor.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/templatecompiler/TemplateVisitorFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
Log:
fix checkstyle vilations
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -25,16 +25,14 @@
package org.richfaces.cdk.apt;
-import java.util.Set;
-
-import javax.tools.JavaCompiler.CompilationTask;
-
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.LibraryBuilder;
import org.richfaces.cdk.Logger;
-import com.google.inject.Inject;
+import javax.tools.JavaCompiler.CompilationTask;
+import java.util.Set;
/**
* <p class="changed_added_4_0">
@@ -69,8 +67,6 @@
for (CdkWriter generator : generators) {
generator.render();
}
-
- }
+ }
}
-
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -26,12 +26,11 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.FacesId;
import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.lang.model.element.TypeElement;
import javax.faces.view.facelets.BehaviorHandler;
+import javax.lang.model.element.TypeElement;
import java.lang.annotation.Annotation;
/**
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -3,7 +3,6 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.annotations.DisplayName;
import org.richfaces.cdk.annotations.Icon;
import org.richfaces.cdk.annotations.Tag;
@@ -13,13 +12,7 @@
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.MirroredTypeException;
-import javax.lang.model.type.MirroredTypesException;
-import javax.lang.model.type.TypeMirror;
-
import java.util.Collection;
-import java.util.List;
-import java.util.Map;
public abstract class ProcessorBase {
@@ -128,11 +121,11 @@
protected void setClassNames(TypeElement componentElement, ModelElementBase modelElement,
String generatedClass, String baseClass) {
- if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
- modelElement.setGenerate(true);
- }
- modelElement.setBaseClass(ClassName.parseName(baseClass));
- modelElement.setTargetClass(ClassName.parseName(generatedClass));
+ if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
+ modelElement.setGenerate(true);
+ }
+ modelElement.setBaseClass(ClassName.parseName(baseClass));
+ modelElement.setTargetClass(ClassName.parseName(generatedClass));
}
protected Collection<Property> parseProperties(String attributesConfig) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/SourceUtilsProvider.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,13 +23,13 @@
package org.richfaces.cdk.apt;
-import javax.annotation.processing.ProcessingEnvironment;
-
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import com.google.inject.Singleton;
+import javax.annotation.processing.ProcessingEnvironment;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -50,7 +50,7 @@
* @param defaultUtils
*/
@Inject
- public SourceUtilsProvider(ReflectionUtils defaultUtils,Injector injector) {
+ public SourceUtilsProvider(ReflectionUtils defaultUtils, Injector injector) {
this.defaultUtils = defaultUtils;
this.utils = defaultUtils;
this.injector = injector;
@@ -68,7 +68,7 @@
* @param processingEnv the processingEnv to set
*/
public void setProcessingEnv(ProcessingEnvironment processingEnv) {
- if(null != processingEnv){
+ if (null != processingEnv) {
this.utils = new AptSourceUtils(processingEnv);
injector.injectMembers(this.utils);
} else {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,36 +23,21 @@
package org.richfaces.cdk.apt;
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Inject;
+import org.richfaces.cdk.*;
+
+import javax.annotation.processing.Processor;
+import javax.tools.*;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler.CompilationTask;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Locale;
-import javax.annotation.processing.Processor;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.JavaCompiler.CompilationTask;
-
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.Output;
-import org.richfaces.cdk.Source;
-import org.richfaces.cdk.Outputs;
-import org.richfaces.cdk.Sources;
-
-import com.google.common.collect.ImmutableCollection;
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Inject;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -85,7 +70,8 @@
}
}
- private static final ImmutableCollection<String> COMPILER_OPTIONS = ImmutableList.of("-proc:only","-implicit:class","-verbose");
+ private static final ImmutableCollection<String> COMPILER_OPTIONS =
+ ImmutableList.of("-proc:only", "-implicit:class", "-verbose");
@Inject
private Logger log;
@@ -124,9 +110,10 @@
@Override
public CompilationTask get() throws AptException {
diagnosticListener = new DiagnosticListenerImplementation();
- Iterable<? extends JavaFileObject> sourceObjects = getFileManager().getJavaFileObjectsFromFiles(sourceFolders.getFiles());
- CompilationTask task =
- getJavaCompiler().getTask(null, getFileManager(), diagnosticListener, COMPILER_OPTIONS, null, sourceObjects);
+ Iterable<? extends JavaFileObject> sourceObjects = getFileManager()
+ .getJavaFileObjectsFromFiles(sourceFolders.getFiles());
+ CompilationTask task = getJavaCompiler()
+ .getTask(null, getFileManager(), diagnosticListener, COMPILER_OPTIONS, null, sourceObjects);
task.setLocale(locale);
task.setProcessors(Collections.singleton(cdkProcessor));
return task;
@@ -143,7 +130,7 @@
}
fileManager.setLocation(StandardLocation.SOURCE_PATH, sourceFolders.getFolders());
} catch (IOException e) {
- throw new CdkException("Cannot configure JavaFileManager for compilator",e);
+ throw new CdkException("Cannot configure JavaFileManager for compilator", e);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -25,25 +25,19 @@
package org.richfaces.cdk.freemarker;
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.LibraryVisitor;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Trackable;
-import org.richfaces.cdk.model.Visitable;
-
import com.google.inject.Inject;
-
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.model.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
/**
* <p class="changed_added_4_0">Base class for all output file buildes that use FreeMarker as template engine.</p>
* @author asmirnov(a)exadel.com
@@ -60,7 +54,7 @@
private final FileManager output;
@Inject
- public FreeMarkerRenderer(Configuration configuration,ComponentLibrary library, FileManager output) {
+ public FreeMarkerRenderer(Configuration configuration, ComponentLibrary library, FileManager output) {
this.configuration = configuration;
this.library = library;
this.output = output;
@@ -126,7 +120,7 @@
ModelElementBase modelElement = (ModelElementBase) c;
return modelElement.getTargetClass().getName().replace('.', File.separatorChar) + ".java";
} else {
- throw new CdkException("Unknown model object "+c);
+ throw new CdkException("Unknown model object " + c);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -25,25 +25,22 @@
package org.richfaces.cdk.freemarker;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.Property;
-
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
-
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.ModelElementBase;
+import org.richfaces.cdk.model.Property;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -119,9 +116,9 @@
Collection<Property> attributes = model.getAttributes();
Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
for (Property entry : attributes) {
- if (entry.isGenerate() ) {
+ if (entry.isGenerate()) {
PropertyModel propertyModel = new PropertyModel(entry, wrapper);
- models.add(propertyModel);
+ models.add(propertyModel);
}
}
return wrapper.wrap(models);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -22,18 +22,20 @@
package org.richfaces.cdk.freemarker;
-import org.richfaces.cdk.model.*;
-
-import java.util.*;
-
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
-import freemarker.ext.beans.BeanModel;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.common.base.Predicate;
+import org.richfaces.cdk.model.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
/**
* @author akolonitsky
* @since Feb 23, 2010
@@ -131,7 +133,7 @@
for (Property entry : attributes) {
if (entry.isGenerate() && entry.isBindingAttribute()) {
PropertyModel propertyModel = new PropertyModel(entry, wrapper);
- models.add(propertyModel);
+ models.add(propertyModel);
}
}
return wrapper.wrap(models);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -22,9 +22,8 @@
package org.richfaces.cdk.generate.java;
-import java.io.File;
-
-import org.richfaces.cdk.CdkException;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Output;
@@ -34,10 +33,6 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Visitable;
-import com.google.inject.Inject;
-
-import freemarker.template.Configuration;
-
/**
* @author akolonitsky
* @since Jan 21, 2010
@@ -49,7 +44,8 @@
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
*/
@Inject
- public BehaviorClassGenerator(Configuration configuration, ComponentLibrary library, @Output(Outputs.JAVA_CLASSES) FileManager output) {
+ public BehaviorClassGenerator(Configuration configuration, ComponentLibrary library,
+ @Output(Outputs.JAVA_CLASSES) FileManager output) {
super(configuration, library, output);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -25,9 +25,8 @@
package org.richfaces.cdk.generate.java;
-import java.io.File;
-
-import org.richfaces.cdk.CdkException;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Output;
@@ -37,10 +36,6 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Visitable;
-import com.google.inject.Inject;
-
-import freemarker.template.Configuration;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -22,9 +22,8 @@
package org.richfaces.cdk.generate.java;
-import java.io.File;
-
-import org.richfaces.cdk.CdkException;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Output;
@@ -34,10 +33,6 @@
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.Visitable;
-import com.google.inject.Inject;
-
-import freemarker.template.Configuration;
-
/**
* @author akolonitsky
* @since Jan 20, 2010
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -22,9 +22,8 @@
package org.richfaces.cdk.generate.java;
-import java.io.File;
-
-import org.richfaces.cdk.CdkException;
+import com.google.inject.Inject;
+import freemarker.template.Configuration;
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Output;
@@ -34,10 +33,6 @@
import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.model.Visitable;
-import com.google.inject.Inject;
-
-import freemarker.template.Configuration;
-
/**
* @author akolonitsky
* @since Jan 15, 2010
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGenerator.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,25 +23,19 @@
package org.richfaces.cdk.generate.taglib;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Map;
-
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWriter;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Output;
-import org.richfaces.cdk.Outputs;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.LibraryVisitor;
-import org.richfaces.cdk.model.Visitable;
-
import com.google.inject.Inject;
-
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
+import org.richfaces.cdk.*;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.LibraryVisitor;
+import org.richfaces.cdk.model.Visitable;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
/**
* <p class="changed_added_4_0">
* </p>
@@ -104,8 +98,8 @@
@Override
public Boolean visit(Visitable c, Writer output) throws CdkException {
TagGenerator<Visitable> tagGenerator = (TagGenerator<Visitable>) tagGenerators.get(c.getClass());
- if(null != tagGenerator){
- tagGenerator.generate(c,output);
+ if (null != tagGenerator) {
+ tagGenerator.generate(c, output);
}
return false;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -28,7 +28,6 @@
import org.richfaces.cdk.model.*;
import java.util.List;
-import java.util.Map;
/**
* @author akolonitsky
@@ -79,34 +78,36 @@
}
private String getTagName(ModelElementBase model) {
- return model.getTag().getName();
+ return model.getTag().getName();
}
public void visitConverter(ConverterModel model) {
TagModel tagModel = model.getTag();
if (null != tagModel) {
- Element tag = createTag(tagModel.getName());
- Element converter = tag.addElement("converter");
- converter.addElement("converter-id", model.getId().toString());
+ Element tag = createTag(tagModel.getName());
+ Element converter = tag.addElement("converter");
+ converter.addElement("converter-id", model.getId().toString());
- addTagHandler(converter, model.getTag());
- appendAttributs(tag, model);
+ addTagHandler(converter, model.getTag());
+ appendAttributs(tag, model);
+ }
+ }
- } }
-
/**
- * <tag>
- * <tag-name>formatValidator</tag-name>
- * <validator>
- * <validator-id></validator-id>
- * <handler-class></handler-class>
- * </validator>
+ * <pre>
+ * <tag>
+ * <tag-name>formatValidator</tag-name>
+ * <validator>
+ * <validator-id></validator-id>
+ * <handler-class></handler-class>
+ * </validator>
*
- * <attribute>
+ * <attribute>
* ...
- * </attribute>
- * </tag>
+ * </attribute>
+ * </tag>
+ * <pre>
*
* */
public void visitValidator(ValidatorModel model) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -24,9 +24,7 @@
import java.util.Collection;
-import org.richfaces.cdk.util.ComparatorUtils;
-
/**
* This is the base class for all Java Bean-like JSF objects in the model.
* @author akolonitsky
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -93,12 +93,12 @@
@Override
public boolean same(BehaviorRenderer other) {
- if(null != getType() && null != other.getType()){
+ if (null != getType() && null != other.getType()) {
// Both types not null, compare them.
return getType().equals(other.getType());
}
// one or both types are null, compare classes.
- if(null != getRendererClass() && getRendererClass().equals(other.getRendererClass())){
+ if (null != getRendererClass() && getRendererClass().equals(other.getRendererClass())) {
return true;
}
return false;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,11 +23,10 @@
package org.richfaces.cdk.model;
-import java.io.Serializable;
-
+import com.google.common.collect.ImmutableMap;
import org.richfaces.cdk.util.Strings;
-import com.google.common.collect.ImmutableMap;
+import java.io.Serializable;
/**
* <p class="changed_added_4_0">
@@ -68,14 +67,6 @@
private String typeParameters;
/**
- * <p class="changed_added_4_0">Factory method to create class names. For empty or null name, returns null</p>
- * @param name fully-cvalified class name
- * @return new class name instance or null.
- */
- public static ClassName parseName(String name){
- return Strings.isEmpty(name)?null:new ClassName(name);
- }
- /**
* <p class="changed_added_4_0"></p>
*
* @param cl
@@ -114,6 +105,15 @@
}
}
+ /**
+ * <p class="changed_added_4_0">Factory method to create class names. For empty or null name, returns null</p>
+ * @param name fully-cvalified class name
+ * @return new class name instance or null.
+ */
+ public static ClassName parseName(String name) {
+ return Strings.isEmpty(name) ? null : new ClassName(name);
+ }
+
public static ClassName get(String name) {
if (name == null) {
return null;
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-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -1,9 +1,9 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
import java.util.Collection;
-import org.richfaces.cdk.CdkException;
-
/**
* That class represents JSF component in the CDK.
* That is mapped to faces-config "component" element.
@@ -62,8 +62,8 @@
@Override
public void merge(ComponentModel otherComponent) {
//merge facets, renderers, events ...
- ComponentLibrary.merge(getAttributes(),otherComponent.getAttributes());
- ComponentLibrary.merge(getFacets(),otherComponent.getFacets());
+ ComponentLibrary.merge(getAttributes(), otherComponent.getAttributes());
+ ComponentLibrary.merge(getFacets(), otherComponent.getFacets());
ComponentLibrary.merge(getEvents(), otherComponent.getEvents());
ComponentLibrary.merge(getRenderers(), otherComponent.getRenderers());
ComponentLibrary.merge(this, otherComponent);
@@ -72,7 +72,7 @@
@Override
public boolean same(ComponentModel other) {
- if(null != getType() && null != other.getType()){
+ if (null != getType() && null != other.getType()) {
// Both types not null, compare them.
return getType().equals(other.getType());
}
@@ -152,7 +152,7 @@
public FacetModel getOrCreateFacet(String name) {
FacetModel facet = getFacet(name);
- if(null == facet){
+ if (null == facet) {
facet = new FacetModel();
facet.setName(name);
facets.add(facet);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -65,7 +65,7 @@
@Override
public void merge(ConverterModel other) {
- ComponentLibrary.merge(getAttributes(),other.getAttributes());
+ ComponentLibrary.merge(getAttributes(), other.getAttributes());
ComponentLibrary.merge(this, other);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/DescriptionGroup.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -69,7 +69,9 @@
*
* @author asmirnov(a)exadel.com
*/
- @XmlType(name = "iconType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,propOrder={"smallIcon","largeIcon"})
+ @XmlType(name = "iconType",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ propOrder = {"smallIcon", "largeIcon"})
public static final class Icon {
private String largeIcon;
private String smallIcon;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,10 +23,10 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.util.Strings;
+
import java.io.Serializable;
-import org.richfaces.cdk.util.Strings;
-
/**
* <p class="changed_added_4_0">This is a FacesId class that should be used to find JSF elements in {@link ComponentLibrary}</p>
*
@@ -37,9 +37,6 @@
private final String type;
- public static FacesId parseId(String id){
- return Strings.isEmpty(id)?null:new FacesId(id);
- }
/**
* <p class="changed_added_4_0"></p>
*
@@ -49,6 +46,10 @@
this.type = type;
}
+ public static FacesId parseId(String id) {
+ return Strings.isEmpty(id) ? null : new FacesId(id);
+ }
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,10 +23,9 @@
package org.richfaces.cdk.model;
+import com.google.common.base.Predicate;
import org.richfaces.cdk.util.ComparatorUtils;
-import com.google.common.base.Predicate;
-
/**
* <p class="changed_added_4_0">This interface represents all models for "named" JSF objects ( attributes, properties, facets )</p>
* @author asmirnov(a)exadel.com
@@ -36,15 +35,15 @@
public static final class NamedPredicate implements Predicate<Named> {
- private final String _name;
-
+ private final String name;
+
public NamedPredicate(String name) {
- this._name = name;
+ this.name = name;
}
@Override
public boolean apply(Named input) {
- return ComparatorUtils.nullSafeEquals(input.getName(), this._name);
+ return ComparatorUtils.nullSafeEquals(input.getName(), this.name);
}
}
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-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -47,7 +47,7 @@
private TagModel tag;
- public RendererModel() {}
+ public RendererModel() { }
public RendererModel(Type type) {
this.type = type;
@@ -171,16 +171,16 @@
@Override
public boolean same(RendererModel other) {
- if(null != getType() && null != other.getType()){
+ if (null != getType() && null != other.getType()) {
// compare families ?
- if(null != getFamily() && null != other.getFamily() && !getFamily().equals(other.getFamily())){
+ if (null != getFamily() && null != other.getFamily() && !getFamily().equals(other.getFamily())) {
return false;
}
// Both types not null, compare them.
return getType().equals(other.getType());
}
// one or both types are null, compare classes.
- if(null != getRendererClass()&& getRendererClass().equals(other.getRendererClass())){
+ if (null != getRendererClass() && getRendererClass().equals(other.getRendererClass())) {
return true;
}
return false;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -25,23 +25,16 @@
package org.richfaces.cdk.model.validator;
-import java.util.Collection;
-
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.ModelValidator;
import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.apt.SourceUtils;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.FacetModel;
-import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.RenderKitModel;
-import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.util.Strings;
-import com.google.inject.Inject;
+import java.util.Collection;
/**
* <p class="changed_added_4_0"></p>
@@ -126,7 +119,7 @@
} else if (null == component.getComponentClass()) {
component.setTargetClass(namingConventions.inferUIComponentClass(component.getType()));
}
- } else if (null == component.getComponentClass()){
+ } else if (null == component.getComponentClass()) {
if (null != component.getBaseClass()) {
component.setTargetClass(component.getBaseClass());
} else {
@@ -135,13 +128,13 @@
}
}
// Check family.
- if(null == component.getFamily()){
+ if (null == component.getFamily()) {
component.setFamily(namingConventions.inferUIComponentFamily(component.getType()));
}
// TODO Propagate attributes from parent component.
// Check attributes.
for (Property attribute : component.getAttributes()) {
- verifyAttribute(attribute,component.isGenerate());
+ verifyAttribute(attribute, component.isGenerate());
}
// compact(component.getAttributes());
// Check renderers.
@@ -154,28 +147,28 @@
protected void verifyAttribute(Property attribute, boolean generatedComponent) {
// Check name.
- if(Strings.isEmpty(attribute.getName())){
- log.error("No name for attribute "+attribute);
+ if (Strings.isEmpty(attribute.getName())) {
+ log.error("No name for attribute " + attribute);
return;
}
- if(attribute.getName().contains(".") || Character.isDigit(attribute.getName().charAt(0)) || attribute.getName().contains(" ") ){
- log.error("Invalid attribute name ["+attribute.getName()+"]");
+ if (attribute.getName().contains(".") || Character.isDigit(attribute.getName().charAt(0)) || attribute.getName().contains(" ")) {
+ log.error("Invalid attribute name [" + attribute.getName() + "]");
return;
}
// Check type
- if(null == attribute.getType()){
- log.error("Unknown type of attribute ["+attribute.getName()+"]");
+ if (null == attribute.getType()) {
+ log.error("Unknown type of attribute [" + attribute.getName() + "]");
return;
}
// Check binding properties.
- if("javax.faces.el.MethodBinding".equals(attribute.getType().getName())){
+ if ("javax.faces.el.MethodBinding".equals(attribute.getType().getName())) {
attribute.setBinding(true);
attribute.setBindingAttribute(true);
- } else if("javax.el.MethodExpression".equals(attribute.getType().getName())){
+ } else if ("javax.el.MethodExpression".equals(attribute.getType().getName())) {
attribute.setBindingAttribute(true);
}
// Check "generate" flag.
- if(generatedComponent){
+ if (generatedComponent) {
// TODO Attribute should be only generated if it does not exist or abstract in the base class.
// Step one - check base class
} else {
@@ -184,7 +177,7 @@
verifyDescription(attribute);
}
- protected void verifyDescription(DescriptionGroup element){
+ protected void verifyDescription(DescriptionGroup element) {
}
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-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,32 +23,18 @@
package org.richfaces.cdk.templatecompiler;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Map;
-
+import com.google.inject.Inject;
+import freemarker.template.TemplateException;
import org.richfaces.builder.model.JavaClass;
-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.Property;
-import org.richfaces.cdk.model.RenderKitModel;
-import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.*;
+import org.richfaces.cdk.model.*;
import org.richfaces.cdk.model.RendererModel.Type;
import org.richfaces.cdk.templatecompiler.model.Template;
-import com.google.common.collect.Maps;
-import com.google.inject.Inject;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collection;
-import freemarker.template.TemplateException;
-
/**
* <p class="changed_added_4_0">
* </p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,35 +23,11 @@
package org.richfaces.cdk.templatecompiler;
-import static org.richfaces.cdk.templatecompiler.QNameComparator.QNAME_COMPARATOR;
-import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
-import static org.richfaces.cdk.util.JavaUtils.getEscapedStringsArray;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-import javax.xml.namespace.QName;
-
-import org.richfaces.builder.model.Argument;
-import org.richfaces.builder.model.JavaClass;
-import org.richfaces.builder.model.JavaField;
-import org.richfaces.builder.model.JavaMethod;
-import org.richfaces.builder.model.JavaModifier;
-import org.richfaces.builder.model.MethodBody;
-import org.richfaces.builder.model.MethodBodyStatementsContainer;
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import org.richfaces.builder.model.*;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.attributes.Attribute;
@@ -60,33 +36,22 @@
import org.richfaces.cdk.attributes.SchemaSet;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.parser.el.ELParserUtils;
-import org.richfaces.cdk.parser.el.ELVisitor;
-import org.richfaces.cdk.parser.el.HelperMethod;
-import org.richfaces.cdk.parser.el.ParsingException;
-import org.richfaces.cdk.parser.el.Type;
+import org.richfaces.cdk.parser.el.*;
import org.richfaces.cdk.parser.el.types.TypesFactory;
-import org.richfaces.cdk.templatecompiler.model.AnyElement;
-import org.richfaces.cdk.templatecompiler.model.CdkBodyElement;
-import org.richfaces.cdk.templatecompiler.model.CdkCallElement;
-import org.richfaces.cdk.templatecompiler.model.CdkChooseElement;
-import org.richfaces.cdk.templatecompiler.model.CdkForEachElement;
-import org.richfaces.cdk.templatecompiler.model.CdkIfElement;
-import org.richfaces.cdk.templatecompiler.model.CdkObjectElement;
-import org.richfaces.cdk.templatecompiler.model.CdkOtherwiseElement;
-import org.richfaces.cdk.templatecompiler.model.CdkWhenElement;
-import org.richfaces.cdk.templatecompiler.model.CompositeImplementation;
-import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
-import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
-import org.richfaces.cdk.util.ComparatorUtils;
+import static org.richfaces.cdk.templatecompiler.QNameComparator.QNAME_COMPARATOR;
+import org.richfaces.cdk.templatecompiler.model.*;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedStringsArray;
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.JAXB;
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.util.*;
/**
* <p class="changed_added_4_0">
@@ -297,7 +262,7 @@
// OPTIMIZATION - use ModelCollection with lookup method
for (Property property : attributes) {
- if(attributeName.equals(property.getName())){
+ if (attributeName.equals(property.getName())) {
Set<EventName> eventNames = property.getEventNames();
if (eventNames != null && !eventNames.isEmpty()) {
sb.append(".setEventNames(");
@@ -322,7 +287,7 @@
private String createPassThroughField(Map<String, Attribute> htmlAttributesMap) {
String fieldName = PASS_THROUGH_ATTRIBUTES_FIELD_NAME;
if (passThroughCounter >= 0) {
- fieldName += ("_" + passThroughCounter);
+ fieldName += "_" + passThroughCounter;
}
passThroughCounter++;
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-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,35 +23,23 @@
package org.richfaces.cdk.templatecompiler;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import com.google.inject.Inject;
+import org.richfaces.cdk.*;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.templatecompiler.model.*;
+import org.richfaces.cdk.xmlconfig.FragmentParser;
+import org.richfaces.cdk.xmlconfig.JAXB;
+
import java.io.File;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.FileManager;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.Source;
-import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.*;
-import org.richfaces.cdk.templatecompiler.model.Attribute;
-import org.richfaces.cdk.templatecompiler.model.ClientBehavior;
-import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
-import org.richfaces.cdk.templatecompiler.model.ImportAttributes;
-import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.FragmentParser;
-import org.richfaces.cdk.xmlconfig.JAXB;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.inject.Inject;
-
/**
* <p class="changed_added_4_0">
* </p>
@@ -85,7 +73,9 @@
* @param sources
*/
@Inject
- public RendererTemplateParser(ComponentLibrary library, JAXB jaxbBinding, Logger log, @Source(Sources.RENDERER_TEMPLATES) FileManager sources,FragmentParser fragmentParser) {
+ public RendererTemplateParser(ComponentLibrary library, JAXB jaxbBinding, Logger log,
+ @Source(Sources.RENDERER_TEMPLATES) FileManager sources,
+ FragmentParser fragmentParser) {
this.library = library;
this.jaxbBinding = jaxbBinding;
this.log = log;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,13 +23,12 @@
package org.richfaces.cdk.templatecompiler;
-import java.util.Collection;
-import java.util.Map;
-
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+import java.util.Collection;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -37,6 +36,6 @@
*/
public interface TemplateVisitorFactory <T extends TemplateVisitor> {
- public T createVisitor(CompositeInterface composite,Collection<Property> attributes);
+ public T createVisitor(CompositeInterface composite, Collection<Property> attributes);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,10 +23,7 @@
package org.richfaces.cdk.xmlconfig;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
+import com.google.inject.Inject;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
@@ -34,7 +31,8 @@
import org.richfaces.cdk.xmlconfig.model.ComponentAdapter;
import org.richfaces.cdk.xmlconfig.model.Fragment;
-import com.google.inject.Inject;
+import java.util.Collection;
+import java.util.Collections;
/**
* <p class="changed_added_4_0">
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,20 +23,21 @@
package org.richfaces.cdk.xmlconfig.model;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentLibrary;
+
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentLibrary;
-
/**
* <p class="changed_added_4_0"></p>
*
* @author asmirnov(a)exadel.com
*/
-@XmlType(name="faces-config-propertyType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"name","type","defaultValue","suggestedValue","extension"})
+@XmlType(name = "faces-config-propertyType",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ propOrder = {"name", "type", "defaultValue", "suggestedValue", "extension"})
@XmlJavaTypeAdapter(AttributeAdapter.class)
public class PropertyBean extends PropertyBase {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2010-03-09 01:17:56 UTC (rev 16537)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2010-03-09 11:07:41 UTC (rev 16538)
@@ -23,26 +23,25 @@
package org.richfaces.cdk.xmlconfig.model;
-import java.util.List;
+import com.google.common.collect.Lists;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.model.RenderKitModel.Id;
import javax.faces.render.RenderKitFactory;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.List;
-import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.*;
-import org.richfaces.cdk.model.RenderKitModel.Id;
-
-import com.google.common.collect.Lists;
-
/**
* <p class="changed_added_4_0"></p>
*
* @author asmirnov(a)exadel.com
*/
-@XmlType(name="faces-config-render-kitType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"key","renderkitClass","renderers","behaviorRenderers","extension"})
+@XmlType(
+ name = "faces-config-render-kitType",
+ namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ propOrder = {"key", "renderkitClass", "renderers", "behaviorRenderers", "extension"})
public class RenderKitBean extends ExtensibleBean<RenderKitBean.RenderKitExtension> implements MapEntry<RenderKitModel.Id> {
private List<RendererModel> renderers = Lists.newArrayList();
14 years, 7 months
JBoss Rich Faces SVN: r16537 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/apt and 16 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-08 20:17:56 -0500 (Mon, 08 Mar 2010)
New Revision: 16537
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.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/apt/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.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/ConverterModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.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/ValidatorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
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/JAXBCopyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
Log:
CODING IN PROGRESS - issue RF-7736: Library model verifier.
https://jira.jboss.org/jira/browse/RF-7736
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -24,7 +24,7 @@
package org.richfaces.cdk;
import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.InvalidNameException;
/**
@@ -50,7 +50,7 @@
* @return JSF component type.
* @throws InvalidNameException if className does not match naming conventions.
*/
- public ComponentModel.Type inferComponentType(ClassName componentClass) throws InvalidNameException;
+ public FacesId inferComponentType(ClassName componentClass) throws InvalidNameException;
/**
* <p class="changed_added_4_0">Calculates concrete component class from explicit value or type.</p>
@@ -63,7 +63,7 @@
* @return Descriptor of generated UIComponent class.
* @throws InvalidNameException if component type does not follow naming conventions.
*/
- public ClassName inferUIComponentClass(ComponentModel.Type componentType) throws InvalidNameException;
+ public ClassName inferUIComponentClass(FacesId componentType) throws InvalidNameException;
/**
@@ -72,10 +72,10 @@
* @return
* @throws InvalidNameException
*/
- public String inferUIComponentFamily(ComponentModel.Type componentType) throws InvalidNameException;
+ public String inferUIComponentFamily(FacesId componentType) throws InvalidNameException;
- public ClassName inferTagHandlerClass(ComponentModel.Type componentType, String markup) throws InvalidNameException;
+ public ClassName inferTagHandlerClass(FacesId componentType, String markup) throws InvalidNameException;
- public String inferTagName(ComponentModel.Type componentType) throws InvalidNameException;
+ public String inferTagName(FacesId componentType) throws InvalidNameException;
}
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-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -1,7 +1,7 @@
package org.richfaces.cdk;
import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.model.Name;
import org.richfaces.cdk.model.Name.Classifier;
@@ -28,7 +28,7 @@
@Override
- public ComponentModel.Type inferComponentType(ClassName componentClass) throws InvalidNameException {
+ public FacesId inferComponentType(ClassName componentClass) throws InvalidNameException {
// check parameters.
if (null == componentClass) {
@@ -70,11 +70,11 @@
name.setSimpleName(simpleName);
- return new ComponentModel.Type(name.toString());
+ return new FacesId(name.toString());
}
@Override
- public ClassName inferUIComponentClass(ComponentModel.Type componentType) throws InvalidNameException {
+ public ClassName inferUIComponentClass(FacesId componentType) throws InvalidNameException {
if (null == componentType) {
throw new IllegalArgumentException();
}
@@ -94,7 +94,7 @@
}
@Override
- public String inferUIComponentFamily(ComponentModel.Type componentType) {
+ public String inferUIComponentFamily( FacesId componentType) {
if (null == componentType) {
throw new IllegalArgumentException();
}
@@ -112,7 +112,7 @@
*
* */
@Override
- public ClassName inferTagHandlerClass(ComponentModel.Type componentType, String markup) {
+ public ClassName inferTagHandlerClass(FacesId componentType, String markup) {
if (null == componentType) {
throw new IllegalArgumentException();
}
@@ -124,7 +124,7 @@
}
@Override
- public String inferTagName(ComponentModel.Type componentType) {
+ public String inferTagName(FacesId componentType) {
if (null == componentType) {
throw new IllegalArgumentException();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -26,6 +26,8 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.FacesId;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
@@ -44,7 +46,7 @@
public void process(TypeElement element) throws CdkProcessingException {
JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
- BehaviorModel behaviorModel = new BehaviorModel(behavior.id());
+ BehaviorModel behaviorModel = new BehaviorModel(new FacesId(behavior.id()));
setClassNames(element, behaviorModel, behavior);
setTagInfo(behavior.tag(), behaviorModel);
@@ -61,11 +63,6 @@
public void setClassNames(TypeElement element, BehaviorModel behaviorModel, JsfBehavior behavior) {
String baseClass = element.getQualifiedName().toString();
- if (behavior == null) {
- behaviorModel.setClassNames(baseClass, null);
- return;
- }
-
setClassNames(element, behaviorModel, behavior.behaviorClass(), baseClass);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -25,16 +25,9 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.Lists;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.annotations.*;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
-import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
-import org.richfaces.cdk.model.*;
-import org.richfaces.cdk.model.ComponentModel.Type;
-import org.richfaces.cdk.util.Strings;
-import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.faces.event.FacesEvent;
@@ -43,10 +36,37 @@
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.List;
-import java.util.Set;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.Attributes;
+import org.richfaces.cdk.annotations.Component;
+import org.richfaces.cdk.annotations.DefaultValue;
+import org.richfaces.cdk.annotations.DisplayName;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.EventNames;
+import org.richfaces.cdk.annotations.Facet;
+import org.richfaces.cdk.annotations.Facets;
+import org.richfaces.cdk.annotations.Family;
+import org.richfaces.cdk.annotations.Fires;
+import org.richfaces.cdk.annotations.Generate;
+import org.richfaces.cdk.annotations.Icon;
+import org.richfaces.cdk.annotations.Signature;
+import org.richfaces.cdk.annotations.SuggestedValue;
+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.ClassName;
+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.model.Property;
+import org.richfaces.cdk.util.Strings;
+import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
+
+import com.google.common.collect.Lists;
+
/**
* <p class="changed_added_4_0">That class process component-related annotations such as {@link Component} or
* {@link javax.faces.component.FacesComponent} and stores information in model.
@@ -62,7 +82,7 @@
ComponentLibrary library = getLibrary();
// Process class-level annotations.
ComponentModel component = new ComponentModel();
- component.setType(new Type(getComponentType(componentElement)));
+ component.setType(new FacesId(getComponentType(componentElement)));
// Should that component be generated ?
setClassNames(componentElement, component);
setComponentProperties(componentElement, component);
@@ -115,7 +135,7 @@
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
- FacetModel facet = component.addFacet(beanProperty.getName());
+ FacetModel facet = component.getOrCreateFacet(beanProperty.getName());
// Documentation
facet.setDescription(beanProperty.getDocComment());
@@ -144,7 +164,7 @@
for (Facet facet : facets) {
if (!Strings.isEmpty(facet.value())) {
- component.addFacet(facet.value());
+ component.getOrCreateFacet(facet.value());
} else {
// TODO - record error.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ConverterProcessor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -25,6 +25,7 @@
import org.richfaces.cdk.annotations.JsfConverter;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ConverterModel;
+import org.richfaces.cdk.model.FacesId;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
@@ -44,7 +45,7 @@
JsfConverter converter = element.getAnnotation(JsfConverter.class);
ConverterModel converterModel = new ConverterModel();
- converterModel.setConverterId(converter.id());
+ converterModel.setId(FacesId.parseId(converter.id()));
try {
converterModel.setConverterForClass(new ClassName(converter.forClass().getName()));
@@ -68,10 +69,6 @@
// TODO same method in the ValidatorProcessor move their in one class
public void setClassNames(TypeElement componentElement, ConverterModel converterModel, JsfConverter converter) {
String baseClass = componentElement.getQualifiedName().toString();
- if (converter == null) {
- converterModel.setClassNames(baseClass, null);
- return;
- }
setClassNames(componentElement, converterModel, converter.converterClass(), baseClass);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -62,93 +62,22 @@
}
protected void setTagInfo(Tag tag, ModelElementBase model) {
- ClassDescriptor tagHandler = getTagHandler(tag, model);
String name = tag.name();
// if (Strings.isEmpty(name)) {
// name = namingConventions.inferTagName(model.getGeneratedClass());
// }
- model.setTag(new TagModel(model, name, tagHandler));
+ 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);
}
- private ClassDescriptor getTagHandler(Tag tag, ModelElementBase model) {
- String tagHandlerClass = getTagHandlerClass(tag);
- if (tagHandlerClass != null) {
- return new ClassDescriptor(tagHandlerClass, false);
- }
-
- String handlerBase = getTagHandlerParentClass(tag);
- String tagHandlerClassName = getTagHandlerClassName(tag);
- boolean generate = isGenerateTagHandler(model, handlerBase, tagHandlerClassName);
-
-// if (Strings.isEmpty(tagHandlerClassName)) {
-// tagHandlerClassName = namingConventions.inferTagHandlerName(model.getGeneratedClass());
-// }
-
- if (handlerBase == null) {
- handlerBase = getDafaultParentTagHandlerClass();
- }
-
- return new ClassDescriptor(tagHandlerClassName, handlerBase, generate);
- }
-
- private boolean isGenerateTagHandler(ModelElementBase model, String handlerBase, String tagHandlerClassName) {
- if (!Strings.isEmpty(tagHandlerClassName) || handlerBase != null) {
- return true;
- }
-
- for (Property entry : model.getAttributes()) {
- if (entry.isBindingAttribute()) {
- return true;
- }
- }
-
- return false;
- }
-
- private String getTagHandlerClassName(Tag tag) {
- return tag.handlerName();
- }
-
- private String getTagHandlerParentClass(Tag tag) {
- String tagHandlerParentClass = null;
- try {
- tagHandlerParentClass = tag.baseHandler().getName();
- } catch (MirroredTypesException mirror) {
- List<? extends TypeMirror> mirrors = mirror.getTypeMirrors();
- if (!mirrors.isEmpty()) {
- tagHandlerParentClass = mirrors.get(0).toString();
- }
- } catch (MirroredTypeException mirror) {
- tagHandlerParentClass = mirror.getTypeMirror().toString();
- }
-
- if (TAG_HANDLER_DEFULT_CLASS.equals(tagHandlerParentClass)) {
- tagHandlerParentClass = null;
- }
- return tagHandlerParentClass;
- }
-
- private String getTagHandlerClass(Tag tag) {
- String tagHandlerClass = null;
- try {
- tagHandlerClass = tag.handler().getName();
- } catch (MirroredTypesException mirror) {
- List<? extends TypeMirror> mirrors = mirror.getTypeMirrors();
- if (!mirrors.isEmpty()) {
- tagHandlerClass = mirrors.get(0).toString();
- }
- } catch (MirroredTypeException mirror) {
- tagHandlerClass = mirror.getTypeMirror().toString();
- }
-
- if (TAG_HANDLER_DEFULT_CLASS.equals(tagHandlerClass)) {
- tagHandlerClass = null;
- }
- return tagHandlerClass;
- }
-
protected String getDafaultParentTagHandlerClass() {
return null;
}
@@ -199,18 +128,11 @@
protected void setClassNames(TypeElement componentElement, ModelElementBase modelElement,
String generatedClass, String baseClass) {
- if (generatedClass == null || generatedClass.isEmpty() || baseClass.equals(generatedClass)) {
if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
modelElement.setGenerate(true);
- //namingConventions.inferUIComponentClass(modelElement.getId(), null, baseClass, true);
- generatedClass = componentElement.getQualifiedName().toString() + "Generated";
- modelElement.setClassNames(generatedClass, baseClass);
- } else {
- modelElement.setClassNames(baseClass, null);
}
- } else {
- modelElement.setClassNames(generatedClass, baseClass);
- }
+ modelElement.setBaseClass(ClassName.parseName(baseClass));
+ modelElement.setTargetClass(ClassName.parseName(generatedClass));
}
protected Collection<Property> parseProperties(String attributesConfig) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ValidatorProcessor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -23,6 +23,7 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.annotations.JsfValidator;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.ValidatorModel;
import javax.annotation.processing.SupportedAnnotationTypes;
@@ -41,7 +42,7 @@
public void process(TypeElement element) throws CdkProcessingException {
JsfValidator validator = element.getAnnotation(JsfValidator.class);
- ValidatorModel validatorModel = new ValidatorModel(validator.id());
+ ValidatorModel validatorModel = new ValidatorModel(FacesId.parseId((validator.id())));
setClassNames(element, validatorModel, validator);
setDescription(element, validatorModel);
@@ -58,11 +59,6 @@
public void setClassNames(TypeElement componentElement, ValidatorModel validatorModel,
JsfValidator validator) {
String baseClass = componentElement.getQualifiedName().toString();
- if (validator == null) {
- validatorModel.setClassNames(baseClass, null);
- return;
- }
-
setClassNames(componentElement, validatorModel, validator.validatorClass(), baseClass);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -25,6 +25,7 @@
package org.richfaces.cdk.freemarker;
+import java.io.File;
import java.io.IOException;
import java.io.Writer;
@@ -33,6 +34,7 @@
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.LibraryVisitor;
+import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
@@ -119,7 +121,14 @@
}
}
- protected abstract String getOutputFile(C c) throws CdkException;
+ protected String getOutputFile(C c) throws CdkException {
+ if (c instanceof ModelElementBase) {
+ ModelElementBase modelElement = (ModelElementBase) c;
+ return modelElement.getTargetClass().getName().replace('.', File.separatorChar) + ".java";
+ } else {
+ throw new CdkException("Unknown model object "+c);
+ }
+ }
protected abstract boolean isMyComponent(Visitable c);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -63,11 +63,6 @@
}
@Override
- protected String getOutputFile(BehaviorModel c) throws CdkException {
- return c.getBehaviorClass().getName().replace('.', File.separatorChar) + ".java";
- }
-
- @Override
protected String getTemplateName() {
return "behavior.ftl";
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -67,11 +67,6 @@
}
@Override
- protected String getOutputFile(ComponentModel c) throws CdkException {
- return c.getComponentClass().getName().replace('.', File.separatorChar) + ".java";
- }
-
- @Override
protected String getTemplateName() {
return "component.ftl";
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -60,11 +60,6 @@
}
@Override
- protected String getOutputFile(ConverterModel converter) throws CdkException {
- return converter.getConverterClass().getName().replace('.', File.separatorChar) + ".java";
- }
-
- @Override
protected String getTemplateName() {
return "converter.ftl";
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -59,11 +59,6 @@
}
@Override
- protected String getOutputFile(ValidatorModel validator) throws CdkException {
- return validator.getValidatorClass().getName().replace('.', File.separatorChar) + ".java";
- }
-
- @Override
protected String getTemplateName() {
return "validator.ftl";
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -91,6 +91,6 @@
}
private String getOutputFileName(TagModel tag) {
- return tag.getTagHandlerClass().replace('.', File.separatorChar) + ".java";
+ return tag.getTargetClass().getName().replace('.', File.separatorChar) + ".java";
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerGeneratorVisitor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -57,7 +57,7 @@
private void generateTagHandler(ModelElementBase model) {
TagModel tag = model.getTag();
- if (tag == null || !tag.getHandler().isGenerate()) {
+ if (tag == null || !tag.isGenerate()) {
return;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -69,37 +69,32 @@
}
private void addTagHandler(Element parent, TagModel tag) {
- if (tag != null && tag.getTagHandlerClass() != null && tag.getHandler().isGenerate()) {
- parent.addElement("handler-class").addText(tag.getTagHandlerClass());
+ if (tag != null && tag.getTargetClass() != null) {
+ parent.addElement("handler-class").addText(tag.getTargetClass().toString());
}
}
private String getComponentTagName(ComponentModel model) {
- return getTagName(model, getTagName(model.getType().getType()));
+ return getTagName(model);
}
- private String getTagName(ModelElementBase model, String defaults) {
- try {
+ private String getTagName(ModelElementBase model) {
return model.getTag().getName();
- } catch (NullPointerException e) {
- return defaults;
- }
}
- private String getTagName(String type) {
- String name = ClassName.getSimpleName(type);
- return name.substring(0, 1).toLowerCase() + name.substring(1);
- }
public void visitConverter(ConverterModel model) {
- Element tag = createTag(getTagName(model, getTagName(model.getConverterId())));
+ TagModel tagModel = model.getTag();
+ if (null != tagModel) {
+ Element tag = createTag(tagModel.getName());
Element converter = tag.addElement("converter");
- converter.addElement("converter-id", model.getConverterId());
+ converter.addElement("converter-id", model.getId().toString());
addTagHandler(converter, model.getTag());
appendAttributs(tag, model);
- }
+ } }
+
/**
* <tag>
* <tag-name>formatValidator</tag-name>
@@ -115,9 +110,9 @@
*
* */
public void visitValidator(ValidatorModel model) {
- Element tag = createTag(getTagName(model, getTagName(model.getValidatorId())));
+ Element tag = createTag(getTagName(model));
Element validator = tag.addElement("validator");
- validator.addElement("validator-id", model.getValidatorId());
+ validator.addElement("validator-id", model.getId().toString());
addTagHandler(validator, model.getTag());
appendAttributs(tag, model);
@@ -164,16 +159,12 @@
public void visitBehavior(BehaviorModel model) {
Element tag = createTag(getTagName(model));
Element validator = tag.addElement("behavior");
- validator.addElement("behavior-id").addText(model.getBehaviorId());
+ validator.addElement("behavior-id").addText(model.getId().toString());
addTagHandler(validator, model.getTag());
appendAttributs(tag, model);
}
- private String getTagName(ModelElementBase model) {
- return getTagName(model, getTagName(model.getId()));
- }
-
public void visitFacet(FacetModel model) {
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -26,6 +26,7 @@
import org.richfaces.cdk.util.ComparatorUtils;
+
/**
* This is the base class for all Java Bean-like JSF objects in the model.
* @author akolonitsky
@@ -52,14 +53,9 @@
* @param name
* @return
*/
- public Property getAttribute(String name) {
+ public Property getAttribute(final String name) {
// OPTIMIZATION keep HashMap for name-property pair for fast lookup.
- for (Property property : attributes) {
- if(ComparatorUtils.nullSafeEquals(property.getName(), name)){
- return property;
- }
- }
- return null;
+ return attributes.find(new Named.NamedPredicate(name));
}
public Property getOrCreateAttribute(String attributeName) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -39,18 +39,11 @@
public BehaviorModel() {
}
- public BehaviorModel(String behaviorId) {
+ public BehaviorModel(FacesId behaviorId) {
setId(behaviorId);
}
- public String getBehaviorId() {
- return getId();
- }
- public ClassName getBehaviorClass() {
- return getGeneratedClass();
- }
-
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
return visitor.visit(this, param);
@@ -68,6 +61,6 @@
@Override
public boolean same(BehaviorModel other) {
- return null != getBehaviorId() && getBehaviorId().equals(other.getBehaviorId());
+ return null != getId() && getId().equals(other.getId());
}
}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescriptor.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -1,117 +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.model;
-
-import java.io.Serializable;
-
-/**
- * @author akolonitsky
- * @since Feb 22, 2010
- */
-public class ClassDescriptor implements Serializable {
-
- private final ClassName name;
-
- private ClassName parent;
-
- private boolean generate = false;
-
- public ClassDescriptor(String name) {
- this(name, null);
- }
-
- public ClassDescriptor(String name, String parent) {
- this(ClassName.get(name), ClassName.get(parent));
- }
-
- public ClassDescriptor(Class name) {
- this(name, null);
- }
-
- public ClassDescriptor(Class name, Class parent) {
- this(ClassName.get(name), ClassName.get(parent));
- }
-
- public ClassDescriptor(String name, boolean generate) {
- this(new ClassName(name), generate);
- }
-
- public ClassDescriptor(String name, String parent, boolean generate) {
- this(ClassName.get(name), ClassName.get(parent), generate);
- }
-
- public ClassDescriptor(Class name, boolean generate) {
- this(ClassName.get(name), null, generate);
- }
-
- public ClassDescriptor(Class name, Class parent, boolean generate) {
- this(ClassName.get(name), ClassName.get(parent), generate);
- }
-
- public ClassDescriptor(ClassName name, boolean generate) {
- this(name, null, generate);
- }
-
- public ClassDescriptor(ClassName name, ClassName parent, boolean generate) {
- this.name = name;
- this.parent = parent;
- this.generate = generate;
- }
-
- public ClassDescriptor(ClassName name) {
- this(name, null, false);
- }
-
- public ClassDescriptor(ClassName name, ClassName parent) {
- this(name, parent, false);
- }
-
- public String getPackage() {
- return name.getPackage();
- }
-
- public String getSimpleName() {
- return name.getSimpleName();
- }
-
- @Override
- public String toString() {
- return name.toString();
- }
-
- public ClassName getName() {
- return name;
- }
-
- public ClassName getParent() {
- return parent;
- }
-
- public boolean isGenerate() {
- return generate;
- }
-
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -25,6 +25,8 @@
import java.io.Serializable;
+import org.richfaces.cdk.util.Strings;
+
import com.google.common.collect.ImmutableMap;
/**
@@ -66,6 +68,14 @@
private String typeParameters;
/**
+ * <p class="changed_added_4_0">Factory method to create class names. For empty or null name, returns null</p>
+ * @param name fully-cvalified class name
+ * @return new class name instance or null.
+ */
+ public static ClassName parseName(String name){
+ return Strings.isEmpty(name)?null:new ClassName(name);
+ }
+ /**
* <p class="changed_added_4_0"></p>
*
* @param cl
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-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -1,7 +1,6 @@
package org.richfaces.cdk.model;
import java.util.Collection;
-import java.util.Map;
import org.richfaces.cdk.CdkException;
@@ -20,7 +19,7 @@
* Facets recognised by the component
* </p>
*/
- private final ModelMap<String, FacetModel> facets = ModelMap.<String, FacetModel>create();
+ private final ModelCollection<FacetModel> facets = ModelCollection.<FacetModel>create();
/**
* <p class="changed_added_4_0">
@@ -39,15 +38,8 @@
private String family;
- /**
- * <p class="changed_added_4_0">
- * Component type
- * </p>
- */
- private Type type;
-
- public ComponentModel(Type key) {
- this.type = key;
+ public ComponentModel(FacesId key) {
+ this.setId(key);
}
public ComponentModel() {
@@ -71,9 +63,9 @@
public void merge(ComponentModel otherComponent) {
//merge facets, renderers, events ...
ComponentLibrary.merge(getAttributes(),otherComponent.getAttributes());
- facets.putAll(otherComponent.getFacets());
- ComponentLibrary.merge(events, otherComponent.getEvents());
- ComponentLibrary.merge(renderers, otherComponent.getRenderers());
+ ComponentLibrary.merge(getFacets(),otherComponent.getFacets());
+ ComponentLibrary.merge(getEvents(), otherComponent.getEvents());
+ ComponentLibrary.merge(getRenderers(), otherComponent.getRenderers());
ComponentLibrary.merge(this, otherComponent);
this.setGenerate(this.isGenerate() || otherComponent.isGenerate());
}
@@ -92,18 +84,14 @@
* <p class="changed_added_4_0"></p>
* @param type the type to set
*/
- public void setType(Type type) {
- this.type = type;
+ public void setType(FacesId type) {
+ setId(type);
}
- public Type getType() {
- return type;
+ public FacesId getType() {
+ return getId();
}
- @Override
- public String getId() {
- return type.getType();
- }
/**
* <p class="changed_added_4_0">
@@ -130,29 +118,44 @@
}
/**
- * <p class="changed_added_4_0">
+ * <p class="changed_added_4_0">Alias for TargetClass.
* </p>
*
* @return the componentClass
+ * @deprecated
*/
@Merge
public ClassName getComponentClass() {
- return getGeneratedClass();
+ return getTargetClass();
}
/**
* <p class="changed_added_4_0"></p>
+ * @param name
+ * @deprecated
+ */
+ public void setComponentClass(ClassName name) {
+ setTargetClass(name);
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the facets
*/
- public Map<String, FacetModel> getFacets() {
+ public Collection<FacetModel> getFacets() {
return facets;
}
- public FacetModel addFacet(String name) {
- FacetModel facet = facets.get(name);
+ public FacetModel getFacet(final String name) {
+ return facets.find(new Named.NamedPredicate(name));
+ }
+
+ public FacetModel getOrCreateFacet(String name) {
+ FacetModel facet = getFacet(name);
if(null == facet){
facet = new FacetModel();
- facets.put(name, facet);
+ facet.setName(name);
+ facets.add(facet);
}
return facet;
}
@@ -182,12 +185,4 @@
public Collection<RendererModel> getRenderers() {
return renderers;
}
-
- public static class Type extends FacesId {
- private static final long serialVersionUID = -6968199073379187423L;
-
- public Type(String type) {
- super(type);
- }
- }
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -39,18 +39,11 @@
public ConverterModel() {
}
- public ConverterModel(String converterId) {
+ public ConverterModel(FacesId converterId) {
setId(converterId);
}
- public String getConverterId() {
- return getId();
- }
- public void setConverterId(String converterId) {
- setId(converterId);
- }
-
@Merge(false)
public ClassName getConverterForClass() {
return converterForClass;
@@ -60,10 +53,6 @@
this.converterForClass = converterForClass;
}
- @Merge(false)
- public ClassName getConverterClass() {
- return getGeneratedClass();
- }
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
@@ -82,6 +71,6 @@
@Override
public boolean same(ConverterModel other) {
- return null != getConverterId() && getConverterId().equals(other.getConverterId());
+ return null != getId() && getId().equals(other.getId());
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -25,6 +25,8 @@
import java.io.Serializable;
+import org.richfaces.cdk.util.Strings;
+
/**
* <p class="changed_added_4_0">This is a FacesId class that should be used to find JSF elements in {@link ComponentLibrary}</p>
*
@@ -35,6 +37,9 @@
private final String type;
+ public static FacesId parseId(String id){
+ return Strings.isEmpty(id)?null:new FacesId(id);
+ }
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacetModel.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -26,18 +26,38 @@
package org.richfaces.cdk.model;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.util.ComparatorUtils;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class FacetModel extends DescriptionGroupBase implements ModelElement<FacetModel> {
+public class FacetModel extends DescriptionGroupBase implements ModelElement<FacetModel>, Named {
+
private static final long serialVersionUID = 7723771279129598243L;
+
+ private String name;
public FacetModel() {
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
@Override
public void merge(FacetModel other) {
ComponentLibrary.merge(this, other);
@@ -54,6 +74,6 @@
@Override
public boolean same(FacetModel other) {
- return equals(other);
+ return ComparatorUtils.nullSafeEquals(this.getName(), other.getName());
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -51,10 +51,8 @@
return new ModelCollection<T>();
}
- // TODO -provide factory methods.
- // private final Method factoryMethod;
- public E find(final Predicate<E> predicate) {
+ public E find(final Predicate<? super E> predicate) {
try {
return Iterables.find(elements, predicate);
} catch (NoSuchElementException e) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -8,9 +8,11 @@
*/
public class ModelElementBase extends BeanModelBase {
- private String id;
+ private FacesId id;
+
+ private ClassName targetClass;
- private ClassDescriptor generatedClass;
+ private ClassName baseClass;
private TagModel tag;
@@ -22,48 +24,43 @@
this.tag = tag;
}
- public String getId() {
+ public FacesId getId() {
return id;
}
- public void setId(String id) {
+ public void setId(FacesId id) {
this.id = id;
}
- public void setGeneratedClass(String generatedClass) {
- setGeneratedClass(new ClassDescriptor(generatedClass));
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param targetClass the targetClass to set
+ */
+ public void setTargetClass(ClassName targetClass) {
+ this.targetClass = targetClass;
}
- public void setGeneratedClass(Class generatedClass) {
- setGeneratedClass(new ClassDescriptor(generatedClass));
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the targetClass
+ */
+ public ClassName getTargetClass() {
+ return targetClass;
}
- public void setGeneratedClass(ClassName generatedClass) {
- setGeneratedClass(new ClassDescriptor(generatedClass));
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param baseClass the baseClass to set
+ */
+ public void setBaseClass(ClassName baseClass) {
+ this.baseClass = baseClass;
}
- public void setGeneratedClass(ClassDescriptor generatedClass) {
- this.generatedClass = generatedClass;
- }
-
- public ClassName getGeneratedClass() {
- if (this.generatedClass == null) {
- return null;
- }
-
- return this.generatedClass.getName();
- }
-
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the baseClass
+ */
public ClassName getBaseClass() {
- if (this.generatedClass == null) {
- return null;
- }
-
- return this.generatedClass.getParent();
+ return baseClass;
}
-
- public void setClassNames(String className, String parentClassName) {
- setGenerate(parentClassName != null);
- this.generatedClass = new ClassDescriptor(className, parentClassName);
- }
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -0,0 +1,64 @@
+/*
+ * $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.model;
+
+import org.richfaces.cdk.util.ComparatorUtils;
+
+import com.google.common.base.Predicate;
+
+/**
+ * <p class="changed_added_4_0">This interface represents all models for "named" JSF objects ( attributes, properties, facets )</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface Named {
+
+ public static final class NamedPredicate implements Predicate<Named> {
+
+ private final String _name;
+
+ public NamedPredicate(String name) {
+ this._name = name;
+ }
+
+ @Override
+ public boolean apply(Named input) {
+ return ComparatorUtils.nullSafeEquals(input.getName(), this._name);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ // TODO - change to class corresponding with Java identifier type from faces-config.xsd
+ * @return the name
+ */
+ public String getName();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name);
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Named.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -37,7 +37,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class Property extends DescriptionGroupBase implements ModelElement<Property> {
+public class Property extends DescriptionGroupBase implements ModelElement<Property> , Named {
private static final long serialVersionUID = 3483864006602184580L;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/TagModel.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -27,12 +27,14 @@
import java.io.Serializable;
+import org.richfaces.cdk.annotations.TagType;
+
/**
* <p class="changed_added_4_0">That bean represents VDL tag</p>
* @author asmirnov(a)exadel.com
*
*/
-public class TagModel implements Serializable {
+public class TagModel implements Named , Serializable {
private static final long serialVersionUID = 3875718626199223087L;
@@ -40,94 +42,109 @@
* <p class="changed_added_4_0">Component that the tag creates. This in bidirectional one to one relation.</p>
* TODO - tag should also works with {@code Validator}, {@code Converter}, {@code Behavior}, {@code FacesListener}
*/
- private final ModelElementBase model;
+ private ModelElementBase model;
+ private ClassName targetClass;
+
+ private ClassName baseClass;
+
+ private TagType type;
+
+ private boolean generate = false;
/**
- * <p class="changed_added_4_0">Jsp tag class</p>
+ * <p class="changed_added_4_0">Tag name</p>
*/
- private String jspClass;
+ private String name;
+
+ public ModelElementBase getModel() {
+ return model;
+ }
+
+ public void setModel(ModelElementBase model) {
+ this.model = model;
+ }
+
+ public String getName() {
+ return name;
+ }
+
/**
- * <p class="changed_added_4_0">Tag library for which that tag is belong.
- * This is bidirectional many to one relation.</p>
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
*/
- private TagLibrary library;
+ public void setName(String name) {
+ this.name = name;
+ }
+
/**
- * <p class="changed_added_4_0">Tag name</p>
+ * <p class="changed_added_4_0"></p>
+ * @return the type
*/
- private final String name;
+ public TagType getType() {
+ return this.type;
+ }
/**
- * <p class="changed_added_4_0">Facelets VDL tag handler class.</p>
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
*/
- private ClassDescriptor handler;
-
- public TagModel(ModelElementBase model, String name, String tagHandlerClass) {
- this(model, name, tagHandlerClass, null);
+ public void setType(TagType type) {
+ this.type = type;
}
- public TagModel(ModelElementBase model, String name, String tagHandlerClass, String tagHandlerParentClass) {
- this.model = model;
- this.name = name;
-
- if (tagHandlerClass != null) {
- this.handler = new ClassDescriptor(tagHandlerClass, tagHandlerParentClass);
- }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the targetClass
+ */
+ public ClassName getTargetClass() {
+ return this.targetClass;
}
- public TagModel(ModelElementBase model, String name, ClassDescriptor tagHandlerClass) {
- this.model = model;
- this.name = name;
- this.handler = tagHandlerClass;
- }
-
- public ModelElementBase getModel() {
- return model;
- }
- public String getJspClass() {
- return jspClass;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param targetClass the targetClass to set
+ */
+ public void setTargetClass(ClassName targetClass) {
+ this.targetClass = targetClass;
}
- public void setJspClass(String jspClass) {
- this.jspClass = jspClass;
- }
- public TagLibrary getLibrary() {
- return library;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the baseClass
+ */
+ public ClassName getBaseClass() {
+ return this.baseClass;
}
- public void setLibrary(TagLibrary library) {
- this.library = library;
- }
- public String getName() {
- return name;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param baseClass the baseClass to set
+ */
+ public void setBaseClass(ClassName baseClass) {
+ this.baseClass = baseClass;
}
- public ClassDescriptor getHandler() {
- return handler;
- }
- public void setHandler(ClassDescriptor handler) {
- this.handler = handler;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the generate
+ */
+ public boolean isGenerate() {
+ return this.generate;
}
- public String getTagHandlerClass() {
- if (handler != null) {
- return handler.getName().getName();
- }
- return null;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param generate the generate to set
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
}
-
- public String getTagHandlerSuperClass() {
- if (handler != null) {
- return handler.getParent().getName();
- }
- return null;
- }
-
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -36,22 +36,10 @@
public ValidatorModel() {
}
- public ValidatorModel(String validatorId) {
- setValidatorId(validatorId);
- }
-
- public String getValidatorId() {
- return getId();
- }
-
- public void setValidatorId(String validatorId) {
+ public ValidatorModel(FacesId validatorId) {
setId(validatorId);
}
- @Merge(false)
- public ClassName getValidatorClass() {
- return getGeneratedClass();
- }
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
@@ -70,6 +58,6 @@
@Override
public boolean same(ValidatorModel other) {
- return null != getValidatorId() && getValidatorId().equals(other.getValidatorId());
+ return null != getId() && getId().equals(other.getId());
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -34,9 +34,12 @@
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.DescriptionGroup;
+import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
+import org.richfaces.cdk.util.Strings;
import com.google.inject.Inject;
@@ -121,11 +124,11 @@
log.error("Base class for generated component is not set :" + component.getType());
// return;
} else if (null == component.getComponentClass()) {
- component.setGeneratedClass(namingConventions.inferUIComponentClass(component.getType()));
+ component.setTargetClass(namingConventions.inferUIComponentClass(component.getType()));
}
} else if (null == component.getComponentClass()){
if (null != component.getBaseClass()) {
- component.setGeneratedClass(component.getBaseClass());
+ component.setTargetClass(component.getBaseClass());
} else {
log.error("No class information available for component: " + component);
// return;
@@ -135,20 +138,56 @@
if(null == component.getFamily()){
component.setFamily(namingConventions.inferUIComponentFamily(component.getType()));
}
+ // TODO Propagate attributes from parent component.
// Check attributes.
for (Property attribute : component.getAttributes()) {
- verifyAttribute(attribute);
+ verifyAttribute(attribute,component.isGenerate());
}
- // compact(component.getAttributes());
+ // compact(component.getAttributes());
// Check renderers.
// Check Tag
+ verifyDescription(component);
+ for (FacetModel facet : component.getFacets()) {
+ verifyDescription(facet);
+ }
}
- protected void verifyAttribute(Property attribute) {
+ protected void verifyAttribute(Property attribute, boolean generatedComponent) {
// Check name.
+ if(Strings.isEmpty(attribute.getName())){
+ log.error("No name for attribute "+attribute);
+ return;
+ }
+ if(attribute.getName().contains(".") || Character.isDigit(attribute.getName().charAt(0)) || attribute.getName().contains(" ") ){
+ log.error("Invalid attribute name ["+attribute.getName()+"]");
+ return;
+ }
+ // Check type
+ if(null == attribute.getType()){
+ log.error("Unknown type of attribute ["+attribute.getName()+"]");
+ return;
+ }
// Check binding properties.
+ if("javax.faces.el.MethodBinding".equals(attribute.getType().getName())){
+ attribute.setBinding(true);
+ attribute.setBindingAttribute(true);
+ } else if("javax.el.MethodExpression".equals(attribute.getType().getName())){
+ attribute.setBindingAttribute(true);
+ }
+ // Check "generate" flag.
+ if(generatedComponent){
+ // TODO Attribute should be only generated if it does not exist or abstract in the base class.
+ // Step one - check base class
+ } else {
+ attribute.setGenerate(false);
+ }
+ verifyDescription(attribute);
+ }
+
+ protected void verifyDescription(DescriptionGroup element){
}
+
protected void compact(Collection<?> collection) {
// if (collection instanceof ModelCollection) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -31,6 +31,7 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.FacesId;
import com.google.common.collect.Lists;
@@ -39,23 +40,24 @@
* @since Jan 21, 2010
*/
@XmlType(name = "faces-config-behaviorType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"behaviorId", "behaviorClass", "attributes", "extension"})
+ propOrder={"id", "behaviorClass", "attributes", "extension"})
@XmlJavaTypeAdapter(BehaviorAdapter.class)
public class BehaviorBean extends ExtensibleBean<BehaviorBean.BehaviorExtension> {
- private String behaviorId;
private String behaviorClass;
private List<PropertyBase> attributes = Lists.newArrayList();
+ private FacesId id;
+
@XmlElement(name = "behavior-id", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getBehaviorId() {
- return behaviorId;
+ public FacesId getId() {
+ return id;
}
- public void setBehaviorId(String behaviorId) {
- this.behaviorId = behaviorId;
+ public void setId(FacesId id) {
+ this.id = id;
}
@XmlElement(name = "behavior-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
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-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -24,12 +24,12 @@
package org.richfaces.cdk.xmlconfig.model;
-import org.richfaces.cdk.model.*;
-
import java.util.Collection;
-import org.richfaces.cdk.model.ComponentModel.Type;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.RendererModel;
+
/**
* <p class="changed_added_4_0"></p>
*
@@ -51,24 +51,10 @@
return ComponentModel.class;
}
- @Override
- protected void postMarshal(ComponentModel model, ComponentBean bean) {
- // Copy properties/attributes
- bean.setFacets(marshalMap(model.getFacets(), FACET_ADAPTER));
- }
@Override
protected void postUnmarshal(ComponentBean bean, ComponentModel model) {
- model.setGenerate(false);
- model.setGeneratedClass(bean.getComponentClass());
-
- // Copy type.
- String type = bean.getType();
- if (null != type) {
- model.setType(new Type(type.trim()));
- }
// Copy properties/attributes
- model.getFacets().putAll(this.<String, FacetBean, FacetModel>unmarshalMap(bean.getFacets(), FACET_ADAPTER));
Collection<RendererModel> renderers = model.getRenderers();
ComponentBean.ComponentExtension extension = bean.getExtension();
if (renderers != null && extension != null) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -30,11 +30,12 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.AttributeModel;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.EventModel;
+import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.Property;
import com.google.common.collect.Lists;
@@ -52,9 +53,9 @@
private boolean generate = false;
private List<Property> attributes = Lists.newArrayList();
- private List<FacetBean> facets = Lists.newArrayList();
+ private List<FacetModel> facets = Lists.newArrayList();
private ClassName componentClass;
- private String type;
+ private FacesId type;
/**
* <p class="changed_added_4_0"></p>
@@ -62,7 +63,7 @@
* @return the type
*/
@XmlElement(name = "component-type", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,required=true)
- public String getType() {
+ public FacesId getType() {
return type;
}
@@ -71,7 +72,7 @@
*
* @param type the type to set
*/
- public void setType(String type) {
+ public void setType(FacesId type) {
this.type = type;
}
@@ -130,7 +131,8 @@
* @return the facets
*/
@XmlElement(name = "facet", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public List<FacetBean> getFacets() {
+ @XmlJavaTypeAdapter(FacetAdapter.class)
+ public List<FacetModel> getFacets() {
return facets;
}
@@ -139,7 +141,7 @@
*
* @param facets the facets to set
*/
- public void setFacets(List<FacetBean> facets) {
+ public void setFacets(List<FacetModel> facets) {
this.facets = facets;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -30,6 +30,7 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.FacesId;
import com.google.common.collect.Lists;
@@ -38,12 +39,11 @@
* @since Jan 6, 2010
*/
@XmlType(name = "faces-config-converterType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"converterId", "converterForClass", "converterClass",
+ propOrder={"id", "converterForClass", "converterClass",
"attributes", "extension"})
@XmlJavaTypeAdapter(ConverterAdapter.class)
public class ConverterBean extends ExtensibleBean<ConverterBean.ConverterExtension> {
- private String converterId;
private String converterForClass;
@@ -51,13 +51,15 @@
private List<PropertyBase> attributes = Lists.newArrayList();
+ private FacesId id;
+
@XmlElement(name = "converter-id", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getConverterId() {
- return converterId;
+ public FacesId getId() {
+ return id;
}
- public void setConverterId(String converterId) {
- this.converterId = converterId;
+ public void setId(FacesId id) {
+ this.id = id;
}
@XmlElement(name = "converter-for-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -0,0 +1,46 @@
+/*
+ * $Id: ClassAdapter.java 16509 2010-03-01 13:40:54Z Alex.Kolonitsky $
+ *
+ * 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.xmlconfig.model;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.model.FacesId;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @author asmirnov(a)exadel.com
+ */
+public class FacesIdAdapter extends XmlAdapter<String, FacesId> {
+ @Override
+ public String marshal(FacesId v) throws Exception {
+
+ return v.toString();
+ }
+
+ @Override
+ public FacesId unmarshal(String v) throws Exception {
+ return new FacesId(v);
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesIdAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -33,7 +33,9 @@
*
* @author asmirnov(a)exadel.com
*/
-public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension> implements MapEntry<String>{
+public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension> {
+
+
private String name;
/**
@@ -42,7 +44,7 @@
* @return the name
*/
@XmlElement(name = "facet-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getKey() {
+ public String getName() {
return name;
}
@@ -51,7 +53,7 @@
*
* @param name the name to set
*/
- public void setKey(String name) {
+ public void setName(String name) {
this.name = name;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -30,6 +30,7 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.FacesId;
import com.google.common.collect.Lists;
@@ -38,23 +39,24 @@
* @since Jan 13, 2010
*/
@XmlType(name = "faces-config-validatorType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"validatorId", "validatorClass", "attributes", "extension"})
+ propOrder={"id", "validatorClass", "attributes", "extension"})
@XmlJavaTypeAdapter(ValidatorAdapter.class)
public class ValidatorBean extends ExtensibleBean<ValidatorBean.ValidatorExtension> {
- private String validatorId;
private String validatorClass;
private List<PropertyBase> attributes = Lists.newArrayList();
+ private FacesId id;
+
@XmlElement(name = "validator-id", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getValidatorId() {
- return validatorId;
+ public FacesId getId() {
+ return id;
}
- public void setValidatorId(String validatorId) {
- this.validatorId = validatorId;
+ public void setId(FacesId id) {
+ this.id = id;
}
@XmlElement(name = "validator-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -17,6 +17,7 @@
@XmlJavaTypeAdapter(type = ClassName.class, value = ClassAdapter.class),
@XmlJavaTypeAdapter(type = AttributeModel.class, value = AttributeAdapter.class),
@XmlJavaTypeAdapter(type = Property.class, value = PropertyAdapter.class),
+ @XmlJavaTypeAdapter(type = FacesId.class, value = FacesIdAdapter.class),
@XmlJavaTypeAdapter(type = ComponentLibrary.class, value = FacesConfigAdapter.class)
})
package org.richfaces.cdk.xmlconfig.model;
@@ -28,5 +29,6 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.AttributeModel;
import org.richfaces.cdk.model.Property;
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/NamingConventionsTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -30,7 +30,7 @@
import org.junit.Test;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ComponentModel.Type;
+import org.richfaces.cdk.model.FacesId;
/**
* <p class="changed_added_4_0">
@@ -40,7 +40,7 @@
*
*/
public class NamingConventionsTest {
- private static final Type COMPONENT_TYPE = new ComponentModel.Type("foo.bar.Test");
+ private static final FacesId COMPONENT_TYPE = FacesId.parseId("foo.bar.Test");
private static final String BASE = "foo.bar";
private RichFacesConventions conventions;
@@ -78,7 +78,7 @@
@Test
public void testInferComponentTypeFromMarkupClass() throws Exception {
- assertEquals(new ComponentModel.Type("foo.bar.HtmlTest"), conventions.inferComponentType(new ClassName("foo.bar.component.html.HtmlTest")));
+ assertEquals(FacesId.parseId("foo.bar.HtmlTest"), conventions.inferComponentType(new ClassName("foo.bar.component.html.HtmlTest")));
}
@Test
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -33,6 +33,7 @@
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
import com.google.inject.Inject;
@@ -55,9 +56,9 @@
assertEquals(2, behaviors.size());
for (BehaviorModel model : behaviors) {
- String id = model.getBehaviorId();
- if (id != null && !id.isEmpty()) {
- assertEquals("my_behavior", id);
+ FacesId id = model.getId();
+ if (id != null ) {
+ assertEquals("my_behavior", id.toString());
}
}
}
Modified: 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-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -40,6 +40,7 @@
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 com.google.inject.Inject;
@@ -67,9 +68,9 @@
assertEquals(2, validators.size());
for (ValidatorModel model : validators) {
- String id = model.getValidatorId();
- if (id != null && !id.isEmpty()) {
- assertEquals("my_validator", id);
+ FacesId id = model.getId();
+ if (id != null ) {
+ assertEquals("my_validator", id.toString());
}
}
}
@@ -128,9 +129,9 @@
}
if (validatorClass != null) {
- assertEquals(model.getValidatorClass().toString(), validatorClass);
+ assertEquals(model.getTargetClass().toString(), validatorClass);
} else {
- assertNull(model.getValidatorClass());
+ assertNull(model.getTargetClass());
}
assertEquals(generate, model.isGenerate());
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -8,6 +8,7 @@
import org.junit.Test;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
public class FreeMarkerRendererTest extends CdkTestBase {
@Test
@@ -20,7 +21,7 @@
@Ignore
public void testProcessComponent() throws Exception {
final StringWriter output = new StringWriter();
- ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.Bar"));
+ ComponentModel component = new ComponentModel(FacesId.parseId("foo.Bar"));
assertEquals("foo.Bar", output.toString());
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -31,8 +31,10 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.Property;
import com.google.inject.Inject;
@@ -53,8 +55,9 @@
expect(output.createOutput((String) anyObject(), anyInt())).andReturn(outputWriter);
replay(output);
- BehaviorModel behavior = new BehaviorModel("foo.bar");
- behavior.setClassNames("org.richfaces.cdk.generate.java.GeneratedBehavior", "Object");
+ BehaviorModel behavior = new BehaviorModel(FacesId.parseId("foo.bar"));
+ behavior.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedBehavior"));
+ behavior.setBaseClass(ClassName.parseName("Object"));
// TODO add test with types boolean, int, Integer, String, Object
addAttribute(behavior, "testValue", Object.class, true);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -40,6 +40,7 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.Property;
import com.google.inject.Inject;
@@ -83,9 +84,10 @@
}
public static ComponentModel createComponent() {
- ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.bar"));
+ ComponentModel component = new ComponentModel(FacesId.parseId("foo.bar"));
component.setGenerate(true);
- component.setClassNames("org.richfaces.cdk.generate.java.GeneratedComponent", UIOutput.class.getName());
+ component.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedComponent"));
+ component.setBaseClass(ClassName.parseName(UIOutput.class.getName()));
Property attribute = component.getOrCreateAttribute("testValue");
attribute.setType(new ClassName(Object.class));
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -31,9 +31,11 @@
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
import org.richfaces.cdk.freemarker.PropertyModel;
+import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.FacesId;
import com.google.inject.Inject;
@@ -54,8 +56,9 @@
replay(output);
ConverterModel converter = new ConverterModel();
- converter.setConverterId("foo.bar");
- converter.setClassNames("org.richfaces.cdk.generate.java.GeneratedConverter", "Object");
+ converter.setId(FacesId.parseId("foo.bar"));
+ converter.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedConverter"));
+ converter.setBaseClass(ClassName.parseName("Object"));
addAttribute(converter, "myClass", PropertyModel.class, true);
addAttribute(converter, "testObject", Object.class, true);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -53,10 +53,12 @@
ComponentModel model = ComponentClassGeneratorTest.createComponent();
library.getComponents().add(model);
- ClassDescriptor handler = new ClassDescriptor("org.richfaces.cdk.generate.java.GeneratedTagHandler",
- ComponentHandler.class.getName());
- TagModel tagModel = new TagModel(model, "mytag", handler);
+ TagModel tagModel = new TagModel();
+ tagModel.setName("mytag");
+ tagModel.setModel(model);
+ tagModel.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedTagHandler"));
+ tagModel.setTargetClass(ClassName.parseName(ComponentHandler.class.getName()));
generator.process(tagModel);
// System.out.println(outputWriter);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -30,8 +30,10 @@
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.EventName;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
@@ -54,8 +56,9 @@
replay(output);
ValidatorModel validator = new ValidatorModel();
- validator.setValidatorId("foo.bar");
- validator.setClassNames("org.richfaces.cdk.generate.java.GeneratedValidator", "Object");
+ validator.setId(FacesId.parseId("foo.bar"));
+ validator.setTargetClass(ClassName.parseName("org.richfaces.cdk.generate.java.GeneratedValidator"));
+ validator.setBaseClass(ClassName.parseName("Object"));
addAttribute(validator, "testValue", Object.class, true);
// TODO test with primitiv type 'boolean'
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -35,6 +35,7 @@
import org.richfaces.cdk.generate.taglib.ValidatorTagGenerator;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.ValidatorModel;
@@ -64,8 +65,8 @@
public void testGetOutputFileComponent() throws Exception {
final StringWriter outputWriter = new StringWriter();
- ValidatorModel validator = new ValidatorModel("foo.bar");
- validator.setGeneratedClass(UIOutput.class);
+ ValidatorModel validator = new ValidatorModel(FacesId.parseId("foo.bar"));
+ validator.setTargetClass(ClassName.parseName(UIOutput.class.getName()));
validator.setGenerate(true);
Property attribute1 = createAttribute( "testValue", Object.class, true);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -51,7 +51,7 @@
@Test
public void testAcceptLibraryVisitorOfRPP() throws Exception {
ComponentLibrary lib = new ComponentLibrary();
- final ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.Bar"));
+ final ComponentModel component = new ComponentModel(FacesId.parseId("foo.Bar"));
lib.getComponents().add(component);
LibraryVisitor<Boolean, Boolean> visitor = new LibraryVisitor<Boolean, Boolean>() {
@Override
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/validator/ModelValidatorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -37,6 +37,7 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
import com.google.inject.Inject;
import org.richfaces.cdk.CdkTestRunner;
@@ -80,8 +81,8 @@
public void testVerifyNoTypeComponent() {
ComponentModel component = new ComponentModel();
ClassName className = new ClassName("foo.component.UIBar");
- ComponentModel.Type type = new ComponentModel.Type("foo.Bar");
- component.setGeneratedClass(className);
+ FacesId type = FacesId.parseId("foo.Bar");
+ component.setTargetClass(className);
expect(namiingConventions.inferComponentType(className)).andReturn(type);
expect(namiingConventions.inferUIComponentFamily(type)).andReturn("foo.baz");
replay(log,utils,namiingConventions);
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-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -106,9 +106,8 @@
assertEquals("Panel", component.getDisplayname());
assertFalse(component.isGenerate());
- FacetModel facet = Iterables.getOnlyElement(component.getFacets().values());
- String key = Iterables.getOnlyElement(component.getFacets().keySet());
- assertEquals("header", key);
+ FacetModel facet = Iterables.getOnlyElement(component.getFacets());
+ assertEquals("header", facet.getName());
assertEquals("Header facet", facet.getDescription());
assertTrue(facet.isGenerate());
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -9,6 +9,7 @@
import org.junit.Ignore;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.model.ComponentBean;
import org.richfaces.cdk.xmlconfig.model.PropertyBase;
@@ -24,10 +25,10 @@
@Test
@Ignore
public void testCreateAdapter() throws Exception {
- ComponentModel component = new ComponentModel(new ComponentModel.Type(FOO_BAR));
+ ComponentModel component = new ComponentModel(FacesId.parseId(FOO_BAR));
component.setDescription(FOO_DESCTIPTION);
- component.setGeneratedClass(FOO_UI_BAR);
+ component.setTargetClass(ClassName.parseName(FOO_UI_BAR));
component.getOrCreateAttribute(BAZ);
component.setFamily(FOO_FAMILY);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -10,6 +10,7 @@
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
@@ -27,7 +28,7 @@
@Test
public void testMarshalResultStringT() throws Exception {
- ComponentModel component = new ComponentModel(new ComponentModel.Type("foo.bar"));
+ ComponentModel component = new ComponentModel(FacesId.parseId("foo.bar"));
library.getComponents().add(component);
RenderKitModel renderKit = library.addRenderKit("HTML");
RendererModel renderer = new RendererModel(new RendererModel.Type("foo.Renderer"));
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -37,8 +37,8 @@
@Test
public void generationTest() throws Exception {
- ValidatorModel validator = new ValidatorModel("foo.bar");
- validator.setGeneratedClass(UIOutput.class);
+ ValidatorModel validator = new ValidatorModel(FacesId.parseId("foo.bar"));
+ validator.setTargetClass(ClassName.parseName(Object.class.getName()));
validator.setGenerate(true);
addAttribute(validator, "testValue", Object.class, true);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -28,6 +28,7 @@
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.XmlTest;
/**
@@ -40,8 +41,8 @@
public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- BehaviorModel behaviorModel = new BehaviorModel("my_behavior");
- behaviorModel.setGeneratedClass(Object.class);
+ BehaviorModel behaviorModel = new BehaviorModel(FacesId.parseId("my_behavior"));
+ behaviorModel.setTargetClass(ClassName.parseName(Object.class.getName()));
library.getBehaviors().add(behaviorModel);
// Jaxb marshaling
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ConverterBeanTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -25,6 +25,7 @@
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 org.richfaces.cdk.xmlconfig.XmlTest;
import java.io.StringWriter;
@@ -39,8 +40,8 @@
public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- ConverterModel converterModel = new ConverterModel("my_converter");
- converterModel.setGeneratedClass(Object.class);
+ ConverterModel converterModel = new ConverterModel(FacesId.parseId("my_converter"));
+ converterModel.setTargetClass(ClassName.parseName(Object.class.getName()));
library.getConverters().add(converterModel);
// Jaxb marshaling
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-03-08 16:19:26 UTC (rev 16536)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/ValidatorBeanTest.java 2010-03-09 01:17:56 UTC (rev 16537)
@@ -26,6 +26,7 @@
import org.junit.Test;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.ValidatorModel;
import org.richfaces.cdk.xmlconfig.XmlTest;
@@ -39,8 +40,8 @@
public void testMarshal() throws Exception {
ComponentLibrary library = new ComponentLibrary();
- ValidatorModel validatorModel = new ValidatorModel("my_validator");
- validatorModel.setGeneratedClass(Object.class);
+ ValidatorModel validatorModel = new ValidatorModel(FacesId.parseId("my_validator"));
+ validatorModel.setTargetClass(ClassName.parseName(Object.class.getName()));
library.getValidators().add(validatorModel);
// Jaxb marshaling
14 years, 7 months
JBoss Rich Faces SVN: r16536 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-08 11:19:26 -0500 (Mon, 08 Mar 2010)
New Revision: 16536
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
Log:
CODING IN PROGRESS - issue RF-7736: Library model verifier.
https://jira.jboss.org/jira/browse/RF-7736
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-08 06:02:17 UTC (rev 16535)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-08 16:19:26 UTC (rev 16536)
@@ -103,11 +103,11 @@
@XmlElements({@XmlElement(
name = "property",
namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- type = Property.class
+ type = PropertyBean.class
), @XmlElement(
name = "attribute",
namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- type = AttributeModel.class
+ type = AttributeBean.class
)})
// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
14 years, 7 months
JBoss Rich Faces SVN: r16535 - branches/community/3.3.X/docs.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-03-08 01:02:17 -0500 (Mon, 08 Mar 2010)
New Revision: 16535
Removed:
branches/community/3.3.X/docs/3.3.1_tlddoc_update.zip
branches/community/3.3.X/docs/RichFaces_3.3.3.CR1_docs_update.zip
Log:
Removed doc bundles
Deleted: branches/community/3.3.X/docs/3.3.1_tlddoc_update.zip
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/RichFaces_3.3.3.CR1_docs_update.zip
===================================================================
(Binary files differ)
14 years, 7 months
JBoss Rich Faces SVN: r16534 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-07 23:03:00 -0500 (Sun, 07 Mar 2010)
New Revision: 16534
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
Log:
CODING IN PROGRESS - issue RF-7736: Library model verifier.
https://jira.jboss.org/jira/browse/RF-7736
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2010-03-07 18:24:15 UTC (rev 16533)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2010-03-08 04:03:00 UTC (rev 16534)
@@ -24,23 +24,22 @@
package org.richfaces.cdk.xmlconfig.model;
import org.richfaces.cdk.model.AttributeModel;
-import org.richfaces.cdk.model.Property;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class AttributeAdapter extends AdapterBase<PropertyBase , Property> {
+public class AttributeAdapter extends AdapterBase<AttributeBean , AttributeModel> {
@Override
- protected Class<? extends PropertyBase> getBeanClass(Property prop) {
- return prop instanceof AttributeModel ? AttributeBean.class : PropertyBean.class;
+ protected Class<? extends AttributeBean> getBeanClass(AttributeModel prop) {
+ return AttributeBean.class;
}
@Override
- protected Class<? extends Property> getModelClass(PropertyBase bean) {
- return bean instanceof AttributeBean ? AttributeModel.class : Property.class;
+ protected Class<? extends AttributeModel> getModelClass(AttributeBean bean) {
+ return AttributeModel.class;
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2010-03-07 18:24:15 UTC (rev 16533)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2010-03-08 04:03:00 UTC (rev 16534)
@@ -36,7 +36,7 @@
* @author asmirnov(a)exadel.com
*/
@XmlType(name = "faces-config-attributeType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder = {"key", "type", "defaultValue", "suggestedValue", "extension"})
+ propOrder = {"name", "type", "defaultValue", "suggestedValue", "extension"})
@XmlJavaTypeAdapter(AttributeAdapter.class)
public class AttributeBean extends PropertyBase {
@@ -46,8 +46,8 @@
* @return the name
*/
@XmlElement(name = "attribute-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, required = true)
- public String getKey() {
- return super.getKey();
+ public String getName() {
+ return super.getName();
}
/**
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java 2010-03-08 04:03:00 UTC (rev 16534)
@@ -0,0 +1,45 @@
+/*
+ * $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.xmlconfig.model;
+
+import org.richfaces.cdk.model.Property;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class PropertyAdapter extends AdapterBase<PropertyBean , Property> {
+
+ @Override
+ protected Class<? extends PropertyBean> getBeanClass(Property prop) {
+ return PropertyBean.class;
+ }
+
+ @Override
+ protected Class<? extends Property> getModelClass(PropertyBean bean) {
+ return Property.class;
+ }
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java 2010-03-07 18:24:15 UTC (rev 16533)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java 2010-03-08 04:03:00 UTC (rev 16534)
@@ -43,7 +43,7 @@
*
* @author asmirnov(a)exadel.com
*/
-public class PropertyBase extends ExtensibleBean<PropertyBase.PropertyExtension> implements MapEntry<String> {
+public class PropertyBase extends ExtensibleBean<PropertyBase.PropertyExtension> {
private String defaultValue;
private String name;
private String suggestedValue;
@@ -54,7 +54,7 @@
*
* @return the name
*/
- public String getKey() {
+ public String getName() {
return name;
}
@@ -63,7 +63,7 @@
*
* @param name the name to set
*/
- public void setKey(String name) {
+ public void setName(String name) {
this.name = name;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-07 18:24:15 UTC (rev 16533)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-08 04:03:00 UTC (rev 16534)
@@ -36,7 +36,7 @@
* @author asmirnov(a)exadel.com
*/
@XmlType(name="faces-config-propertyType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
- propOrder={"key","type","defaultValue","suggestedValue","extension"})
+ propOrder={"name","type","defaultValue","suggestedValue","extension"})
@XmlJavaTypeAdapter(AttributeAdapter.class)
public class PropertyBean extends PropertyBase {
@@ -46,14 +46,14 @@
* @return the name
*/
@XmlElement(name = "property-name", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getKey() {
- return super.getKey();
+ public String getName() {
+ return super.getName();
}
@Override
- public void setKey(String name) {
- super.setKey(name);
+ public void setName(String name) {
+ super.setName(name);
}
/**
* <p class="changed_added_4_0"></p>
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2010-03-07 18:24:15 UTC (rev 16533)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2010-03-08 04:03:00 UTC (rev 16534)
@@ -15,6 +15,8 @@
namespaceURI = ComponentLibrary.FACES_CONFIG_NAMESPACE)})
@XmlJavaTypeAdapters({
@XmlJavaTypeAdapter(type = ClassName.class, value = ClassAdapter.class),
+ @XmlJavaTypeAdapter(type = AttributeModel.class, value = AttributeAdapter.class),
+ @XmlJavaTypeAdapter(type = Property.class, value = PropertyAdapter.class),
@XmlJavaTypeAdapter(type = ComponentLibrary.class, value = FacesConfigAdapter.class)
})
package org.richfaces.cdk.xmlconfig.model;
@@ -26,4 +28,5 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
-
+import org.richfaces.cdk.model.AttributeModel;
+import org.richfaces.cdk.model.Property;
14 years, 7 months
JBoss Rich Faces SVN: r16533 - in root/framework/trunk: impl/src/main/java/org/ajax4jsf/cache and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-03-07 13:24:15 -0500 (Sun, 07 Mar 2010)
New Revision: 16533
Modified:
root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java
Log:
TODOs for ServiceTracker
Small fix for CacheManager
Modified: root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java 2010-03-06 00:18:24 UTC (rev 16532)
+++ root/framework/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java 2010-03-07 18:24:15 UTC (rev 16533)
@@ -21,12 +21,13 @@
*/
package org.richfaces.application;
-import javax.faces.context.FacesContext;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import javax.faces.context.FacesContext;
+
/**
* <p>Tracker class to provide access to various framework implementation services.
* Examples of such services are: {@link org.richfaces.skin.SkinFactory}, TBD</p>
@@ -71,6 +72,7 @@
serviceImplementation = (T) servicesMap.get(serviceInterfaceClass);
}
+ //TODO - factories support
//TODO - null?
return serviceImplementation;
}
@@ -100,6 +102,7 @@
}
private static Map<Class<?>, Object> getServicesMap(FacesContext facesContext, boolean createIfNull) {
+ //TODO replicate in FacesContext map for better performance
Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap();
@SuppressWarnings("unchecked")
Map<Class<?>, Object> servicesMap = (Map<Class<?>, Object>) applicationMap.get(SERVICES_MAP_ATTRIBUTE);
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java 2010-03-06 00:18:24 UTC (rev 16532)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java 2010-03-07 18:24:15 UTC (rev 16533)
@@ -16,22 +16,23 @@
package org.ajax4jsf.cache;
-import org.ajax4jsf.cache.lru.LRUMapCacheFactory;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import org.ajax4jsf.cache.lru.LRUMapCacheFactory;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* TODO stop caches on application stop
* CacheManager is used in J2SE environments for looking up named caches.
@@ -89,7 +90,7 @@
String configuredFactoryName = findFactory(FACTORY_PROPERTY_NAME, env);
if (configuredFactoryName != null) {
- LOG.info("Configured to use [{0}] cache factory", configuredFactoryName);
+ LOG.info(MessageFormat.format("Configured to use [{0}] cache factory", configuredFactoryName));
factories = new String[]{configuredFactoryName};
} else {
factories = DEFAULT_FACTORIES_CHAIN;
@@ -102,7 +103,7 @@
Class<?> spiClass = Class.forName(factoryName, true, loader);
CacheFactory cacheFactory = CacheFactory.class.cast(spiClass.newInstance());
- LOG.info("Selected [{0}]", factoryName);
+ LOG.info(MessageFormat.format("Selected [{0}]", factoryName));
return cacheFactory;
} catch (Throwable iae) {
14 years, 7 months
JBoss Rich Faces SVN: r16532 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/freemarker and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-03-05 19:18:24 -0500 (Fri, 05 Mar 2010)
New Revision: 16532
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyMapModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.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/ConverterModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.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/model/ValidatorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.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/RendererClassVisitor.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/templatecompiler/TemplateVisitorFactory.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/ComparatorUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.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/generate/java/AbstractClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
Log:
CODING IN PROGRESS - issue RF-7736: Library model verifier.
https://jira.jboss.org/jira/browse/RF-7736
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ComponentProcessor.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -208,7 +208,7 @@
for (String attributesConfig : attributes.value()) {
// process additional properties.
- component.getAttributes().putAll(parseProperties(attributesConfig));
+ component.getAttributes().addAll(parseProperties(attributesConfig));
}
}
@@ -218,7 +218,7 @@
@Override
public void visit(ClassName type) {
try {
- component.getAttributes().putAll(
+ component.getAttributes().addAll(
parseProperties(CdkEntityResolver.URN_ATTRIBUTES + type.toString() + ".xml"));
} catch (CdkException e) {
// TODO - log errors ?
@@ -234,7 +234,7 @@
continue;
}
- Property attribute = component.addAttribute(beanProperty.getName());
+ Property attribute = component.getOrCreateAttribute(beanProperty.getName());
// Documentation
attribute.setDescription(beanProperty.getDocComment());
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/ProcessorBase.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -16,6 +16,8 @@
import javax.lang.model.type.MirroredTypeException;
import javax.lang.model.type.MirroredTypesException;
import javax.lang.model.type.TypeMirror;
+
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -96,8 +98,8 @@
return true;
}
- for (Map.Entry<String, Property> entry : model.getAttributes().entrySet()) {
- if (entry.getValue().isBingingAttribute()) {
+ for (Property entry : model.getAttributes()) {
+ if (entry.isBindingAttribute()) {
return true;
}
}
@@ -211,7 +213,7 @@
}
}
- protected Map<String, Property> parseProperties(String attributesConfig) {
+ protected Collection<Property> parseProperties(String attributesConfig) {
return getFragmentParser().parseProperties(CdkEntityResolver.URN_ATTRIBUTES + attributesConfig + ".xml");
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ModelElementBaseTemplateModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -107,7 +107,7 @@
if (null == eventNames) {
eventNames = Sets.newHashSet();
- for (Property property : model.getAttributes().values()) {
+ for (Property property : model.getAttributes()) {
eventNames.addAll(property.getEventNames());
}
}
@@ -116,20 +116,21 @@
}
private TemplateModel generatedAttributes() throws TemplateModelException {
- Map<String, Property> attributes = model.getAttributes();
+ Collection<Property> attributes = model.getAttributes();
Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (Map.Entry<String, Property> entry : attributes.entrySet()) {
- if (entry.getValue().isGenerate()) {
- models.add(new PropertyModel(entry.getKey(), entry.getValue(), wrapper));
+ for (Property entry : attributes) {
+ if (entry.isGenerate() ) {
+ PropertyModel propertyModel = new PropertyModel(entry, wrapper);
+ models.add(propertyModel);
}
}
return wrapper.wrap(models);
}
private TemplateModel attributes() throws TemplateModelException {
- Map<String, Property> attributes = model.getAttributes();
+ Collection<Property> attributes = model.getAttributes();
Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (Map.Entry<String, Property> entry : attributes.entrySet()) {
- models.add(new PropertyModel(entry.getKey(), entry.getValue(), wrapper));
+ for (Property entry : attributes) {
+ models.add(new PropertyModel(entry, wrapper));
}
return wrapper.wrap(models);
}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyMapModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyMapModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyMapModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -1,75 +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.freemarker;
-
-import java.util.List;
-import java.util.Map;
-
-import org.richfaces.cdk.model.Property;
-
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.ext.beans.MapModel;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class PropertyMapModel extends MapModel {
-
- private final Map<String, Property> map;
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param map
- * @param wrapper
- */
- public PropertyMapModel(Map<String,Property> map, BeansWrapper wrapper) {
- super(map, wrapper);
- this.map = map;
- }
-
- @Override
- public TemplateModel get(String key) throws TemplateModelException {
- Property property = map.get(key);
- if(null != property){
- return new PropertyModel(key.toString(), property, wrapper);
- }
- return super.get(key);
- }
-
-
-
- @Override
- public Object exec(List arguments) throws TemplateModelException {
- Object key = unwrap((TemplateModel)arguments.get(0));
- Property property = map.get(key);
- if(null != property){
- return new PropertyModel(key.toString(), property, wrapper);
- }
- return super.exec(arguments);
- }
-}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -40,7 +40,6 @@
*/
public class PropertyModel extends BeanModel implements TemplateModel {
private final Property property;
- private final String name;
/**
* <p class="changed_added_4_0"></p>
@@ -48,9 +47,8 @@
* @param object
* @param wrapper
*/
- public PropertyModel(String name, Property object, BeansWrapper wrapper) {
+ public PropertyModel(Property object, BeansWrapper wrapper) {
super(object, wrapper);
- this.name = name;
property = object;
}
@@ -59,7 +57,7 @@
* @return the name
*/
public String getName() {
- return this.name;
+ return property.getName();
}
@Override
@@ -98,11 +96,11 @@
}
public boolean isBingingAttribute() {
- return this.property.isBingingAttribute();
+ return this.property.isBindingAttribute();
}
public boolean isBinging() {
- return this.property.isBinging();
+ return this.property.isBinding();
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/TagTemplateModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -117,7 +117,7 @@
if (null == eventNames) {
eventNames = Sets.newHashSet();
- for (Property property : model.getModel().getAttributes().values()) {
+ for (Property property : model.getModel().getAttributes()) {
eventNames.addAll(property.getEventNames());
}
}
@@ -126,23 +126,21 @@
}
private TemplateModel generatedAttributes() throws TemplateModelException {
- Map<String, Property> attributes = model.getModel().getAttributes();
+ Collection<Property> attributes = model.getModel().getAttributes();
Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (Map.Entry<String, Property> entry : attributes.entrySet()) {
- if (entry.getValue().isGenerate()) {
- PropertyModel propertyModel = new PropertyModel(entry.getKey(), entry.getValue(), wrapper);
- if (propertyModel.isBingingAttribute()) {
+ for (Property entry : attributes) {
+ if (entry.isGenerate() && entry.isBindingAttribute()) {
+ PropertyModel propertyModel = new PropertyModel(entry, wrapper);
models.add(propertyModel);
- }
}
}
return wrapper.wrap(models);
}
private TemplateModel attributes() throws TemplateModelException {
- Map<String, Property> attributes = model.getModel().getAttributes();
+ Collection<Property> attributes = model.getModel().getAttributes();
Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (Map.Entry<String, Property> entry : attributes.entrySet()) {
- models.add(new PropertyModel(entry.getKey(), entry.getValue(), wrapper));
+ for (Property entry : attributes) {
+ models.add(new PropertyModel(entry, wrapper));
}
return wrapper.wrap(models);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -124,9 +124,9 @@
}
- private void appendAttributs(Element tag, Attributable model) {
- for (Map.Entry<String, Property> entry : model.getAttributes().entrySet()) {
- createAttributeElement(tag, entry.getKey(), entry.getValue());
+ private void appendAttributs(Element tag, BeanModelBase model) {
+ for (Property entry : model.getAttributes()) {
+ createAttributeElement(tag, entry.getName(), entry);
}
}
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -1,61 +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.model;
-
-import java.util.Map;
-
-/**
- * @author akolonitsky
- * @since Jan 22, 2010
- *
- * Please rename it with more suitable name
- */
-public class Attributable extends DescriptionGroupBase {
-
- private final ModelMap<String,Property> attributes = ModelMap.<String,Property>create();
-
- /**
- * <p class="changed_added_4_0">
- * Represents JSF component attributes and properties.
- * </p>
- *
- * @return the attributes
- */
- public Map<String,Property> getAttributes() {
- return attributes;
- }
-
- public Property getAttribute(String name) {
- return attributes.get(name);
- }
-
- public Property addAttribute(String attributeName) {
- Property attribute = attributes.get(attributeName);
- if (null == attribute) {
- attribute = new Property();
- attributes.put(attributeName, attribute);
- }
-
- return attribute;
- }
-}
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java (from rev 16531, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Attributable.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BeanModelBase.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -0,0 +1,75 @@
+/*
+ * 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.model;
+
+import java.util.Collection;
+
+import org.richfaces.cdk.util.ComparatorUtils;
+
+/**
+ * This is the base class for all Java Bean-like JSF objects in the model.
+ * @author akolonitsky
+ * @since Jan 22, 2010
+ *
+ */
+public class BeanModelBase extends DescriptionGroupBase {
+
+ private final ModelCollection<Property> attributes = ModelCollection.<Property>create();
+
+ /**
+ * <p class="changed_added_4_0">
+ * Represents JSF component attributes and properties.
+ * </p>
+ *
+ * @return the attributes
+ */
+ public Collection<Property> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * <p class="changed_added_4_0">Return bean attribute for given name.</p>
+ * @param name
+ * @return
+ */
+ public Property getAttribute(String name) {
+ // OPTIMIZATION keep HashMap for name-property pair for fast lookup.
+ for (Property property : attributes) {
+ if(ComparatorUtils.nullSafeEquals(property.getName(), name)){
+ return property;
+ }
+ }
+ return null;
+ }
+
+ public Property getOrCreateAttribute(String attributeName) {
+ Property attribute = getAttribute(attributeName);
+ if (null == attribute) {
+ attribute = new Property();
+ attribute.setName(attributeName);
+ attributes.add(attribute);
+ }
+
+ return attribute;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -62,9 +62,8 @@
@Override
public void merge(BehaviorModel other) {
+ ComponentLibrary.merge(getAttributes(),other.getAttributes());
ComponentLibrary.merge(this, other);
-
- getAttributes().putAll(other.getAttributes());
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -109,7 +109,7 @@
*
*/
@SuppressWarnings("serial")
- public static final class Type extends Key {
+ public static final class Type extends FacesId {
/**
* <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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -70,7 +70,7 @@
@Override
public void merge(ComponentModel otherComponent) {
//merge facets, renderers, events ...
- getAttributes().putAll(otherComponent.getAttributes());
+ ComponentLibrary.merge(getAttributes(),otherComponent.getAttributes());
facets.putAll(otherComponent.getFacets());
ComponentLibrary.merge(events, otherComponent.getEvents());
ComponentLibrary.merge(renderers, otherComponent.getRenderers());
@@ -183,7 +183,7 @@
return renderers;
}
- public static class Type extends Key {
+ public static class Type extends FacesId {
private static final long serialVersionUID = -6968199073379187423L;
public Type(String type) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ConverterModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -76,9 +76,8 @@
@Override
public void merge(ConverterModel other) {
+ ComponentLibrary.merge(getAttributes(),other.getAttributes());
ComponentLibrary.merge(this, other);
-
- getAttributes().putAll(other.getAttributes());
}
@Override
Copied: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java (from rev 16531, root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -0,0 +1,105 @@
+/*
+ * $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.model;
+
+import java.io.Serializable;
+
+/**
+ * <p class="changed_added_4_0">This is a FacesId class that should be used to find JSF elements in {@link ComponentLibrary}</p>
+ *
+ * @author asmirnov(a)exadel.com
+ */
+public class FacesId implements Serializable {
+ private static final long serialVersionUID = -8199984910177820771L;
+
+ private final String type;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param type
+ */
+ public FacesId(String type) {
+ this.type = type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return type;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+
+ result = prime * result + ((type == null) ? 0 : type.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;
+ }
+
+ FacesId other = (FacesId) obj;
+
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+
+ return true;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/FacesId.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Deleted: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Key.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -1,105 +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.model;
-
-import java.io.Serializable;
-
-/**
- * <p class="changed_added_4_0">This is a Key class that should be used to find JSF elements in {@link ComponentLibrary}</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class Key implements Serializable {
- private static final long serialVersionUID = -8199984910177820771L;
-
- private final String type;
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param type
- */
- public Key(String type) {
- this.type = type;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- @Override
- public String toString() {
- return type;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((type == null) ? 0 : type.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;
- }
-
- Key other = (Key) obj;
-
- if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
-
- return true;
- }
-}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ListenerModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -83,7 +83,7 @@
return equals(other);
}
- public static final class Type extends Key {
+ public static final class Type extends FacesId {
public Type(String name) {
super(name);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelElementBase.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -6,7 +6,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ModelElementBase extends Attributable {
+public class ModelElementBase extends BeanModelBase {
private String id;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -27,6 +27,7 @@
import java.util.Set;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.util.ComparatorUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -40,21 +41,30 @@
private static final long serialVersionUID = 3483864006602184580L;
+ /**
+ * <p class="changed_added_4_0">The name of bean property</p>
+ */
+ private String name;
+
private boolean hidden = false;
private boolean literal = false;
private boolean required = false;
private boolean readOnly = false;
private boolean passThrough = false;
- //TODO nick - ordering seems to be important!
private Set<EventName> eventNames = Sets.newLinkedHashSet();
private List<ClassName> signature = Lists.newArrayList();
private Set<String> aliases = Sets.newHashSet();
private String defaultValue;
private String suggestedValue;
+
private ClassName type;
+ private boolean bindingAttribute;
+
+ private boolean binding;
+
/**
* <p class="changed_added_4_0"></p>
*/
@@ -63,6 +73,22 @@
/**
* <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the type
*/
@Merge
@@ -264,47 +290,32 @@
@Override
public boolean same(Property other) {
- return this == other;
+ return ComparatorUtils.nullSafeEquals(this.getName(), other.getName());
}
- public boolean isBingingAttribute() {
- return isBinging() || isInstanceof("javax.el.MethodExpression");
+ public boolean isBindingAttribute() {
+ return this.bindingAttribute;
}
- public boolean isBinging() {
- return isInstanceof("javax.faces.el.MethodBinding");
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param bindingAttribute the bindingAttribute to set
+ */
+ public void setBindingAttribute(boolean bindingAttribute) {
+ this.bindingAttribute = bindingAttribute;
}
- public boolean isInstanceof(String name) {
- String classname = getType().getName();
- if (null == classname) {
- String msg = "classname not set in " + getClass().getName() + " for element " + name;
-// getLog().error(msg);
- throw new NullPointerException(msg);
- }
-
- if (classname.equals(name)) {
- return true;
- }
-
- try {
- if (!new ClassName(classname).isPrimitive()) {
- Class<?> beanClass = getLoader().loadClass(classname);
- Class<?> superClass = getLoader().loadClass(name);
- return superClass.isAssignableFrom(beanClass);
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
-// getLog().warn("Could't instantiate for testing class " + classname);
- } catch (Exception e) {
-// getLog().warn("Error in testing class " + classname);
- e.printStackTrace();
- }
- return false;
+ public boolean isBinding() {
+ return this.binding;
}
- private ClassLoader getLoader() {
- return Thread.currentThread().getContextClassLoader(); // TODO ???
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param binding the binding to set
+ */
+ public void setBinding(boolean binding) {
+ this.binding = binding;
}
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKitModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -113,7 +113,7 @@
* @author asmirnov(a)exadel.com
*
*/
- public static final class Id extends Key {
+ public static final class Id extends FacesId {
private static final long serialVersionUID = 9169827614943311779L;
/**
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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RendererModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -34,7 +34,7 @@
*
*/
//@SuppressWarnings("serial")
-public class RendererModel extends Attributable implements ModelElement<RendererModel> {
+public class RendererModel extends BeanModelBase implements ModelElement<RendererModel> {
private static final long serialVersionUID = -5802466539382148578L;
@@ -187,11 +187,11 @@
}
/**
- * <p class="changed_added_4_0">Key for lookup renderer in the model.</p>
+ * <p class="changed_added_4_0">FacesId for lookup renderer in the model.</p>
* @author asmirnov(a)exadel.com
*
*/
- public static class Type extends Key {
+ public static class Type extends FacesId {
private static final long serialVersionUID = -7819560321446149642L;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ValidatorModel.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -64,9 +64,8 @@
@Override
public void merge(ValidatorModel other) {
+ ComponentLibrary.merge(getAttributes(),other.getAttributes());
ComponentLibrary.merge(this, other);
-
- getAttributes().putAll(other.getAttributes());
}
@Override
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -34,6 +34,7 @@
import org.richfaces.cdk.apt.SourceUtils;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
@@ -135,10 +136,19 @@
component.setFamily(namingConventions.inferUIComponentFamily(component.getType()));
}
// Check attributes.
+ for (Property attribute : component.getAttributes()) {
+ verifyAttribute(attribute);
+ }
+ // compact(component.getAttributes());
// Check renderers.
-// compact(component.getAttributes());
+ // Check Tag
}
+ protected void verifyAttribute(Property attribute) {
+ // Check name.
+ // Check binding properties.
+
+ }
protected void compact(Collection<?> collection) {
// if (collection instanceof ModelCollection) {
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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassGenerator.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -37,6 +37,7 @@
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.Property;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
@@ -118,15 +119,15 @@
for (RendererModel renderer : renderKit.getRenderers()) {
Template template = renderer.getTemplate();
if (null != template) {
- Map<String, Property> attributesMap = Maps.newHashMap();
+ Collection<Property> attributes = ModelCollection.<Property>create();
ComponentModel component = findComponentByRenderer(renderer);
if (component != null) {
- attributesMap.putAll(component.getAttributes());
+ attributes.addAll(component.getAttributes());
}
- attributesMap.putAll(renderer.getAttributes());
- RendererClassVisitor visitor = visitorFactory.createVisitor(template.getInterface(), attributesMap);
+ attributes.addAll(renderer.getAttributes());
+ RendererClassVisitor visitor = visitorFactory.createVisitor(template.getInterface(), attributes);
try {
// TODO - put real parameters.
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -79,6 +79,7 @@
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+import org.richfaces.cdk.util.ComparatorUtils;
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.JAXB;
@@ -160,9 +161,9 @@
private Type lastCompiledExpressionType;
private int passThroughCounter;
- private Map<String, Property> attributes;
+ private Collection<Property> attributes;
- public RendererClassVisitor(CompositeInterface compositeInterface, Map<String, Property> attributes,
+ public RendererClassVisitor(CompositeInterface compositeInterface, Collection<Property> attributes,
ClassLoader classLoader, JAXB jaxbBinding, Logger log) {
this.compositeInterface = compositeInterface;
this.attributes = attributes;
@@ -294,24 +295,24 @@
sb.append(")");
}
- Property property = attributes.get(attributeName);
- if (property != null) {
- Set<EventName> eventNames = property.getEventNames();
- if (eventNames != null && !eventNames.isEmpty()) {
- sb.append(".setEventNames(");
- sb.append("new String[] {");
-
- Collection<String> eventNamesStrings = Collections2.transform(eventNames,
- new Function<EventName, String>() {
- @Override
- public String apply(EventName from) {
- return from.getName();
- }
- });
-
- sb.append(getEscapedStringsArray(eventNamesStrings));
-
- sb.append("})");
+ // OPTIMIZATION - use ModelCollection with lookup method
+ for (Property property : attributes) {
+ if(attributeName.equals(property.getName())){
+ Set<EventName> eventNames = property.getEventNames();
+ if (eventNames != null && !eventNames.isEmpty()) {
+ sb.append(".setEventNames(");
+ sb.append("new String[] {");
+ Collection<String> eventNamesStrings = Collections2.transform(eventNames,
+ new Function<EventName, String>() {
+ @Override
+ public String apply(EventName from) {
+ return from.getName();
+ }
+ });
+ sb.append(getEscapedStringsArray(eventNamesStrings));
+ sb.append("})");
+ }
+ break;
}
}
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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -180,15 +180,15 @@
renderer.setRendersChildren(rendersChildren.booleanValue());
}
- Map<String, Property> rendererAttributes = renderer.getAttributes();
+ Collection<Property> rendererAttributes = renderer.getAttributes();
List<ImportAttributes> attributesImports = compositeInterface.getAttributesImports();
if (attributesImports != null) {
for (ImportAttributes attributesImport : attributesImports) {
String importURI = attributesImport.getSource();
- Map<String, Property> properties = fragmentParser.parseProperties(importURI);
+ Collection<Property> properties = fragmentParser.parseProperties(importURI);
if (properties != null) {
- rendererAttributes.putAll(properties);
+ rendererAttributes.addAll(properties);
}
}
}
@@ -197,6 +197,7 @@
if (templateAttributes != null) {
for (Attribute templateAttribute : templateAttributes) {
Property rendererProperty = new Property();
+ rendererProperty.setName(templateAttribute.getName());
rendererProperty.setDefaultValue(templateAttribute.getDefaultValue());
// TODO is it the right one?
@@ -230,7 +231,7 @@
rendererProperty.setType(new ClassName(templateAttributeType));
}
- rendererAttributes.put(templateAttribute.getName(), rendererProperty);
+ rendererAttributes.add(rendererProperty);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateVisitorFactory.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -23,6 +23,7 @@
package org.richfaces.cdk.templatecompiler;
+import java.util.Collection;
import java.util.Map;
import org.richfaces.cdk.model.Property;
@@ -36,6 +37,6 @@
*/
public interface TemplateVisitorFactory <T extends TemplateVisitor> {
- public T createVisitor(CompositeInterface composite,Map<String, Property> attributes);
+ public T createVisitor(CompositeInterface composite,Collection<Property> attributes);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.templatecompiler;
-import java.util.Map;
+import java.util.Collection;
import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.Logger;
@@ -61,7 +61,7 @@
* @see org.richfaces.cdk.templatecompiler.TemplateVisitorFactory#createVisitor(org.richfaces.cdk.templatecompiler.model.CompositeInterface)
*/
@Override
- public RendererClassVisitor createVisitor(CompositeInterface composite,Map<String, Property> attributes) {
+ public RendererClassVisitor createVisitor(CompositeInterface composite,Collection<Property> attributes) {
return new RendererClassVisitor(composite, attributes,classLoader, jaxbBinding, log);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/ComparatorUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/ComparatorUtils.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/util/ComparatorUtils.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -57,5 +57,22 @@
return t1.compareTo(t2);
}
}
-
+
+ /**
+ * <p class="changed_added_4_0">Null-safe equals check. Return true if both arguments are null or equal.</p>
+ * @param <T> the type of objects to compare.
+ * @param t1
+ * @param t2
+ * @return true if both arguments are null or equal
+ */
+ public static <T> boolean nullSafeEquals(T t1, T t2) {
+ if (t1 == null) {
+ return t2 == null;
+ } else if (t2 == null) {
+ return false;
+ } else {
+ return t1.equals(t2);
+ }
+ }
+
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -23,6 +23,7 @@
package org.richfaces.cdk.xmlconfig;
+import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -62,7 +63,7 @@
* @param url
* @return
*/
- public Map<String, Property> parseProperties(String url) throws CdkException {
+ public Collection<Property> parseProperties(String url) throws CdkException {
String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
Class<Fragment> bindClass = Fragment.class;
Fragment unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
@@ -70,7 +71,7 @@
ComponentModel component = adapter.unmarshal(unmarshal);
return component.getAttributes();
} else {
- return Collections.<String, Property> emptyMap();
+ return Collections.<Property> emptySet();
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeBean.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -37,6 +37,7 @@
*/
@XmlType(name = "faces-config-attributeType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
propOrder = {"key", "type", "defaultValue", "suggestedValue", "extension"})
+(a)XmlJavaTypeAdapter(AttributeAdapter.class)
public class AttributeBean extends PropertyBase {
/**
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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -54,7 +54,6 @@
@Override
protected void postMarshal(ComponentModel model, ComponentBean bean) {
// Copy properties/attributes
- bean.setAttributes(marshalMap(model.getAttributes(), ATTRIBUTE_ADAPTER));
bean.setFacets(marshalMap(model.getFacets(), FACET_ADAPTER));
}
@@ -69,8 +68,6 @@
model.setType(new Type(type.trim()));
}
// Copy properties/attributes
- model.getAttributes().putAll(this.<String, PropertyBase, Property>unmarshalMap(
- bean.getAttributes(), ATTRIBUTE_ADAPTER));
model.getFacets().putAll(this.<String, FacetBean, FacetModel>unmarshalMap(bean.getFacets(), FACET_ADAPTER));
Collection<RendererModel> renderers = model.getRenderers();
ComponentBean.ComponentExtension extension = bean.getExtension();
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -30,10 +30,12 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.richfaces.cdk.model.AttributeModel;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.EventModel;
+import org.richfaces.cdk.model.Property;
import com.google.common.collect.Lists;
@@ -49,7 +51,7 @@
public class ComponentBean extends ExtensibleBean<ComponentBean.ComponentExtension> {
private boolean generate = false;
- private List<PropertyBase> attributes = Lists.newArrayList();
+ private List<Property> attributes = Lists.newArrayList();
private List<FacetBean> facets = Lists.newArrayList();
private ClassName componentClass;
private String type;
@@ -101,15 +103,15 @@
@XmlElements({@XmlElement(
name = "property",
namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- type = PropertyBean.class
+ type = Property.class
), @XmlElement(
name = "attribute",
namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
- type = AttributeBean.class
+ type = AttributeModel.class
)})
// @XmlElement(name="attributes",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public List<PropertyBase> getAttributes() {
+ public List<Property> getAttributes() {
return attributes;
}
@@ -118,7 +120,7 @@
*
* @param property the attributes to set
*/
- public void setAttributes(List<PropertyBase> property) {
+ public void setAttributes(List<Property> property) {
this.attributes = property;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -37,6 +37,7 @@
*/
@XmlType(name="faces-config-propertyType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE,
propOrder={"key","type","defaultValue","suggestedValue","extension"})
+(a)XmlJavaTypeAdapter(AttributeAdapter.class)
public class PropertyBean extends PropertyBase {
/**
Modified: 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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ComponentProcessorTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -118,7 +118,7 @@
assertEquals(1, components.size());
ComponentModel component = Iterables.get(components, 0);
- Map<String, Property> attributes = component.getAttributes();
+ Collection<Property> attributes = component.getAttributes();
assertEquals(3, attributes.size());
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -69,7 +69,7 @@
protected FileManager output;
protected static Property addAttribute(ModelElementBase model, String attributeName, Class<?> type, boolean generate) {
- Property attribute = model.addAttribute(attributeName);
+ Property attribute = model.getOrCreateAttribute(attributeName);
attribute.setType(new ClassName(type));
attribute.setGenerate(generate);
return attribute;
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -87,23 +87,23 @@
component.setGenerate(true);
component.setClassNames("org.richfaces.cdk.generate.java.GeneratedComponent", UIOutput.class.getName());
- Property attribute = component.addAttribute("testValue");
+ Property attribute = component.getOrCreateAttribute("testValue");
attribute.setType(new ClassName(Object.class));
attribute.setGenerate(true);
- attribute = component.addAttribute("testFlag");
+ attribute = component.getOrCreateAttribute("testFlag");
attribute.setType(new ClassName(Boolean.class));
attribute.setGenerate(true);
- attribute = component.addAttribute("testBinding");
+ attribute = component.getOrCreateAttribute("testBinding");
attribute.setType(new ClassName(MethodBinding.class));
attribute.setGenerate(true);
- attribute = component.addAttribute("testExpr");
+ attribute = component.getOrCreateAttribute("testExpr");
attribute.setType(new ClassName(MethodExpression.class));
attribute.setGenerate(true);
- attribute = component.addAttribute("id");
+ attribute = component.getOrCreateAttribute("id");
attribute.setType(new ClassName(String.class));
attribute.setGenerate(false);
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/TaglibTestBase.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -59,7 +59,6 @@
* @author akolonitsky
* @since Jan 18, 2010
*/
-(a)RunWith(CdkTestRunner.class)
public class TaglibTestBase extends CdkTestBase {
@@ -88,8 +87,9 @@
return event;
}
- protected Property createAttribute( Class<?> type, boolean generate) {
+ protected Property createAttribute( String name, Class<?> type, boolean generate) {
Property attribute = new Property();
+ attribute.setName(name);
attribute.setType(new ClassName(type));
attribute.setGenerate(generate);
return attribute;
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/taglib/ValidatorTagGeneratorTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -68,12 +68,12 @@
validator.setGeneratedClass(UIOutput.class);
validator.setGenerate(true);
- Property attribute1 = createAttribute( Object.class, true);
- validator.getAttributes().put("testValue", attribute1);
- Property attribute2 = createAttribute( boolean.class, true);
- validator.getAttributes().put("testFlag", attribute2);
- Property attribute = createAttribute(String.class, false);
- validator.getAttributes().put("id", attribute);
+ Property attribute1 = createAttribute( "testValue", Object.class, true);
+ validator.getAttributes().add( attribute1);
+ Property attribute2 = createAttribute( "testFlag", boolean.class, true);
+ validator.getAttributes().add( attribute2);
+ Property attribute = createAttribute("id", String.class, false);
+ validator.getAttributes().add(attribute);
Set<EventName> eventNames = attribute.getEventNames();
eventNames.add(createEvent("id", false));
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -184,7 +184,7 @@
return null != getType() && getType().equals(other.getType());
}
- public static final class Type extends Key {
+ public static final class Type extends FacesId {
private static final long serialVersionUID = 6227413669285563473L;
public Type(String type) {
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -46,7 +46,6 @@
import org.richfaces.cdk.Mock;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.Sources;
-import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.*;
import org.richfaces.cdk.model.RenderKitModel.Id;
import org.richfaces.cdk.templatecompiler.model.Template;
@@ -299,23 +298,32 @@
assertEquals("org.richfaces.Dummy", renderer.getFamily());
assertSame(template, renderer.getTemplate());
- Map<String, Property> attributes = renderer.getAttributes();
+ Collection<Property> attributes = renderer.getAttributes();
assertNotNull(attributes);
- checkDummyComponentOnclick(attributes.get("onclick"));
- checkDummyComponentOnchange(attributes.get("onchange"));
- checkDummyComponentAction(attributes.get("action"));
- checkDummyComponentActionListener(attributes.get("actionListener"));
- checkDummyComponentCoolMethod(attributes.get("coolMethod"));
- checkDummyComponentIntegerAttribute(attributes.get("integerAttribute"));
- checkDummyComponentRequiredAttribute(attributes.get("requiredAttribute"));
+ checkDummyComponentOnclick(getAttribute(attributes,"onclick"));
+ checkDummyComponentOnchange(getAttribute(attributes,"onchange"));
+ checkDummyComponentAction(getAttribute(attributes,"action"));
+ checkDummyComponentActionListener(getAttribute(attributes,"actionListener"));
+ checkDummyComponentCoolMethod(getAttribute(attributes,"coolMethod"));
+ checkDummyComponentIntegerAttribute(getAttribute(attributes,"integerAttribute"));
+ checkDummyComponentRequiredAttribute(getAttribute(attributes,"requiredAttribute"));
- checkDummyComponentImportedAttribute(attributes.get("anotherImportedStringProperty"), String.class);
- checkDummyComponentImportedAttribute(attributes.get("anotherImportedProperty"), Object.class);
- checkDummyComponentImportedAttribute(attributes.get("importedBooleanProperty"), boolean.class);
- checkDummyComponentImportedAttribute(attributes.get("importedIntegerProperty"), Integer.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes,"anotherImportedStringProperty"), String.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes,"anotherImportedProperty"), Object.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes,"importedBooleanProperty"), boolean.class);
+ checkDummyComponentImportedAttribute(getAttribute(attributes,"importedIntegerProperty"), Integer.class);
assertEquals(11, attributes.size());
}
+ private Property getAttribute(Collection<Property> attributes, String string) {
+ for (Property property : attributes) {
+ if(string.equals(property.getName())){
+ return property;
+ }
+ }
+ return null;
+ }
+
}
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-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -25,6 +25,7 @@
import static org.junit.Assert.*;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -111,7 +112,7 @@
assertEquals("Header facet", facet.getDescription());
assertTrue(facet.isGenerate());
- Map<String, Property> attributes = component.getAttributes();
+ Collection<Property> attributes = component.getAttributes();
assertEquals(3, attributes.size());
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -25,6 +25,7 @@
import static org.junit.Assert.*;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -43,6 +44,7 @@
import org.richfaces.cdk.model.Property;
import org.xml.sax.ext.EntityResolver2;
+import com.google.common.collect.Iterables;
import com.google.inject.Binder;
import com.google.inject.Inject;
@@ -84,7 +86,7 @@
@Test
public void parserTest() throws Exception {
- Map<String, Property> properties =
+ Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
assertEquals(3, properties.size());
@@ -93,7 +95,7 @@
@Test
public void xincludeTest() throws Exception {
- Map<String, Property> properties =
+ Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
assertEquals(2, properties.size());
@@ -102,7 +104,7 @@
@Test
public void nestedXincludeTest() throws Exception {
- Map<String, Property> properties =
+ Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent2.xml");
assertEquals(2, properties.size());
@@ -111,14 +113,14 @@
@Test
public void propertyTest() throws Exception {
- Map<String, Property> properties =
+ Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/properties.xml");
assertEquals(1, properties.size());
- Property property = properties.get("ontest2");
+ Property property = Iterables.getOnlyElement(properties);
+ assertEquals("ontest2",property.getName());
- assertNotNull(property);
assertEquals("int", property.getType().getName());
assertEquals("test2 property", property.getDescription());
assertEquals("ontest2.png", property.getIcon().getSmallIcon());
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JAXBCopyTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -2,12 +2,14 @@
import static org.junit.Assert.*;
+import java.util.Collection;
import java.util.List;
import org.junit.Test;
import org.junit.Ignore;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.model.ComponentBean;
import org.richfaces.cdk.xmlconfig.model.PropertyBase;
import org.richfaces.cdk.xmlconfig.model.ComponentBean.ComponentExtension;
@@ -26,13 +28,13 @@
component.setDescription(FOO_DESCTIPTION);
component.setGeneratedClass(FOO_UI_BAR);
- component.addAttribute(BAZ);
+ component.getOrCreateAttribute(BAZ);
component.setFamily(FOO_FAMILY);
ComponentBean componentBean = null; //JAXBBinding.createAdapter(ComponentBean.class, component);
assertEquals(FOO_BAR, componentBean.getType());
- List<PropertyBase> attributes = componentBean.getAttributes();
+ Collection<Property> attributes = componentBean.getAttributes();
assertEquals(0, attributes.size());
// assertEquals(BAZ, attributes.get(0).getKey().toString());
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-03-05 16:22:26 UTC (rev 16531)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/TaglibGeneratorVisitorTest.java 2010-03-06 00:18:24 UTC (rev 16532)
@@ -67,7 +67,7 @@
}
private Property addAttribute(ValidatorModel validator, String attributeName, Class<?> type, boolean generate) {
- Property attribute = validator.addAttribute(attributeName);
+ Property attribute = validator.getOrCreateAttribute(attributeName);
attribute.setType(new ClassName(type));
attribute.setGenerate(generate);
return attribute;
14 years, 7 months
JBoss Rich Faces SVN: r16531 - in root/ui-sandbox/trunk/components/tables: impl/src/main/java/org/richfaces/model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-03-05 11:22:26 -0500 (Fri, 05 Mar 2010)
New Revision: 16531
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeable.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangeableState.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableStateDefaultImpl.java
Removed:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
Log:
RF-8118 RF-8119
Copied: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeable.java (from rev 16530, root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeable.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeable.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface Arrangeable {
+
+ void arrange(FacesContext context, ArrangeableState state);
+}
Copied: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangeableState.java (from rev 16530, root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangeableState.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangeableState.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface ArrangeableState {
+
+ List<FilterField> getFilterFields();
+
+ List<SortField> getSortFields();
+
+ Locale getLocale();
+}
Deleted: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java 2010-03-05 15:54:16 UTC (rev 16530)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface Arrangeble {
-
- void arrange(FacesContext context, ArrangebleState state);
-}
Deleted: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java 2010-03-05 15:54:16 UTC (rev 16530)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.util.List;
-import java.util.Locale;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface ArrangebleState {
-
- List<FilterField> getFilterFields();
-
- List<SortField> getSortFields();
-
- Locale getLocale();
-}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableModel.java (from rev 16530, root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableModel.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -0,0 +1,371 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+import javax.swing.SortOrder;
+
+import org.ajax4jsf.context.ContextInitParameters;
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ArrangeableModel extends ExtendedDataModel<Object> implements Arrangeable {
+
+ protected ArrangeableState state;
+
+ protected List<Object> rowKeys;
+
+ protected ExtendedDataModel<?> originalModel;
+
+ protected String var;
+
+ protected String filterVar;
+
+ private Comparator<? super String> stringComparator;
+
+ public ArrangeableModel(ExtendedDataModel<?> originalModel, String var, String filterVar) {
+ this.originalModel = originalModel;
+ this.var = var;
+ this.filterVar = filterVar;
+ }
+
+ @Override
+ public void addDataModelListener(DataModelListener listener) {
+ originalModel.addDataModelListener(listener);
+ }
+
+ @Override
+ public void removeDataModelListener(DataModelListener listener) {
+ originalModel.removeDataModelListener(listener);
+ }
+
+ @Override
+ public DataModelListener[] getDataModelListeners() {
+ return originalModel.getDataModelListeners();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ @Override
+ public Object getRowKey() {
+ return originalModel.getRowKey();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ @Override
+ public void setRowKey(Object key) {
+ originalModel.setRowKey(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor,
+ * org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if (rows > 0) {
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, rowKeys.get(currentRow), argument);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ if (rowKeys == null) {
+ return -1;
+ } else {
+ return rowKeys.size();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ @Override
+ public Object getRowData() {
+ return originalModel.getRowData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ @Override
+ public int getRowIndex() {
+ return rowKeys.indexOf(originalModel.getRowKey());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ @Override
+ public Object getWrappedData() {
+ return originalModel.getWrappedData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ @Override
+ public boolean isRowAvailable() {
+ return originalModel.isRowAvailable();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ @Override
+ public void setRowIndex(int rowIndex) {
+ Object originalKey = null;
+ if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
+ originalKey = rowKeys.get(rowIndex);
+ }
+ originalModel.setRowKey(originalKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ @Override
+ public void setWrappedData(Object data) {
+ originalModel.setWrappedData(data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.Modifiable#modify(org.richfaces.model.ModifiableState)
+ */
+ public void arrange(FacesContext context, ArrangeableState state) {
+ initializeRowKeys(context);
+ if (state != null) {
+ this.state = state;
+ Map<Object, Object> attributes = context.getAttributes();
+ Object value = null;
+ Object filterValue = null;
+ if (var != null && var.length() > 0) {
+ value = attributes.get(var);
+ }
+ if (filterVar != null && filterVar.length() > 0) {
+ filterValue = attributes.get(filterVar);
+ }
+ filter(context);
+ sort(context);
+ if (var != null && var.length() > 0) {
+ attributes.put(var, value);
+ }
+ if (filterVar != null && filterVar.length() > 0) {
+ attributes.put(filterVar, filterValue);
+ }
+ }
+ }
+
+ private void initializeRowKeys(FacesContext context) {
+ int rowCount = originalModel.getRowCount();
+ if (rowCount > 0) {
+ rowKeys = new ArrayList<Object>(rowCount);
+ } else {
+ rowKeys = new ArrayList<Object>();
+ }
+ Object rowKey = originalModel.getRowKey();
+ originalModel.walk(context, new DataVisitor() {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ originalModel.setRowKey(rowKey);
+ if (originalModel.isRowAvailable()) {
+ rowKeys.add(rowKey);
+ }
+ return DataVisitResult.CONTINUE;
+ }
+ }, new SequenceRange(0, -1), null);
+ originalModel.setRowKey(rowKey);
+ }
+
+ protected void filter(FacesContext context) {
+ List<FilterField> filterFields = state.getFilterFields();
+ if (filterFields != null && !filterFields.isEmpty()) {
+ List<Object> filteredCollection = new ArrayList<Object>();
+ for (Object rowKey : rowKeys) {
+ if (accept(context, rowKey)) {
+ filteredCollection.add(rowKey);
+ }
+ }
+ rowKeys = filteredCollection;
+ }
+ }
+
+ protected void sort(final FacesContext context) {
+ List<SortField> sortFields = state.getSortFields();
+ if (sortFields != null && !sortFields.isEmpty()) {
+ Collections.sort(rowKeys, new Comparator<Object>() {
+ public int compare(Object rowKey1, Object rowKey2) {
+ return ArrangeableModel.this.compare(context, rowKey1, rowKey2);
+ }
+ });
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected boolean accept(FacesContext context, Object rowKey) {
+ originalModel.setRowKey(rowKey);
+ Object object = originalModel.getRowData();
+ updateVar(context, var, object);
+ for (FilterField filterField : state.getFilterFields()) {
+ Filter filter = filterField.getFilter();
+ if (filter != null && !filter.accept(object)) {
+ return false;
+ } else {
+ ValueExpression filterExpression = filterField.getFilterExpression();
+ if (filterExpression != null) {
+ updateVar(context, filterVar, filterField.getFilterValue());
+ if (Boolean.FALSE.equals(filterExpression.getValue(context.getELContext()))) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected int compare(FacesContext context, Object rowKey1, Object rowKey2) {
+ originalModel.setRowKey(rowKey1);
+ Object object1 = originalModel.getRowData();
+ originalModel.setRowKey(rowKey2);
+ Object object2 = originalModel.getRowData();
+ int result = 0;
+ for (Iterator<SortField> iterator = state.getSortFields().iterator(); iterator.hasNext() && result == 0;) {
+ SortField sortField = iterator.next();
+ SortOrder sortOrder = sortField.getSortOrder();
+ if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
+ Comparator comparator = sortField.getComparator();
+ if (comparator != null) {
+ result = comparator.compare(object1, object2);
+ } else {
+ ValueExpression sortBy = sortField.getSortBy();
+ if (sortBy != null) {
+ updateVar(context, var, object1);
+ Object value1 = sortBy.getValue(context.getELContext());
+ updateVar(context, var, object2);
+ Object value2 = sortBy.getValue(context.getELContext());
+ result = compareSortByValues(context, value1, value2);
+ }
+ }
+ if (SortOrder.DESCENDING.equals(sortOrder)) {
+ result = -result;
+ }
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ private int compareSortByValues(FacesContext context, Object value1, Object value2) {
+ int result = 0;
+ if (value1 instanceof String && value2 instanceof String) {
+ if (stringComparator == null) {
+ stringComparator = createStringComparator(context);
+ }
+ result = stringComparator.compare(((String) value1).trim(), ((String) value2).trim());
+ } else if (value1 instanceof Comparable<?>) {
+ result = ((Comparable) value1).compareTo(value2);
+ } else if (value1 == null && value2 != null) {
+ result = -1;
+ } else if (value2 == null && value1 != null) {
+ result = 1;
+ }
+ return result;
+ }
+
+ private Comparator<? super String> createStringComparator(FacesContext context) {
+ Comparator<? super String> comparator = null;
+ Locale locale = state.getLocale();
+ if (locale != null && ContextInitParameters.isDatatableUsesViewLocale(context)) {
+ comparator = Collator.getInstance(locale);
+ } else {
+ comparator = new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ };
+ }
+ return comparator;
+ }
+
+ private void updateVar(FacesContext context, String var, Object value) {
+ if (var != null && var.length() > 0) {
+ context.getAttributes().put(var, value);
+ }
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableStateDefaultImpl.java (from rev 16530, root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableStateDefaultImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangeableStateDefaultImpl.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ArrangeableStateDefaultImpl implements ArrangeableState {
+
+ private List<FilterField> filterFields;
+
+ private List<SortField> sortFields;
+
+ private Locale locale;
+
+ public ArrangeableStateDefaultImpl(List<FilterField> filterFields, List<SortField> sortFields, Locale locale) {
+ this.filterFields = filterFields;
+ this.sortFields = sortFields;
+ this.locale = locale;
+ }
+
+ public List<FilterField> getFilterFields() {
+ return filterFields;
+ }
+
+ public List<SortField> getSortFields() {
+ return sortFields;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+}
Deleted: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java 2010-03-05 15:54:16 UTC (rev 16530)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -1,371 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-import javax.swing.SortOrder;
-
-import org.ajax4jsf.context.ContextInitParameters;
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ArrangebleModel extends ExtendedDataModel<Object> implements Arrangeble {
-
- protected ArrangebleState state;
-
- protected List<Object> rowKeys;
-
- protected ExtendedDataModel<?> originalModel;
-
- protected String var;
-
- protected String filterVar;
-
- private Comparator<? super String> stringComparator;
-
- public ArrangebleModel(ExtendedDataModel<?> originalModel, String var, String filterVar) {
- this.originalModel = originalModel;
- this.var = var;
- this.filterVar = filterVar;
- }
-
- @Override
- public void addDataModelListener(DataModelListener listener) {
- originalModel.addDataModelListener(listener);
- }
-
- @Override
- public void removeDataModelListener(DataModelListener listener) {
- originalModel.removeDataModelListener(listener);
- }
-
- @Override
- public DataModelListener[] getDataModelListeners() {
- return originalModel.getDataModelListeners();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- @Override
- public Object getRowKey() {
- return originalModel.getRowKey();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- @Override
- public void setRowKey(Object key) {
- originalModel.setRowKey(key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor,
- * org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = getRowCount();
- int currentRow = seqRange.getFirstRow();
- if (rows > 0) {
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- visitor.process(context, rowKeys.get(currentRow), argument);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- if (rowKeys == null) {
- return -1;
- } else {
- return rowKeys.size();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowData()
- */
- @Override
- public Object getRowData() {
- return originalModel.getRowData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- return rowKeys.indexOf(originalModel.getRowKey());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- @Override
- public Object getWrappedData() {
- return originalModel.getWrappedData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- @Override
- public boolean isRowAvailable() {
- return originalModel.isRowAvailable();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- Object originalKey = null;
- if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
- originalKey = rowKeys.get(rowIndex);
- }
- originalModel.setRowKey(originalKey);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- @Override
- public void setWrappedData(Object data) {
- originalModel.setWrappedData(data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.model.Modifiable#modify(org.richfaces.model.ModifiableState)
- */
- public void arrange(FacesContext context, ArrangebleState state) {
- initializeRowKeys(context);
- if (state != null) {
- this.state = state;
- Map<Object, Object> attributes = context.getAttributes();
- Object value = null;
- Object filterValue = null;
- if (var != null && var.length() > 0) {
- value = attributes.get(var);
- }
- if (filterVar != null && filterVar.length() > 0) {
- filterValue = attributes.get(filterVar);
- }
- filter(context);
- sort(context);
- if (var != null && var.length() > 0) {
- attributes.put(var, value);
- }
- if (filterVar != null && filterVar.length() > 0) {
- attributes.put(filterVar, filterValue);
- }
- }
- }
-
- private void initializeRowKeys(FacesContext context) {
- int rowCount = originalModel.getRowCount();
- if (rowCount > 0) {
- rowKeys = new ArrayList<Object>(rowCount);
- } else {
- rowKeys = new ArrayList<Object>();
- }
- Object rowKey = originalModel.getRowKey();
- originalModel.walk(context, new DataVisitor() {
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- originalModel.setRowKey(rowKey);
- if (originalModel.isRowAvailable()) {
- rowKeys.add(rowKey);
- }
- return DataVisitResult.CONTINUE;
- }
- }, new SequenceRange(0, -1), null);
- originalModel.setRowKey(rowKey);
- }
-
- protected void filter(FacesContext context) {
- List<FilterField> filterFields = state.getFilterFields();
- if (filterFields != null && !filterFields.isEmpty()) {
- List<Object> filteredCollection = new ArrayList<Object>();
- for (Object rowKey : rowKeys) {
- if (accept(context, rowKey)) {
- filteredCollection.add(rowKey);
- }
- }
- rowKeys = filteredCollection;
- }
- }
-
- protected void sort(final FacesContext context) {
- List<SortField> sortFields = state.getSortFields();
- if (sortFields != null && !sortFields.isEmpty()) {
- Collections.sort(rowKeys, new Comparator<Object>() {
- public int compare(Object rowKey1, Object rowKey2) {
- return ArrangebleModel.this.compare(context, rowKey1, rowKey2);
- }
- });
- }
- }
-
- @SuppressWarnings("unchecked")
- protected boolean accept(FacesContext context, Object rowKey) {
- originalModel.setRowKey(rowKey);
- Object object = originalModel.getRowData();
- updateVar(context, var, object);
- for (FilterField filterField : state.getFilterFields()) {
- Filter filter = filterField.getFilter();
- if (filter != null && !filter.accept(object)) {
- return false;
- } else {
- ValueExpression filterExpression = filterField.getFilterExpression();
- if (filterExpression != null) {
- updateVar(context, filterVar, filterField.getFilterValue());
- if (Boolean.FALSE.equals(filterExpression.getValue(context.getELContext()))) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- @SuppressWarnings("unchecked")
- protected int compare(FacesContext context, Object rowKey1, Object rowKey2) {
- originalModel.setRowKey(rowKey1);
- Object object1 = originalModel.getRowData();
- originalModel.setRowKey(rowKey2);
- Object object2 = originalModel.getRowData();
- int result = 0;
- for (Iterator<SortField> iterator = state.getSortFields().iterator(); iterator.hasNext() && result == 0;) {
- SortField sortField = iterator.next();
- SortOrder sortOrder = sortField.getSortOrder();
- if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
- Comparator comparator = sortField.getComparator();
- if (comparator != null) {
- result = comparator.compare(object1, object2);
- } else {
- ValueExpression sortBy = sortField.getSortBy();
- if (sortBy != null) {
- updateVar(context, var, object1);
- Object value1 = sortBy.getValue(context.getELContext());
- updateVar(context, var, object2);
- Object value2 = sortBy.getValue(context.getELContext());
- result = compareSortByValues(context, value1, value2);
- }
- }
- if (SortOrder.DESCENDING.equals(sortOrder)) {
- result = -result;
- }
- }
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private int compareSortByValues(FacesContext context, Object value1, Object value2) {
- int result = 0;
- if (value1 instanceof String && value2 instanceof String) {
- if (stringComparator == null) {
- stringComparator = createStringComparator(context);
- }
- result = stringComparator.compare(((String) value1).trim(), ((String) value2).trim());
- } else if (value1 instanceof Comparable<?>) {
- result = ((Comparable) value1).compareTo(value2);
- } else if (value1 == null && value2 != null) {
- result = -1;
- } else if (value2 == null && value1 != null) {
- result = 1;
- }
- return result;
- }
-
- private Comparator<? super String> createStringComparator(FacesContext context) {
- Comparator<? super String> comparator = null;
- Locale locale = state.getLocale();
- if (locale != null && ContextInitParameters.isDatatableUsesViewLocale(context)) {
- comparator = Collator.getInstance(locale);
- } else {
- comparator = new Comparator<String>() {
- public int compare(String o1, String o2) {
- return o1.compareToIgnoreCase(o2);
- }
- };
- }
- return comparator;
- }
-
- private void updateVar(FacesContext context, String var, Object value) {
- if (var != null && var.length() > 0) {
- context.getAttributes().put(var, value);
- }
- }
-}
Deleted: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java 2010-03-05 15:54:16 UTC (rev 16530)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.util.List;
-import java.util.Locale;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ArrangebleStateDefaultImpl implements ArrangebleState {
-
- private List<FilterField> filterFields;
-
- private List<SortField> sortFields;
-
- private Locale locale;
-
- public ArrangebleStateDefaultImpl(List<FilterField> filterFields, List<SortField> sortFields, Locale locale) {
- this.filterFields = filterFields;
- this.sortFields = sortFields;
- this.locale = locale;
- }
-
- public List<FilterField> getFilterFields() {
- return filterFields;
- }
-
- public List<SortField> getSortFields() {
- return sortFields;
- }
-
- public Locale getLocale() {
- return locale;
- }
-}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-05 15:54:16 UTC (rev 16530)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-05 16:22:26 UTC (rev 16531)
@@ -34,10 +34,10 @@
import org.ajax4jsf.model.ExtendedDataModel;
import org.richfaces.model.FilterField;
-import org.richfaces.model.Arrangeble;
-import org.richfaces.model.ArrangebleModel;
-import org.richfaces.model.ArrangebleState;
-import org.richfaces.model.ArrangebleStateDefaultImpl;
+import org.richfaces.model.Arrangeable;
+import org.richfaces.model.ArrangeableModel;
+import org.richfaces.model.ArrangeableState;
+import org.richfaces.model.ArrangeableStateDefaultImpl;
import org.richfaces.model.SortField;
import org.richfaces.model.SortMode;
@@ -85,25 +85,25 @@
@Override
protected ExtendedDataModel<?> createExtendedDataModel() {
ExtendedDataModel<?> dataModel = super.createExtendedDataModel();
- Arrangeble arrangeble = null;
+ Arrangeable arrangeable = null;
FacesContext context = getFacesContext();
- ArrangebleState state = createArrangebleState(context);
- if (dataModel instanceof Arrangeble) {
- arrangeble = (Arrangeble) dataModel;
+ ArrangeableState state = createArrangeableState(context);
+ if (dataModel instanceof Arrangeable) {
+ arrangeable = (Arrangeable) dataModel;
} else if (state != null) {
- ArrangebleModel arrangebleModel = new ArrangebleModel(dataModel, getVar(), getFilterVar());
+ ArrangeableModel arrangebleModel = new ArrangeableModel(dataModel, getVar(), getFilterVar());
dataModel = arrangebleModel;
- arrangeble = arrangebleModel;
+ arrangeable = arrangebleModel;
}
- if (arrangeble != null) {
- arrangeble.arrange(context, state);
+ if (arrangeable != null) {
+ arrangeable.arrange(context, state);
}
return dataModel;
}
- private ArrangebleState createArrangebleState(FacesContext context) {
- ArrangebleState state = null;
+ private ArrangeableState createArrangeableState(FacesContext context) {
+ ArrangeableState state = null;
List<FilterField> filterFields = new LinkedList<FilterField>();
Map<Object, SortField> sortFieldsMap = new LinkedHashMap<Object, SortField>();
for (Iterator<UIComponent> iterator = columns(); iterator.hasNext();) {
@@ -133,7 +133,7 @@
}
sortFields.addAll(sortFieldsMap.values());
if (!filterFields.isEmpty() || !sortFields.isEmpty()) {
- state = new ArrangebleStateDefaultImpl(filterFields, sortFields,
+ state = new ArrangeableStateDefaultImpl(filterFields, sortFields,
context.getViewRoot().getLocale());
}
return state;
14 years, 7 months
JBoss Rich Faces SVN: r16530 - in root/ui-sandbox/trunk/components/tables: impl/src/main/java/org/richfaces/model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-03-05 10:54:16 -0500 (Fri, 05 Mar 2010)
New Revision: 16530
Added:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java
Removed:
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java
root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
Log:
RF-8118 RF-8119
Copied: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java (from rev 16528, root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Arrangeble.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface Arrangeble {
+
+ void arrange(FacesContext context, ArrangebleState state);
+}
Copied: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java (from rev 16528, root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ArrangebleState.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface ArrangebleState {
+
+ List<FilterField> getFilterFields();
+
+ List<SortField> getSortFields();
+
+ Locale getLocale();
+}
Deleted: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java 2010-03-05 01:18:15 UTC (rev 16529)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/LocaleAware.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.util.Locale;
-
-/**
- * Models that are based on locale-dependent operations should implement this interface
- *
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-public interface LocaleAware {
-
- Locale getLocale();
-
- void setLocale(Locale locale);
-}
Deleted: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java 2010-03-05 01:18:15 UTC (rev 16529)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/Modifiable.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface Modifiable {
-
- void modify(FacesContext context, ModifiableState state);
-}
Deleted: root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java 2010-03-05 01:18:15 UTC (rev 16529)
+++ root/ui-sandbox/trunk/components/tables/api/src/main/java/org/richfaces/model/ModifiableState.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.util.List;
-import java.util.Locale;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface ModifiableState {
-
- List<FilterField> getFilterFields();
-
- List<SortField> getSortFields();
-
- Locale getLocale();
-}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java (from rev 16528, root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleModel.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -0,0 +1,371 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+import javax.swing.SortOrder;
+
+import org.ajax4jsf.context.ContextInitParameters;
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ArrangebleModel extends ExtendedDataModel<Object> implements Arrangeble {
+
+ protected ArrangebleState state;
+
+ protected List<Object> rowKeys;
+
+ protected ExtendedDataModel<?> originalModel;
+
+ protected String var;
+
+ protected String filterVar;
+
+ private Comparator<? super String> stringComparator;
+
+ public ArrangebleModel(ExtendedDataModel<?> originalModel, String var, String filterVar) {
+ this.originalModel = originalModel;
+ this.var = var;
+ this.filterVar = filterVar;
+ }
+
+ @Override
+ public void addDataModelListener(DataModelListener listener) {
+ originalModel.addDataModelListener(listener);
+ }
+
+ @Override
+ public void removeDataModelListener(DataModelListener listener) {
+ originalModel.removeDataModelListener(listener);
+ }
+
+ @Override
+ public DataModelListener[] getDataModelListeners() {
+ return originalModel.getDataModelListeners();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ @Override
+ public Object getRowKey() {
+ return originalModel.getRowKey();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ @Override
+ public void setRowKey(Object key) {
+ originalModel.setRowKey(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor,
+ * org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if (rows > 0) {
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, rowKeys.get(currentRow), argument);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ if (rowKeys == null) {
+ return -1;
+ } else {
+ return rowKeys.size();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ @Override
+ public Object getRowData() {
+ return originalModel.getRowData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ @Override
+ public int getRowIndex() {
+ return rowKeys.indexOf(originalModel.getRowKey());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ @Override
+ public Object getWrappedData() {
+ return originalModel.getWrappedData();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ @Override
+ public boolean isRowAvailable() {
+ return originalModel.isRowAvailable();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ @Override
+ public void setRowIndex(int rowIndex) {
+ Object originalKey = null;
+ if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
+ originalKey = rowKeys.get(rowIndex);
+ }
+ originalModel.setRowKey(originalKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ @Override
+ public void setWrappedData(Object data) {
+ originalModel.setWrappedData(data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.Modifiable#modify(org.richfaces.model.ModifiableState)
+ */
+ public void arrange(FacesContext context, ArrangebleState state) {
+ initializeRowKeys(context);
+ if (state != null) {
+ this.state = state;
+ Map<Object, Object> attributes = context.getAttributes();
+ Object value = null;
+ Object filterValue = null;
+ if (var != null && var.length() > 0) {
+ value = attributes.get(var);
+ }
+ if (filterVar != null && filterVar.length() > 0) {
+ filterValue = attributes.get(filterVar);
+ }
+ filter(context);
+ sort(context);
+ if (var != null && var.length() > 0) {
+ attributes.put(var, value);
+ }
+ if (filterVar != null && filterVar.length() > 0) {
+ attributes.put(filterVar, filterValue);
+ }
+ }
+ }
+
+ private void initializeRowKeys(FacesContext context) {
+ int rowCount = originalModel.getRowCount();
+ if (rowCount > 0) {
+ rowKeys = new ArrayList<Object>(rowCount);
+ } else {
+ rowKeys = new ArrayList<Object>();
+ }
+ Object rowKey = originalModel.getRowKey();
+ originalModel.walk(context, new DataVisitor() {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ originalModel.setRowKey(rowKey);
+ if (originalModel.isRowAvailable()) {
+ rowKeys.add(rowKey);
+ }
+ return DataVisitResult.CONTINUE;
+ }
+ }, new SequenceRange(0, -1), null);
+ originalModel.setRowKey(rowKey);
+ }
+
+ protected void filter(FacesContext context) {
+ List<FilterField> filterFields = state.getFilterFields();
+ if (filterFields != null && !filterFields.isEmpty()) {
+ List<Object> filteredCollection = new ArrayList<Object>();
+ for (Object rowKey : rowKeys) {
+ if (accept(context, rowKey)) {
+ filteredCollection.add(rowKey);
+ }
+ }
+ rowKeys = filteredCollection;
+ }
+ }
+
+ protected void sort(final FacesContext context) {
+ List<SortField> sortFields = state.getSortFields();
+ if (sortFields != null && !sortFields.isEmpty()) {
+ Collections.sort(rowKeys, new Comparator<Object>() {
+ public int compare(Object rowKey1, Object rowKey2) {
+ return ArrangebleModel.this.compare(context, rowKey1, rowKey2);
+ }
+ });
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected boolean accept(FacesContext context, Object rowKey) {
+ originalModel.setRowKey(rowKey);
+ Object object = originalModel.getRowData();
+ updateVar(context, var, object);
+ for (FilterField filterField : state.getFilterFields()) {
+ Filter filter = filterField.getFilter();
+ if (filter != null && !filter.accept(object)) {
+ return false;
+ } else {
+ ValueExpression filterExpression = filterField.getFilterExpression();
+ if (filterExpression != null) {
+ updateVar(context, filterVar, filterField.getFilterValue());
+ if (Boolean.FALSE.equals(filterExpression.getValue(context.getELContext()))) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected int compare(FacesContext context, Object rowKey1, Object rowKey2) {
+ originalModel.setRowKey(rowKey1);
+ Object object1 = originalModel.getRowData();
+ originalModel.setRowKey(rowKey2);
+ Object object2 = originalModel.getRowData();
+ int result = 0;
+ for (Iterator<SortField> iterator = state.getSortFields().iterator(); iterator.hasNext() && result == 0;) {
+ SortField sortField = iterator.next();
+ SortOrder sortOrder = sortField.getSortOrder();
+ if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
+ Comparator comparator = sortField.getComparator();
+ if (comparator != null) {
+ result = comparator.compare(object1, object2);
+ } else {
+ ValueExpression sortBy = sortField.getSortBy();
+ if (sortBy != null) {
+ updateVar(context, var, object1);
+ Object value1 = sortBy.getValue(context.getELContext());
+ updateVar(context, var, object2);
+ Object value2 = sortBy.getValue(context.getELContext());
+ result = compareSortByValues(context, value1, value2);
+ }
+ }
+ if (SortOrder.DESCENDING.equals(sortOrder)) {
+ result = -result;
+ }
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ private int compareSortByValues(FacesContext context, Object value1, Object value2) {
+ int result = 0;
+ if (value1 instanceof String && value2 instanceof String) {
+ if (stringComparator == null) {
+ stringComparator = createStringComparator(context);
+ }
+ result = stringComparator.compare(((String) value1).trim(), ((String) value2).trim());
+ } else if (value1 instanceof Comparable<?>) {
+ result = ((Comparable) value1).compareTo(value2);
+ } else if (value1 == null && value2 != null) {
+ result = -1;
+ } else if (value2 == null && value1 != null) {
+ result = 1;
+ }
+ return result;
+ }
+
+ private Comparator<? super String> createStringComparator(FacesContext context) {
+ Comparator<? super String> comparator = null;
+ Locale locale = state.getLocale();
+ if (locale != null && ContextInitParameters.isDatatableUsesViewLocale(context)) {
+ comparator = Collator.getInstance(locale);
+ } else {
+ comparator = new Comparator<String>() {
+ public int compare(String o1, String o2) {
+ return o1.compareToIgnoreCase(o2);
+ }
+ };
+ }
+ return comparator;
+ }
+
+ private void updateVar(FacesContext context, String var, Object value) {
+ if (var != null && var.length() > 0) {
+ context.getAttributes().put(var, value);
+ }
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java (from rev 16528, root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ArrangebleStateDefaultImpl.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.model;
+
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ArrangebleStateDefaultImpl implements ArrangebleState {
+
+ private List<FilterField> filterFields;
+
+ private List<SortField> sortFields;
+
+ private Locale locale;
+
+ public ArrangebleStateDefaultImpl(List<FilterField> filterFields, List<SortField> sortFields, Locale locale) {
+ this.filterFields = filterFields;
+ this.sortFields = sortFields;
+ this.locale = locale;
+ }
+
+ public List<FilterField> getFilterFields() {
+ return filterFields;
+ }
+
+ public List<SortField> getSortFields() {
+ return sortFields;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+}
Deleted: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2010-03-05 01:18:15 UTC (rev 16529)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -1,371 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-import javax.swing.SortOrder;
-
-import org.ajax4jsf.context.ContextInitParameters;
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ModifiableModel extends ExtendedDataModel<Object> implements Modifiable {
-
- protected ModifiableState state;
-
- protected List<Object> rowKeys;
-
- protected ExtendedDataModel<?> originalModel;
-
- protected String var;
-
- protected String filterVar;
-
- private Comparator<? super String> stringComparator;
-
- public ModifiableModel(ExtendedDataModel<?> originalModel, String var, String filterVar) {
- this.originalModel = originalModel;
- this.var = var;
- this.filterVar = filterVar;
- }
-
- @Override
- public void addDataModelListener(DataModelListener listener) {
- originalModel.addDataModelListener(listener);
- }
-
- @Override
- public void removeDataModelListener(DataModelListener listener) {
- originalModel.removeDataModelListener(listener);
- }
-
- @Override
- public DataModelListener[] getDataModelListeners() {
- return originalModel.getDataModelListeners();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- @Override
- public Object getRowKey() {
- return originalModel.getRowKey();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- @Override
- public void setRowKey(Object key) {
- originalModel.setRowKey(key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor,
- * org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = getRowCount();
- int currentRow = seqRange.getFirstRow();
- if (rows > 0) {
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- visitor.process(context, rowKeys.get(currentRow), argument);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- if (rowKeys == null) {
- return -1;
- } else {
- return rowKeys.size();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowData()
- */
- @Override
- public Object getRowData() {
- return originalModel.getRowData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- return rowKeys.indexOf(originalModel.getRowKey());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- @Override
- public Object getWrappedData() {
- return originalModel.getWrappedData();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- @Override
- public boolean isRowAvailable() {
- return originalModel.isRowAvailable();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- Object originalKey = null;
- if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
- originalKey = rowKeys.get(rowIndex);
- }
- originalModel.setRowKey(originalKey);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- @Override
- public void setWrappedData(Object data) {
- originalModel.setWrappedData(data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.model.Modifiable#modify(org.richfaces.model.ModifiableState)
- */
- public void modify(FacesContext context, ModifiableState state) {
- initializeRowKeys(context);
- if (state != null) {
- this.state = state;
- Map<Object, Object> attributes = context.getAttributes();
- Object value = null;
- Object filterValue = null;
- if (var != null && var.length() > 0) {
- value = attributes.get(var);
- }
- if (filterVar != null && filterVar.length() > 0) {
- filterValue = attributes.get(filterVar);
- }
- filter(context);
- sort(context);
- if (var != null && var.length() > 0) {
- attributes.put(var, value);
- }
- if (filterVar != null && filterVar.length() > 0) {
- attributes.put(filterVar, filterValue);
- }
- }
- }
-
- private void initializeRowKeys(FacesContext context) {
- int rowCount = originalModel.getRowCount();
- if (rowCount > 0) {
- rowKeys = new ArrayList<Object>(rowCount);
- } else {
- rowKeys = new ArrayList<Object>();
- }
- Object rowKey = originalModel.getRowKey();
- originalModel.walk(context, new DataVisitor() {
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- originalModel.setRowKey(rowKey);
- if (originalModel.isRowAvailable()) {
- rowKeys.add(rowKey);
- }
- return DataVisitResult.CONTINUE;
- }
- }, new SequenceRange(0, -1), null);
- originalModel.setRowKey(rowKey);
- }
-
- protected void filter(FacesContext context) {
- List<FilterField> filterFields = state.getFilterFields();
- if (filterFields != null && !filterFields.isEmpty()) {
- List<Object> filteredCollection = new ArrayList<Object>();
- for (Object rowKey : rowKeys) {
- if (accept(context, rowKey)) {
- filteredCollection.add(rowKey);
- }
- }
- rowKeys = filteredCollection;
- }
- }
-
- protected void sort(final FacesContext context) {
- List<SortField> sortFields = state.getSortFields();
- if (sortFields != null && !sortFields.isEmpty()) {
- Collections.sort(rowKeys, new Comparator<Object>() {
- public int compare(Object rowKey1, Object rowKey2) {
- return ModifiableModel.this.compare(context, rowKey1, rowKey2);
- }
- });
- }
- }
-
- @SuppressWarnings("unchecked")
- protected boolean accept(FacesContext context, Object rowKey) {
- originalModel.setRowKey(rowKey);
- Object object = originalModel.getRowData();
- updateVar(context, var, object);
- for (FilterField filterField : state.getFilterFields()) {
- Filter filter = filterField.getFilter();
- if (filter != null && !filter.accept(object)) {
- return false;
- } else {
- ValueExpression filterExpression = filterField.getFilterExpression();
- if (filterExpression != null) {
- updateVar(context, filterVar, filterField.getFilterValue());
- if (Boolean.FALSE.equals(filterExpression.getValue(context.getELContext()))) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- @SuppressWarnings("unchecked")
- protected int compare(FacesContext context, Object rowKey1, Object rowKey2) {
- originalModel.setRowKey(rowKey1);
- Object object1 = originalModel.getRowData();
- originalModel.setRowKey(rowKey2);
- Object object2 = originalModel.getRowData();
- int result = 0;
- for (Iterator<SortField> iterator = state.getSortFields().iterator(); iterator.hasNext() && result == 0;) {
- SortField sortField = iterator.next();
- SortOrder sortOrder = sortField.getSortOrder();
- if (sortOrder != null && !SortOrder.UNSORTED.equals(sortOrder)) {
- Comparator comparator = sortField.getComparator();
- if (comparator != null) {
- result = comparator.compare(object1, object2);
- } else {
- ValueExpression sortBy = sortField.getSortBy();
- if (sortBy != null) {
- updateVar(context, var, object1);
- Object value1 = sortBy.getValue(context.getELContext());
- updateVar(context, var, object2);
- Object value2 = sortBy.getValue(context.getELContext());
- result = compareSortByValues(context, value1, value2);
- }
- }
- if (SortOrder.DESCENDING.equals(sortOrder)) {
- result = -result;
- }
- }
- }
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private int compareSortByValues(FacesContext context, Object value1, Object value2) {
- int result = 0;
- if (value1 instanceof String && value2 instanceof String) {
- if (stringComparator == null) {
- stringComparator = createStringComparator(context);
- }
- result = stringComparator.compare(((String) value1).trim(), ((String) value2).trim());
- } else if (value1 instanceof Comparable<?>) {
- result = ((Comparable) value1).compareTo(value2);
- } else if (value1 == null && value2 != null) {
- result = -1;
- } else if (value2 == null && value1 != null) {
- result = 1;
- }
- return result;
- }
-
- private Comparator<? super String> createStringComparator(FacesContext context) {
- Comparator<? super String> comparator = null;
- Locale locale = state.getLocale();
- if (locale != null && ContextInitParameters.isDatatableUsesViewLocale(context)) {
- comparator = Collator.getInstance(locale);
- } else {
- comparator = new Comparator<String>() {
- public int compare(String o1, String o2) {
- return o1.compareToIgnoreCase(o2);
- }
- };
- }
- return comparator;
- }
-
- private void updateVar(FacesContext context, String var, Object value) {
- if (var != null && var.length() > 0) {
- context.getAttributes().put(var, value);
- }
- }
-}
Deleted: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java 2010-03-05 01:18:15 UTC (rev 16529)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableStateDefaultImpl.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.model;
-
-import java.util.List;
-import java.util.Locale;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ModifiableStateDefaultImpl implements ModifiableState {
-
- private List<FilterField> filterFields;
-
- private List<SortField> sortFields;
-
- protected Locale locale;
-
- public ModifiableStateDefaultImpl(List<FilterField> filterFields, List<SortField> sortFields, Locale locale) {
- this.filterFields = filterFields;
- this.sortFields = sortFields;
- this.locale = locale;
- }
-
- public List<FilterField> getFilterFields() {
- return filterFields;
- }
-
- public List<SortField> getSortFields() {
- return sortFields;
- }
-
- public Locale getLocale() {
- return locale;
- }
-}
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-05 01:18:15 UTC (rev 16529)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-03-05 15:54:16 UTC (rev 16530)
@@ -34,10 +34,10 @@
import org.ajax4jsf.model.ExtendedDataModel;
import org.richfaces.model.FilterField;
-import org.richfaces.model.Modifiable;
-import org.richfaces.model.ModifiableModel;
-import org.richfaces.model.ModifiableState;
-import org.richfaces.model.ModifiableStateDefaultImpl;
+import org.richfaces.model.Arrangeble;
+import org.richfaces.model.ArrangebleModel;
+import org.richfaces.model.ArrangebleState;
+import org.richfaces.model.ArrangebleStateDefaultImpl;
import org.richfaces.model.SortField;
import org.richfaces.model.SortMode;
@@ -85,25 +85,25 @@
@Override
protected ExtendedDataModel<?> createExtendedDataModel() {
ExtendedDataModel<?> dataModel = super.createExtendedDataModel();
- Modifiable modifiable = null;
+ Arrangeble arrangeble = null;
FacesContext context = getFacesContext();
- ModifiableState modifiableState = createModifiableState(context);
- if (dataModel instanceof Modifiable) {
- modifiable = (Modifiable) dataModel;
- } else if (modifiableState != null) {
- ModifiableModel modifiableModel = new ModifiableModel(dataModel, getVar(), getFilterVar());
- dataModel = modifiableModel;
- modifiable = modifiableModel;
+ ArrangebleState state = createArrangebleState(context);
+ if (dataModel instanceof Arrangeble) {
+ arrangeble = (Arrangeble) dataModel;
+ } else if (state != null) {
+ ArrangebleModel arrangebleModel = new ArrangebleModel(dataModel, getVar(), getFilterVar());
+ dataModel = arrangebleModel;
+ arrangeble = arrangebleModel;
}
- if (modifiable != null) {
- modifiable.modify(context, modifiableState);
+ if (arrangeble != null) {
+ arrangeble.arrange(context, state);
}
return dataModel;
}
- private ModifiableState createModifiableState(FacesContext context) {
- ModifiableState modifiableState = null;
+ private ArrangebleState createArrangebleState(FacesContext context) {
+ ArrangebleState state = null;
List<FilterField> filterFields = new LinkedList<FilterField>();
Map<Object, SortField> sortFieldsMap = new LinkedHashMap<Object, SortField>();
for (Iterator<UIComponent> iterator = columns(); iterator.hasNext();) {
@@ -133,10 +133,10 @@
}
sortFields.addAll(sortFieldsMap.values());
if (!filterFields.isEmpty() || !sortFields.isEmpty()) {
- modifiableState = new ModifiableStateDefaultImpl(filterFields, sortFields,
+ state = new ArrangebleStateDefaultImpl(filterFields, sortFields,
context.getViewRoot().getLocale());
}
- return modifiableState;
+ return state;
}
public String getFilterVar() {
14 years, 7 months