Author: baranda
Date: Sat Nov 25 09:41:05 2006
New Revision: 479151
URL: http://svn.apache.org/viewvc?view=rev&rev=479151
Log:
Applied ADFFACES-303 patch by Andreas Berger
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/ComponentTagGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
Sat Nov 25 09:41:05 2006
@@ -140,8 +140,8 @@
if (componentFamily == null)
{
- getLog().error("Missing <component-family> for \"" +
- fullClassName + "\"");
+ getLog().warn("Missing <component-family> for \"" +
+ fullClassName + "\", generation of this Component
is skipped");
}
else
{
@@ -212,7 +212,12 @@
generator.writeFacetMethods(out, component);
- generator.writePropertyMethods(out, component);
+ if (template == null)
+ {
+ generator.writePropertyMethods(out, component);
+ } else {
+ generator.writePropertyMethods(out, component,
template.getIgnoreMethods());
+ }
if (!suppressListenerMethods)
generator.writeListenerMethods(out, component);
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
Sat Nov 25 09:41:05 2006
@@ -1468,99 +1468,102 @@
}
}
- class ComponentTagHandlerGenerator
- {
- public void generateTagHandler(
- ComponentBean component)
- {
- String fullClassName = component.getTagClass();
-
- ComponentTagGenerator generator;
-
- if (component.isTrinidadComponent())
- {
- generator = new TrinidadComponentTagGenerator(_is12());
- }
- else
- {
- generator = new MyFacesComponentTagGenerator(_is12());
- }
-
- try
- {
- getLog().debug("Generating " + fullClassName);
-
- String sourcePath = Util.convertClassToSourcePath(fullClassName,
".java");
- File targetFile = new File(generatedSourceDirectory, sourcePath);
-
- targetFile.getParentFile().mkdirs();
- StringWriter sw = new StringWriter();
- PrettyWriter out = new PrettyWriter(sw);
-
- String className = Util.getClassFromFullClass(fullClassName);
- String packageName = Util.getPackageFromFullClass(fullClassName);
- String fullSuperclassName = component.findJspTagSuperclass();
- if (fullSuperclassName == null)
- {
- getLog().error("Missing JSP Tag superclass for component:
"+component.getComponentClass());
- return;
- }
- String superclassName = Util.getClassFromFullClass
(fullSuperclassName);
- if (superclassName.equals(className))
- superclassName = fullSuperclassName;
- String componentFullClass = component.getComponentClass();
- String componentClass = Util.getClassFromFullClass
(componentFullClass);
-
- // header/copyright
- writePreamble(out);
-
- // package
- out.println("package " + packageName + ";");
-
- out.println();
-
-
- generator.writeImports(out, null, packageName,
fullSuperclassName, superclassName,
- component);
-
- generator.writeClassBegin(out, className, superclassName,
component, null);
-
- int modifiers = component.getTagClassModifiers();
- generator.writeConstructor(out, component, modifiers);
-
-
- if (!Modifier.isAbstract(modifiers))
- {
- generator.writeGetComponentType(out, component);
- generator.writeGetRendererType(out, component);
- }
- generator.writePropertyMembers(out, component);
- generator.writeSetPropertiesMethod(out, componentClass,
component);
- generator.writeReleaseMethod(out, component);
-
- generator.writeClassEnd(out);
- out.close();
-
- // delay write in case of error
- // timestamp should not be updated when an error occurs
- // delete target file first, because it is readonly
- targetFile.delete();
- FileWriter fw = new FileWriter(targetFile);
- StringBuffer buf = sw.getBuffer();
- fw.write(buf.toString());
- fw.close();
- targetFile.setReadOnly();
- }
- catch (Throwable e)
- {
- getLog().error("Error generating " + fullClassName, e);
- }
- }
+ class ComponentTagHandlerGenerator {
-
- }
+ private Set initComponentList(ComponentBean component,
String fullSuperclassName) {
+ Set _componentList = new HashSet();
+ _componentList.add(component);
+ ComponentBean lBean = component;
+ while ((lBean = lBean.resolveSupertype()) != null
&& !fullSuperclassName.equals(lBean.getTagClass())) {
+ getLog().debug(component.getComponentType()+":
Add additional Tags from: " + lBean.getComponentType());
+ _componentList.add(lBean);
+ }
+ return _componentList;
+ }
+
+ public void generateTagHandler(ComponentBean component) {
+ ComponentTagGenerator generator;
+ Set componentList;
+
+ String fullSuperclassName =
component.findJspTagSuperclass();
+ if (fullSuperclassName == null) {
+ getLog().warn("Missing JSP Tag superclass
for component: " + component.getComponentClass()
+ + ", generation of this
Tag is skipped");
+ return;
+ }
+ componentList = initComponentList(component,
fullSuperclassName);
+
+ String fullClassName = component.getTagClass();
+ try {
+ getLog().debug("Generating " +
fullClassName);
+
+ String sourcePath =
Util.convertClassToSourcePath(fullClassName, ".java");
+ File targetFile = new
File(generatedSourceDirectory, sourcePath);
+
+ targetFile.getParentFile().mkdirs();
+ StringWriter sw = new StringWriter();
+ PrettyWriter out = new PrettyWriter(sw);
+
+ if (component.isTrinidadComponent()) {
+ generator = new
TrinidadComponentTagGenerator(_is12());
+ } else {
+ generator = new
MyFacesComponentTagGenerator(_is12());
+ }
+
+ String className =
Util.getClassFromFullClass(fullClassName);
+ String packageName =
Util.getPackageFromFullClass(fullClassName);
+
+ // header/copyright
+ writePreamble(out);
+
+ // package
+ out.println("package " + packageName +
";");
+
+ out.println();
+
+ String superclassName =
Util.getClassFromFullClass(fullSuperclassName);
+ if (superclassName.equals(className)) {
+ superclassName =
fullSuperclassName;
+ }
+ String componentFullClass =
component.getComponentClass();
+ String componentClass =
Util.getClassFromFullClass(componentFullClass);
+
+ generator.writeImports(out, null,
packageName, fullSuperclassName, superclassName, componentList);
+
+ generator.writeClassBegin(out, className,
superclassName, component, null);
+
+ int modifiers =
component.getTagClassModifiers();
+ generator.writeConstructor(out, component,
modifiers);
+
+
+ if (!Modifier.isAbstract(modifiers)) {
+ generator.writeGetComponentType(out,
component);
+ generator.writeGetRendererType(out,
component);
+ }
+ generator.writePropertyMembers(out,
componentList);
+ generator.writeSetPropertiesMethod(out,
componentClass, componentList);
+ generator.writeReleaseMethod(out,
componentList);
+
+ generator.writeClassEnd(out);
+ out.close();
+
+ // delay write in case of error
+ // timestamp should not be updated when an
error occurs
+ // delete target file first, because it is
readonly
+ targetFile.delete();
+ FileWriter fw = new
FileWriter(targetFile);
+ StringBuffer buf = sw.getBuffer();
+ fw.write(buf.toString());
+ fw.close();
+ targetFile.setReadOnly();
+ }
+ catch (Throwable e) {
+ getLog().error("Error generating " +
fullClassName, e);
+ }
+ }
+ }
- private boolean _is12()
+ private boolean _is12()
{
return "1.2".equals(jsfVersion) || "12".equals(jsfVersion);
}
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java
Sat Nov 25 09:41:05 2006
@@ -20,6 +20,7 @@
import org.apache.myfaces.trinidadbuild.plugin.faces.util.SourceTemplate;
import java.io.IOException;
+import java.util.Collection;
/**
* Generator
@@ -36,6 +37,14 @@
String fullSuperclassName,
String superclassName,
ComponentBean component);
+
+ void writeImports(
+ PrettyWriter out,
+ SourceTemplate template,
+ String packageName,
+ String fullSuperclassName,
+ String superclassName,
+ Collection components);
void writeClassBegin(
PrettyWriter out,
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
Sat Nov 25 09:41:05 2006
@@ -67,10 +67,10 @@
&& property.getJspPropertyName().equals("action"));
}
- public static boolean isActionListener(PropertyBean property)
+ public static boolean isActionListener(PropertyBean property, boolean
is12)
{
- return (property.getClass().equals("javax.el.MethodExpression")
- && property.getJspPropertyName
().equals("actionListener"));
+ return (property.getJspPropertyName().equals("actionListener")
&&
+ (property.isMethodExpression()) || (is12
&& property.isMethodBinding()));
}
static public void writeImports(
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
Sat Nov 25 09:41:05 2006
@@ -38,6 +38,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -200,7 +201,13 @@
out.println("}");
}
- public void writeImports(
+
+ public void writeImports(PrettyWriter out, SourceTemplate
template, String packageName, String fullSuperclassName,
+ String
superclassName, Collection components) {
+ throw new UnsupportedOperationException("not
implemented");
+ }
+
+ public void writeImports(
PrettyWriter out,
SourceTemplate template,
String packageName,
@@ -525,7 +532,13 @@
PrettyWriter out,
ComponentBean component) throws IOException
{
- Iterator properties = component.properties();
+ writePropertyMethods(out, component, null);
+ }
+
+
+ public void writePropertyMethods(PrettyWriter out, ComponentBean
component, Collection ignoreList)
+ throws IOException {
+ Iterator properties = component.properties();
properties = new FilteredIterator(properties, new
NonVirtualFilter());
while (properties.hasNext())
{
@@ -534,14 +547,14 @@
writePropertyListMethods(out, property);
else
{
- writePropertyDeclaration(out, property);
- writePropertyGet(out, property);
- writePropertySet(out, property);
+ writePropertyDeclaration(out, property);
+ writePropertyGet(out, property, ignoreList);
+ writePropertySet(out, property, ignoreList);
}
}
- }
+ }
- abstract protected void writePropertyListMethods(
+ abstract protected void writePropertyListMethods(
PrettyWriter out,
PropertyBean property) throws IOException;
@@ -558,28 +571,32 @@
protected void writePropertySet(
PrettyWriter out,
- PropertyBean property) throws IOException
+ PropertyBean property,
+ Collection ignoreList) throws IOException
{
String propertyClass = Util.getPropertyClass(property);
- writePropertySet(out, property, propertyClass);
+ writePropertySet(out, property, propertyClass, ignoreList);
if (property.getAlternateClass() != null)
{
String alternateClass = Util.getAlternatePropertyClass
(property);
- writePropertySet(out, property, alternateClass);
+ writePropertySet(out, property, alternateClass, ignoreList);
}
}
protected void writePropertySet(
PrettyWriter out,
PropertyBean property,
- String propertyClass) throws IOException
+ String propertyClass,
+ Collection ignoreList) throws IOException
{
String propName = property.getPropertyName();
String propVar = Util.getVariableFromName(propName);
String description = property.getDescription();
String setMethod = Util.getPrefixedPropertyName("set", propName);
-
+ if (ignoreList != null && ignoreList.contains(setMethod)){
+ return;
+ }
out.println();
out.println("/**");
if (description != null)
@@ -616,14 +633,17 @@
protected void writePropertyGet(
PrettyWriter out,
- PropertyBean property) throws IOException
+ PropertyBean property,
+ Collection ignoreList) throws IOException
{
String propName = property.getPropertyName();
String propertyFullClass = property.getPropertyClass();
String propertyClass = Util.getClassFromFullClass
(propertyFullClass);
String description = property.getDescription();
String getMethod = Util.getMethodReaderFromProperty(propName,
propertyClass);
-
+ if (ignoreList != null && ignoreList.contains(getMethod)){
+ return;
+ }
boolean isUnchecked = false;
String[] genericTypes = property.getPropertyClassParameters();
if (genericTypes != null && genericTypes.length > 0)
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java
Sat Nov 25 09:41:05 2006
@@ -18,8 +18,10 @@
import
org.apache.myfaces.trinidadbuild.plugin.faces.generator.ClassGenerator;
import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.SourceTemplate;
import java.io.IOException;
+import java.util.Collection;
/**
* Generates component classes
@@ -69,4 +71,9 @@
void writeOther(
PrettyWriter out, ComponentBean component) throws IOException;
+
+
+ void writePropertyMethods(PrettyWriter out,
+ ComponentBean component,
+ Collection ignoreList) throws IOException;
}
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java
Sat Nov 25 09:41:05 2006
@@ -28,6 +28,8 @@
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
+import java.util.Collection;
+import java.util.HashSet;
/**
* TODO: comment this!
@@ -38,70 +40,72 @@
public abstract class AbstractComponentTagGenerator implements
ComponentTagGenerator
{
- public void writeImports(PrettyWriter out,
+ public void writeImports(PrettyWriter out,
SourceTemplate template,
String packageName,
String fullSuperclassName,
String superclassName,
ComponentBean component)
{
- String componentFullClass = component.getComponentClass();
-
- Set imports = new TreeSet();
-
- Iterator properties = component.properties();
- properties = new FilteredIterator(properties, new
TagAttributeFilter());
- //if (properties.hasNext())
- //{
- // imports.add(componentFullClass);
- //}
-
- // TODO: remove these imports
- // FIXME: Actually last 2 can be kept when not abstract
- //imports.add("javax.faces.component.UIComponent");
-
- // superclassName is fully qualified if it collides
- // with the generated class name and should not be
- // imported when such a collision would occur
- if (!superclassName.equals(fullSuperclassName))
- imports.add(fullSuperclassName);
-
- while (properties.hasNext())
- {
- PropertyBean property = (PropertyBean)properties.next();
-
- String propertyClass = property.getPropertyClass();
- String[] propertyClassParams =
property.getPropertyClassParameters();
-
- if (propertyClass != null && property.isLiteralOnly())
- {
- // Import the property class only if only litterals are
supported
- // otherwise the class will be a String inside the tag to
support
- // ValueBinding
- imports.add(propertyClass);
- }
-
-
-
- // TODO: restore import and make reference to
- // ConstantMethodBinding relative rather
- // than absolute
- //if (property.isMethodBinding() &&
- // isStringMethodBindingReturnType(property))
- //{
- // imports.add("
org.apache.myfaces.trinidadinternal.taglib.ConstantMethodBinding");
- //}
- }
+ Collection components = new HashSet();
+ components.add(component);
+ writeImports(out, template, packageName,
fullSuperclassName, superclassName, components);
+ }
- addSpecificImports(imports, component);
- // do not import implicit!
- imports.removeAll(Util.PRIMITIVE_TYPES);
+ public void writeImports(PrettyWriter out, SourceTemplate
template, String packageName, String fullSuperclassName,
+ String
superclassName, Collection components) {
+ Set imports = new TreeSet();
+
+ for (Iterator lIterator = components.iterator();
lIterator.hasNext();) {
+ ComponentBean component = (ComponentBean)
lIterator.next();
+ Iterator properties = component.properties();
+ properties = new FilteredIterator(properties, new
TagAttributeFilter());
+
+ // TODO: remove these imports
+ // FIXME: Actually last 2 can be kept when not
abstract
+ //imports.add("javax.faces.component.UIComponent
");
+
+ // superclassName is fully qualified if it
collides
+ // with the generated class name and should not be
+ // imported when such a collision would occur
+ if (!superclassName.equals(fullSuperclassName)) {
+ imports.add(fullSuperclassName);
+ }
+
+ while (properties.hasNext()) {
+ PropertyBean property = (PropertyBean)
properties.next();
+
+ String propertyClass =
property.getPropertyClass();
+ String[] propertyClassParams =
property.getPropertyClassParameters();
+
+ if (propertyClass != null &&
property.isLiteralOnly()) {
+ // Import the property class only
if only litterals are supported
+ // otherwise the class will be a
String inside the tag to support
+ // ValueBinding
+ imports.add(propertyClass);
+ }
+
+ // TODO: restore import and make reference
to
+ // ConstantMethodBinding relative
rather
+ // than absolute
+ //if (property.isMethodBinding() &&
+
// isStringMethodBindingReturnType(property))
+ //{
+ // imports.add("
org.apache.myfaces.trinidadinternal.taglib.ConstantMethodBinding");
+ //}
+ addSpecificImports(imports, component);
+
+ }
+
+ }
+ // do not import implicit!
+ imports.removeAll(Util.PRIMITIVE_TYPES);
- GeneratorHelper.writeImports(out, packageName, imports);
- }
+ GeneratorHelper.writeImports(out, packageName, imports);
+ }
- public void writeClassBegin(PrettyWriter out,
+ public void writeClassBegin(PrettyWriter out,
String className,
String superclassName,
ComponentBean component,
@@ -194,14 +198,38 @@
}
}
- public void writeReleaseMethod(PrettyWriter out,
+
+ public void writePropertyMembers(PrettyWriter out, Collection
components) throws IOException {
+ for (Iterator lIterator = components.iterator();
lIterator.hasNext();) {
+ writePropertyMembers(out, (ComponentBean)
lIterator.next());
+ }
+ }
+
+ public void writeReleaseMethod(PrettyWriter out,
ComponentBean component) throws
IOException
{
- Iterator properties = component.properties();
- properties = new FilteredIterator(properties, new
TagAttributeFilter());
- // TODO: remove special case for UIXFormTag
- if (properties.hasNext() ||
- "org.apache.myfaces.trinidadinternal.taglib.UIXFormTag
".equals(component.getTagClass()))
+ Collection components = new HashSet();
+ components.add(component);
+ writeReleaseMethod(out, components);
+ }
+
+
+ public void writeReleaseMethod(PrettyWriter out, Collection
components) throws IOException {
+ Collection all = new HashSet();
+ boolean special = false;
+ for (Iterator lIterator = components.iterator();
lIterator.hasNext();) {
+ ComponentBean component = (ComponentBean)
lIterator.next();
+ Iterator prop = component.properties();
+ // TODO: remove special case for UIXFormTag
+ special |= "
org.apache.myfaces.trinidadinternal.taglib.UIXFormTag".equals(
component.getTagClass());
+ while (prop.hasNext()) {
+ all.add(prop.next());
+ }
+ }
+
+ Iterator properties = all.iterator();
+ properties = new FilteredIterator(properties, new
TagAttributeFilter());
+ if (properties.hasNext() || special)
{
out.println();
out.println("@Override");
@@ -219,11 +247,7 @@
out.unindent();
out.println("}");
}
- }
-
- public abstract void writeSetPropertiesMethod(PrettyWriter out,
- String componentClass,
- ComponentBean component) throws
IOException;
+ }
protected void addSpecificImports(
Set imports,
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/ComponentTagGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/ComponentTagGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/ComponentTagGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/ComponentTagGenerator.java
Sat Nov 25 09:41:05 2006
@@ -20,6 +20,7 @@
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
import java.io.IOException;
+import java.util.Collection;
/**
* Generates tag classes
@@ -34,9 +35,16 @@
String componentClass,
ComponentBean component) throws
IOException;
+ void writeSetPropertiesMethod(PrettyWriter out,
+ String componentClass,
+ Collection components) throws
IOException;
+
void writeReleaseMethod(PrettyWriter out,
ComponentBean component) throws IOException;
+ void writeReleaseMethod(PrettyWriter out,
+ Collection components) throws IOException;
+
void writeGetComponentType(PrettyWriter out,
ComponentBean component) throws IOException;
@@ -45,4 +53,7 @@
void writePropertyMembers(PrettyWriter out,
ComponentBean component) throws IOException;
+
+ void writePropertyMembers(PrettyWriter out,
+ Collection components) throws IOException;
}
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
Sat Nov 25 09:41:05 2006
@@ -26,6 +26,8 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
/**
* Component tag generator for myfaces
@@ -74,7 +76,11 @@
if (_is12)
{
imports.add("javax.el.MethodExpression");
- }
+ if (
GeneratorHelper.isActionListener(property, _is12))
+ {
+ imports.add("
javax.faces.event.MethodExpressionActionListener");
+ }
+ }
else
{
imports.add("javax.faces.el.MethodBinding");
@@ -84,7 +90,7 @@
{
imports.add("javax.el.MethodExpression");
}
- else if (GeneratorHelper.isActionListener(property))
+ else if (GeneratorHelper.isActionListener(property, _is12))
{
imports.add("
javax.faces.event.MethodExpressionActionListener");
}
@@ -124,7 +130,25 @@
String componentClass,
ComponentBean component) throws
IOException
{
- Iterator properties = component.properties();
+ Collection components = new HashSet();
+ components.add(component);
+ writeSetPropertiesMethod(out, componentClass, components);
+ }
+
+
+ public void writeSetPropertiesMethod(PrettyWriter out, String
componentClass, Collection components)
+ throws IOException {
+
+ Collection all = new HashSet();
+ for (Iterator lIterator = components.iterator();
lIterator.hasNext();) {
+ ComponentBean component = (ComponentBean)
lIterator.next();
+ Iterator prop = component.properties();
+ while (prop.hasNext()) {
+ all.add(prop.next());
+ }
+ }
+
+ Iterator properties = all.iterator();
properties = new FilteredIterator(properties, new
TagAttributeFilter());
out.println();
@@ -141,10 +165,9 @@
writeSetPropertyMethodBody(out, componentClass, properties);
out.unindent();
out.println("}");
- // }
- }
+ }
- protected void writeSetPropertyMethodBody(PrettyWriter out,
+ protected void writeSetPropertyMethodBody(PrettyWriter out,
String componentClass,
Iterator properties) throws
IOException
{
@@ -257,12 +280,19 @@
if (_is12)
{
- out.println("if (" + propVar + " != null)");
+ out.println("if (" + propVar + " != null)");
+ out.println("{");
out.indent();
- out.println("bean.setProperty(" + componentClass + "." +
propKey + ", " +
- "new MethodExpressionMethodBinding(" + propVar +
"));");
+ if (GeneratorHelper.isActionListener(property,
_is12))
+ {
+ out.println("comp.addActionListener(new
MethodExpressionActionListener(" + propVar + "));");
+ } else {
+ out.println("bean.setProperty(" +
componentClass + "." + propKey + ", " +
+ "new
MethodExpressionMethodBinding(" + propVar + "));");
+ }
out.unindent();
- }
+ out.println("}");
+ }
else
{
MethodSignatureBean signature =
property.getMethodBindingSignature();
@@ -338,7 +368,7 @@
{
out.println("comp.setActionExpression("+propVar+");");
}
- else if (GeneratorHelper.isActionListener(property))
+ else if (GeneratorHelper.isActionListener(property, _is12))
{
out.println("comp.addActionListener(new
MethodExpressionActionListener(" + propVar + "));");
}
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
Sat Nov 25 09:41:05 2006
@@ -26,6 +26,8 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
/**
* TODO: comment this!
@@ -164,7 +166,24 @@
String componentClass,
ComponentBean component) throws
IOException
{
- Iterator properties = component.properties();
+ Collection components = new HashSet();
+ components.add(component);
+ writeSetPropertiesMethod(out, componentClass, components);
+ }
+
+
+ public void writeSetPropertiesMethod(PrettyWriter out, String
componentClass, Collection components)
+ throws IOException {
+ Collection all = new HashSet();
+ for (Iterator lIterator = components.iterator();
lIterator.hasNext();) {
+ ComponentBean component = (ComponentBean)
lIterator.next();
+ Iterator prop = component.properties();
+ while (prop.hasNext()) {
+ all.add(prop.next());
+ }
+ }
+
+ Iterator properties = all.iterator();
properties = new FilteredIterator(properties, new
TagAttributeFilter());
// TODO: only write out setProperties when properties exist
// if (properties.hasNext())
@@ -182,9 +201,9 @@
out.unindent();
out.println("}");
// }
- }
+ }
- protected void writeSetPropertyMethodBody(PrettyWriter out,
+ protected void writeSetPropertyMethodBody(PrettyWriter out,
String componentClass,
Iterator properties) throws
IOException
{
Modified:
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
URL:
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java?view=diff&rev=479151&r1=479150&r2=479151
==============================================================================
---
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
(original)
+++
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
Sat Nov 25 09:41:05 2006
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.Collection;
public class SourceTemplate
{
@@ -100,8 +101,15 @@
if (line == null)
throw new EOFException("File " + _file + " ended prematurely");
- if (line.trim().startsWith(_IGNORE_PREFIX))
- continue;
+ if (line.trim().startsWith(_IGNORE_PREFIX)){
+ if (line.trim().startsWith(_IGNORE_PREFIX2)){
+ String method = line.trim
().substring(_IGNORE_PREFIX2.length()).trim();
+ if (method.length() > 0 ){
+ _ignoreMethods.add(method);
+ }
+ }
+ continue;
+ }
if (line.equals("}"))
break;
@@ -146,13 +154,19 @@
return buffer.toString();
}
- private File _file;
+ public Collection getIgnoreMethods() {
+ return _ignoreMethods;
+ }
+
+ private File _file;
private BufferedReader _reader;
private Set _imports = new HashSet();
private Map _fqcnMap = new HashMap();
private Set _implements = new HashSet();
private Map _substitutions = new HashMap();
+ private Set _ignoreMethods = new HashSet();
// Magic syntax indicating "please ignore this line"
static private final String _IGNORE_PREFIX = "/**/";
+ static private final String _IGNORE_PREFIX2 = "/**///";
}