Author: alexsmirnov
Date: 2009-07-31 20:27:52 -0400 (Fri, 31 Jul 2009)
New Revision: 15087
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
root/cdk/trunk/plugins/generator/src/main/models/
root/cdk/trunk/plugins/generator/src/main/models/faces-config.mdo
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
Removed:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/LibraryBuilderTest.java
Modified:
root/cdk/trunk/plugins/generator/pom.xml
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
Log:
continue development of LibraryBuilder class.
Modified: root/cdk/trunk/plugins/generator/pom.xml
===================================================================
--- root/cdk/trunk/plugins/generator/pom.xml 2009-07-31 16:56:22 UTC (rev 15086)
+++ root/cdk/trunk/plugins/generator/pom.xml 2009-08-01 00:27:52 UTC (rev 15087)
@@ -93,5 +93,15 @@
<artifactId>easymock</artifactId>
<version>2.5.1</version>
</dependency>
+ <dependency>
+ <groupId>com.google.collections</groupId>
+ <artifactId>google-collections</artifactId>
+ <version>1.0-rc2</version>
+ </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-07-31
16:56:22 UTC (rev 15086)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2009-08-01
00:27:52 UTC (rev 15087)
@@ -36,9 +36,26 @@
*/
public class LibraryBuilder {
- public static LibraryBuilder createInstance() {
- return new LibraryBuilder();
+ /**
+ * <p class="changed_added_4_0">Current CDK context</p>
+ */
+ private final CdkContext context;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param context
+ */
+ public LibraryBuilder(CdkContext context) {
+ this.context = context;
}
+
+ /**
+ * <p class="changed_added_4_0">Static factory method</p>
+ * @return
+ */
+ public static LibraryBuilder createInstance(CdkContext context) {
+ return new LibraryBuilder(context);
+ }
/**
* <p class="changed_added_4_0">Parse source files for annotations and
populate CDK-related information into model.</p>
@@ -46,19 +63,36 @@
* @param sources
* @throws CdkException
*/
- public void buildModelFromAnnotations(CdkContext context,Iterable<File> sources)
throws CdkException {
- CdkCompiler compiler = CdkCompiler.create(context);
- ComponentLibrary componentLibrary = context.getLibrary();
+ public void buildModelFromAnnotations(Iterable<File> sources) throws CdkException
{
+ CdkCompiler compiler = CdkCompiler.create(getContext());
+ ComponentLibrary componentLibrary = getContext().getLibrary();
if (null == componentLibrary) {
componentLibrary = createLibrary();
- context.setLibrary(componentLibrary);
+ getContext().setLibrary(componentLibrary);
}
compiler.process(sources, new CdkProcessor());
+ // TODO - check and fix library consittence.
}
- public void buildModelFromFacesConfig(CdkContext context,Iterable<File> configs)
throws CdkException {
-
+ /**
+ * <p class="changed_added_4_0">Append configuration from
faces-config.xml to existing library.</p>
+ * @param context
+ * @param configs
+ * @throws CdkException
+ */
+ public void applyFacesConfigToModel(Iterable<File> configs) throws CdkException {
+ ComponentLibrary componentLibrary = getContext().getLibrary();
+ // Read faces-config.xml and build a new model.
+ buildModelFromFacesConfig(configs);
+ if(null != componentLibrary){
+ componentLibrary.apply(getContext().getLibrary());
+ getContext().setLibrary(componentLibrary);
+ }
}
+
+ public void buildModelFromFacesConfig(Iterable<File> configs) throws CdkException
{
+ // Read faces-config.xml and build a new model.
+ }
/**
@@ -68,4 +102,12 @@
protected ComponentLibrary createLibrary(){
return new ComponentLibrary();
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the context
+ */
+ protected CdkContext getContext() {
+ return context;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-07-31
16:56:22 UTC (rev 15086)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-01
00:27:52 UTC (rev 15087)
@@ -23,6 +23,7 @@
package org.richfaces.cdk.model;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -35,21 +36,119 @@
/**
* <p class="changed_added_4_0">JSF components in that
library</p>
*/
- private List<Component> components;
+ private List<Component> components = new ArrayList<Component>();
/**
* <p class="changed_added_4_0">JSF renderer associated with that
library</p>
*/
- private List<Renderer> renderers;
+ private List<Renderer> renderers = new ArrayList<Renderer>();
- private List<Converter> converters;
+ private List<Converter> converters = new ArrayList<Converter>();
- private List<Validator> validators;
+ private List<Validator> validators = new ArrayList<Validator>();
- private List<Behavior> behaviors;
+ private List<Behavior> behaviors = new ArrayList<Behavior>();
+
+ private List<Listener> listeners = new ArrayList<Listener>();
+
/**
* <p class="changed_added_4_0">Tag library with references of all used
tags</p>
*/
private TagLibrary tagLibrary;
+ /**
+ * <p class="changed_added_4_0">Merge component library model with
other.</p>
+ * @param otherLibrary
+ */
+ public void apply(ComponentLibrary otherLibrary) {
+ // TODO Auto-generated method stub
+
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the components
+ */
+ public List<Component> getComponents() {
+ return components;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param components the components to set
+ */
+ public void setComponents(List<Component> components) {
+ this.components = components;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the renderers
+ */
+ public List<Renderer> getRenderers() {
+ return renderers;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param renderers the renderers to set
+ */
+ public void setRenderers(List<Renderer> renderers) {
+ this.renderers = renderers;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the converters
+ */
+ public List<Converter> getConverters() {
+ return converters;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param converters the converters to set
+ */
+ public void setConverters(List<Converter> converters) {
+ this.converters = converters;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the validators
+ */
+ public List<Validator> getValidators() {
+ return validators;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param validators the validators to set
+ */
+ public void setValidators(List<Validator> validators) {
+ this.validators = validators;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the behaviors
+ */
+ public List<Behavior> getBehaviors() {
+ return behaviors;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param behaviors the behaviors to set
+ */
+ public void setBehaviors(List<Behavior> behaviors) {
+ this.behaviors = behaviors;
+ }
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the listeners
+ */
+ public List<Listener> getListeners() {
+ return listeners;
+ }
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param listeners the listeners to set
+ */
+ public void setListeners(List<Listener> listeners) {
+ this.listeners = listeners;
+ }
+
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-08-01
00:27:52 UTC (rev 15087)
@@ -0,0 +1,51 @@
+/*
+ * $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;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class Listener implements JsfComponent {
+
+ private String type;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: root/cdk/trunk/plugins/generator/src/main/models/faces-config.mdo
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/models/faces-config.mdo
(rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/models/faces-config.mdo 2009-08-01 00:27:52
UTC (rev 15087)
@@ -0,0 +1,4 @@
+<model
xmlns="http://modello.codehaus.org/MODELLO/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://modello.codehaus.org/MODELLO/1.0.0
http://modello.codehaus.org/xsd/modello-1.0.0.xsd"
+ >
+</model>
\ No newline at end of file
Copied:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
(from rev 15067,
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/LibraryBuilderTest.java)
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2009-08-01
00:27:52 UTC (rev 15087)
@@ -0,0 +1,69 @@
+/**
+ *
+ */
+package org.richfaces.cdk;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.cdk.xmlutils.XMLBodyMergeTest;
+import org.richfaces.cdk.xmlutils.XMLBodySerializerTest;
+import org.richfaces.cdk.xmlutils.XMLBodyTest;
+import org.richfaces.cdk.xmlutils.XPathComparatorTest;
+
+/**
+ * @author asmirnov
+ *
+ */
+(a)RunWith(Parameterized.class)
+public class LibraryBuilderTest {
+
+ private String param;
+
+
+ public LibraryBuilderTest(String param) {
+ this.param=param;
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
+ */
+ @Test
+ public void createInstance() {
+ assertEquals("Parameter match","Two", param);
+ }
+
+
+ @Parameters
+ public static Collection<String[]> values(){
+ return Arrays.asList(new String[]{"One"},new String[]{"Two"},new
String[]{"Tree"});
+ }
+
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/LibraryBuilderTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/LibraryBuilderTest.java 2009-07-31
16:56:22 UTC (rev 15086)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/LibraryBuilderTest.java 2009-08-01
00:27:52 UTC (rev 15087)
@@ -1,69 +0,0 @@
-/**
- *
- */
-package org.richfaces.cdk.apt;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-import org.richfaces.cdk.xmlutils.XMLBodyMergeTest;
-import org.richfaces.cdk.xmlutils.XMLBodySerializerTest;
-import org.richfaces.cdk.xmlutils.XMLBodyTest;
-import org.richfaces.cdk.xmlutils.XPathComparatorTest;
-
-/**
- * @author asmirnov
- *
- */
-(a)RunWith(Parameterized.class)
-public class LibraryBuilderTest {
-
- private String param;
-
-
- public LibraryBuilderTest(String param) {
- this.param=param;
- }
-
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Test method for {@link org.richfaces.cdk.LibraryBuilder#createInstance()}.
- */
- @Test
- public void createInstance() {
- assertEquals("Parameter match","Two", param);
- }
-
-
- @Parameters
- public static Collection<String[]> values(){
- return Arrays.asList(new String[]{"One"},new String[]{"Two"},new
String[]{"Tree"});
- }
-
-
-}