JBoss Rich Faces SVN: r16363 - tags.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-01-26 13:05:48 -0500 (Tue, 26 Jan 2010)
New Revision: 16363
Removed:
tags/3.3.1.SP1/
Log:
delete tag for 3.3.1.SP1
15 years
JBoss Rich Faces SVN: r16362 - branches/enterprise/3.3.X/ui/message/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-01-26 13:01:15 -0500 (Tue, 26 Jan 2010)
New Revision: 16362
Modified:
branches/enterprise/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
Log:
RFPL-240
porting RF-7351 to enterprise branch
Modified: branches/enterprise/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java
===================================================================
--- branches/enterprise/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2010-01-26 17:00:20 UTC (rev 16361)
+++ branches/enterprise/3.3.X/ui/message/src/main/java/org/richfaces/component/UIRichMessages.java 2010-01-26 18:01:15 UTC (rev 16362)
@@ -169,6 +169,9 @@
*/
protected void addMessagesForId(FacesContext context, String forId,
List<String> severenities) {
+ if (isGlobalOnly() && forId != null) {
+ return;
+ }
Iterator<FacesMessage> messages = context.getMessages(forId);
while (messages.hasNext()) {
FacesMessage message = messages.next();
15 years
JBoss Rich Faces SVN: r16361 - in root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk: parser/el/types and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-26 12:00:20 -0500 (Tue, 26 Jan 2010)
New Revision: 16361
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
Log:
https://jira.jboss.org/jira/browse/RF-8288
Move log to injections
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-26 03:26:02 UTC (rev 16360)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-26 17:00:20 UTC (rev 16361)
@@ -25,6 +25,14 @@
package org.richfaces.cdk.apt;
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.StandardSources;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,6 +42,7 @@
import java.util.Locale;
import javax.annotation.processing.Processor;
+import javax.inject.Inject;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaCompiler;
@@ -44,15 +53,6 @@
import javax.tools.Diagnostic.Kind;
import javax.tools.JavaCompiler.CompilationTask;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
-
import com.google.common.collect.Lists;
/**
@@ -64,7 +64,8 @@
*
*/
public class AptBuilder implements ModelBuilder {
- private static final Logger LOG = LoggerFactory.getLogger();
+ @Inject
+ private static Logger LOG ;
private boolean initialized = false;
private CdkContext context;
private StandardJavaFileManager fileManager;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-01-26 03:26:02 UTC (rev 16360)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/VirtualFileManager.java 2010-01-26 17:00:20 UTC (rev 16361)
@@ -23,18 +23,8 @@
package org.richfaces.cdk.apt;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Lists;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-import javax.tools.FileObject;
-import javax.tools.ForwardingJavaFileManager;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.StandardLocation;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
@@ -44,6 +34,18 @@
import java.util.List;
import java.util.Set;
+import javax.inject.Inject;
+import javax.tools.FileObject;
+import javax.tools.ForwardingJavaFileManager;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+import javax.tools.JavaFileObject.Kind;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Lists;
+
/**
* <p class="changed_added_4_0">
* That class wraps {@link javax.tools.StandardJavaFileManager}
@@ -52,7 +54,8 @@
* @author asmirnov(a)exadel.com
*/
final class VirtualFileManager extends ForwardingJavaFileManager<JavaFileManager> {
- private static final Logger LOG = LoggerFactory.getLogger();
+ @Inject
+ private static Logger LOG;
// private final BiMap<FileObjectKey, FileObject> classPathFiles;
// private final BiMap<FileObject, FileObjectKey> inversedClassPathFiles;
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-26 03:26:02 UTC (rev 16360)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/parser/el/types/TypesFactory.java 2010-01-26 17:00:20 UTC (rev 16361)
@@ -21,6 +21,10 @@
*/
package org.richfaces.cdk.parser.el.types;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.parser.el.Type;
+import org.richfaces.cdk.util.ArrayUtils;
+
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.text.MessageFormat;
@@ -35,19 +39,16 @@
import javax.faces.component.behavior.Behavior;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import javax.inject.Inject;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.parser.el.Type;
-import org.richfaces.cdk.util.ArrayUtils;
-
/**
* @author Nick Belaevski
*
*/
public final class TypesFactory {
- private static final Logger LOG = LoggerFactory.getLogger();
+ @Inject
+ private static Logger LOG;
private static final Map<java.lang.reflect.Type, Type> REFLECTION_TYPES_CACHE = Collections
.synchronizedMap(new HashMap<java.lang.reflect.Type, Type>());
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-26 03:26:02 UTC (rev 16360)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-01-26 17:00:20 UTC (rev 16361)
@@ -23,22 +23,6 @@
package org.richfaces.cdk.templatecompiler;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.annotation.Generated;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-import javax.xml.namespace.QName;
-
import org.richfaces.builder.model.Argument;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.model.JavaField;
@@ -48,7 +32,6 @@
import org.richfaces.builder.model.MethodBodyStatementsContainer;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.attributes.Attribute;
import org.richfaces.cdk.attributes.Element;
import org.richfaces.cdk.attributes.Schema;
@@ -74,6 +57,23 @@
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.JAXBBinding;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.annotation.Generated;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+import javax.inject.Inject;
+import javax.xml.namespace.QName;
+
import com.google.common.collect.Lists;
/**
@@ -114,7 +114,8 @@
*/
private static final String PASS_THROUGH_ATTRIBUTES_FIELD_NAME = "PASS_THROUGH_ATTRIBUTES";
- private static final Logger LOG = LoggerFactory.getLogger();
+ @Inject
+ private static Logger LOG;
private static final Set<String> DEFAULT_NAMESPACES = new HashSet<String>();
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-01-26 03:26:02 UTC (rev 16360)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/wutka/WutkaDefinitionFactory.java 2010-01-26 17:00:20 UTC (rev 16361)
@@ -21,12 +21,7 @@
package org.richfaces.cdk.xmlutils.dtd.wutka;
-import com.wutka.dtd.DTD;
-import com.wutka.dtd.DTDAttribute;
-import com.wutka.dtd.DTDElement;
-import com.wutka.dtd.DTDParser;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.xmlutils.dtd.Attribute;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinitionFactory;
@@ -37,11 +32,20 @@
import java.util.HashMap;
import java.util.Map;
+import javax.inject.Inject;
+
+import com.wutka.dtd.DTD;
+import com.wutka.dtd.DTDAttribute;
+import com.wutka.dtd.DTDElement;
+import com.wutka.dtd.DTDParser;
+
/**
* @author Maksim Kaszynski
*/
public class WutkaDefinitionFactory extends DocumentDefinitionFactory {
- private final Logger log = LoggerFactory.getLogger();
+
+ @Inject
+ private Logger log;
private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
@Override
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-01-26 03:26:02 UTC (rev 16360)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlutils/dtd/xerces/XercesDefinitionFactory.java 2010-01-26 17:00:20 UTC (rev 16361)
@@ -32,7 +32,6 @@
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xs.XSModel;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinition;
import org.richfaces.cdk.xmlutils.dtd.DocumentDefinitionFactory;
@@ -41,6 +40,8 @@
import java.util.HashMap;
import java.util.Map;
+import javax.inject.Inject;
+
/**
* <p class="changed_added_4_0">
* That class implements {@link DocumentDefinitionFactory} that parses XML
@@ -102,7 +103,9 @@
// feature: continue-after-fatal-error
public static final String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX
+ Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
- private final Logger log = LoggerFactory.getLogger();
+
+ @Inject
+ private Logger log;
private Map<URL, DocumentDefinition> definitions = new HashMap<URL, DocumentDefinition>();
@Override
15 years
JBoss Rich Faces SVN: r16360 - in root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk: xmlconfig and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-25 22:26:02 -0500 (Mon, 25 Jan 2010)
New Revision: 16360
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
Log:
https://jira.jboss.org/jira/browse/RF-8288
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-01-26 03:16:25 UTC (rev 16359)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-01-26 03:26:02 UTC (rev 16360)
@@ -22,7 +22,7 @@
package org.richfaces.cdk;
/**
- * That interface hides current logging system from generator classe.
+ * That interface hides current logging system from generator classes.
* Concrete tools ( Maven, Ant, JUnit ) should provide appropriate logger instance that delegates
* messages to the current log system.
*
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java 2010-01-26 03:26:02 UTC (rev 16360)
@@ -0,0 +1,19 @@
+package org.richfaces.cdk.xmlconfig;
+
+import org.richfaces.cdk.CdkException;
+
+import java.io.File;
+
+import javax.xml.transform.Result;
+
+public interface JAXB {
+
+ public abstract <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException;
+
+ public abstract <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException;
+
+ public abstract <T> void marshal(File output, String schemaLocation, T model) throws CdkException;
+
+ public abstract <T> void marshal(Result output, String schemaLocation, T model) throws CdkException;
+
+}
\ No newline at end of file
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-26 03:16:25 UTC (rev 16359)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-01-26 03:26:02 UTC (rev 16360)
@@ -70,7 +70,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class JAXBBinding implements CdkWorker {
+public class JAXBBinding implements CdkWorker, JAXB {
private static final FacesConfigNamespacePreffixMapper PREFFIX_MAPPER = new FacesConfigNamespacePreffixMapper();
private static final ImmutableSet<String> IGNORE_PROPERTIES = ImmutableSet.of("class", "extension");
@@ -90,6 +90,9 @@
this.resolver = new CdkEntityResolver(context);
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.io.File, java.lang.String, java.lang.Class)
+ */
public <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException {
try {
InputSource input = new InputSource(new FileInputStream(file));
@@ -104,6 +107,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.lang.String, java.lang.String, java.lang.Class)
+ */
public <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException {
try {
InputSource inputSource = resolver.resolveSystemId(url);
@@ -122,7 +128,7 @@
@SuppressWarnings("unchecked")
//TODO nick - schemaLocation is unused
- public <T> T unmarshal(String schemaLocation, Class<T> bindClass, InputSource inputSource) throws CdkException {
+ <T> T unmarshal(String schemaLocation, Class<T> bindClass, InputSource inputSource) throws CdkException {
T unmarshal = null;
try {
@@ -176,6 +182,9 @@
return unmarshal;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#marshal(java.io.File, java.lang.String, T)
+ */
public <T> void marshal(File output, String schemaLocation, T model) throws CdkException {
try {
FileOutputStream outputStream = new FileOutputStream(output);
@@ -191,6 +200,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.xmlconfig.JAXB#marshal(javax.xml.transform.Result, java.lang.String, T)
+ */
public <T> void marshal(Result output, String schemaLocation, T model) throws CdkException {
try {
JAXBContext jc = JAXBContext.newInstance(model.getClass());
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java 2010-01-26 03:26:02 UTC (rev 16360)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.xmlconfig;
+
+import org.xml.sax.EntityResolver;
+
+import com.google.inject.AbstractModule;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+public class XmlModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ bind(EntityResolver.class).to(CdkEntityResolver.class);
+ bind(JAXB.class).to(JAXBBinding.class);
+ }
+
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
15 years
JBoss Rich Faces SVN: r16359 - in root/cdk/branches/guice/plugins/generator: src/main/java/org/richfaces/cdk and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-25 22:16:25 -0500 (Mon, 25 Jan 2010)
New Revision: 16359
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
Removed:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
Modified:
root/cdk/branches/guice/plugins/generator/pom.xml
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
Log:
https://jira.jboss.org/jira/browse/RF-8288
Modified: root/cdk/branches/guice/plugins/generator/pom.xml
===================================================================
--- root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-26 03:16:25 UTC (rev 16359)
@@ -197,11 +197,34 @@
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.2</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-multibindings</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-assisted-inject</artifactId>
+ <version>2.0</version>
+ </dependency>
+
+ <!--
<dependency>
<groupId>com.sun.xsom</groupId>
<artifactId>xsom</artifactId>
@@ -217,5 +240,5 @@
</exclusion>
</exclusions>
</dependency>
- </dependencies>
+ --></dependencies>
</project>
\ No newline at end of file
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.richfaces.cdk.CdkContext.SourceType;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import java.io.File;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.Maps;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+public class Generator {
+
+ private CdkClassLoader loader;
+
+ private Logger log = new JavaLogger();
+
+ private Injector injector;
+
+ private Map<StandardOutputFolders, File> outputFolders;
+
+ private Map<StandardSources, Iterable<File>> sources;
+
+ public void setLoader(CdkClassLoader loader) {
+ this.loader = loader;
+ }
+
+ public void setLog(Logger log) {
+ this.log = log;
+ }
+
+ public void setOutputFolders(Map<StandardOutputFolders, File> outputFolders) {
+ this.outputFolders = outputFolders;
+ }
+
+ public void init(){
+ checkNotNull(loader, "classLoader");
+ injector = Guice.createInjector(new CdkConfigurationModule());
+ }
+
+ public void execute() {
+ checkNotNull(injector, "initialized");
+ injector.getInstance(LibraryBuilder.class).build();
+ }
+
+ public class CdkConfigurationModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(CdkClassLoader.class).toInstance(loader);
+ bind(Logger.class).toInstance(log);
+ for (Map.Entry<StandardOutputFolders, File> entry : outputFolders.entrySet()) {
+ bind(File.class).annotatedWith(new OutputFolderImpl(entry.getKey())).toInstance(entry.getValue());
+ }
+ for (Map.Entry<StandardSources, Iterable<File>> entry : sources.entrySet()) {
+ bind(new TypeLiteral<Iterable<File>>(){}).annotatedWith(new SourceImpl(entry.getKey())).toInstance(entry.getValue());
+ }
+ bind(ComponentLibrary.class).in(Singleton.class);
+ }
+
+ }
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -31,8 +31,13 @@
* @author asmirnov(a)exadel.com
*/
class JavaLogger implements Logger {
- java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
+
+ public static final String CDK_LOG = "org.richfaces.cdk";
+ private int errorCount = 0;
+
+ private java.util.logging.Logger jdkLogger = java.util.logging.Logger.getLogger(CDK_LOG);
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
@@ -66,6 +71,7 @@
*/
@Override
public void error(CharSequence content) {
+ errorCount++;
jdkLogger.severe(String.valueOf(content));
}
@@ -75,6 +81,7 @@
*/
@Override
public void error(CharSequence content, Throwable error) {
+ errorCount++;
jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
}
@@ -84,9 +91,15 @@
*/
@Override
public void error(Throwable error) {
+ errorCount++;
jdkLogger.log(Level.SEVERE, "", error);
}
+ @Override
+ public int getErrorCount() {
+ return errorCount;
+ }
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -29,35 +29,37 @@
* @author shura
*/
public interface Logger {
- boolean isDebugEnabled();
+ public boolean isDebugEnabled();
- void debug(CharSequence content);
+ public void debug(CharSequence content);
- void debug(CharSequence content, Throwable error);
+ public void debug(CharSequence content, Throwable error);
- void debug(Throwable error);
+ public void debug(Throwable error);
- boolean isInfoEnabled();
+ public boolean isInfoEnabled();
- void info(CharSequence content);
+ public void info(CharSequence content);
- void info(CharSequence content, Throwable error);
+ public void info(CharSequence content, Throwable error);
- void info(Throwable error);
+ public void info(Throwable error);
- boolean isWarnEnabled();
+ public boolean isWarnEnabled();
- void warn(CharSequence content);
+ public void warn(CharSequence content);
- void warn(CharSequence content, Throwable error);
+ public void warn(CharSequence content, Throwable error);
- void warn(Throwable error);
+ public void warn(Throwable error);
- boolean isErrorEnabled();
+ public boolean isErrorEnabled();
- void error(CharSequence content);
+ public void error(CharSequence content);
- void error(CharSequence content, Throwable error);
+ public void error(CharSequence content, Throwable error);
- void error(Throwable error);
+ public void error(Throwable error);
+
+ public int getErrorCount();
}
Deleted: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -1,143 +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;
-
-/**
- * <p class="changed_added_4_0"></p>
- *
- * @author asmirnov(a)exadel.com
- */
-public final class LoggerFactory {
- public static final String CDK_LOG = "org.richfaces.cdk";
-
- /**
- * <p class="changed_added_4_0">Current logger. By default all calls will be sent to system
- * {@link java.util.logging.Logger}</p>
- */
- private static Logger logger = new JavaLogger();
-
- /**
- * <p class="changed_added_4_0">
- * That constant wraps current logger object to allow access to logger at
- * the class instantiation time.
- * </p>
- */
- private static final Logger WRAPPER = new LoggerWrapper();
-
- private LoggerFactory() {
-
- // That class has static methods only.
- }
-
- public static Logger getLogger() {
- return WRAPPER;
- }
-
- public static void setLogger(Logger newLogger) {
- assert null != newLogger;
- logger = newLogger;
- }
-
- private static final class LoggerWrapper implements Logger {
- @Override
- public void debug(CharSequence content) {
- logger.debug(content);
- }
-
- @Override
- public void debug(CharSequence content, Throwable error) {
- logger.debug(content, error);
- }
-
- @Override
- public void debug(Throwable error) {
- logger.debug(error);
- }
-
- @Override
- public void error(CharSequence content) {
- logger.error(content);
- }
-
- @Override
- public void error(CharSequence content, Throwable error) {
- logger.error(content, error);
- }
-
- @Override
- public void error(Throwable error) {
- logger.error(error);
- }
-
- @Override
- public void info(CharSequence content) {
- logger.info(content);
- }
-
- @Override
- public void info(CharSequence content, Throwable error) {
- logger.info(content, error);
- }
-
- @Override
- public void info(Throwable error) {
- logger.info(error);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- @Override
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- @Override
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- @Override
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- @Override
- public void warn(CharSequence content) {
- logger.warn(content);
- }
-
- @Override
- public void warn(CharSequence content, Throwable error) {
- logger.warn(content, error);
- }
-
- @Override
- public void warn(Throwable error) {
- logger.warn(error);
- }
- }
-}
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
+public @interface OutputFolder {
+ public StandardOutputFolders value();
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -0,0 +1,36 @@
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+
+
+public class OutputFolderImpl implements OutputFolder {
+
+ private final StandardOutputFolders value;
+
+ public OutputFolderImpl(StandardOutputFolders value) {
+ this.value = value;
+ }
+
+ @Override
+ public StandardOutputFolders value() {
+ return value;
+ }
+
+ public int hashCode() {
+ // This is specified in java.lang.Annotation.
+ return (127 * "value".hashCode()) ^ value.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof OutputFolder)) {
+ return false;
+ }
+
+ OutputFolder other = (OutputFolder) o;
+ return value.equals(other.value());
+ }
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return OutputFolder.class;
+ }
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
+public @interface Source {
+ public StandardSources value();
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java (rev 0)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -0,0 +1,36 @@
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+
+
+public class SourceImpl implements Source {
+
+ private final StandardSources value;
+
+ public SourceImpl(StandardSources value) {
+ this.value = value;
+ }
+
+ @Override
+ public StandardSources value() {
+ return value;
+ }
+
+ public int hashCode() {
+ // This is specified in java.lang.Annotation.
+ return (127 * "value".hashCode()) ^ value.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof Source)) {
+ return false;
+ }
+
+ Source other = (Source) o;
+ return value.equals(other.value());
+ }
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Source.class;
+ }
+}
Property changes on: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -23,8 +23,9 @@
package org.richfaces.cdk.model;
-import org.dom4j.Element;
+import org.w3c.dom.Element;
+
import javax.xml.bind.annotation.XmlAnyElement;
import java.util.List;
Modified: root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-01-26 03:16:25 UTC (rev 16359)
@@ -25,6 +25,8 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import org.w3c.dom.Element;
+
import java.util.ArrayList;
import java.util.List;
@@ -34,7 +36,6 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
-import org.dom4j.Element;
/**
* <p class="changed_added_4_0"></p>
15 years
JBoss Rich Faces SVN: r16358 - in root/cdk/trunk/plugins/annotations/src/main/java: javax and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-25 22:15:23 -0500 (Mon, 25 Jan 2010)
New Revision: 16358
Added:
root/cdk/trunk/plugins/annotations/src/main/java/javax/
root/cdk/trunk/plugins/annotations/src/main/java/javax/annotation/
root/cdk/trunk/plugins/annotations/src/main/java/javax/annotation/Nullable.java
Log:
add JSR-305 "Nullable" annotation
Added: root/cdk/trunk/plugins/annotations/src/main/java/javax/annotation/Nullable.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/javax/annotation/Nullable.java (rev 0)
+++ root/cdk/trunk/plugins/annotations/src/main/java/javax/annotation/Nullable.java 2010-01-26 03:15:23 UTC (rev 16358)
@@ -0,0 +1,24 @@
+package javax.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+
+/**
+ * This is a <a href="http://jcp.org/en/jsr/detail?id=305">JSR-305</a> annotation. The presence of this annotation
+ * indicates that parameter or field may have null value
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+@Documented
+
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.PARAMETER, ElementType.FIELD})
+public @interface Nullable {
+
+}
Property changes on: root/cdk/trunk/plugins/annotations/src/main/java/javax/annotation/Nullable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
15 years
JBoss Rich Faces SVN: r16357 - in root/ui-sandbox/trunk/components/tables/ui/src/main: resources/META-INF/resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-01-25 14:44:06 -0500 (Mon, 25 Jan 2010)
New Revision: 16357
Modified:
root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css
root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-7869
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-01-25 17:51:25 UTC (rev 16356)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-01-25 19:44:06 UTC (rev 16357)
@@ -21,9 +21,14 @@
*/
package org.richfaces.renderkit;
+import static org.ajax4jsf.renderkit.AjaxRendererUtils.AJAX_FUNCTION_NAME;
+import static org.ajax4jsf.renderkit.AjaxRendererUtils.buildAjaxFunction;
+import static org.ajax4jsf.renderkit.AjaxRendererUtils.buildEventOptions;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -33,6 +38,9 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxEventOptions;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.util.HtmlUtil;
@@ -52,22 +60,29 @@
public RendererState(FacesContext context, UIDataTableBase table) {
super(context);
this.table = table;
- int count = getFrozenColumnsCount();
- frozenColumns = new ArrayList<UIComponent>();
columns = new ArrayList<UIComponent>();
Iterator<UIComponent> iterator = table.columns();
- for (; iterator.hasNext() && count > 0; count--) {
+ Map<String, UIComponent> columnsMap = new LinkedHashMap<String, UIComponent>();
+ for (; iterator.hasNext();) {
UIComponent component = iterator.next();
if (component.isRendered()) {
- frozenColumns.add(component);
+ columnsMap.put(component.getId(), component);
}
+ }
+ String[] columnsOrder = (String[]) table.getAttributes().get("columnsOrder");
+ if (columnsOrder != null && columnsOrder.length > 0) {
+ int i = 0;
+ for (; i < columnsOrder.length && !columnsMap.isEmpty(); i++) {
+ columns.add(columnsMap.remove(columnsOrder[i]));
+ }
}
+ iterator = columnsMap.values().iterator();
for (; iterator.hasNext();) {
- UIComponent component = iterator.next();
- if (component.isRendered()) {
- columns.add(component);
- }
+ columns.add(iterator.next());
}
+ int count = getFrozenColumnsCount();
+ frozenColumns = columns.subList(0, count);
+ columns = columns.subList(count, columns.size());
}
private int getFrozenColumnsCount() {
@@ -139,6 +154,28 @@
writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context) + ":d", null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-drag", null);
writer.endElement(HTML.DIV_ELEM);
+ writer.startElement(HTML.TABLE_ELEMENT, component);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context) + ":r", null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-reorder", null);
+ writer.writeAttribute(HTML.CELLPADDING_ATTRIBUTE, "0", null);
+ writer.writeAttribute(HTML.CELLSPACING_ATTRIBUTE, "0", null);
+ writer.startElement(HTML.TBOBY_ELEMENT, component);
+ writer.startElement(HTML.TR_ELEMENT, component);
+ writer.startElement(HTML.TD_ELEM, component);
+ writer.write(" ");
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.startElement(HTML.TR_ELEMENT, component);
+ writer.startElement(HTML.TD_ELEM, component);
+ writer.write(" ");
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.startElement(HTML.TR_ELEMENT, component);
+ writer.startElement(HTML.TD_ELEM, component);
+ writer.write(" ");
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.endElement(HTML.TABLE_ELEMENT);
writer.startElement(HTML.INPUT_ELEM, component);
writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context) + ":wi", null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, component.getClientId(context) + ":wi", null);
@@ -146,7 +183,16 @@
writer.endElement(HTML.INPUT_ELEM);
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- writer.write("new RichFaces.ExtendedDataTable('" + component.getClientId(context) + "');");
+
+ JSFunction ajaxFunction = buildAjaxFunction(context, component, AJAX_FUNCTION_NAME);
+ AjaxEventOptions eventOptions = buildEventOptions(context, component);
+ eventOptions.getParameters().put("rich:columnsOrder", new JSReference("columnsOrder"));
+ if (!eventOptions.isEmpty()) {
+ ajaxFunction.addParameter(eventOptions);
+ }
+
+ writer.write("new RichFaces.ExtendedDataTable('" + component.getClientId(context)
+ + "', function(event, columnsOrder) {" + ajaxFunction.toScript() + ";});");
writer.endElement(HTML.SCRIPT_ELEM);
writer.endElement(HTML.DIV_ELEM);
}
@@ -284,7 +330,6 @@
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-resizer-holder rich-extable-cell-width-"
+ column.getId(), null);
writer.startElement(HTML.DIV_ELEM, column);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context) + ":r", null);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-extable-resizer", null);
writer.endElement(HTML.DIV_ELEM);
writer.endElement(HTML.DIV_ELEM);
@@ -337,6 +382,9 @@
super.doDecode(context, component);
Map<String, String> map = context.getExternalContext().getRequestParameterMap();
updateWidthOfColumns(component, map.get(component.getClientId(context) + ":wi"));
+ if (map.get(component.getClientId(context)) != null) {
+ updateColumnsOrder(context, component, map.get("rich:columnsOrder"));
+ }
}
/**
@@ -357,6 +405,14 @@
}
}
+ private void updateColumnsOrder(FacesContext context, UIComponent component, String columnsOrderString) {
+ if (columnsOrderString != null && columnsOrderString.length() > 0) {
+ String[] columnsOrder = columnsOrderString.split(",");
+ component.getAttributes().put("columnsOrder", columnsOrder);
+ context.getPartialViewContext().getRenderIds().add(component.getClientId(context));
+ }
+ }
+
private String getColumnWidth(UIComponent column) {
String width = (String) column.getAttributes().get("width");
if (width == null || width.length() == 0 || width.indexOf("%") != -1) {
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css 2010-01-25 17:51:25 UTC (rev 16356)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.css 2010-01-25 19:44:06 UTC (rev 16357)
@@ -77,6 +77,19 @@
display: none;
}
+.rich-extable-reorder{
+ position:absolute;
+ border-collapse: collapse;
+ display: none;
+}
+
+.rich-extable-reorder td{
+ width: 30px;
+ height: 10px;
+ font-size: 5px;
+ border: 1px solid #C4C0C9;
+}
+
.rich-extable-cell, .rich-extable-header-cell, .rich-extable-footer-cell{
height: 20px;
overflow: hidden;
Modified: root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
--- root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-01-25 17:51:25 UTC (rev 16356)
+++ root/ui-sandbox/trunk/components/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-01-25 19:44:06 UTC (rev 16357)
@@ -34,8 +34,8 @@
return rule;
};
- richfaces.ExtendedDataTable = function(id) {
- var WIDTH_CLASS_NAME_BASE = ".rich-extable-cell-width-";
+ richfaces.ExtendedDataTable = function(id, ajaxFunction) {
+ var WIDTH_CLASS_NAME_BASE = "rich-extable-cell-width-";
var MIN_WIDTH = 20;
var element = document.getElementById(id);
@@ -45,6 +45,7 @@
var dataTableElement = contentElement.lastChild;//TODO this.dataTableElement = Richfaces.lastDescendant(this.contentElement);
var frozenHeaderPartElement = document.getElementById(id + ":frozenHeader");
var dragElement = document.getElementById(id + ":d");
+ var reorderElement = document.getElementById(id + ":r");
var widthInput = document.getElementById(id + ":wi");
var normalPartStyle = richfaces.getCSSRule(".rich-extable-part-width").style;
@@ -58,6 +59,7 @@
var scrollElement = document.getElementById(id + idSuffixs[2]);
var resizeData = {};
+ var idOfReorderingColumn = "";
var newWidths = {};
var updateLayout = function() {
@@ -140,10 +142,10 @@
return false;
};
var beginResize = function(event) {
- var parts = this.id.split(":");
+ var className = this.parentNode.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "[^\w]*"))[0];
var thisElement = jQuery(this);
resizeData = {
- id : parts[parts.length - 2],
+ className : className,
left : thisElement.parent().offset().left
};
dragElement.style.height = element.clientHeight + "px";
@@ -159,8 +161,8 @@
jQuery(document).unbind("mousemove", drag);
dragElement.style.display = "none";
var width = Math.max(MIN_WIDTH, event.pageX - resizeData.left) + "px";
- richfaces.getCSSRule(WIDTH_CLASS_NAME_BASE + resizeData.id).style.width = width;
- newWidths[resizeData.id] = width;
+ richfaces.getCSSRule("." + resizeData.className).style.width = width;
+ newWidths[resizeData.className.substr(WIDTH_CLASS_NAME_BASE.length)] = width;
var widthsArray = new Array();
for (var id in newWidths) {
widthsArray.push(id + ":" + newWidths[id]);
@@ -168,13 +170,59 @@
widthInput.value = widthsArray.toString();
updateLayout();
adjustResizers();
- richfaces.ajax(element, event); // Maybe, event model should be used here.
+ ajaxFunction(event, ""); // Maybe, event model should be used here.
};
+ var reorder = function(event) {
+ reorderElement.style.display = "block";
+ reorderElement.style.top = (event.pageY - jQuery(reorderElement).offsetParent().offset().top) + "px";
+ reorderElement.style.left = (event.pageX - jQuery(reorderElement).offsetParent().offset().left + 20) + "px";
+ return false;
+ };
+
+ var beginReorder = function(event) {
+ idOfReorderingColumn = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "[^\w]*"))[0].substr(WIDTH_CLASS_NAME_BASE.length); //To try to do this without substr.
+ jQuery(document).bind("mousemove", reorder);
+ jQuery(element).children(".rich-extable-header").find(".rich-extable-header-cell").one("mouseup", endReorder);
+ jQuery(document).one("mouseup", cancelReorder);
+ return false;
+ };
+
+ var endReorder = function(event) {
+ var id = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "[^\w]*"))[0].substr(WIDTH_CLASS_NAME_BASE.length); //To try to do this without substr.
+ var colunmsOrder = "";
+ jQuery(element).children(".rich-extable-header").find(".rich-extable-header-cell").each(function() {
+ var i = this.className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "[^\w]*"))[0].substr(WIDTH_CLASS_NAME_BASE.length); //To try to do this without substr.
+ if (i == id) {
+ colunmsOrder += idOfReorderingColumn + "," + id + ",";
+ } else if (i != idOfReorderingColumn) {
+ colunmsOrder += i + ",";
+ }
+ });
+ ajaxFunction(event, colunmsOrder);
+// bodyElement.style.display = "none";
+// jQuery("#" + escapedId + "\\:" + classNameOfReorderingColumn + "\\:h").insertBefore("#" + escapedId + "\\:" + className + "\\:h");
+// jQuery(bodyElement).find("table div tr").each(function(){
+// var div = jQuery(this).find("." + WIDTH_CLASS_NAME_BASE + classNameOfReorderingColumn);
+// if (div.length) {
+// div.parent().insertBefore(jQuery(this).find("." + WIDTH_CLASS_NAME_BASE + className).parent());
+// }
+// });
+// jQuery("#" + escapedId + "\\:" + classNameOfReorderingColumn + "\\:f").insertBefore("#" + escapedId + "\\:" + className + "\\:f");
+// bodyElement.style.display = "";
+ };
+
+ var cancelReorder = function(event) {
+ jQuery(document).unbind("mousemove", reorder);
+ jQuery(element).children(".rich-extable-header").find(".rich-extable-header-cell").unbind("mouseup", endReorder);
+ reorderElement.style.display = "none";
+ };
+
jQuery(document).ready(initializeLayout);
jQuery(window).bind("resize", updateLayout);
jQuery(scrollElement).bind("scroll", updateScrollPosition);
jQuery(element).children(".rich-extable-header").find(".rich-extable-resizer").bind("mousedown", beginResize);
+ jQuery(element).children(".rich-extable-header").find(".rich-extable-header-cell").bind("mousedown", beginReorder);
};
}(window.RichFaces, jQuery));
15 years
JBoss Rich Faces SVN: r16356 - root/cdk/branches.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-01-25 12:51:25 -0500 (Mon, 25 Jan 2010)
New Revision: 16356
Added:
root/cdk/branches/guice/
Log:
Dependency injection experiment
Copied: root/cdk/branches/guice (from rev 16355, root/cdk/trunk)
15 years
JBoss Rich Faces SVN: r16355 - in branches/community/3.3.X/cdk/generator/src/main/resources/META-INF: templates12 and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-01-23 11:54:54 -0500 (Sat, 23 Jan 2010)
New Revision: 16355
Modified:
branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/taglib.vm
branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm
Log:
Fix RF-7363
Modified: branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/taglib.vm
===================================================================
--- branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/taglib.vm 2010-01-22 19:22:24 UTC (rev 16354)
+++ branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates/taglib.vm 2010-01-23 16:54:54 UTC (rev 16355)
@@ -31,18 +31,18 @@
#foreach( $prop in ${component.properties} )
#if( !${prop.hidden} && !${prop.disabled} )
<attribute>
+ <description>${prop.xmlEncodedDescription}</description>
<name>${prop.name}</name>
#if(${prop.required})
<required>true</required>
#end
<rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
</attribute>
#if( $prop.alias )
<attribute>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
<name>${prop.alias}</name>
<rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
</attribute>
#end
#end
@@ -70,18 +70,18 @@
#foreach( $prop in ${validator.properties} )
#if( !${prop.hidden} && !${prop.disabled} )
<attribute>
+ <description>${prop.xmlEncodedDescription}</description>
<name>${prop.name}</name>
#if(${prop.required})
<required>true</required>
#end
<rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
</attribute>
#if( $prop.alias )
<attribute>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
<name>${prop.alias}</name>
<rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
</attribute>
#end
#end
@@ -109,18 +109,18 @@
#foreach( $prop in ${converter.properties} )
#if( !${prop.hidden} && !${prop.disabled} )
<attribute>
+ <description>${prop.xmlEncodedDescription}</description>
<name>${prop.name}</name>
#if(${prop.required})
<required>true</required>
#end
<rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
</attribute>
#if( $prop.alias )
<attribute>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
<name>${prop.alias}</name>
<rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
</attribute>
#end
#end
@@ -151,37 +151,37 @@
#end
<attribute>
+ <description>
+ Attribute defines the fully qualified Java class name for listener
+ </description>
<name>type</name>
<rtexprvalue>false</rtexprvalue>
- <description>
- Attribute defines the fully qualified Java class name for listener
- </description>
</attribute>
<attribute>
+ <description>
+ The attribute takes a value-binding expression for a component property of a backing bean
+ </description>
<name>binding</name>
<rtexprvalue>false</rtexprvalue>
- <description>
- The attribute takes a value-binding expression for a component property of a backing bean
- </description>
</attribute>
#foreach( $prop in ${listener.properties} )
#if( !${prop.hidden} && !${prop.disabled} )
<attribute>
+ <description>${prop.xmlEncodedDescription}</description>
<name>${prop.name}</name>
#if(${prop.required})
<required>true</required>
#end
<rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
</attribute>
#if( $prop.alias )
<attribute>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
<name>${prop.alias}</name>
<rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
</attribute>
#end
#end
Modified: branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm
===================================================================
--- branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm 2010-01-22 19:22:24 UTC (rev 16354)
+++ branches/community/3.3.X/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm 2010-01-23 16:54:54 UTC (rev 16355)
@@ -26,9 +26,9 @@
</attribute>
#if( $prop.alias )
<attribute>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
<name>${prop.alias}</name>
<rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
</attribute>
#end
#end
15 years
JBoss Rich Faces SVN: r16354 - in root/cdk/trunk/plugins: generator/src/main/java/org/richfaces/cdk and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-01-22 14:22:24 -0500 (Fri, 22 Jan 2010)
New Revision: 16354
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyBehavior.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml
Removed:
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverterClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.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/apt/BehaviorProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorAdapter.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java
root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyConverter.java
Log:
https://jira.jboss.org/jira/browse/RF-8232
Tags support - behavior class generator
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/JsfBehavior.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -50,6 +50,7 @@
*
* @return converter type.
*/
- public String value();
+ public String id() default "";
+ public String behaviorClass() default "";
}
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 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -36,6 +36,7 @@
COMPONENT_CLASSES(StandardOutputFolders.JAVA_CLASSES),
VALIDATOR_CLASSES(StandardOutputFolders.JAVA_CLASSES),
CONVERTER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
+ BEHAVIOR_CLASSES(StandardOutputFolders.JAVA_CLASSES),
RENDERER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
EVENT_LISTENER_CLASSES(StandardOutputFolders.JAVA_CLASSES),
EVENT_SOURCE_CLASSES(StandardOutputFolders.JAVA_CLASSES),
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/BehaviorProcessor.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -23,27 +23,33 @@
package org.richfaces.cdk.apt;
-import java.lang.annotation.Annotation;
+import org.richfaces.cdk.CdkProcessingException;
+import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ClassDescription;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
+import java.lang.annotation.Annotation;
-import org.richfaces.cdk.CdkProcessingException;
-import org.richfaces.cdk.annotations.JsfBehavior;
-
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
+@SupportedAnnotationTypes({"javax.faces.component.FacesComponent", JsfBehavior.NAME})
public class BehaviorProcessor extends ProcessorBase implements CdkAnnotationProcessor {
- /* (non-Javadoc)
- * @see org.richfaces.cdk.apt.CdkAnnotationProcessor#process(javax.lang.model.element.TypeElement)
- */
@Override
public void process(TypeElement element) throws CdkProcessingException {
- // TODO Auto-generated method stub
+ JsfBehavior behavior = element.getAnnotation(JsfBehavior.class);
+ BehaviorModel behaviorModel = new BehaviorModel(behavior.id(), new ClassDescription(element.getQualifiedName().toString()));
+ setClassNames(element, behaviorModel, behavior);
+ setDescription(element, behaviorModel);
+
+ getLibrary().getBehaviors().add(behaviorModel);
}
@Override
@@ -51,5 +57,24 @@
return JsfBehavior.class;
}
+ // TODO remove this method
+ public static void setClassNames(TypeElement componentElement, BehaviorModel validatorModel, JsfBehavior validator) {
+ String baseClass = componentElement.getQualifiedName().toString();
+ if (validator == null) {
+ validatorModel.setClassNames(baseClass, null);
+ return;
+ }
+ String validatorClass = validator.behaviorClass();
+ if (validatorClass == null || validatorClass.isEmpty() || baseClass.equals(validatorClass)) {
+ if (componentElement.getModifiers().contains(Modifier.ABSTRACT)) {
+ throw new IllegalStateException("You can't use an abstract class as a validator. Please set the validatorClass or remove the 'abstract' modifier.");
+ } else {
+ validatorModel.setClassNames(baseClass, null);
+ }
+ } else {
+ validatorModel.setClassNames(validatorClass, baseClass);
+ }
+ }
+
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.Visitable;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.StandardOutputs;
+
+import java.io.File;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+public class BehaviorClassGenerator extends FreeMarkerRenderer<BehaviorModel, ComponentLibrary> implements CdkWriter {
+
+ /*
+ * (non-Javadoc)
+ * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
+ */
+ @Override
+ public void init(CdkContext context) {
+ super.init(context);
+ }
+
+ @Override
+ protected boolean isMyComponent(Visitable c) {
+ if (c instanceof BehaviorModel) {
+ return ((BehaviorModel) c).isGenerate();
+ }
+
+ return false;
+ }
+
+ @Override
+ protected String getOutputFile(BehaviorModel c) throws CdkException {
+ return c.getBehaviorClass().getName().replace('.', File.separatorChar) + ".java";
+ }
+
+ @Override
+ protected String getTemplateName() {
+ return "behavior.ftl";
+ }
+
+ @Override
+ protected CdkContext.OutputType getOutputType() {
+ return StandardOutputs.BEHAVIOR_CLASSES;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -56,9 +56,7 @@
@Override
protected boolean isMyComponent(Visitable c) {
if (c instanceof ComponentModel) {
- ComponentModel component = (ComponentModel) c;
-
- return component.isGenerate();
+ return ((ComponentModel) c).isGenerate();
}
return false;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -46,9 +46,7 @@
@Override
protected boolean isMyComponent(Visitable visitable) {
if (visitable instanceof ValidatorModel) {
- ValidatorModel validator = (ValidatorModel) visitable;
-
- return validator.isGenerate();
+ return ((ValidatorModel) visitable).isGenerate();
}
return false;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/BehaviorModel.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -32,54 +32,83 @@
* @author asmirnov(a)exadel.com
*
*/
-@SuppressWarnings("serial")
-public class BehaviorModel implements ModelElement<BehaviorModel> {
+public class BehaviorModel extends ModelElementBase implements ModelElement<BehaviorModel> {
- private Type type;
+ private static final long serialVersionUID = -5023589072935390357L;
+ private boolean generate = false;
+
+ private String behaviorId;
+
+ private ClassDescription behaviorClass;
+
+ private ClassDescription baseClass;
+
public BehaviorModel() {
}
- public BehaviorModel(Type type) {
- this.type = type;
+ public BehaviorModel(String behaviorId, ClassDescription behaviorClass) {
+ setBehaviorId(behaviorId);
+ setBehaviorClass(behaviorClass);
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the type
- */
- public Type getType() {
- return this.type;
+ public boolean isGenerate() {
+ return generate;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @param type the type to set
- */
- public void setType(Type type) {
- this.type = type;
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
}
- @Override
- public void merge(BehaviorModel other) {
+ public String getBehaviorId() {
+ return behaviorId;
+ }
- // TODO Auto-generated method stub
+ public void setBehaviorId(String behaviorId) {
+ this.behaviorId = behaviorId;
}
+ public ClassDescription getBehaviorClass() {
+ return behaviorClass;
+ }
+
+ public void setBehaviorClass(ClassDescription behaviorClass) {
+ this.behaviorClass = behaviorClass;
+ }
+
+ public ClassDescription getBaseClass() {
+ return baseClass;
+ }
+
+ public void setBaseClass(ClassDescription baseClass) {
+ this.baseClass = baseClass;
+ }
+
+ public void setClassNames(String validatorClass, String baseClass) {
+ this.behaviorClass = new ClassDescription(validatorClass);
+
+ if (baseClass != null) {
+ this.baseClass = new ClassDescription(baseClass);
+ this.generate = true;
+ } else {
+ this.generate = false;
+ }
+ }
+
@Override
public <R, P> R accept(LibraryVisitor<R, P> visitor, P param) throws CdkException {
return visitor.visit(this, param);
}
@Override
- public boolean same(BehaviorModel other) {
- return null != getType() && getType().equals(other.getType());
+ public void merge(BehaviorModel other) {
+ ComponentLibrary.merge(this, other);
+
+ getAttributes().putAll(other.getAttributes());
}
-
- public static final class Type extends Key {
- public Type(String name) {
- super(name);
- }
+ @Override
+ public boolean same(BehaviorModel other) {
+ return null != getBehaviorId() && getBehaviorId().equals(other.getBehaviorId());
}
}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorAdapter.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorAdapter.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.xmlconfig.model;
+
+import org.richfaces.cdk.model.BehaviorModel;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+public class BehaviorAdapter extends AdapterBase<BehaviorBean, BehaviorModel> {
+
+ @Override
+ protected Class<? extends BehaviorBean> getBeanClass(BehaviorModel model) {
+ return BehaviorBean.class;
+ }
+
+ @Override
+ protected Class<? extends BehaviorModel> getModelClass(BehaviorBean bean) {
+ return BehaviorModel.class;
+ }
+}
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.xmlconfig.model;
+
+import com.google.common.collect.Lists;
+
+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 java.util.List;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ConfigExtension;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+@XmlType(name = "faces-config-behaviorType", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE,
+ propOrder={"behaviorId", "behaviorClass", "attributes", "extension"})
+(a)XmlJavaTypeAdapter(BehaviorAdapter.class)
+public class BehaviorBean extends ExtensibleBean<BehaviorBean.BehaviorExtension> {
+
+ private String behaviorId;
+
+ private String behaviorClass;
+
+ private List<PropertyBase> attributes = Lists.newArrayList();
+
+ @XmlElement(name = "behavior-id", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getBehaviorId() {
+ return behaviorId;
+ }
+
+ public void setBehaviorId(String behaviorId) {
+ this.behaviorId = behaviorId;
+ }
+
+ @XmlElement(name = "behavior-class", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public String getBehaviorClass() {
+ return behaviorClass;
+ }
+
+ public void setBehaviorClass(String behaviorClass) {
+ this.behaviorClass = behaviorClass;
+ }
+
+
+ @XmlElements({
+ @XmlElement(name = "property", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, type = PropertyBean.class),
+ @XmlElement(name = "attribute", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE, type = AttributeBean.class)
+ })
+ public List<PropertyBase> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(List<PropertyBase> property) {
+ this.attributes = property;
+ }
+
+ @Override
+ @XmlElement(name = "behavior-extension", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ public BehaviorExtension getExtension() {
+ return super.getExtension();
+ }
+
+ @Override
+ public void setExtension(BehaviorExtension extension) {
+ super.setExtension(extension);
+ }
+
+ public static class BehaviorExtension extends ConfigExtension { }
+}
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 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/FacesConfigBean.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -38,6 +38,7 @@
import org.richfaces.cdk.model.Extensible;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.model.BehaviorModel;
import com.google.common.collect.Lists;
@@ -64,6 +65,10 @@
@XmlJavaTypeAdapter(ValidatorAdapter.class)
private List<ValidatorModel> validators = Lists.newArrayList();
+ @XmlElement(name = "behavior", namespace = ComponentLibrary.FACES_CONFIG_NAMESPACE)
+ @XmlJavaTypeAdapter(BehaviorAdapter.class)
+ private List<BehaviorModel> behaviors = Lists.newArrayList();
+
@XmlAttribute
private String version = "2.0";
@@ -159,6 +164,14 @@
this.validators = validators;
}
+ public List<BehaviorModel> getBehaviors() {
+ return behaviors;
+ }
+
+ public void setBehaviors(List<BehaviorModel> behaviors) {
+ this.behaviors = behaviors;
+ }
+
/**
* <p class="changed_added_4_0"></p>
*
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorAdapter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorAdapter.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorAdapter.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -27,7 +27,7 @@
* @author akolonitsky
* @since Jan 13, 2010
*/
-public class ValidatorAdapter extends AdapterBase<ValidatorBean, ValidatorModel>{
+public class ValidatorAdapter extends AdapterBase<ValidatorBean, ValidatorModel> {
@Override
protected Class<? extends ValidatorBean> getBeanClass(ValidatorModel model) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -89,6 +89,5 @@
super.setExtension(extension);
}
- public static class ValidatorExtension extends ConfigExtension {
- }
+ public static class ValidatorExtension extends ConfigExtension { }
}
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/behavior.ftl 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,111 @@
+<#include "copyright.ftl">
+
+package ${behaviorClass.package};
+
+import javax.annotation.Generated;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import javax.faces.event.BehaviorEvent;
+
+/**
+ * ${description?if_exists}
+ **/
+@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
+public class ${behaviorClass.simpleName} extends ${baseClass} implements Behavior, PartialStateHolder {
+
+ @Override
+ public void broadcast(BehaviorEvent event) {
+ }
+
+ protected enum Properties {
+ <#list generatedAttributes as attribute>${attribute.name}<#if attribute_has_next>${",\n "}</#if></#list>
+ }
+
+ <#list generatedAttributes as attribute>
+ /**
+ * ${attribute.description?if_exists}
+ **/
+ public ${attribute.type} ${attribute.getterName}(){
+ return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
+ }
+
+ /**
+ * Setter for ${attribute.name}
+ **/
+ public void ${attribute.setterName}(${attribute.type} ${attribute.name}){
+ getStateHelper().put(Properties.${attribute.name},${attribute.name});
+ }
+ </#list>
+
+ protected StateHelper getStateHelper() {
+ return getStateHelper(true);
+ }
+
+ protected StateHelper getStateHelper(boolean create) {
+ return null;
+ }
+
+ // ----------------------------------------------------- StateHolder Methods
+ @Override
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (!initialStateMarked()) {
+ Object values[] = new Object[1];
+ <#list generatedAttributes as attribute>
+ values[${attribute_index}] = this.${attribute.getterName}();
+ </#list>
+
+ return values;
+ }
+ return null;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ Object values[] = (Object[]) state;
+ <#list generatedAttributes as attribute>
+ ${attribute.setterName}((${attribute.type}) values[${attribute_index}]);
+ </#list>
+ }
+
+ private boolean transientValue = false;
+
+ @Override
+ public boolean isTransient() {
+ return this.transientValue;
+ }
+
+ @Override
+ public void setTransient(boolean transientValue) {
+ this.transientValue = transientValue;
+ }
+
+
+ private boolean initialState;
+
+ @Override
+ public void markInitialState() {
+ initialState = true;
+ }
+
+ @Override
+ public boolean initialStateMarked() {
+ return initialState;
+ }
+
+ @Override
+ public void clearInitialState() {
+ initialState = false;
+ }
+}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-01-22 19:22:24 UTC (rev 16354)
@@ -3,29 +3,10 @@
<#nested item/><#if item_has_next>${delimiter}</#if>
</#list>
</#macro>
-/*
- * 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
- */
+<#include "copyright.ftl">
+
package ${componentClass.package};
-// Import declarations
import javax.annotation.Generated;
import java.io.IOException;
import java.util.ArrayList;
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/converter.ftl 2010-01-22 19:22:24 UTC (rev 16354)
@@ -1,24 +1,5 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+<#include "copyright.ftl">
+
package ${converterClass.package};
import javax.annotation.Generated;
@@ -50,14 +31,14 @@
/**
* ${attribute.description?if_exists}
**/
- public ${attribute.type} ${attribute.getterName}(){
+ public ${attribute.type} ${attribute.getterName}() {
return (${attribute.type})getStateHelper().eval(Properties.${attribute.name});
}
/**
* Setter for ${attribute.name}
**/
- public void ${attribute.setterName}(${attribute.type} ${attribute.name}){
+ public void ${attribute.setterName}(${attribute.type} ${attribute.name}) {
getStateHelper().put(Properties.${attribute.name},${attribute.name});
}
</#list>
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/copyright.ftl 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,21 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/validator.ftl 2010-01-22 19:22:24 UTC (rev 16354)
@@ -1,24 +1,5 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+<#include "copyright.ftl">
+
package ${validatorClass.package};
import javax.annotation.Generated;
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/BehaviorProcessorTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.apt;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import java.util.Collection;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+public class BehaviorProcessorTest extends AnnotationProcessorTest {
+ private static final String BEHAVIOR_CLASS_JAVA = "org/richfaces/cdk/test/component/MyBehavior.java";
+
+ @Test
+ public void testProcess() throws Exception {
+ ComponentLibrary library = prepareMockCompilationContext(BEHAVIOR_CLASS_JAVA);
+ Collection<BehaviorModel> behaviors = library.getBehaviors();
+
+ assertEquals(2, behaviors.size());
+
+ for (BehaviorModel model: behaviors) {
+ String id = model.getBehaviorId();
+ if (id != null && !id.isEmpty()) {
+ assertEquals("my_behavior", id);
+ }
+ }
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/ValidatorProcessorTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -54,7 +54,7 @@
for (ValidatorModel model: validators) {
String id = model.getValidatorId();
if (id != null && !id.isEmpty()) {
- assertEquals("my_validator", model.getValidatorId());
+ assertEquals("my_validator", id);
}
}
}
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/BehaviorClassGeneratorTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.java;
+
+import org.junit.Test;
+import org.richfaces.cdk.model.ValidatorModel;
+import org.richfaces.cdk.model.Property;
+import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.CdkContext;
+import static org.easymock.EasyMock.verify;
+
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Set;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+public class BehaviorClassGeneratorTest extends AbstractClassGeneratorTest {
+
+ /**
+ * Test method for {@link org.richfaces.cdk.generate.java.ComponentClassGenerator#getOutputFile(org.richfaces.cdk.model.ComponentModel)}.
+ * @throws Exception
+ */
+ @Test
+ public void testGetOutputFileBehavior() throws Exception {
+ final StringWriter output = new StringWriter();
+ BehaviorClassGenerator generator = new BehaviorClassGenerator() {
+ @Override
+ protected Writer getOutput(BehaviorModel c) throws CdkException {
+ return output;
+ }
+ };
+ CdkContext mockContext = createMockContext();
+
+ generator.init(mockContext);
+
+ BehaviorModel behavior = new BehaviorModel();
+ behavior.setBehaviorId("foo.bar");
+ behavior.setClassNames("org.richfaces.cdk.generate.java.GeneratedBehavior", "Object");
+
+ // TODO add test with types boolean, int, Integer, String, Object
+ addAttribute(behavior, "testValue", Object.class, true);
+ addAttribute(behavior, "testFlag", Boolean.class, true);
+ Property attribute = addAttribute(behavior, "id", String.class, false);
+
+ Set<EventName> eventNames = attribute.getEventNames();
+ eventNames.add(getEvent("id", false));
+ eventNames.add(getEvent("action", true));
+
+ ComponentLibrary library = new ComponentLibrary();
+ library.getBehaviors().add(behavior);
+ generator.visit(behavior, library);
+
+ System.out.println(output);
+ verify(mockContext);
+
+ compare(output, "GeneratedBehavior.java");
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -71,7 +71,7 @@
library.getComponents().add(component);
component.setGenerate(true);
component.setBaseClass(new ClassDescription(UIOutput.class));
- component.setComponentClass(new ClassDescription("foo.bar.UIBar"));
+ component.setComponentClass(new ClassDescription("org.richfaces.cdk.generate.java.GeneratedComponent"));
Property attribute = component.addAttribute("testValue");
@@ -92,6 +92,6 @@
System.out.println(output);
verify(mockContext);
- compare(output, "UIBar.java");
+ compare(output, "GeneratedComponent.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ConverterClassGeneratorTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -26,12 +26,10 @@
import org.junit.Test;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.Property;
-import org.richfaces.cdk.model.ValidatorModel;
import java.io.StringWriter;
import java.io.Writer;
@@ -62,7 +60,7 @@
ConverterModel converter = new ConverterModel();
converter.setConverterId("foo.bar");
- converter.setClassNames("org.richfaces.cdk.generate.java.GeneratedConverterClass", "Object");
+ converter.setClassNames("org.richfaces.cdk.generate.java.GeneratedConverter", "Object");
addAttribute(converter, "testValue", Object.class, true);
// TODO test with primitiv type 'boolean'
@@ -81,6 +79,6 @@
verify(mockContext);
- // TODO - check generated file.
+ compare(output, "GeneratedConverter.java");
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ValidatorClassGeneratorTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -85,7 +85,7 @@
verify(mockContext);
- // TODO - check generated file.
+ compare(output, "GeneratedClass.java");
}
}
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.xmlconfig.testmodel;
+
+import org.junit.Test;
+import org.richfaces.cdk.model.BehaviorModel;
+import org.richfaces.cdk.model.ClassDescription;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import java.io.StringWriter;
+
+/**
+ * @author akolonitsky
+ * @since Jan 21, 2010
+ */
+public class BehaviorBeanTest extends ModelBeanTest {
+
+ @Test
+ public void testMarshal() throws Exception {
+ ComponentLibrary library = new ComponentLibrary();
+
+ BehaviorModel behaviorModel = new BehaviorModel("my_behavior", new ClassDescription(Object.class));
+ library.getBehaviors().add(behaviorModel);
+
+ // Jaxb marshaling
+ StringWriter facesConfig = generateFacesConfig(library);
+
+ // Checks
+ checkXmlStructure(facesConfig);
+ validateXml(facesConfig);
+ }
+}
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedBehavior.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.generate.java;
+
+import javax.annotation.Generated;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import javax.faces.event.BehaviorEvent;
+
+/**
+ *
+ **/
+@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
+public class GeneratedBehavior extends Object implements Behavior, PartialStateHolder {
+
+ @Override
+ public void broadcast(BehaviorEvent event) {
+ }
+
+ protected enum Properties {
+ testValue,
+ testFlag
+ }
+
+ /**
+ *
+ **/
+ public java.lang.Object getTestValue(){
+ return (java.lang.Object)getStateHelper().eval(Properties.testValue);
+ }
+
+ /**
+ * Setter for testValue
+ **/
+ public void setTestValue(java.lang.Object testValue){
+ getStateHelper().put(Properties.testValue,testValue);
+ }
+ /**
+ *
+ **/
+ public java.lang.Boolean isTestFlag(){
+ return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
+ }
+
+ /**
+ * Setter for testFlag
+ **/
+ public void setTestFlag(java.lang.Boolean testFlag){
+ getStateHelper().put(Properties.testFlag,testFlag);
+ }
+
+ protected StateHelper getStateHelper() {
+ return getStateHelper(true);
+ }
+
+ protected StateHelper getStateHelper(boolean create) {
+ return null;
+ }
+
+ // ----------------------------------------------------- StateHolder Methods
+ @Override
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (!initialStateMarked()) {
+ Object values[] = new Object[1];
+ values[0] = this.getTestValue();
+ values[1] = this.isTestFlag();
+
+ return values;
+ }
+ return null;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ Object values[] = (Object[]) state;
+ setTestValue((java.lang.Object) values[0]);
+ setTestFlag((java.lang.Boolean) values[1]);
+ }
+
+ private boolean transientValue = false;
+
+ @Override
+ public boolean isTransient() {
+ return this.transientValue;
+ }
+
+ @Override
+ public void setTransient(boolean transientValue) {
+ this.transientValue = transientValue;
+ }
+
+
+ private boolean initialState;
+
+ @Override
+ public void markInitialState() {
+ initialState = true;
+ }
+
+ @Override
+ public boolean initialStateMarked() {
+ return initialState;
+ }
+
+ @Override
+ public void clearInitialState() {
+ initialState = false;
+ }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedClass.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -94,7 +94,7 @@
values[0] = this.getTestValue();
values[1] = this.isTestFlag();
- return (values);
+ return values;
}
return null;
}
Copied: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java (from rev 16344, root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedComponent.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.generate.java;
+
+import javax.annotation.Generated;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+/**
+ *
+ **/
+@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
+public class GeneratedComponent extends javax.faces.component.UIOutput implements ClientBehaviorHolder {
+
+
+ public static final String COMPONENT_TYPE="foo.bar";
+
+
+ private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
+ "id",
+ "action"
+
+ ));
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES; }
+
+
+ public String getDefaultEventName() {
+ return "action";
+ }
+ protected enum Properties {
+ testValue,
+ testFlag
+
+ }
+
+ /**
+ *
+ **/
+ public java.lang.Object getTestValue(){
+ return (java.lang.Object)getStateHelper().eval(Properties.testValue);
+ }
+
+ /**
+ * Setter for testValue
+ **/
+ public void setTestValue(java.lang.Object testValue){
+ getStateHelper().put(Properties.testValue,testValue);
+ }
+ /**
+ *
+ **/
+ public java.lang.Boolean isTestFlag(){
+ return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
+ }
+
+ /**
+ * Setter for testFlag
+ **/
+ public void setTestFlag(java.lang.Boolean testFlag){
+ getStateHelper().put(Properties.testFlag,testFlag);
+ }
+
+}
Copied: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java (from rev 16344, root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverterClass.java)
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverter.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,146 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.generate.java;
+
+import javax.annotation.Generated;
+import javax.faces.component.StateHelper;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ *
+ **/
+@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
+public class GeneratedConverter extends Object implements Converter, PartialStateHolder {
+
+ public Object getAsObject(FacesContext context, UIComponent component, String value) {
+ return null;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component, Object value) {
+ return null;
+ }
+
+ protected enum Properties {
+ testValue,
+ testFlag
+ }
+
+ /**
+ *
+ **/
+ public java.lang.Object getTestValue() {
+ return (java.lang.Object)getStateHelper().eval(Properties.testValue);
+ }
+
+ /**
+ * Setter for testValue
+ **/
+ public void setTestValue(java.lang.Object testValue) {
+ getStateHelper().put(Properties.testValue,testValue);
+ }
+ /**
+ *
+ **/
+ public java.lang.Boolean isTestFlag() {
+ return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
+ }
+
+ /**
+ * Setter for testFlag
+ **/
+ public void setTestFlag(java.lang.Boolean testFlag) {
+ getStateHelper().put(Properties.testFlag,testFlag);
+ }
+
+
+
+ protected StateHelper getStateHelper() {
+ return getStateHelper(true);
+ }
+
+ protected StateHelper getStateHelper(boolean create) {
+ return null;
+ }
+
+ // ----------------------------------------------------- StateHolder Methods
+ @Override
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (!initialStateMarked()) {
+ Object values[] = new Object[1];
+ values[0] = this.getTestValue();
+ values[1] = this.isTestFlag();
+
+ return values;
+ }
+ return null;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ Object values[] = (Object[]) state;
+ setTestValue((java.lang.Object) values[0]);
+ setTestFlag((java.lang.Boolean) values[1]);
+ }
+
+ private boolean transientValue = false;
+
+ @Override
+ public boolean isTransient() {
+ return this.transientValue;
+ }
+
+ @Override
+ public void setTransient(boolean transientValue) {
+ this.transientValue = transientValue;
+ }
+
+
+ private boolean initialState;
+
+ @Override
+ public void markInitialState() {
+ initialState = true;
+ }
+
+ @Override
+ public boolean initialStateMarked() {
+ return initialState;
+ }
+
+ @Override
+ public void clearInitialState() {
+ initialState = false;
+ }
+}
Deleted: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverterClass.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverterClass.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/GeneratedConverterClass.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.generate.java;
-
-import javax.annotation.Generated;
-import javax.faces.component.StateHelper;
-import javax.faces.component.PartialStateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-/**
- *
- **/
-@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
-public class GeneratedConverterClass extends Object implements Converter, PartialStateHolder {
- public Object getAsObject(FacesContext context, UIComponent component, String value) {
- return null;
- }
-
- public String getAsString(FacesContext context, UIComponent component, Object value) {
- return null;
- }
-
- protected enum Properties {
- testValue,
- testFlag
- }
-
- /**
- *
- **/
- public java.lang.Object getTestValue(){
- return (java.lang.Object)getStateHelper().eval(Properties.testValue);
- }
-
- /**
- * Setter for testValue
- **/
- public void setTestValue(java.lang.Object testValue){
- getStateHelper().put(Properties.testValue,testValue);
- }
- /**
- *
- **/
- public java.lang.Boolean isTestFlag() {
- return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
- }
-
- /**
- * Setter for testFlag
- **/
- public void setTestFlag(java.lang.Boolean testFlag){
- getStateHelper().put(Properties.testFlag,testFlag);
- }
-
-
-
- protected StateHelper getStateHelper() {
- return getStateHelper(true);
- }
-
- protected StateHelper getStateHelper(boolean create) {
- return null;
- }
-
- // ----------------------------------------------------- StateHolder Methods
- @Override
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (!initialStateMarked()) {
- Object values[] = new Object[1];
- values[0] = this.getTestValue();
- values[1] = this.isTestFlag();
-
- return values;
- }
- return null;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- Object values[] = (Object[]) state;
- setTestValue((java.lang.Object) values[0]);
- setTestFlag((java.lang.Boolean) values[1]);
- }
-
- private boolean transientValue = false;
-
- @Override
- public boolean isTransient() {
- return this.transientValue;
- }
-
- @Override
- public void setTransient(boolean transientValue) {
- this.transientValue = transientValue;
- }
-
-
- private boolean initialState;
-
- @Override
- public void markInitialState() {
- initialState = true;
- }
-
- @Override
- public boolean initialStateMarked() {
- return initialState;
- }
-
- @Override
- public void clearInitialState() {
- initialState = false;
- }
-}
Deleted: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/generate/java/UIBar.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -1,92 +0,0 @@
-/*
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package foo.bar;
-
-// Import declarations
-import javax.annotation.Generated;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-
-/**
- *
- **/
-@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
-public class UIBar extends javax.faces.component.UIOutput implements ClientBehaviorHolder {
-
-
- public static final String COMPONENT_TYPE="foo.bar";
-
-
- private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
- "id",
- "action"
-
- ));
- public Collection<String> getEventNames() {
- return EVENT_NAMES; }
-
-
- public String getDefaultEventName() {
- return "action";
- }
- protected enum Properties {
- testValue,
- testFlag
-
- }
-
- /**
- *
- **/
- public java.lang.Object getTestValue(){
- return (java.lang.Object)getStateHelper().eval(Properties.testValue);
- }
-
- /**
- * Setter for testValue
- **/
- public void setTestValue(java.lang.Object testValue){
- getStateHelper().put(Properties.testValue,testValue);
- }
- /**
- *
- **/
- public java.lang.Boolean isTestFlag(){
- return (java.lang.Boolean)getStateHelper().eval(Properties.testFlag);
- }
-
- /**
- * Setter for testFlag
- **/
- public void setTestFlag(java.lang.Boolean testFlag){
- getStateHelper().put(Properties.testFlag,testFlag);
- }
-
-}
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyBehavior.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyBehavior.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyBehavior.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,49 @@
+/**
+ * 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.test.component;
+
+import org.richfaces.cdk.annotations.JsfConverter;
+import org.richfaces.cdk.annotations.JsfBehavior;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.convert.Converter;
+import javax.faces.event.BehaviorEvent;
+
+/**
+ * @author akolonitsky
+ * @since Jan 14, 2010
+ */
+@JsfBehavior(id = "my_behavior")
+public class MyBehavior implements Behavior {
+
+ @Override
+ public void broadcast(BehaviorEvent event) { }
+}
+
+@JsfBehavior
+class MyBehavior04 implements Behavior {
+
+ @Override
+ public void broadcast(BehaviorEvent event) { }
+}
Modified: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyConverter.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyConverter.java 2010-01-22 12:44:51 UTC (rev 16353)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/test/component/MyConverter.java 2010-01-22 19:22:24 UTC (rev 16354)
@@ -25,13 +25,14 @@
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
+import javax.faces.convert.Converter;
/**
* @author akolonitsky
* @since Jan 14, 2010
*/
@JsfConverter(id = "my_converter", forClass = Integer.class)
-public class MyConverter implements javax.faces.convert.Converter{
+public class MyConverter implements Converter {
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
@@ -45,7 +46,7 @@
}
@JsfConverter(forClass = Integer.class)
-class MyConverter01 implements javax.faces.convert.Converter{
+class MyConverter01 implements Converter{
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
@@ -59,7 +60,7 @@
}
@JsfConverter(id = "my_converter_02")
-class MyConverter02 implements javax.faces.convert.Converter{
+class MyConverter02 implements Converter{
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
@@ -73,7 +74,7 @@
}
@JsfConverter
-class MyConverter03 implements javax.faces.convert.Converter{
+class MyConverter03 implements Converter{
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Added: root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/resources/org/richfaces/cdk/xmlconfig/testmodel/BehaviorBeanTest.xml 2010-01-22 19:22:24 UTC (rev 16354)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<faces-config version="2.0" metadata-complete="false" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://richfaces.org/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <behavior>
+ <behavior-id>my_behavior</behavior-id>
+ <behavior-class>java.lang.Object</behavior-class>
+ <behavior-extension/>
+ </behavior>
+ <faces-config-extension/>
+</faces-config>
15 years