Author: alexsmirnov
Date: 2009-08-27 20:25:48 -0400 (Thu, 27 Aug 2009)
New Revision: 15382
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.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/model/BehaviorRenderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
Removed:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.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/LibraryModelWrapper.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/model/Behavior.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
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/ModelCollection.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/RenderKit.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
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/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/DescriptionGroupBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.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/Properties.java
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/PropertyBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java
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/RendererAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.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/ModelBean.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/JaxbMarshalTest.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Log:
fire alarm saving
Deleted:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -1,132 +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;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import org.richfaces.cdk.CdkWriter.OutputType;
-import org.richfaces.cdk.model.ComponentLibrary;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-/**
- * <p class="changed_added_4_0">Base CDK context class. Particular build
tool ( Ant, Maven ) should extend that class with
- * tool-specific methods.</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class AbstractCdkContext implements CdkContext {
-
- private final ClassLoader loader;
-
- private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
-
- private Map<OutputType,File> outputs = Maps.newHashMap();
-
- private Map<SourceType,Iterable<File>> inputFolders = Maps.newHashMap();
-
- private Map<Class<? extends CdkWorker>,CdkWorker> workers =
Maps.newHashMap();
-
- private List<CdkError> errors = Lists.newArrayList();
-
- public AbstractCdkContext(ClassLoader loader) {
- this.loader = loader;
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkContext#getLoader()
- */
- public ClassLoader getLoader() {
- return loader;
- }
-
- public void addSources(SourceType type,Iterable<File> files) {
- sources.put(type, files);
- }
-
- @Override
- public Iterable<File> getSources(SourceType type) {
- return sources.get(type);
- }
-
- @Override
- public File getOutputFolder(OutputType type) {
- File outputFolder = outputs.get(type);
- return outputFolder;
- }
-
-
- public void setOutputFolder(OutputType type, File folder) {
- outputs.put(type, folder);
- }
-
- @Override
- public void sendError(CdkError error) {
- errors.add(error);
- }
-
- @Override
- public Iterable<CdkError> getErrors() {
- return errors;
- }
-
-
- @Override
- public Iterable<File> getSourceFolders(SourceType type) {
- return inputFolders.get(type);
- }
-
-
- public void setSourceFolders(SourceType type, Iterable<File> folders){
- inputFolders.put(type, folders);
- }
-
- @Override
- public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
- throws CdkException {
- CdkWorker worker = workers.get(workerClass);
- if(null == worker){
- // TODO - instantiate worker.
- try {
- worker = workerClass.newInstance();
- worker.init(this);
- workers.put(workerClass, worker);
- } catch (InstantiationException e) {
- throw new CdkException("error to instantiate cdk component
"+workerClass.getName(), e);
- } catch (IllegalAccessException e) {
- throw new CdkException("Illegal access to cdk component
"+workerClass.getName(), e);
- }
- }
- return (W) worker;
- }
-
-
- public <W extends CdkWorker> void addWorker(Class<W> workerClass, W worker)
{
- workers.put(workerClass, worker);
- }
-}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -49,7 +49,16 @@
*/
public File getOutputFolder(OutputType type);
+
/**
+ * <p class="changed_added_4_0">This method creates output file in the
appropriate output folder. If target file exists and its modification time is late than
model modification time from {@code lastModified} parameter, no new file will be
created.</p>
+ * @param output target output folder.
+ * @param relativePath path to file in the output folder.
+ * @param lastModified model modification time. If that parameter is less then 0, no
checks for existing file will be performed.
+ * @return new created file or null if the target file exists and its modification time
is late then model.
+ */
+ public File createOutputFile(OutputType output,String relativePath,long lastModified)
throws CdkException;
+ /**
* <p class="changed_added_4_0">Record recowerable CdkError. To avoid
consequence builds of the project with many errors, all non-fatal errors ( Java
compilation errors, incorrect xml fales, inconsistent component descriptions ) these error
are stored in the context and marks whole build failed.</p>
* @param error
*/
Copied:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java (from
rev 15351,
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/AbstractCdkContext.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,183 @@
+/*
+ * $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;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.richfaces.cdk.CdkWriter.OutputType;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * <p class="changed_added_4_0">Base CDK context class. Particular build
tool ( Ant, Maven ) should extend that class with
+ * tool-specific methods.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CdkContextBase implements CdkContext {
+
+ private final ClassLoader loader;
+
+ private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
+
+ private Map<OutputType,File> outputs = Maps.newHashMap();
+
+ private Map<SourceType,Iterable<File>> inputFolders = Maps.newHashMap();
+
+ private Map<Class<? extends CdkWorker>,CdkWorker> workers =
Maps.newHashMap();
+
+ private List<CdkError> errors = Lists.newArrayList();
+
+ public CdkContextBase(ClassLoader loader) {
+ this.loader = loader;
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.CdkContext#getLoader()
+ */
+ public ClassLoader getLoader() {
+ return loader;
+ }
+
+ public void addSources(SourceType type,Iterable<File> files) {
+ sources.put(type, files);
+ }
+
+ @Override
+ public Iterable<File> getSources(SourceType type) {
+ return sources.get(type);
+ }
+
+ @Override
+ public File getOutputFolder(OutputType type) {
+ File outputFolder = outputs.get(type);
+ OutputType folderType = type.getFolderType();
+ if(null == outputFolder && null != folderType){
+ // Lookup for standard folder type.
+ outputFolder = outputs.get(folderType);
+ // Lookup for output with same folder type.
+ Iterator<OutputType> keysIterator = outputs.keySet().iterator();
+ while (null == outputFolder && keysIterator.hasNext()) {
+ CdkWriter.OutputType outputType = (CdkWriter.OutputType) keysIterator
+ .next();
+ if(folderType.equals(outputType.getFolderType())){
+ outputFolder = outputs.get(outputType);
+ }
+ }
+ }
+ return outputFolder;
+ }
+
+
+ public void setOutputFolder(OutputType type, File folder) {
+ outputs.put(type, folder);
+ }
+
+ @Override
+ public void sendError(CdkError error) {
+ errors.add(error);
+ }
+
+ @Override
+ public Iterable<CdkError> getErrors() {
+ return errors;
+ }
+
+
+ @Override
+ public Iterable<File> getSourceFolders(SourceType type) {
+ return inputFolders.get(type);
+ }
+
+
+ public void setSourceFolders(SourceType type, Iterable<File> folders){
+ inputFolders.put(type, folders);
+ }
+
+ @Override
+ public <W extends CdkWorker> W getWorkerInstance(Class<W> workerClass)
+ throws CdkException {
+ CdkWorker worker = workers.get(workerClass);
+ if(null == worker){
+ // TODO - instantiate worker.
+ try {
+ worker = workerClass.newInstance();
+ worker.init(this);
+ workers.put(workerClass, worker);
+ } catch (InstantiationException e) {
+ throw new CdkException("error to instantiate cdk component
"+workerClass.getName(), e);
+ } catch (IllegalAccessException e) {
+ throw new CdkException("Illegal access to cdk component
"+workerClass.getName(), e);
+ }
+ }
+ return (W) worker;
+ }
+
+
+ public <W extends CdkWorker> void addWorker(Class<W> workerClass, W worker)
{
+ workers.put(workerClass, worker);
+ }
+
+ @Override
+ public File createOutputFile(OutputType output, String relativePath,
+ long lastModified) throws CdkException {
+ if(null == relativePath){
+ throw new NullPointerException();
+ }
+ File outputFolder = getOutputFolder(output);
+ if(null == outputFolder){
+ throw new CdkException("No output folder for type "+output.getName());
+ }
+ if(outputFolder.exists() && !outputFolder.isDirectory()){
+ throw new CdkException("Output folder "+outputFolder+" not is
directory.");
+ }
+ // Strip leading '/'
+ if(relativePath.startsWith(File.separator)){
+ relativePath = relativePath.substring(1);
+ }
+ File outputFile = new File(outputFolder,relativePath);
+ if(outputFile.exists()){
+ if(lastModified > 0 && outputFile.lastModified() > lastModified){
+ return null;
+ } else {
+ outputFile.delete();
+ }
+ }
+ // Create file folder.
+ outputFile.getParentFile().mkdirs();
+ try {
+ outputFile.createNewFile();
+ } catch (IOException e) {
+ throw new CdkException("Error create output file", e);
+ }
+ return outputFile;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -34,6 +34,7 @@
interface OutputType {
String getName();
+ OutputType getFolderType();
}
public void init(CdkContext context) throws CdkException;
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import org.richfaces.cdk.CdkWriter.OutputType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public enum StandardOutputFolders implements OutputType {
+ JAVA_CLASSES,
+ RESOURCES,
+ TEST_JAVA_CLASSES,
+ TEST_RESOURCES,
+ DOCUMENTATION;
+
+ @Override
+ public OutputType getFolderType() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return name();
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -31,19 +31,33 @@
*
*/
public enum StandardOutputs implements OutputType {
- COMPONENT_CLASSES,
- RENDERER_CLASSES,
- EVENT_LISTENER_CLASSES,
- EVENT_SOURCE_CLASSES,
- TAG_HANDLER_CLASSES,
- FACES_CONFIG,
- TAG_LIBRARY,
- JBDS_RENDERERS,
- XML_SCHEMA;
+ COMPONENT_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ RENDERER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ EVENT_LISTENER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ EVENT_SOURCE_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ TAG_HANDLER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ FACES_CONFIG(StandardOutputFolders.RESOURCES),
+ TAG_LIBRARY(StandardOutputFolders.RESOURCES),
+ JBDS_RENDERERS(StandardOutputFolders.JAVA_CLASSES),
+ XML_SCHEMA(StandardOutputFolders.RESOURCES);
+ private final OutputType folderType;
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param folderType
+ */
+ private StandardOutputs(OutputType folderType) {
+ this.folderType = folderType;
+ }
+
@Override
public String getName() {
return name();
}
+ @Override
+ public OutputType getFolderType() {
+ return folderType;
+ }
+
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,73 @@
+/*
+ * $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 org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.Property;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
+import freemarker.ext.beans.BeanModel;
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentTemplateModel extends BeanModel implements TemplateModel {
+
+ private final Component component;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param object
+ * @param wrapper
+ */
+ public ComponentTemplateModel(Component object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ component = object;
+ }
+
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ if("generatedAttributes".equals(key)){
+ return generatedAttributes();
+ }
+ return super.get(key);
+ }
+
+ private TemplateModel generatedAttributes() throws TemplateModelException {
+ return wrapper.wrap(Collections2.filter(component.getAttributes(), new
Predicate<Property>() {
+
+ @Override
+ public boolean apply(Property input) {
+ return input.isGenerate();
+ }
+ }));
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ComponentTemplateModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,7 @@
package org.richfaces.cdk.freemarker;
+import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
@@ -33,6 +34,7 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.LibraryVisitor;
import org.richfaces.cdk.model.Searchable;
+import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
import freemarker.template.Configuration;
@@ -71,14 +73,14 @@
}
@Override
- public Boolean visit(Visitable c, P param) {
+ public Boolean visit(Visitable c, P param) throws CdkException {
if(isMyComponent(c)){
return processComponent((C)c, param);
}
return null;
}
- protected boolean processComponent(C c, P param) {
+ protected boolean processComponent(C c, P param) throws CdkException {
try {
Writer out = getOutput(c);
template.process(c, out);
@@ -94,15 +96,27 @@
return false;
}
- protected Writer getOutput(C c) throws IOException {
- return new FileWriter(getOutputFile(c));
+ protected Writer getOutput(C c) throws CdkException {
+ long lastModified = Long.MIN_VALUE;
+ if (c instanceof Trackable) {
+ Trackable trackuble = (Trackable) c;
+ lastModified = trackuble.lastModified();
+ }
+ File sourceOutput = getContext().createOutputFile(getOutputType(), getOutputFile(c),
lastModified);
+ try {
+ return new FileWriter(sourceOutput);
+ } catch (IOException e) {
+ throw new CdkException(e);
+ }
}
- protected abstract String getOutputFile(C c) throws IOException;
+ protected abstract String getOutputFile(C c) throws CdkException;
protected abstract boolean isMyComponent(Visitable c);
protected abstract String getTemplateName();
+
+ protected abstract OutputType getOutputType();
/**
* <p class="changed_added_4_0"></p>
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/LibraryModelWrapper.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,22 +23,43 @@
package org.richfaces.cdk.freemarker;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.Property;
+
+import freemarker.ext.beans.BeansWrapper;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateScalarModel;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class LibraryModelWrapper extends DefaultObjectWrapper implements
+public class LibraryModelWrapper extends BeansWrapper implements
ObjectWrapper {
+ public LibraryModelWrapper() {
+ super();
+ setStrict(true);
+ setSimpleMapWrapper(true);
+// setNullModel(TemplateScalarModel.EMPTY_STRING);
+ setUseCache(true);
+ }
+
@Override
public TemplateModel wrap(Object obj) throws TemplateModelException {
// TODO wrap specified model classes.
- return super.wrap(obj);
+ TemplateModel templateModel;
+ if (obj instanceof Component) {
+ templateModel = new ComponentTemplateModel((Component)obj,this);
+ } else if (obj instanceof Property) {
+ templateModel = new PropertyModel((Property)obj,this);
+ }else {
+ templateModel = super.wrap(obj);
+ }
+ return templateModel;
}
}
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,75 @@
+/*
+ * $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 org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.util.Strings;
+
+import freemarker.ext.beans.BeanModel;
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class PropertyModel extends BeanModel implements TemplateModel {
+
+ private final Property property;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param object
+ * @param wrapper
+ */
+ public PropertyModel(Property object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ property = object;
+ }
+
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+ Object value;
+ if("getterName".equals(key)){
+ value = getGetterName();
+ } else if("setterName".equals(key)){
+ value = getSetterName();
+ } else {
+ return super.get(key);
+ }
+ return wrapper.wrap(value);
+ }
+ // Model utility methods.
+
+ public String getGetterName(){
+ return
property.getType().getGetterPrefix()+Strings.firstToUpperCase(property.getName().toString());
+ }
+
+ public String getSetterName(){
+ return "set"+Strings.firstToUpperCase(property.getName().toString());
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/PropertyModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -41,7 +41,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class ComponentClassGenerator extends FreeMarkerRenderer<Component, String>
implements CdkWriter {
+public class ComponentClassGenerator extends FreeMarkerRenderer<Component,
ComponentLibrary> implements CdkWriter {
/* (non-Javadoc)
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
@@ -57,23 +57,15 @@
protected boolean isMyComponent(Visitable c) {
if (c instanceof Component) {
Component component = (Component) c;
- return !component.isGenerate();
+ return component.isGenerate();
}
return false;
}
@Override
- protected String getOutputFile(Component c) throws IOException {
- File sourceOutput = getContext().getOutputFolder(StandardOutputs.COMPONENT_CLASSES);
- File outputFile = new
File(sourceOutput,c.getComponentClass().getName().replace('.',
File.separatorChar)+".java");
- if(!outputFile.exists()){
- outputFile.getParentFile().mkdirs();
- } else {
- outputFile.delete();
- }
-// outputFile.createNewFile();
- return outputFile.getAbsolutePath();
+ protected String getOutputFile(Component c) throws CdkException {
+ return c.getComponentClass().getName().replace('.',
File.separatorChar)+".java";
}
@@ -81,4 +73,10 @@
protected String getTemplateName() {
return "component.ftl";
}
+
+
+ @Override
+ protected OutputType getOutputType() {
+ return StandardOutputs.COMPONENT_CLASSES;
+ }
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Behavior.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -58,7 +60,7 @@
}
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,102 @@
+/*
+ * $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.CdkException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@SuppressWarnings("serial")
+public class BehaviorRenderer implements ModelElement<BehaviorRenderer,
BehaviorRenderer.Type>{
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ @SuppressWarnings("serial")
+ public static final class Type extends Key {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param type
+ */
+ public Type(String type) {
+ super(type);
+ // TODO Auto-generated constructor stub
+ }
+
+ }
+
+ private final Type type;
+
+ private ClassDescription rendererClass;
+
+ public BehaviorRenderer(Type type) {
+ this.type = type;
+ }
+
+ @Override
+ public Type getKey() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ public Type getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
+
+ @Override
+ public void merge(BehaviorRenderer other) {
+ ComponentLibrary.merge(this, other);
+ }
+
+ @Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassDescription.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -96,6 +96,14 @@
}
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param cl
+ */
+ public ClassDescription(Class<?>cl) {
+ // TODO get information directly from class.
+ this(cl.getName());
+ }
/**
* <p class="changed_added_4_0"></p>
@@ -168,6 +176,10 @@
public String getBoxingName() {
return boxingClassName;
}
+
+ public String getGetterPrefix(){
+ return Boolean.class.getName().equals(boxingClassName)?"is":"get";
+ }
@Override
public String toString() {
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Component.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -12,6 +12,7 @@
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlType;
+import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.Event.ClassName;
import org.richfaces.cdk.model.Facet.Name;
import org.richfaces.cdk.util.Strings;
@@ -111,7 +112,7 @@
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
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-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ComponentLibrary.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -36,6 +36,8 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import org.richfaces.cdk.CdkException;
+
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
@@ -53,7 +55,7 @@
*/
@XmlRootElement(name = "faces-config", namespace =
ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlType(namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, name =
"faces-configType")
-public class ComponentLibrary implements Serializable {
+public class ComponentLibrary implements
Serializable,Extensible<ConfigExtension>,Trackable {
public static final String FACES_CONFIG_NAMESPACE =
"http://java.sun.com/xml/ns/javaee";
@@ -123,12 +125,16 @@
return listener;
}
};
+
+ private ConfigExtension extension;
/**
* <p class="changed_added_4_0">
* Tag library with references of all used tags
* </p>
*/
private final TagLibrary tagLibrary;
+
+ private long lastModified = Long.MIN_VALUE;
/**
* <p class="changed_added_4_0">
@@ -155,7 +161,7 @@
listeners.merge(otherLibrary.listeners);
}
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
R result = accept(components, visitor, param, null);
result = accept(renderKits, visitor, param, result);
result = accept(converters, visitor, param, result);
@@ -270,6 +276,27 @@
// Utility methods.
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ public ConfigExtension getExtension() {
+ return extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(ConfigExtension extension) {
+ this.extension = extension;
+ }
+
+ @Override
+ public long lastModified() {
+ return lastModified;
+ }
+
static <K extends Key,T extends ModelElement<T,K>> void
merge(Collection<T> target,
Collection<T> source) {
for (T element : source) {
@@ -312,7 +339,7 @@
}
static <R, P, T extends ModelElement<T,?>> R accept(Iterable<T>
components,
- LibraryVisitor<R, P> visitor, P param, R result) {
+ LibraryVisitor<R, P> visitor, P param, R result) throws CdkException {
if (null == result) {
for (T t : components) {
R accept = t.accept(visitor, param);
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Converter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -34,7 +36,7 @@
private final Key type;
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Event.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -25,6 +25,8 @@
import javax.faces.event.FacesEvent;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0">That bean represent {@link FacesEvent}
subclass that can be fired by component.</p>
* @author asmirnov(a)exadel.com
@@ -92,7 +94,7 @@
}
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Facet.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -83,7 +85,7 @@
}
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/LibraryVisitor.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -37,7 +39,8 @@
* @param c
* @param param
* @return
+ * @throws CdkException
*/
- public R visit(Visitable c, P param);
+ public R visit(Visitable c, P param) throws CdkException;
}
Modified:
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Listener.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -37,7 +39,7 @@
private final Key type;
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelCollection.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,20 +23,14 @@
package org.richfaces.cdk.model;
-import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
+import org.richfaces.cdk.CdkException;
+
import com.google.common.base.Predicate;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
/**
* <p class="changed_added_4_0">
@@ -50,6 +44,7 @@
implements SearchableCollection<E, K>, Visitable,
Mergeable<SearchableCollection<E, K>> {
+ @SuppressWarnings("unused")
private final class SearchPredicate implements Predicate<E> {
private final K key;
@@ -179,7 +174,7 @@
}
public <R, P> R accept(
- org.richfaces.cdk.model.LibraryVisitor<R, P> visitor, P param) {
+ org.richfaces.cdk.model.LibraryVisitor<R, P> visitor, P param) throws
CdkException {
R result = null;
Iterator<E> iterator = iterator();
while (null == result && iterator.hasNext()) {
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Property.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -24,6 +24,9 @@
import java.util.List;
import java.util.Set;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.util.Strings;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -321,7 +324,7 @@
}
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/RenderKit.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -65,12 +65,20 @@
@Override
public Renderer create(Renderer.Type key) {
- Renderer renderer = new Renderer();
- renderer.setType(key);
+ Renderer renderer = new Renderer(key);
return renderer;
}
};
+ private final SearchableCollection<BehaviorRenderer,BehaviorRenderer.Type>
behaviorRenderers = new ModelCollection<BehaviorRenderer, BehaviorRenderer.Type>()
{
+
+ @Override
+ public BehaviorRenderer create(BehaviorRenderer.Type key) {
+ BehaviorRenderer renderer = new BehaviorRenderer(key);
+ return renderer;
+ }
+ };
+
public RenderKit(Id id) {
this.id = id;
}
@@ -116,6 +124,14 @@
return renderers;
}
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the behaviorRenderers
+ */
+ public SearchableCollection<BehaviorRenderer, BehaviorRenderer.Type>
getBehaviorRenderers() {
+ return behaviorRenderers;
+ }
+
/* (non-Javadoc)
* @see
org.richfaces.cdk.model.ModelElement#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)
*/
@@ -133,11 +149,22 @@
public Renderer getOrCreateRenderer(String rendererType) {
Renderer.Type type = new Renderer.Type(rendererType);
- return renderers.findOrCreate(type);
+ return renderers.find(type);
}
public Renderer findOrCreateRenderer(String rendererType) {
Renderer.Type type = new Renderer.Type(rendererType);
return renderers.findOrCreate(type);
}
+
+ public BehaviorRenderer getOrCreateBehaviorRenderer(String rendererType) {
+ BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
+ return behaviorRenderers.find(type);
+ }
+
+ public BehaviorRenderer findOrCreateBehaviorRenderer(String rendererType) {
+ BehaviorRenderer.Type type = new BehaviorRenderer.Type(rendererType);
+ return behaviorRenderers.findOrCreate(type);
+ }
+
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Renderer.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -24,6 +24,7 @@
package org.richfaces.cdk.model;
import org.richfaces.builder.model.JavaClass;
+import org.richfaces.cdk.CdkException;
/**
* <p class="changed_added_4_0"></p>
@@ -41,10 +42,14 @@
private ClassDescription rendererClass;
- @Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
- return visitor.visit(this, param);
+
+ public Renderer() {
}
+
+ public Renderer(Type type) {
+ this.type=type;
+ }
+
/* (non-Javadoc)
* @see org.richfaces.cdk.model.ModelElement#getType()
*/
@@ -60,6 +65,9 @@
this.type = type;
}
+ public Type getType() {
+ return type;
+ }
/**
* <p class="changed_added_4_0"></p>
* @return the template
@@ -108,6 +116,11 @@
}
@Override
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
+ return visitor.visit(this, param);
+ }
+
+ @Override
public void merge(Renderer other) {
ComponentLibrary.merge(this, other);
}
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,16 @@
+package org.richfaces.cdk.model;
+
+/**
+ * <p class="changed_added_4_0">Interface for model components that have
related modification time.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface Trackable {
+
+ /**
+ * <p class="changed_added_4_0">Last modification time for model
information.</p>
+ * @return
+ */
+ public long lastModified();
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Trackable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Validator.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -34,7 +36,7 @@
private final Key type;
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
return visitor.visit(this, param);
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/Visitable.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -1,5 +1,7 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
public interface Visitable {
/**
@@ -10,6 +12,6 @@
* @param param
* @return
*/
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param);
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException;
}
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigGenerator.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -34,9 +34,11 @@
import org.richfaces.cdk.xmlconfig.model.FacesConfigAdapter;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class FacesConfigGenerator implements CdkWriter {
@@ -44,9 +46,12 @@
private CdkContext context;
private JAXBBinding jaxbBinding;
private FacesConfigAdapter libraryAdapter;
- public static final String FACES_SCHEMA_LOCATION =
ComponentLibrary.FACES_CONFIG_NAMESPACE+"
"+ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
+ public static final String FACES_SCHEMA_LOCATION =
ComponentLibrary.FACES_CONFIG_NAMESPACE
+ + " " + ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
*/
@Override
@@ -56,34 +61,33 @@
libraryAdapter = new FacesConfigAdapter();
}
- /* (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary
+ * )
*/
@Override
public void render(ComponentLibrary library) throws CdkException {
- File outputFolder = context.getOutputFolder(StandardOutputs.FACES_CONFIG);
- File facesConfigXml = new File(outputFolder,FACES_CONFIG_XML);
- try {
- if(facesConfigXml.exists()){
- // TODO - check last modification time and bypass generation for non-modified source.
- facesConfigXml.delete();
- } else if(!facesConfigXml.getParentFile().exists()){
- facesConfigXml.getParentFile().mkdirs();
- }
- facesConfigXml.createNewFile();
- try {
- // TODO - transform output to strip prefixes from faces-config namespace.
- jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION,
libraryAdapter.marshal(library));
- } catch (Exception e) {
- if (e instanceof CdkException) {
- throw (CdkException) e;
- } else {
- throw new CdkException(e);
+ // TODO - check modification time.
+ File facesConfigXml = context.createOutputFile(
+ StandardOutputs.FACES_CONFIG, FACES_CONFIG_XML, library.lastModified());
+ if (null != facesConfigXml) {
+ try {
+ // TODO - transform output to strip prefixes from faces-config
+ // namespace.
+ jaxbBinding.marshal(facesConfigXml, FACES_SCHEMA_LOCATION,
+ libraryAdapter.marshal(library));
+ } catch (Exception e) {
+ if (e instanceof CdkException) {
+ throw (CdkException) e;
+ } else {
+ throw new CdkException(e);
+ }
}
+
}
- } catch(IOException e){
- throw new CdkException("error create faces-config.xml", e);
- }
}
}
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/AttributeAdapter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -26,7 +26,6 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.richfaces.cdk.model.Attribute;
-import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,48 @@
+/*
+ * $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 javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.richfaces.cdk.model.BehaviorRenderer;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class BehaviorRendererAdapter extends XmlAdapter<BehaviorRendererBean,
BehaviorRenderer> {
+
+ @Override
+ public BehaviorRendererBean marshal(BehaviorRenderer v) throws Exception {
+ return JAXBBinding.createAdapter(BehaviorRendererBean.class, v);
+ }
+
+ @Override
+ public BehaviorRenderer unmarshal(BehaviorRendererBean v) throws Exception {
+ return JAXBBinding.createModelElement(BehaviorRenderer.class, v, new
BehaviorRenderer.Type(v.getType()));
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,100 @@
+/*
+ * $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 javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@XmlType(name="faces-config-client-behavior-rendererType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class BehaviorRendererBean {
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ public static class BehaviorRendererExtension extends ConfigExtension {
+
+ }
+
+ private String type;
+
+
+ private ClassDescription rendererClass;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the type
+ */
+ @XmlElement(name="client-behavior-renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ 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;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererClass
+ */
+ @XmlElement(name="client-behavior-renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
+ public ClassDescription getRendererClass() {
+ return rendererClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererClass the rendererClass to set
+ */
+ public void setRendererClass(ClassDescription rendererClass) {
+ this.rendererClass = rendererClass;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+// @XmlElement(name="client-behavior-renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+// public BehaviorRendererExtension getExtension() {
+// return super.getExtension();
+// }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorRendererBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentAdapter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -25,9 +25,7 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Component;
-import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
/**
@@ -40,14 +38,14 @@
@Override
public ComponentBean marshal(Component v) throws Exception {
ComponentBean bean = JAXBBinding.createAdapter(ComponentBean.class, v);
+ // TODO - copy renderer types.
return bean;
}
@Override
public Component unmarshal(ComponentBean v) throws Exception {
- Component component = new Component(new Component.Type(v.getType()));
- JAXBBinding.copyProperties(v, component);
- JAXBBinding.copyExtensions(v, component, false);
+ Component component = JAXBBinding.createModelElement(Component.class, v, new
Component.Type(v.getType()));
+ // TODO - copy renderer types.
return component;
}
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -24,29 +24,27 @@
package org.richfaces.cdk.xmlconfig.model;
import java.util.List;
-import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.Extensible;
import org.richfaces.cdk.model.Facet;
import org.richfaces.cdk.model.Property;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class ComponentBean implements
Extensible<ComponentBean.ComponentExtension>,DescriptionGroup {
+@XmlType(name="faces-config-componentType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class ComponentBean extends ExtensibleBean<ComponentBean.ComponentExtension>
{
private String type;
@@ -55,14 +53,6 @@
private List<Property> attributes = Lists.newArrayList();
- private ComponentExtension extension;
-
- private String icon;
-
- private String description;
-
- private String displayname;
-
private List<Facet> facets = Lists.newArrayList();
/**
@@ -142,69 +132,14 @@
@XmlElement(name="component-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
@Override
public ComponentExtension getExtension() {
- return extension;
+ return super.getExtension();
}
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
+
@Override
public void setExtension(ComponentExtension extension) {
- this.extension = extension;
+ super.setExtension(extension);
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the icon
- */
- @XmlElement(name="icon",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getIcon() {
- return icon;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param icon the icon to set
- */
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the description
- */
- @XmlElement(name="description",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getDescription() {
- return description;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param description the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the displayname
- */
- @XmlElement(name="display-name",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- public String getDisplayname() {
- return displayname;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param displayname the displayname to set
- */
- public void setDisplayname(String displayname) {
- this.displayname = displayname;
- }
-
public static class ComponentExtension extends ConfigExtension {
private String family;
@@ -212,6 +147,8 @@
private ClassDescription baseClass;
private boolean generate;
+
+ private List<String> rendererTypes = Lists.newArrayList();
/**
* <p class="changed_added_4_0"></p>
@@ -264,5 +201,22 @@
public void setGenerate(boolean generate) {
this.generate = generate;
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param rendererTypes the rendererTypes to set
+ */
+ @XmlElement(name="renderer-type",namespace=ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public void setRendererTypes(List<String> rendererTypes) {
+ this.rendererTypes = rendererTypes;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the rendererTypes
+ */
+ public List<String> getRendererTypes() {
+ return rendererTypes;
+ }
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/DescriptionGroupBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -4,8 +4,6 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.Extensible;
-import org.richfaces.cdk.xmlconfig.model.FacetBean.FacetExtension;
public class DescriptionGroupBean implements DescriptionGroup {
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,55 @@
+/*
+ * $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.ConfigExtension;
+import org.richfaces.cdk.model.Extensible;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ExtensibleBean<E extends ConfigExtension> extends DescriptionGroupBean
implements
+ Extensible<E> {
+
+ private E extension;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ public E getExtension() {
+ return extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(E extension) {
+ this.extension = extension;
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ExtensibleBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -25,12 +25,15 @@
import java.util.List;
+import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+import org.richfaces.cdk.model.Extensible;
import org.richfaces.cdk.model.RenderKit;
import com.google.common.collect.Lists;
@@ -41,8 +44,11 @@
*
*/
@XmlRootElement(name="faces-config",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
-public class FacesConfigBean {
+public class FacesConfigBean implements
Extensible<FacesConfigBean.FacesConfigExtension> {
+ public static final class FacesConfigExtension extends ConfigExtension {
+
+ }
@XmlElement(name="component",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
@XmlJavaTypeAdapter(ComponentAdapter.class)
private List<Component> components = Lists.newArrayList();
@@ -51,8 +57,28 @@
@XmlJavaTypeAdapter(RenderKitAdapter.class)
private List<RenderKit> renderKits = Lists.newArrayList();
+ private FacesConfigExtension extension;
+
+ private String version="2.0";
/**
* <p class="changed_added_4_0"></p>
+ * @return the version
+ */
+ @XmlAttribute
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param version the version to set
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
* @return the components
*/
public List<Component> getComponents() {
@@ -82,4 +108,21 @@
public void setRenderKits(List<RenderKit> renderKits) {
this.renderKits = renderKits;
}
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the extension
+ */
+ @XmlElement(name="faces-config-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public FacesConfigExtension getExtension() {
+ return extension;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param extension the extension to set
+ */
+ public void setExtension(FacesConfigExtension extension) {
+ this.extension = extension;
+ }
}
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacetBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -27,16 +27,13 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.DescriptionGroup;
-import org.richfaces.cdk.model.Extensible;
-import org.richfaces.cdk.xmlconfig.model.ComponentBean.ComponentExtension;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class FacetBean extends DescriptionGroupBean implements
Extensible<FacetBean.FacetExtension>,DescriptionGroup{
+public class FacetBean extends ExtensibleBean<FacetBean.FacetExtension>{
/**
* <p class="changed_added_4_0"></p>
@@ -68,8 +65,6 @@
private String name;
- private FacetExtension extension;
-
/**
* <p class="changed_added_4_0"></p>
* @return the name
@@ -93,15 +88,12 @@
*/
@XmlElement(name="facet-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public FacetExtension getExtension() {
- return extension;
+ return super.getExtension();
}
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
+
+ @Override
public void setExtension(FacetExtension extension) {
- this.extension = extension;
+ super.setExtension(extension);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/Properties.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -28,9 +28,7 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import org.richfaces.cdk.model.Attribute;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.Property;
Modified:
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyAdapter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -25,7 +25,6 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -33,9 +33,7 @@
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.DescriptionGroup;
import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.Extensible;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -45,7 +43,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class PropertyBean extends DescriptionGroupBean implements
Extensible<PropertyBean.PropertyExtension> {
+public class PropertyBean extends ExtensibleBean<PropertyBean.PropertyExtension> {
/**
* <p class="changed_added_4_0"></p>
@@ -236,8 +234,6 @@
private String suggestedValue;
- private PropertyExtension extension;
-
/**
* <p class="changed_added_4_0"></p>
* @return the name
@@ -310,16 +306,11 @@
@Override
@XmlElement(name="property-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public PropertyExtension getExtension() {
- return extension;
+ return super.getExtension();
}
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
@Override
public void setExtension(PropertyExtension extension) {
- this.extension = extension;
+ super.setExtension(extension);
}
-
}
\ No newline at end of file
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitAdapter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -25,8 +25,6 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.RenderKit;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RenderKitBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -30,10 +30,10 @@
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.richfaces.cdk.model.BehaviorRenderer;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.Extensible;
import org.richfaces.cdk.model.Renderer;
import com.google.common.collect.Lists;
@@ -43,7 +43,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class RenderKitBean extends DescriptionGroupBean implements
Extensible<RenderKitBean.RenderKitExtension>{
+public class RenderKitBean extends
ExtensibleBean<RenderKitBean.RenderKitExtension>{
/**
* <p class="changed_added_4_0"></p>
@@ -54,8 +54,6 @@
}
- @XmlElement(name="render-kit-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- private RenderKitExtension extension;
@XmlElement(name="render-kit-id",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
private String id = RenderKitFactory.HTML_BASIC_RENDER_KIT;
@@ -68,6 +66,10 @@
@XmlJavaTypeAdapter(RendererAdapter.class)
private List<Renderer> renderers = Lists.newArrayList();
+ @XmlElement(name="client-behavior-renderer",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(BehaviorRendererAdapter.class)
+ private List<BehaviorRenderer> behaviorRenderers = Lists.newArrayList();
+
/**
* <p class="changed_added_4_0"></p>
* @return the renderkitClass
@@ -120,8 +122,9 @@
* <p class="changed_added_4_0"></p>
* @return the extension
*/
+ @XmlElement(name="render-kit-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public RenderKitExtension getExtension() {
- return extension;
+ return super.getExtension();
}
/**
@@ -129,6 +132,6 @@
* @param extension the extension to set
*/
public void setExtension(RenderKitExtension extension) {
- this.extension = extension;
+ super.setExtension(extension);
}
}
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererAdapter.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -25,8 +25,6 @@
import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.richfaces.cdk.model.ClassDescription;
-import org.richfaces.cdk.model.Property;
import org.richfaces.cdk.model.Renderer;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/RendererBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -24,19 +24,20 @@
package org.richfaces.cdk.xmlconfig.model;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
-import org.richfaces.cdk.model.Extensible;
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
-public class RendererBean extends DescriptionGroupBean implements
Extensible<RendererBean.RendererExtension>{
+@XmlType(name="faces-config-rendererType",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+public class RendererBean extends ExtensibleBean<RendererBean.RendererExtension>{
/**
* <p class="changed_added_4_0"></p>
@@ -47,23 +48,17 @@
}
- @XmlElement(name="renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
private String type;
- @XmlElement(name="component-family",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
private String family;
- @XmlElement(name="renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
private ClassDescription rendererClass;
- @XmlElement(name="renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
- private RendererExtension extension;
-
/**
* <p class="changed_added_4_0"></p>
* @return the type
*/
+ @XmlElement(name="renderer-type",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public String getType() {
return type;
}
@@ -80,6 +75,7 @@
* <p class="changed_added_4_0"></p>
* @return the family
*/
+ @XmlElement(name="component-family",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public String getFamily() {
return family;
}
@@ -96,6 +92,8 @@
* <p class="changed_added_4_0"></p>
* @return the rendererClass
*/
+ @XmlElement(name="renderer-class",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(ClassAdapter.class)
public ClassDescription getRendererClass() {
return rendererClass;
}
@@ -112,15 +110,13 @@
* <p class="changed_added_4_0"></p>
* @return the extension
*/
+ @XmlElement(name="renderer-extension",namespace=ComponentLibrary.FACES_CONFIG_NAMESPACE)
public RendererExtension getExtension() {
- return extension;
+ return super.getExtension();
}
- /**
- * <p class="changed_added_4_0"></p>
- * @param extension the extension to set
- */
+ @Override
public void setExtension(RendererExtension extension) {
- this.extension = extension;
+ super.setExtension(extension);
}
}
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/package-info.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -11,16 +11,18 @@
namespaceURI = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE ) })
@XmlJavaTypeAdapters({(a)XmlJavaTypeAdapter(type=Property.class,value=PropertyAdapter.class),
@XmlJavaTypeAdapter(type=Attribute.class,value=AttributeAdapter.class),
+ @XmlJavaTypeAdapter(type=ClassDescription.class,value=ClassAdapter.class),
@XmlJavaTypeAdapter(type=ComponentLibrary.class,value=FacesConfigAdapter.class)
})
package org.richfaces.cdk.xmlconfig.model;
+import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
+import org.richfaces.cdk.model.Attribute;
+import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.model.Attribute;
import org.richfaces.cdk.model.Property;
Modified:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2009-08-28
00:25:48 UTC (rev 15382)
@@ -1,3 +1,8 @@
+<#macro concat seq delimiter=",">
+<#list seq as item>
+ <#nested item/><#if item_has_next>${delimiter}</#if>
+</#list>
+</#macro>
/*
* $Id$
*
@@ -26,7 +31,7 @@
import javax.annotation.Generated;
/**
- * ${description}
+ * ${description!}
**/
@Generated({"RicFaces CDK","4.0.0-SNAPSHOT"})
public class ${componentClass.simpleName} extends ${baseClass} {
@@ -34,39 +39,34 @@
public static final String COMPONENT_TYPE="${type}";
+ <#if family?exists>
public static final String COMPONENT_FAMILY="${family}";
-
+ </#if>
protected enum Properties {
- [#list component.attributes as attribute]
- [#if attribute.exists == false ]
- ${attribute.hame},
- [/#if]
- [/#list]
+ <@concat seq=generatedAttributes ; attribute>${attribute.name}</@concat>
;
String toString;
- PropertyKeys(String toString) { this.toString = toString; }
- PropertyKeys() { }
+ Properties(String toString) { this.toString = toString; }
+ Properties() { }
public String toString() {
return ((toString != null) ? toString : super.toString());
}
}
- [#list component.attributes as attribute]
- [#if attribute.exists == false ]
+ <#list generatedAttributes as attribute>
/**
- * ${attribute.description}
+ * ${attribute.description!}
**/
- public ${attribute.type} get${attribute.name}(){
+ public ${attribute.type} ${attribute.getterName}(){
return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
}
/**
* Setter for ${attribute.name}
**/
- public void set${attribute.name}(${attribute.type} ${attribute.name}){
+ public void ${attribute.setterName}(${attribute.type} ${attribute.name}){
getStateHelper().put(Properties.${attribute.name},${attribute.name});
}
- [/#if]
- [/#list]
+ </#list>
}
\ No newline at end of file
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -45,7 +45,7 @@
}
@Override
- protected Writer getOutput(Component c) throws IOException {
+ protected Writer getOutput(Component c) throws CdkException {
return output;
}
@Override
@@ -58,6 +58,11 @@
protected boolean isMyComponent(Visitable c) {
return true;
}
+
+ @Override
+ protected OutputType getOutputType() {
+ return null;
+ }
};
CdkContext cdkContext = createMockContext();
renderer.init(cdkContext);
Added:
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
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -0,0 +1,104 @@
+/*
+ * $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.generate.java;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.faces.component.UIOutput;
+
+import org.junit.Test;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.CdkWriter.OutputType;
+import org.richfaces.cdk.freemarker.FreeMarkerRendererTest;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.Component;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Property;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ComponentClassGeneratorTest extends CdkTestBase {
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#isMyComponent(org.richfaces.cdk.model.Visitable)}.
+ */
+ @Test
+ public void testIsMyComponent() {
+ fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.Component)}.
+ * @throws Exception
+ */
+ @Test
+ public void testGetOutputFileComponent() throws Exception {
+ final StringWriter output = new StringWriter();
+ ComponentClassGenerator generator = new ComponentClassGenerator(){
+ @Override
+ protected Writer getOutput(Component c) throws CdkException {
+ return output;
+ }
+ };
+ CdkContext mockContext = createMockContext();
+ generator.init(mockContext);
+ ComponentLibrary library = new ComponentLibrary();
+ Component component = library.findOrCreateComponent("foo.bar");
+ component.setGenerate(true);
+ component.setBaseClass(new ClassDescription(UIOutput.class));
+ component.setComponentClass(new ClassDescription("foo.bar.UIBar"));
+ Property attribute = component.findOrCreateAttribute("testValue");
+ attribute.setType(new ClassDescription(Object.class));
+ attribute.setGenerate(true);
+ attribute = component.findOrCreateAttribute("testFlag");
+ attribute.setType(new ClassDescription(boolean.class));
+ attribute.setGenerate(true);
+ attribute = component.findOrCreateAttribute("id");
+ attribute.setType(new ClassDescription(String.class));
+ attribute.setGenerate(false);
+ generator.visit(component, library);
+ System.out.println(output);
+ verify(mockContext);
+ }
+
+ private CdkContext createMockContext() {
+ CdkContext cdkContext = createMock(CdkContext.class);
+ expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
+ expect(cdkContext.getOutputFolder((OutputType) anyObject())).andStubReturn(null);
+ expect(cdkContext.getLoader()).andStubReturn(
+ FreeMarkerRendererTest.class.getClassLoader());
+ replay(cdkContext);
+ return cdkContext;
+ }
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ComponentLibraryTest.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -31,6 +31,7 @@
import javax.faces.render.RenderKitFactory;
import org.junit.Test;
+import org.richfaces.cdk.CdkException;
/**
* <p class="changed_added_4_0"></p>
@@ -57,9 +58,10 @@
/**
* Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#accept(org.richfaces.cdk.model.LibraryVisitor,
java.lang.Object)}.
+ * @throws Exception
*/
@Test
- public void testAcceptLibraryVisitorOfRPP() {
+ public void testAcceptLibraryVisitorOfRPP() throws Exception {
ComponentLibrary lib = new ComponentLibrary();
final Component component = lib.findOrCreateComponent("foo.Bar");
LibraryVisitor<Boolean, Boolean> visitor = new LibraryVisitor<Boolean,
Boolean>() {
@@ -122,9 +124,10 @@
/**
* Test method for {@link
org.richfaces.cdk.model.ComponentLibrary#accept(java.lang.Iterable,
org.richfaces.cdk.model.LibraryVisitor, java.lang.Object, java.lang.Object)}.
+ * @throws Exception
*/
@Test
- public void testAcceptIterableOfTLibraryVisitorOfRPPR() {
+ public void testAcceptIterableOfTLibraryVisitorOfRPPR() throws Exception {
List<ModelBean> beans = new ArrayList<ModelBean>();
ModelBean foo = new ModelBean("foo");
foo.setResult("foo");
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/model/ModelBean.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -23,6 +23,8 @@
package org.richfaces.cdk.model;
+import org.richfaces.cdk.CdkException;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
@@ -152,7 +154,7 @@
}
@Override
- public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) {
+ public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws
CdkException {
vizited = true;
return (R) visitor.visit(this, param);
}
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FacesConfigTest.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -28,7 +28,7 @@
import java.util.Collection;
import org.junit.Test;
-import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkTestBase;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -49,7 +49,7 @@
@Test
public void testComponentUnmarshal() throws Exception {
- JAXBBinding jaxbBinding = JAXBBinding.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ JAXBBinding jaxbBinding = JAXBBinding.getInstance(new
CdkContextBase(this.getClass().getClassLoader()));
FacesConfigBean library =
jaxbBinding.unmarshal("urn:resource:org/richfaces/cdk/xmlconfig/component.xml",
ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
assertEquals(1,library.getComponents().size());
Component component = library.getComponents().get(0);
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -30,7 +30,7 @@
import java.util.Set;
import org.junit.Test;
-import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.Property;
@@ -46,21 +46,21 @@
@Test
public void parserTest() throws Exception {
- FragmentParser parser = FragmentParser.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ FragmentParser parser = FragmentParser.getInstance(new
CdkContextBase(this.getClass().getClassLoader()));
Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/fragment.xml");
assertEquals(3,properties.size());
}
@Test
public void xincludeTest() throws Exception {
- FragmentParser parser = FragmentParser.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ FragmentParser parser = FragmentParser.getInstance(new
CdkContextBase(this.getClass().getClassLoader()));
Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/parent.xml");
assertEquals(1,properties.size());
}
@Test
public void propertyTest() throws Exception {
- FragmentParser parser = FragmentParser.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ FragmentParser parser = FragmentParser.getInstance(new
CdkContextBase(this.getClass().getClassLoader()));
Collection<Property> properties =
parser.parseProperties("urn:resource:org/richfaces/cdk/xmlconfig/include.xml");
assertEquals(1,properties.size());
Property property = Iterables.getOnlyElement(properties);
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 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/JaxbMarshalTest.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -7,7 +7,7 @@
import javax.xml.transform.stream.StreamResult;
import org.junit.Test;
-import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.model.Component;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -18,7 +18,7 @@
@Test
public void testMarshalResultStringT() throws Exception {
- JAXBBinding jaxbBinding = JAXBBinding.getInstance(new
AbstractCdkContext(this.getClass().getClassLoader()));
+ JAXBBinding jaxbBinding = JAXBBinding.getInstance(new
CdkContextBase(this.getClass().getClassLoader()));
ComponentLibrary library = new ComponentLibrary();
Component component = library.findOrCreateComponent("foo.bar");
RenderKit renderKit = library.findOrCreateRenderKit("HTML");
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -21,13 +21,13 @@
package org.richfaces.builder.maven;
-import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkContextBase;
/**
* @author shura
*
*/
-public class MavenCompilationContext extends AbstractCdkContext {
+public class MavenCompilationContext extends CdkContextBase {
private MavenLogger logger;
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-28
00:23:22 UTC (rev 15381)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-28
00:25:48 UTC (rev 15382)
@@ -30,7 +30,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.LibraryBuilder;
import org.richfaces.cdk.ModelValidator;
@@ -60,7 +60,7 @@
public void execute() throws MojoExecutionException, MojoFailureException {
// TODO set logging.
checkLibraryConfig();
- AbstractCdkContext context = new AbstractCdkContext(this
+ CdkContextBase context = new CdkContextBase(this
.createProjectClassLoader(project));
ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
for (String sourceFolder : compileSourceRoots) {