JBoss Rich Faces SVN: r3627 - in trunk/ui/tooltip/src: main/java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-10-30 19:16:45 -0400 (Tue, 30 Oct 2007)
New Revision: 3627
Modified:
trunk/ui/tooltip/src/main/config/component/toolTip.xml
trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java
trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
trunk/ui/tooltip/src/test/java/org/richfaces/renderkit/html/ToolTipRendererTest.java
Log:
http://jira.jboss.com/jira/browse/RF-1269
Modified: trunk/ui/tooltip/src/main/config/component/toolTip.xml
===================================================================
--- trunk/ui/tooltip/src/main/config/component/toolTip.xml 2007-10-30 20:39:59 UTC (rev 3626)
+++ trunk/ui/tooltip/src/main/config/component/toolTip.xml 2007-10-30 23:16:45 UTC (rev 3627)
@@ -80,6 +80,11 @@
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
+ <property>
+ <name>for</name>
+ <classname>java.lang.String</classname>
+ <description>Id of the target component.</description>
+ </property>
<property>
Modified: trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java 2007-10-30 20:39:59 UTC (rev 3626)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/component/UIToolTip.java 2007-10-30 23:16:45 UTC (rev 3627)
@@ -105,7 +105,10 @@
public abstract void setZorder(int delay);
+ public abstract String getFor();
+ public abstract void setFor(String _for);
+
public String getUsedElementType(){
return getLayout().equals("block") ? "div" : "span";
}
Modified: trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java
===================================================================
--- trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-10-30 20:39:59 UTC (rev 3626)
+++ trunk/ui/tooltip/src/main/java/org/richfaces/renderkit/html/ToolTipRenderer.java 2007-10-30 23:16:45 UTC (rev 3627)
@@ -135,18 +135,19 @@
}
- public Map buildEventOptions(FacesContext context, UIComponent component){
+ public Map buildEventOptions(FacesContext context, UIComponent component, String targetId){
Map eventOptions = AjaxRendererUtils.buildEventOptions(context, component);
+ String jsVarName = "Richfaces.tooltips[\'" + targetId + "\']";
//after element is subsituted in DOM tree, we have to re-create
//it's JS-reference, cause old one is already invalid
- String refreshTooltipInDOM = ";" + getJsVarName(context, component) + ".toolTip = $('" + component.getClientId(context) + "');" +
- ";" + getJsVarName(context, component) + ".toolTipContent = $('" + component.getClientId(context) + "content');";
+ String refreshTooltipInDOM = ";" + jsVarName + ".toolTip = $('" + component.getClientId(context) + "');" +
+ ";" + jsVarName + ".toolTipContent = $('" + component.getClientId(context) + "content');";
- String showNewToolTip = ";" + getJsVarName(context, component) + ".displayDiv();";
+ String showNewToolTip = ";" + jsVarName + ".displayDiv();";
// before element will be substituted in DOM tree, we need to hide toolTipe to avoid blinking
- String fireBeforeUpdateDOM = ";" + getJsVarName(context, component) + ".toolTip.style.display = 'none';";
+ String fireBeforeUpdateDOM = ";" + jsVarName + ".toolTip.style.display = 'none';";
//enable ajaxSingle mode, i.e. we do not need to submit all form controls to get tooltip content
@@ -204,10 +205,26 @@
writer.write(ret.toString());
}
+
+ private String getTargetId(FacesContext context, UIComponent component) {
+ UIToolTip toolTip = (UIToolTip) component;
+ String forValue = toolTip.getFor();
+
+ if (forValue != null && forValue.length() != 0) {
+ UIComponent targetComponent = component.findComponent(forValue);
+ if (targetComponent != null) {
+ return targetComponent.getClientId(context);
+ } else {
+ return forValue;
+ }
+ } else {
+ return component.getParent().getClientId(context);
+ }
+ }
public String constructJSVariable(FacesContext context, UIComponent component) {
UIToolTip toolTip = (UIToolTip)component;
- String parentClientId = toolTip.getParent().getClientId(context);
+ String targetClientId = getTargetId(context, component);
StringBuffer ret = new StringBuffer();
String comma = ",";
String quot = "\"";
@@ -229,10 +246,10 @@
function.addParameter(ref);
String ajaxFunc = function.toScript();
- Map ajaxOptions = buildEventOptions(context, toolTip);
+ Map ajaxOptions = buildEventOptions(context, toolTip, targetClientId);
ret.append("new ToolTip(" + ScriptUtils.toScript(eventsMap)).append(comma).append(quot).append( toolTip.getClientId(context)).append(quot).append(comma).
- append(quot).append(parentClientId).append(quot).append(comma).
+ append(quot).append(targetClientId).append(quot).append(comma).
append(quot).append(toolTip.getMode()).append(quot).append(comma).
append(toolTip.isDisabled()).append(comma).
append(quot).append(toolTip.getDirection()).append(quot).append(comma).
@@ -245,10 +262,6 @@
}
- private String getJsVarName(FacesContext context, UIComponent component){
- return "Richfaces.tooltips[\'" + component.getParent().getClientId(context) + "\']";
- }
-
protected void doDecode(FacesContext context, UIComponent component) {
UIToolTip tooltip = (UIToolTip)component;
Modified: trunk/ui/tooltip/src/test/java/org/richfaces/renderkit/html/ToolTipRendererTest.java
===================================================================
--- trunk/ui/tooltip/src/test/java/org/richfaces/renderkit/html/ToolTipRendererTest.java 2007-10-30 20:39:59 UTC (rev 3626)
+++ trunk/ui/tooltip/src/test/java/org/richfaces/renderkit/html/ToolTipRendererTest.java 2007-10-30 23:16:45 UTC (rev 3627)
@@ -1,13 +1,10 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlOutputText;
-import javax.faces.context.FacesContext;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.richfaces.component.UIToolTip;
@@ -104,7 +101,8 @@
public void testBuildEventOptions(){
- Map eventOptions = renderer.buildEventOptions(facesContext, toolTip);
+ Map eventOptions = renderer.buildEventOptions(facesContext, toolTip,
+ toolTip.getParent().getClientId(facesContext));
assertNotNull(eventOptions);
assertNotNull(eventOptions.get("oncomplete"));
}
17 years, 1 month
JBoss Rich Faces SVN: r3626 - in trunk/cdk/generator/src/main: java/org/ajax4jsf/builder/component and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-10-30 16:39:59 -0400 (Tue, 30 Oct 2007)
New Revision: 3626
Added:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/ELPropertyAccessorMethodBody.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/VelocityMethodBody.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/AttachedStateDescriptor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateDescriptor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateManager.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/PrimitiveStateDescriptor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/SimplePropertyDescriptor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator2.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaConstructor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPrimitive.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaFieldRenderer.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaMethodRenderer.java
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/el-property-accessor.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-el-property-accessor.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-accessor.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-mutator.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/restore-state.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/save-state.vm
Removed:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ComponentModelBuilder.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/MethodRenderer.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ObjectPropertyProcessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/PropertyProcessor.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/methods/
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessorMethodBody.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutatorMethodBody.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/PropertyBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/Argument.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaAnnotation.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaClass.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaComment.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaField.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaLanguageElement.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaMethod.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaModifier.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPackage.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/MethodBody.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaClassRenderer.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaLanguageElementRenderer.java
Log:
added Java Class model to be able to generate java class sources on the fly.
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java (from rev 3610, trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ComponentModelBuilder.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,204 @@
+/**
+ * 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.ajax4jsf.builder.component;
+
+import static org.ajax4jsf.builder.model.Argument.arg;
+
+import java.util.Collection;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.builder.component.state.ComponentStateManager;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.RendererBean;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.JavaClass;
+import org.ajax4jsf.builder.model.JavaConstructor;
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.JavaModifier;
+import org.ajax4jsf.builder.model.JavaPackage;
+import org.ajax4jsf.builder.model.MethodBody;
+
+/**
+ * Build component class model from configs
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentModelBuilder {
+
+ private PropertyProcessor[] propertyProcessors = {
+ new PrimitivePropertyProcessor(),
+ new ELPropertyProcessor(),
+ new ComponentPropertyProcessor()};
+
+ public JavaClass build(ComponentBean componentBean, JSFGeneratorConfiguration configuration) {
+
+ String superclassname =
+ componentBean.getSuperclass();
+
+ JavaClass javaClass =
+ new JavaClass(componentBean.getSimpleClassName(),
+ new JavaPackage(componentBean.getPackageName()));
+
+ try {
+ Class<?> superClass =
+ Class.forName(superclassname, false, configuration.getClassLoader());
+
+ javaClass.setSuperClass(superClass);
+
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ javaClass.setSuperClass(UIComponentBase.class);
+ }
+
+ javaClass.addModifier(JavaModifier.PUBLIC);
+
+ javaClass.addField(getComponentFamily(componentBean));
+ javaClass.addField(getComponentType(componentBean));
+
+ javaClass.addMethod(getConstructor(componentBean, javaClass));
+
+ Collection<PropertyBean> properties = componentBean.getProperties();
+
+ for (PropertyBean propertyBean : properties) {
+ PropertyProcessor proc = null;
+
+ for (int i = 0; i < propertyProcessors.length && proc == null; i++) {
+
+ PropertyProcessor processor =
+ propertyProcessors[i];
+
+ if (processor.accept(propertyBean)) {
+ proc = processor;
+ }
+ }
+
+ if (proc != null) {
+ proc.process(propertyBean, javaClass, configuration);
+ }
+ }
+
+ javaClass.addMethod(getComponentFamilyMethod(componentBean));
+
+ ComponentStateManager stateManager = new ComponentStateManager(javaClass);
+
+ JavaMethod saveState = getSaveStateTemplate();
+ try {
+ saveState.setMethodBody(stateManager.getSaveStateMethodBody(configuration));
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+ javaClass.addMethod(saveState);
+
+ JavaMethod restoreState = getRestoreStateTemplate();
+ try {
+ restoreState.setMethodBody(stateManager.getRestoreStateMethodBody(configuration));
+ } catch (GeneratorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ javaClass.addMethod(restoreState);
+
+
+
+ return javaClass;
+
+ }
+
+ private JavaMethod getComponentFamilyMethod(ComponentBean componentBean) {
+ JavaMethod javaMethod = new JavaMethod("getFamily", String.class);
+ javaMethod.addModifier(JavaModifier.PUBLIC);
+ javaMethod.setMethodBody(new MethodBody() {
+ @Override
+ public String toCode() {
+ return "return COMPONENT_FAMILY;";
+ }
+ });
+ return javaMethod;
+ }
+
+ private JavaMethod getRestoreStateTemplate() {
+ JavaMethod method =
+ new JavaMethod("restoreState",
+ Void.TYPE,
+ arg("context", FacesContext.class),
+ arg("state", Object.class));
+ method.addModifier(JavaModifier.PUBLIC);
+ method.addAnnotation(Override.class);
+
+ return method;
+ }
+
+ private JavaMethod getSaveStateTemplate() {
+ JavaMethod method =
+ new JavaMethod("saveState",
+ Object.class,
+ arg("context", FacesContext.class));
+ method.addModifier(JavaModifier.PUBLIC);
+ method.addAnnotation(Override.class);
+ method.setMethodBody(new MethodBody() {
+ @Override
+ public String toCode() {
+ return "return super.saveState(context);";
+ }
+ });
+ return method;
+ }
+
+ private JavaField getComponentType(ComponentBean componentBean) {
+ JavaField field = new JavaField(String.class, "COMPONENT_TYPE");
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addModifier(JavaModifier.STATIC);
+ field.addModifier(JavaModifier.FINAL);
+ field.setValue("\"" + componentBean.getName() + "\"");
+ return field;
+ }
+ private JavaField getComponentFamily(ComponentBean componentBean) {
+ JavaField field = new JavaField(String.class, "COMPONENT_FAMILY");
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addModifier(JavaModifier.STATIC);
+ field.addModifier(JavaModifier.FINAL);
+ field.setValue("\"" + componentBean.getFamily() + "\"");
+ return field;
+ }
+
+ private JavaMethod getConstructor(ComponentBean componentBean, JavaClass javaClass) {
+ final RendererBean renderer = componentBean.getRenderer();
+ JavaMethod method = new JavaConstructor(javaClass);
+ method.addModifier(JavaModifier.PUBLIC);
+ method.setMethodBody(new MethodBody(method) {
+ @Override
+ public String toCode() {
+ if (renderer != null) {
+ return "setRendererType(\"" + renderer.getName() + "\");";
+ }
+ return super.toCode();
+ }
+ });
+
+ return method;
+ }
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,120 @@
+/**
+ * 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.ajax4jsf.builder.component;
+
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.Argument;
+import org.ajax4jsf.builder.model.JavaClass;
+import org.ajax4jsf.builder.model.JavaComment;
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.JavaModifier;
+import org.ajax4jsf.builder.model.JavaPrimitive;
+import org.ajax4jsf.builder.model.MethodBody;
+
+/**
+ * Default property handler - a fallback one.
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentPropertyProcessor implements PropertyProcessor {
+
+ public boolean accept(PropertyBean propertyBean) {
+ return !propertyBean.isExist();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.render.PropertyProcessor#process(org.ajax4jsf.builder.config.PropertyBean, org.ajax4jsf.builder.model.JavaClass)
+ */
+ public void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ JavaField field = getField(propertyBean, configuration.getClassLoader());
+
+ javaClass.addField(field);
+ javaClass.addMethod(getAccessor(configuration, propertyBean, field));
+ javaClass.addMethod(getMutator(configuration, propertyBean, field));
+ }
+
+ protected JavaField getField(PropertyBean propertyBean, ClassLoader classLoader) {
+ String name = propertyBean.getName();
+ String defaultvalue = propertyBean.getDefaultvalue();
+ Class<?> propertyClass = getType(propertyBean, classLoader);
+ JavaField field = new JavaField(propertyClass, "_" + name, defaultvalue);
+ field.getComments().add(new JavaComment(propertyBean.getDescription()));
+ field.getModifiers().add(JavaModifier.PRIVATE);
+
+ return field;
+ }
+
+ protected Class<?> getType(PropertyBean propertyBean, ClassLoader classLoader) {
+ if (propertyBean.isSimpleType()) {
+ try {
+ Class<?> clazz = JavaPrimitive.forName(propertyBean.getClassname());
+ return clazz;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ Class<?> clazz = Class.forName(propertyBean.getClassname(), false, classLoader);
+ return clazz;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ return Object.class;
+ }
+
+ protected JavaMethod getAccessor(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
+ JavaMethod accessor =
+ new JavaMethod(propertyBean.getGetterName(), field.getType());
+
+ accessor.setMethodBody(new MethodBody() {
+ @Override
+ public String toCode() {
+ return "return " + field.getName() + ";";
+ }
+ });
+
+ accessor.addModifier(JavaModifier.PUBLIC);
+
+ return accessor;
+ }
+
+ protected JavaMethod getMutator(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
+ JavaMethod mutator =
+ new JavaMethod(propertyBean.getSetterName(),
+ new Argument(field.getName(), field.getType()));
+
+ mutator.setMethodBody(new MethodBody(mutator) {
+ @Override
+ public String toCode() {
+ return "this." + field.getName() + " = " + field.getName() + ";";
+ }
+ });
+
+ mutator.addModifier(JavaModifier.PUBLIC);
+
+ return mutator;
+ }
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,64 @@
+/**
+ * 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.ajax4jsf.builder.component;
+
+import org.ajax4jsf.builder.component.methods.ELPropertyAccessorMethodBody;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.MethodBody;
+
+/**
+ * Processing of EL-enabled properties
+ * @author Maksim Kaszynski
+ *
+ */
+public class ELPropertyProcessor extends ComponentPropertyProcessor {
+
+ @Override
+ public boolean accept(PropertyBean propertyBean) {
+ return !(propertyBean.isExist() || propertyBean.isSimpleType() || propertyBean.isElonly()) && propertyBean.isEl() ;
+ }
+
+ @Override
+ protected JavaMethod getAccessor(JSFGeneratorConfiguration config, PropertyBean propertyBean, JavaField field) {
+ field.setValue("null");
+
+ JavaMethod accessor = super.getAccessor(config, propertyBean, field);
+
+ try {
+ ELPropertyAccessorMethodBody propertyAccessorMethodBody =
+ new ELPropertyAccessorMethodBody(config, propertyBean, field);
+
+ accessor.setMethodBody(propertyAccessorMethodBody);
+
+ } catch (GeneratorException e) {
+ accessor.setMethodBody(new MethodBody());
+ e.printStackTrace();
+ }
+
+ return accessor;
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,139 @@
+/**
+ * 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.ajax4jsf.builder.component;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+
+import org.ajax4jsf.builder.component.methods.VelocityMethodBody;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.JavaClass;
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.JavaModifier;
+import org.ajax4jsf.builder.model.JavaPrimitive;
+import org.ajax4jsf.builder.model.MethodBody;
+
+/**
+ * Handle primitive properties
+ * @author Maksim Kaszynski
+ *
+ */
+public class PrimitivePropertyProcessor extends ComponentPropertyProcessor {
+
+ class PrimitiveELPropertyAccessorMethodBody extends VelocityMethodBody {
+
+ public PrimitiveELPropertyAccessorMethodBody(
+ JSFGeneratorConfiguration configuration, JavaField field, JavaField field2, PropertyBean property)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("field1", field);
+ getContext().put("field2", field2);
+ getContext().put("wrapperClass", JavaPrimitive.wrapperType(field.getType()));
+ getContext().put("property", property);
+ addType(ValueExpression.class);
+ addType(ELException.class);
+ addType(FacesException.class);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/primitive-el-property-accessor.vm";
+ }
+ }
+
+ class PrimitivePropertyAccessorMethodBody extends VelocityMethodBody {
+
+ public PrimitivePropertyAccessorMethodBody(
+ JSFGeneratorConfiguration configuration, JavaField field, JavaField field2)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("field1", field);
+ getContext().put("field2", field2);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/primitive-property-accessor.vm";
+ }
+ }
+
+ class PrimitivePropertyMutatorMethodBody extends VelocityMethodBody {
+
+ public PrimitivePropertyMutatorMethodBody(
+ JSFGeneratorConfiguration configuration, JavaField field, JavaField field2)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("field1", field);
+ getContext().put("field2", field2);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/primitive-property-mutator.vm";
+ }
+ }
+
+ @Override
+ public boolean accept(PropertyBean propertyBean) {
+ return propertyBean.isSimpleType() && super.accept(propertyBean);
+ }
+
+ @Override
+ public void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ JavaField field = getField(propertyBean, configuration.getClassLoader());
+ JavaField field2 = new JavaField(boolean.class, field.getName() + "Set", "false");
+ field2.addModifier(JavaModifier.PRIVATE);
+
+ JavaMethod accessor = getAccessor(configuration, propertyBean, field);
+ MethodBody accessorMethodBody;
+
+ try {
+ if (propertyBean.isEl()) {
+ accessorMethodBody = new PrimitiveELPropertyAccessorMethodBody(configuration, field, field2, propertyBean);
+ } else {
+ accessorMethodBody = new PrimitivePropertyAccessorMethodBody(configuration, field, field2);
+ }
+ accessor.setMethodBody(accessorMethodBody);
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+
+ JavaMethod mutator = getMutator(configuration, propertyBean, field);
+
+ try {
+ PrimitivePropertyMutatorMethodBody mutatorBody = new PrimitivePropertyMutatorMethodBody(configuration, field, field2);
+ mutator.setMethodBody(mutatorBody);
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+
+ javaClass.addField(field);
+ javaClass.addField(field2);
+ javaClass.addMethod(accessor);
+ javaClass.addMethod(mutator);
+ }
+
+}
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java (from rev 3610, trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/PropertyProcessor.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,36 @@
+/**
+ * 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.ajax4jsf.builder.component;
+
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.JavaClass;
+
+/**
+ * Process single property - add field to class, accessor, mutator, etc.
+ * @author Maksim Kaszynski
+ *
+ */
+public interface PropertyProcessor {
+ boolean accept(PropertyBean propertyBean);
+ void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration);
+}
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods (from rev 3610, trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/methods)
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/ELPropertyAccessorMethodBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/ELPropertyAccessorMethodBody.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/ELPropertyAccessorMethodBody.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,58 @@
+/**
+ * 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.ajax4jsf.builder.component.methods;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.JavaField;
+
+/**
+ * Render accessor for EL-enabled property
+ * @author Maksim Kaszynski
+ *
+ */
+public class ELPropertyAccessorMethodBody extends VelocityMethodBody {
+
+ public ELPropertyAccessorMethodBody(JSFGeneratorConfiguration configuration,
+ PropertyBean propertyBean,
+ JavaField field)
+ throws GeneratorException {
+ super(configuration);
+
+ getContext().put("field", field);
+ getContext().put("property", propertyBean);
+ addType(ValueExpression.class);
+ addType(ELException.class);
+ addType(FacesException.class);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/el-property-accessor.vm";
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,40 @@
+/**
+ * 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.ajax4jsf.builder.component.methods;
+
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.JavaModifier;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SimpleAccessor extends JavaMethod {
+
+ public SimpleAccessor(String name, JavaField field) {
+ super(name, field.getType());
+ addModifier(JavaModifier.PUBLIC);
+ setMethodBody(new SimpleAccessorMethodBody(this, field));
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessorMethodBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/methods/SimpleAccessorMethodBody.java 2007-10-30 01:07:16 UTC (rev 3610)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessorMethodBody.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,8 +1,26 @@
/**
- *
+ * 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.ajax4jsf.builder.render.methods;
+package org.ajax4jsf.builder.component.methods;
+
import org.ajax4jsf.builder.model.JavaField;
import org.ajax4jsf.builder.model.JavaMethod;
import org.ajax4jsf.builder.model.MethodBody;
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutator.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,40 @@
+/**
+ * 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.ajax4jsf.builder.component.methods;
+
+import org.ajax4jsf.builder.model.Argument;
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.JavaModifier;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SimpleMutator extends JavaMethod {
+
+ public SimpleMutator(String name, JavaField field) {
+ super(name, new Argument(field.getName().substring(1), field.getType()));
+ addModifier(JavaModifier.PUBLIC);
+ setMethodBody(new SimpleMutatorMethodBody(this, field));
+ }
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutatorMethodBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/methods/SimpleMutatorMethodBody.java 2007-10-30 01:07:16 UTC (rev 3610)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutatorMethodBody.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,8 +1,26 @@
/**
- *
+ * 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.ajax4jsf.builder.render.methods;
+package org.ajax4jsf.builder.component.methods;
+
import org.ajax4jsf.builder.model.JavaField;
import org.ajax4jsf.builder.model.JavaMethod;
import org.ajax4jsf.builder.model.MethodBody;
@@ -15,6 +33,11 @@
private JavaField field;
+ public SimpleMutatorMethodBody(JavaMethod method, JavaField field) {
+ super(method);
+ this.field = field;
+ }
+
protected JavaField getField() {
return field;
}
@@ -23,11 +46,6 @@
this.field = field;
}
- public SimpleMutatorMethodBody(JavaMethod method, JavaField field) {
- super(method);
- this.field = field;
- }
-
@Override
public String toCode() {
return field.getName() + " = " + getMethod().getArguments().get(0).getName();
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/VelocityMethodBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/VelocityMethodBody.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/VelocityMethodBody.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,76 @@
+/**
+ * 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.ajax4jsf.builder.component.methods;
+
+import java.io.StringWriter;
+
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.MethodBody;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * Render method body by using Velocity
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class VelocityMethodBody extends MethodBody {
+
+ private Template template;
+ private VelocityContext context;
+
+ public abstract String getTemplate();
+
+ protected Template loadTemplate(String id, JSFGeneratorConfiguration configuration) throws GeneratorException{
+ return configuration.getTemplate(configuration.getTemplatesPath() + "/" + id);
+ }
+
+ public VelocityMethodBody(JSFGeneratorConfiguration configuration) throws GeneratorException{
+ String t = getTemplate();
+ try {
+ template = loadTemplate(t, configuration);
+ } catch (Exception e) {
+
+ }
+ context = new VelocityContext();
+ }
+
+ protected VelocityContext getContext() {
+ return context;
+ }
+
+ @Override
+ public String toCode() {
+
+ StringWriter stringWriter = new StringWriter();
+
+ try {
+ template.merge(context, stringWriter);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return stringWriter.toString();
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/AttachedStateDescriptor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/AttachedStateDescriptor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/AttachedStateDescriptor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,51 @@
+/**
+ * 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.ajax4jsf.builder.component.state;
+
+import org.ajax4jsf.builder.model.JavaField;
+
+/**
+ * Save attached state,
+ * @author Maksim Kaszynski
+ *
+ */
+public class AttachedStateDescriptor extends ComponentStateDescriptor {
+
+ private static final String restoreTemplate = "(%s)restoreAttachedState(context, %s)";
+
+ private static final String saveTemplate = "saveAttachedState(context, %s)";
+
+
+ public AttachedStateDescriptor(JavaField field) {
+ super(field);
+ }
+
+ @Override
+ public String saveStateCode() {
+ return String.format(saveTemplate, getField().getName());
+ }
+
+ @Override
+ public String restoreStateCode(String stateFragment) {
+ return String.format(restoreTemplate, getField().getType().getSimpleName(), stateFragment);
+ }
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateDescriptor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateDescriptor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateDescriptor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,52 @@
+/**
+ * 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.ajax4jsf.builder.component.state;
+
+import org.ajax4jsf.builder.model.JavaField;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentStateDescriptor {
+
+ private JavaField field;
+
+ public ComponentStateDescriptor(JavaField field) {
+ super();
+ this.field = field;
+
+ }
+
+ public JavaField getField() {
+ return field;
+ }
+
+ public String saveStateCode() {
+ return "null";
+ }
+
+ public String restoreStateCode(String stateFragment) {
+ return "null";
+ }
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateManager.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateManager.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateManager.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,138 @@
+/**
+ * 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.ajax4jsf.builder.component.state;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.ajax4jsf.builder.component.methods.VelocityMethodBody;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.model.JavaClass;
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaModifier;
+import org.ajax4jsf.builder.model.MethodBody;
+
+/**
+ * Class responsible for generating save/restore state methods.
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentStateManager {
+
+ private class SaveStateMethodBody extends VelocityMethodBody {
+
+ public SaveStateMethodBody(JSFGeneratorConfiguration configuration)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("size", componentStates.size() + 1);
+ getContext().put("descriptors", componentStates);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/save-state.vm";
+ }
+ }
+
+ private class RestoreStateMethodBody extends VelocityMethodBody {
+
+ public RestoreStateMethodBody(JSFGeneratorConfiguration configuration)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("size", componentStates.size() + 1);
+ getContext().put("descriptors", componentStates);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/restore-state.vm";
+ }
+
+ }
+
+
+ @SuppressWarnings("serial")
+ private static final List<Class<?>> detached = new ArrayList<Class<?>>() {
+ {
+ add(String.class);
+ add(Integer.class);
+ add(Boolean.class);
+ add(Long.class);
+ add(Float.class);
+ add(Double.class);
+ add(BigDecimal.class);
+ }
+ };
+
+ private List<ComponentStateDescriptor> componentStates =
+ new ArrayList<ComponentStateDescriptor>();
+
+
+ public ComponentStateManager(JavaClass componentClass) {
+ List<JavaField> fields = componentClass.getFields();
+ for (JavaField javaField : fields) {
+ registerField(javaField);
+ }
+ }
+
+ public ComponentStateDescriptor getDesriptor(PropertyBean propertyBean, JavaField field) {
+
+ Set<JavaModifier> modifiers = field.getModifiers();
+ if (modifiers.contains(JavaModifier.FINAL) || modifiers.contains(JavaModifier.STATIC)){
+ return null;
+ }
+
+ Class<?> type = field.getType();
+ if (type.isPrimitive()) {
+ return new PrimitiveStateDescriptor(field);
+ }
+ if (detached.contains(type)) {
+ return new SimplePropertyDescriptor(field);
+ }
+
+ return new AttachedStateDescriptor(field);
+ }
+
+
+
+ public void registerField(JavaField field) {
+ ComponentStateDescriptor desriptor = getDesriptor(null, field);
+ if (desriptor != null){
+ componentStates.add(desriptor);
+ }
+ }
+
+ public MethodBody getSaveStateMethodBody(JSFGeneratorConfiguration configuration)
+ throws GeneratorException{
+ return new SaveStateMethodBody(configuration);
+ }
+
+ public MethodBody getRestoreStateMethodBody(JSFGeneratorConfiguration configuration)
+ throws GeneratorException{
+ return new RestoreStateMethodBody(configuration);
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/PrimitiveStateDescriptor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/PrimitiveStateDescriptor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/PrimitiveStateDescriptor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,54 @@
+/**
+ * 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.ajax4jsf.builder.component.state;
+
+import org.ajax4jsf.builder.model.JavaField;
+import org.ajax4jsf.builder.model.JavaPrimitive;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class PrimitiveStateDescriptor extends ComponentStateDescriptor {
+
+ private static final String saveTemplate = "%s.valueOf(%s)";
+ private static final String restoreTemplate = "((%s)%s).%sValue()";
+
+ private Class<?> wrapperType;
+
+
+ public PrimitiveStateDescriptor(JavaField field) {
+ super(field);
+ wrapperType = JavaPrimitive.wrapperType(field.getType());
+ }
+
+ @Override
+ public String restoreStateCode(String stateFragment) {
+ return String.format(restoreTemplate, wrapperType.getSimpleName(), stateFragment, getField().getType().getSimpleName());
+ }
+
+ @Override
+ public String saveStateCode() {
+ return String.format(saveTemplate, wrapperType.getSimpleName(), getField().getName());
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/SimplePropertyDescriptor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/SimplePropertyDescriptor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/SimplePropertyDescriptor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,45 @@
+/**
+ * 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.ajax4jsf.builder.component.state;
+
+import org.ajax4jsf.builder.model.JavaField;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SimplePropertyDescriptor extends ComponentStateDescriptor {
+
+ public SimplePropertyDescriptor(JavaField field) {
+ super(field);
+ }
+
+ @Override
+ public String saveStateCode() {
+ return getField().getName();
+ }
+
+ @Override
+ public String restoreStateCode(String stateFragment) {
+ return "(" + getField().getType().getSimpleName() + ")" + stateFragment + ";";
+ }
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -139,14 +139,14 @@
getLog().debug("Parse properties for Component "+getName()+" with superclass "+getSuperclass());
if (getSuperclass() != null)
{
- Class superClass = getLoader().loadClass(getSuperclass());
+ Class <?> superClass = getLoader().loadClass(getSuperclass());
- Class superSuperClass = superClass;
+ Class<?> superSuperClass = superClass;
while (null != superSuperClass ) {
- Class[] interfaces = superSuperClass.getInterfaces();
+ Class<?>[] interfaces = superSuperClass.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
- Class interfaceClass = interfaces[i];
+ Class<?> interfaceClass = interfaces[i];
checkPropertiesForClass(interfaceClass);
}
superSuperClass = superSuperClass.getSuperclass();
@@ -205,7 +205,7 @@
/**
* @param superClass
*/
- private void checkPropertiesForClass(Class superClass) {
+ private void checkPropertiesForClass(Class<?> superClass) {
getLog().debug("Check properties for class "+superClass.getName());
// get all property descriptors
PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
@@ -218,7 +218,7 @@
if(isIgnorableProperty(superClass, descriptor.getName())) {
continue;
}
- Class type = descriptor.getPropertyType();
+ Class<?> type = descriptor.getPropertyType();
getLog().debug("Register property "+descriptor.getName()+" with type name "+type.getCanonicalName());
property = new PropertyBean();
property.setName(descriptor.getName());
@@ -250,7 +250,7 @@
Method setter = descriptor.getWriteMethod();
// Abstract methods
if(null != setter && null != getter ){
- if( Modifier.isAbstract(getter.getModifiers()) && Modifier.isAbstract(setter.getModifiers())&& Modifier.isPublic(setter.getModifiers()) ){
+ if( (Modifier.isAbstract(getter.getModifiers()) && Modifier.isAbstract(setter.getModifiers())) || superClass.isInterface()){
getLog().debug("Detect as abstract property "+descriptor.getName());
property.setExist(false);
}
@@ -270,7 +270,7 @@
}
}
- private boolean isIgnorableProperty(Class base, String name) {
+ private boolean isIgnorableProperty(Class<?> base, String name) {
return Arrays.asList(ignorableComponentProperties).contains(name);
}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/PropertyBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/PropertyBean.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/PropertyBean.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -389,4 +389,5 @@
}
return null;
}
+
}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator2.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator2.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator2.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,96 @@
+/**
+ * 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.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.List;
+
+import org.ajax4jsf.builder.component.ComponentModelBuilder;
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.model.JavaClass;
+import org.ajax4jsf.builder.render.JavaClassRenderer;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentGenerator2 extends InnerGenerator {
+
+ private ComponentModelBuilder componentModelBuilder = new ComponentModelBuilder();
+ private JavaClassRenderer classRenderer = new JavaClassRenderer();
+
+ public ComponentGenerator2(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.generator.InnerGenerator#createFiles(org.ajax4jsf.builder.config.BuilderConfig)
+ */
+ @Override
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ List<ComponentBean> components = config.getComponents();
+ for (ComponentBean componentBean : components) {
+ if (componentBean.isGenerate()) {
+ JavaClass componentClass =
+ componentModelBuilder.build(componentBean, getConfig());
+
+ String resultPath = componentBean.getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ PrintWriter printWriter = new PrintWriter(out);
+
+ classRenderer.render(componentClass, printWriter);
+
+ printWriter.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Component Java file ", e);
+ }
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.generator.InnerGenerator#getDefaultTemplateName()
+ */
+ @Override
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/Argument.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/Argument.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/Argument.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,9 +1,28 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
/**
+ * Representation of method argument
* @author Maksim Kaszynski
*
*/
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaAnnotation.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaAnnotation.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaAnnotation.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,19 +1,44 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
+
+
/**
+ * Wrapper for '@annotations
* @author Maksim Kaszynski
*
*/
-public class JavaAnnotation extends JavaLanguageElement{
+public class JavaAnnotation {
- public static JavaAnnotation OVERRIDE = new JavaAnnotation("Override");
+ private Class<?> type;
+
+ public JavaAnnotation(Class<?> type) {
+ super();
+ this.type = type;
+ }
- public JavaAnnotation(String name) {
- super(name);
+ public Class<?> getType() {
+ return type;
}
-
}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaClass.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaClass.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaClass.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,21 +1,47 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
/**
+ * Java Class model.
+ * Intended for building java classes.
* @author Maksim Kaszynski
*
*/
public class JavaClass extends JavaLanguageElement{
private List<JavaField> fields = new ArrayList<JavaField>();
private List<JavaMethod> methods = new ArrayList<JavaMethod>();
- private Set<Class<?>> imports = new TreeSet<Class<?>>();
+ private Set<Class<?>> imports = new TreeSet<Class<?>>(
+ new Comparator<Class<?>> () {
+ public int compare(Class<?> o1, Class<?> o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
private JavaPackage pakg;
private Class<?> superClass = Object.class;
@@ -36,9 +62,22 @@
}
}
+ @Override
+ public void addAnnotation(JavaAnnotation annotation) {
+ super.addAnnotation(annotation);
+ addImport(annotation.getType());
+ }
+
public void addField(JavaField field) {
fields.add(field);
addImport(field.getType());
+
+ List<JavaAnnotation> annotations2 = field.getAnnotations();
+ if (annotations2 != null) {
+ for (JavaAnnotation javaAnnotation : annotations2) {
+ addImport(javaAnnotation.getType());
+ }
+ }
}
public void addMethod(JavaMethod method) {
@@ -53,11 +92,28 @@
List<Argument> arguments =
method.getArguments();
+
if (arguments != null) {
for (Argument argument : arguments) {
addImport(argument.getType());
}
}
+
+ List<JavaAnnotation> annotations2 = method.getAnnotations();
+ if (annotations2 != null) {
+ for (JavaAnnotation javaAnnotation : annotations2) {
+ addImport(javaAnnotation.getType());
+ }
+ }
+
+ MethodBody methodBody = method.getMethodBody();
+ if (methodBody != null) {
+ Set<Class<?>> usedClasses = methodBody.getUsedClasses();
+ for (Class<?> class1 : usedClasses) {
+ addImport(class1);
+ }
+ }
+
}
public JavaPackage getPakg() {
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaComment.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaComment.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaComment.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,9 +1,28 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
/**
+ * Java comment representation
* @author Maksim Kaszynski
*
*/
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaConstructor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaConstructor.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaConstructor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,35 @@
+/**
+ * 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.ajax4jsf.builder.model;
+
+
+/**
+ * Constructor method
+ * @author Maksim Kaszynski
+ *
+ */
+public class JavaConstructor extends JavaMethod {
+
+ public JavaConstructor(JavaClass javaClass, Argument ... arguments) {
+ super(javaClass.getName(), null, arguments);
+ }
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaField.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaField.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaField.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,9 +1,28 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
/**
+ * Class field abstraction
* @author Maksim Kaszynski
*
*/
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaLanguageElement.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaLanguageElement.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaLanguageElement.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,3 +1,24 @@
+/**
+ * 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.ajax4jsf.builder.model;
import java.util.ArrayList;
@@ -4,7 +25,11 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
+/**
+ *
+ * @author Maksim Kaszynski
+ *
+ */
public class JavaLanguageElement {
private Set<JavaModifier> modifiers = new HashSet<JavaModifier>();
@@ -32,5 +57,16 @@
public String getName() {
return name;
}
+
+ public void addModifier(JavaModifier modifier) {
+ modifiers.add(modifier);
+ }
+
+ public void addAnnotation(JavaAnnotation annotation) {
+ annotations.add(annotation);
+ }
+ public void addAnnotation(Class<?> annotation) {
+ annotations.add(new JavaAnnotation(annotation));
+ }
}
\ No newline at end of file
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaMethod.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaMethod.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaMethod.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,6 +1,24 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
import java.util.ArrayList;
@@ -34,12 +52,12 @@
}
public JavaMethod(String name, Argument ... arguments) {
- super(name);
+ this(name);
this.arguments = Arrays.asList(arguments);
}
public JavaMethod(String name, Class<?> returnType, Argument ... arguments) {
- super(name);
+ this(name);
this.returnType = returnType;
this.arguments = Arrays.asList(arguments);
}
@@ -58,5 +76,8 @@
public void setMethodBody(MethodBody methodBody) {
this.methodBody = methodBody;
+ if (methodBody != null) {
+ methodBody.setMethod(this);
+ }
}
}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaModifier.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaModifier.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaModifier.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,6 +1,24 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
/**
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPackage.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPackage.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPackage.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,6 +1,24 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
/**
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPrimitive.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPrimitive.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPrimitive.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,75 @@
+/**
+ * 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.ajax4jsf.builder.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class JavaPrimitive {
+
+ @SuppressWarnings("serial")
+ private static Map<String, Class<?>> types =
+ new HashMap<String, Class<?>> () {{
+ put("boolean", boolean.class);
+ put("byte", byte.class);
+ put("short", short.class);
+ put("char", char.class);
+ put("int", int.class);
+ put("long", long.class);
+ put("float", float.class);
+ put("double", double.class);
+ }};
+
+ @SuppressWarnings("serial")
+ private static Map<String, Class<?>> wrappers =
+ new HashMap<String, Class<?>>() {
+ {
+ put(boolean.class.getName(), Boolean.class);
+ put(byte.class.getName(), Byte.class);
+ put(short.class.getName(), Short.class);
+ put(char.class.getName(), Character.class);
+ put(int.class.getName(), Integer.class);
+ put(float.class.getName(), Float.class);
+ put(long.class.getName(), Long.class);
+ put(double.class.getName(), Double.class);
+ }};
+
+ public static final Class<?> forName(String name) throws ClassNotFoundException{
+ Class<?> class1 = types.get(name);
+ if (class1 == null) {
+ throw new ClassNotFoundException(name);
+ }
+ return class1;
+ }
+
+ public static final Class<?> wrapperType(Class<?> primitive) {
+ if (!primitive.isPrimitive()) {
+ throw new IllegalArgumentException("Class " + primitive + " is not primitive.");
+ }
+
+ return wrappers.get(primitive.getName());
+ }
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/MethodBody.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/MethodBody.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/model/MethodBody.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,8 +1,29 @@
/**
- *
+ * 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.ajax4jsf.builder.model;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* @author Maksim Kaszynski
*
@@ -11,6 +32,8 @@
private JavaMethod method;
+ private Set<Class<?>> usedClasses = new HashSet<Class<?>>();
+
public MethodBody() {
// TODO Auto-generated constructor stub
}
@@ -30,4 +53,12 @@
public String toCode() {
return "";
}
+
+ public void addType(Class<?> clazz) {
+ usedClasses.add(clazz);
+ }
+
+ public Set<Class<?>> getUsedClasses() {
+ return usedClasses;
+ }
}
Deleted: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ComponentModelBuilder.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ComponentModelBuilder.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ComponentModelBuilder.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,96 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.render;
-
-import java.util.Collection;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.model.JavaAnnotation;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.model.JavaPackage;
-
-import static org.ajax4jsf.builder.model.Argument.arg;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ComponentModelBuilder {
-
- private PropertyProcessor[] propertyProcessors = {};
-
- public JavaClass build(ComponentBean componentBean) {
-
- String superclassname =
- componentBean.getSuperclass();
-
- JavaClass javaClass =
- new JavaClass(componentBean.getClassname(),
- new JavaPackage(componentBean.getPackageName()),
- UIComponent.class);
-
- try {
- Class<?> superClass =
- Class.forName(superclassname);
-
- javaClass.setSuperClass(superClass);
-
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
-
- Collection<PropertyBean> properties = componentBean.getProperties();
-
- for (PropertyBean propertyBean : properties) {
- PropertyProcessor proc = null;
-
- for (int i = 0; i < propertyProcessors.length && proc == null; i++) {
-
- PropertyProcessor processor =
- propertyProcessors[i];
-
- if (processor.accept(propertyBean)) {
- proc = processor;
- }
- }
-
- if (proc != null) {
- proc.process(propertyBean, javaClass);
- }
- }
-
- javaClass.addMethod(getSaveState());
- javaClass.addMethod(getRestoreState());
- return javaClass;
-
- }
-
- private JavaMethod getRestoreState() {
- JavaMethod method =
- new JavaMethod("restoreState",
- Void.class,
- arg("context", FacesContext.class),
- arg("state", Object.class));
- method.getModifiers().add(JavaModifier.PUBLIC);
- method.getAnnotations().add(JavaAnnotation.OVERRIDE);
-
- return method;
- }
-
- private JavaMethod getSaveState() {
- JavaMethod method =
- new JavaMethod("saveState",
- Object.class,
- arg("context", FacesContext.class));
- method.getModifiers().add(JavaModifier.PUBLIC);
- method.getAnnotations().add(JavaAnnotation.OVERRIDE);
- return method;
- }
-}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaClassRenderer.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaClassRenderer.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaClassRenderer.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,16 +1,35 @@
/**
- *
+ * 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.ajax4jsf.builder.render;
import java.io.PrintWriter;
import java.util.List;
import java.util.Set;
+import javax.faces.component.UIComponentBase;
+
import org.ajax4jsf.builder.model.Argument;
import org.ajax4jsf.builder.model.JavaClass;
import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaLanguageElement;
import org.ajax4jsf.builder.model.JavaMethod;
import org.ajax4jsf.builder.model.JavaModifier;
import org.ajax4jsf.builder.model.JavaPackage;
@@ -20,33 +39,66 @@
* @author Maksim Kaszynski
*
*/
-public class JavaClassRenderer extends JavaLanguageElementRenderer {
+public class JavaClassRenderer extends JavaLanguageElementRenderer<JavaClass> {
- private MethodRenderer methodRenderer = new MethodRenderer();
+ private JavaMethodRenderer methodRenderer = new JavaMethodRenderer();
- public void render(JavaLanguageElement element, PrintWriter out){
- JavaClass javaClass = (JavaClass) element;
+ private JavaFieldRenderer fieldRenderer = new JavaFieldRenderer();
+
+ public void render(JavaClass javaClass, PrintWriter out){
out.println("package " + javaClass.getPackage().getName() + ";");
-
+ out.println();
Set<Class<?>> imports = javaClass.getImports();
for (Class<?> impord : imports) {
- out.println("import " + impord.getName());
+ out.println("import " + impord.getName() + ";");
}
+ out.println();
+
+ renderAnnotations(javaClass, out);
+
renderModifiers(javaClass, out);
- out.println("class " + javaClass.getName() + " {");
+ out.print("class " + javaClass.getName() );
+ Class<?> superClass =
+ javaClass.getSuperClass();
+
+ if (!Object.class.getName().equals(superClass.getName())) {
+ out.print(" extends " + superClass.getSimpleName());
+ }
+
+ out.println("{");
+
+ out.println();
+
+ List<JavaField> fields = javaClass.getFields();
+ for (JavaField javaField : fields) {
+ fieldRenderer.render(javaField, out);
+ out.println();
+
+ }
+
+ out.println();
+
+
List<JavaMethod> methods = javaClass.getMethods();
for (JavaMethod javaMethod : methods) {
methodRenderer.render(javaMethod, out);
+ out.println();
+
}
+
out.println("}");
out.flush();
out.close();
}
+ @interface Tezt {
+
+ }
+
public static void main(String[] args) {
JavaClass javaClass = new JavaClass("MyClass", new JavaPackage("mypackage"));
@@ -55,6 +107,14 @@
javaField.getModifiers().add(JavaModifier.PRIVATE);
javaClass.addField(javaField);
+ JavaField field =
+ new JavaField(UIComponentBase.class, "component", "null");
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addAnnotation(Deprecated.class);
+ javaClass.addField(field);
+
+ javaClass.addAnnotation(Deprecated.class);
+
JavaMethod accessor = new JavaMethod("getCount", int.class);
accessor.setMethodBody(
new MethodBody(accessor) {
@@ -68,7 +128,7 @@
accessor.getModifiers().add(JavaModifier.FINAL);
javaClass.addMethod(accessor);
- JavaMethod mutator = new JavaMethod("setCount", int.class,
+ JavaMethod mutator = new JavaMethod("setCount",
new Argument("i", int.class));
mutator.setMethodBody(
new MethodBody(mutator) {
@@ -78,8 +138,9 @@
}
}
);
- mutator.getModifiers().add(JavaModifier.PUBLIC);
- mutator.getModifiers().add(JavaModifier.FINAL);
+ mutator.addAnnotation(Tezt.class);
+ mutator.addModifier(JavaModifier.PUBLIC);
+ mutator.addModifier(JavaModifier.FINAL);
javaClass.addMethod(mutator);
PrintWriter printWriter = new PrintWriter(System.out);
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaFieldRenderer.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaFieldRenderer.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaFieldRenderer.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,50 @@
+/**
+ * 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.ajax4jsf.builder.render;
+
+import java.io.PrintWriter;
+
+import org.ajax4jsf.builder.model.JavaField;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class JavaFieldRenderer extends JavaLanguageElementRenderer<JavaField> {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.render.JavaLanguageElementRenderer#render(org.ajax4jsf.builder.model.JavaLanguageElement, java.io.PrintWriter)
+ */
+ @Override
+ public void render(JavaField field, PrintWriter out) {
+ renderComments(field, out);
+ renderAnnotations(field, out);
+ renderModifiers(field, out);
+ out.print(" " + field.getType().getSimpleName());
+ out.print(" " + field.getName());
+ if (field.getValue() != null) {
+ out.print(" = " + field.getValue());
+ }
+ out.println(";");
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaLanguageElementRenderer.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaLanguageElementRenderer.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaLanguageElementRenderer.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,3 +1,23 @@
+/**
+ * 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.ajax4jsf.builder.render;
import java.io.PrintWriter;
@@ -5,16 +25,22 @@
import java.util.Set;
import org.ajax4jsf.builder.model.JavaAnnotation;
+import org.ajax4jsf.builder.model.JavaComment;
import org.ajax4jsf.builder.model.JavaLanguageElement;
import org.ajax4jsf.builder.model.JavaModifier;
+/**
+ *
+ * @author Maksim Kaszynski
+ *
+ * @param <T>
+ */
+public abstract class JavaLanguageElementRenderer<T extends JavaLanguageElement> {
-public abstract class JavaLanguageElementRenderer {
-
public JavaLanguageElementRenderer() {
super();
}
- public void renderModifiers(JavaLanguageElement element, PrintWriter out) {
+ public void renderModifiers(T element, PrintWriter out) {
Set<JavaModifier> modifiers = element.getModifiers();
for (JavaModifier javaModifier : modifiers) {
out.print(javaModifier);
@@ -22,14 +48,23 @@
}
}
- public void renderAnnotations(JavaLanguageElement element, PrintWriter out) {
+ public void renderAnnotations(T element, PrintWriter out) {
List<JavaAnnotation> annotations = element.getAnnotations();
if (annotations != null) {
for (JavaAnnotation javaAnnotation : annotations) {
- out.println("@" + javaAnnotation.getName());
+ out.println("@" + javaAnnotation.getType().getSimpleName());
}
}
}
- public abstract void render(JavaLanguageElement element, PrintWriter out);
+ public void renderComments(T element, PrintWriter out) {
+ List<JavaComment> comments = element.getComments();
+ for (JavaComment javaComment : comments) {
+ out.println("/*");
+ out.println("* " + javaComment.getValue());
+ out.println("*/");
+ }
+ }
+
+ public abstract void render(T element, PrintWriter out);
}
\ No newline at end of file
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaMethodRenderer.java (from rev 3610, trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/MethodRenderer.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaMethodRenderer.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaMethodRenderer.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,88 @@
+/**
+ * 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.ajax4jsf.builder.render;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+
+import org.ajax4jsf.builder.model.Argument;
+import org.ajax4jsf.builder.model.JavaMethod;
+import org.ajax4jsf.builder.model.MethodBody;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class JavaMethodRenderer extends JavaLanguageElementRenderer<JavaMethod> {
+
+ @Override
+ public void render(JavaMethod javaMethod, PrintWriter out) {
+ renderComments(javaMethod, out);
+ renderAnnotations(javaMethod, out);
+ renderModifiers(javaMethod, out);
+
+ Class<?> returnType = javaMethod.getReturnType();
+
+ if (returnType != null) {
+ out.print(returnType.getSimpleName() + " ");
+ }
+
+ out.print(javaMethod.getName());
+
+ out.print("(");
+ List<Argument> arguments = javaMethod.getArguments();
+ if (arguments != null) {
+ for (Iterator<Argument> iterator = arguments.iterator(); iterator.hasNext();) {
+ Argument argument = iterator.next();
+ out.print(argument.getType().getSimpleName());
+ out.print(" ");
+ out.print(argument.getName());
+ if (iterator.hasNext()) {
+ out.print(", ");
+ }
+ }
+ }
+ out.print(")");
+ List<Class<Throwable>> exceptions = javaMethod.getExceptions();
+
+ if (exceptions != null && !exceptions.isEmpty()) {
+ out.print(" throws ");
+ for (Iterator<Class<Throwable>> iterator = exceptions.iterator(); iterator.hasNext();) {
+ Class<Throwable> class1 = iterator.next();
+ out.print(class1.getSimpleName());
+ if (iterator.hasNext()) {
+ out.print(", ");
+ }
+
+ }
+ }
+
+ out.println("{");
+ MethodBody methodBody = javaMethod.getMethodBody();
+ if (methodBody != null){
+ out.println(methodBody.toCode());
+ }
+ out.println("}");
+
+ }
+}
Deleted: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/MethodRenderer.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/MethodRenderer.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/MethodRenderer.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,59 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.render;
-
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.List;
-
-import org.ajax4jsf.builder.model.Argument;
-import org.ajax4jsf.builder.model.JavaLanguageElement;
-import org.ajax4jsf.builder.model.JavaMethod;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class MethodRenderer extends JavaLanguageElementRenderer {
-
- @Override
- public void render(JavaLanguageElement element, PrintWriter out) {
- JavaMethod javaMethod = (JavaMethod) element;
- renderModifiers(javaMethod, out);
- renderAnnotations(element, out);
- out.print(javaMethod.getReturnType() + " " + javaMethod.getName());
- out.print("(");
- List<Argument> arguments = javaMethod.getArguments();
- if (arguments != null) {
- for (Iterator<Argument> iterator = arguments.iterator(); iterator.hasNext();) {
- Argument argument = iterator.next();
- out.print(argument.getType().getSimpleName());
- out.print(" ");
- out.print(argument.getName());
- if (iterator.hasNext()) {
- out.print(", ");
- }
- }
- }
- out.print(")");
- List<Class<Throwable>> exceptions = javaMethod.getExceptions();
-
- if (exceptions != null && !exceptions.isEmpty()) {
- out.print(" throws ");
- for (Iterator<Class<Throwable>> iterator = exceptions.iterator(); iterator.hasNext();) {
- Class<Throwable> class1 = iterator.next();
- out.print(class1.getSimpleName());
- if (iterator.hasNext()) {
- out.print(", ");
- }
-
- }
- }
-
- out.println("{");
- out.println(javaMethod.getMethodBody().toCode());
- out.println("}");
-
- }
-}
Deleted: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ObjectPropertyProcessor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ObjectPropertyProcessor.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/ObjectPropertyProcessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,70 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.render;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.model.Argument;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaComment;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.render.methods.SimpleAccessorMethodBody;
-import org.ajax4jsf.builder.render.methods.SimpleMutatorMethodBody;
-
-/**
- * Default property handler - a fallback one.
- * @author Maksim Kaszynski
- *
- */
-public class ObjectPropertyProcessor implements PropertyProcessor {
-
- public boolean accept(PropertyBean propertyBean) {
- return !propertyBean.isHidden();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.render.PropertyProcessor#process(org.ajax4jsf.builder.config.PropertyBean, org.ajax4jsf.builder.model.JavaClass)
- */
- public void process(PropertyBean propertyBean, JavaClass javaClass) {
-
- String classname = propertyBean.getClassname();
- String name = propertyBean.getName();
- String defaultvalue = propertyBean.getDefaultvalue();
-
- try {
- Class<?> propertyClass = Class.forName(classname);
-
- JavaField field = new JavaField(propertyClass, "_" + name, defaultvalue);
- field.getComments().add(new JavaComment(propertyBean.getDescription()));
- field.getModifiers().add(JavaModifier.PRIVATE);
- javaClass.addField(field);
-
- javaClass.addMethod(getAccessor(propertyBean, field));
- javaClass.addMethod(getMutator(propertyBean, field));
-
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- protected JavaMethod getAccessor(PropertyBean propertyBean, JavaField field) {
- JavaMethod accessor =
- new JavaMethod(propertyBean.getGetterName(), field.getType());
-
- accessor.setMethodBody(new SimpleAccessorMethodBody(accessor, field));
-
- return accessor;
- }
-
- protected JavaMethod getMutator(PropertyBean propertyBean, JavaField field) {
- JavaMethod mutator =
- new JavaMethod(propertyBean.getSetterName(),
- new Argument(field.getName(), field.getType()));
-
- mutator.setMethodBody(new SimpleMutatorMethodBody(mutator, field));
-
- return mutator;
- }
-}
Deleted: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/PropertyProcessor.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/PropertyProcessor.java 2007-10-30 18:10:44 UTC (rev 3625)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/render/PropertyProcessor.java 2007-10-30 20:39:59 UTC (rev 3626)
@@ -1,16 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.render;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.model.JavaClass;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface PropertyProcessor {
- boolean accept(PropertyBean propertyBean);
- void process(PropertyBean propertyBean, JavaClass javaClass);
-}
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/el-property-accessor.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/el-property-accessor.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/el-property-accessor.vm 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,18 @@
+ if (this.${field.name} != null) {
+ return this.${field.name};
+ }
+ ValueExpression ve = getValueExpression("${property.name}");
+ if (ve != null) {
+ ${field.type.simpleName} value = null;
+
+ try {
+ value = (${field.type.simpleName}) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ return value;
+ }
+
+ return ${property.defaultvalue};
+
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-el-property-accessor.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-el-property-accessor.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-el-property-accessor.vm 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,21 @@
+ if (this.${field2.name}) {
+ return (this.${field1.name});
+ }
+ ValueExpression ve = getValueExpression("${property.name}");
+ if (ve != null) {
+ ${wrapperClass.simpleName} value = null;
+
+ try {
+ value = (${wrapperClass.simpleName}) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null == value) {
+ return (this.${field1.name});
+ }
+
+ return value;
+ } else {
+ return (this.${field1.name});
+ }
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-accessor.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-accessor.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-accessor.vm 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1 @@
+return ${field1.name};
\ No newline at end of file
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-mutator.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-mutator.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/primitive-property-mutator.vm 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,2 @@
+this.${field1.name} = ${field1.name};
+this.${field2.name} = true;
\ No newline at end of file
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/restore-state.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/restore-state.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/restore-state.vm 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,8 @@
+Object[] states = (Object[]) state;
+super.restoreState(context, states[0]);
+#set($counter = 1)
+#foreach($descriptor in $descriptors)
+ #set($fragment = "states[${counter}]")
+ ${descriptor.field.name} = ${descriptor.restoreStateCode($fragment)};
+ #set($counter = $counter+1)
+#end
\ No newline at end of file
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/save-state.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/save-state.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/snippets/save-state.vm 2007-10-30 20:39:59 UTC (rev 3626)
@@ -0,0 +1,8 @@
+Object [] state = new Object[$size];
+state[0] = super.saveState(context);
+#set($counter = 1)
+#foreach($descriptor in $descriptors)
+state[$counter] = ${descriptor.saveStateCode()};
+#set($counter = $counter + 1)
+#end
+return state;
\ No newline at end of file
17 years, 1 month
JBoss Rich Faces SVN: r3625 - trunk/ui/dataTable/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-10-30 14:10:44 -0400 (Tue, 30 Oct 2007)
New Revision: 3625
Modified:
trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1252
Modified: trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx
===================================================================
--- trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx 2007-10-30 17:39:47 UTC (rev 3624)
+++ trunk/ui/dataTable/src/main/templates/org/richfaces/htmlDataTable.jspx 2007-10-30 18:10:44 UTC (rev 3625)
@@ -19,7 +19,7 @@
class="dr-table rich-table #{component.attributes['styleClass']}"
>
<f:call name="utils.encodePassThruWithExclusions">
- <f:parameter value="value,name,type,id,class" />
+ <f:parameter value="value,name,type,id,class,rows" />
</f:call>
<f:call name="encodeTableStructure"/>
<tbody>
17 years, 1 month
JBoss Rich Faces SVN: r3624 - in branches/3.1.x/ui/virtualEarth/src: main/templates and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-10-30 13:39:47 -0400 (Tue, 30 Oct 2007)
New Revision: 3624
Modified:
branches/3.1.x/ui/virtualEarth/src/main/config/component/virtualEarth.xml
branches/3.1.x/ui/virtualEarth/src/main/templates/virtualEarth.jspx
branches/3.1.x/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-1264
Modified: branches/3.1.x/ui/virtualEarth/src/main/config/component/virtualEarth.xml
===================================================================
--- branches/3.1.x/ui/virtualEarth/src/main/config/component/virtualEarth.xml 2007-10-30 17:33:21 UTC (rev 3623)
+++ branches/3.1.x/ui/virtualEarth/src/main/config/component/virtualEarth.xml 2007-10-30 17:39:47 UTC (rev 3624)
@@ -85,5 +85,13 @@
</description>
<defaultvalue>"Normal"</defaultvalue>
</property>
+ <property>
+ <name>version</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Virtual earth version, default - "6"
+ </description>
+ <defaultvalue>"6"</defaultvalue>
+ </property>
</component>
</components>
Modified: branches/3.1.x/ui/virtualEarth/src/main/templates/virtualEarth.jspx
===================================================================
--- branches/3.1.x/ui/virtualEarth/src/main/templates/virtualEarth.jspx 2007-10-30 17:33:21 UTC (rev 3623)
+++ branches/3.1.x/ui/virtualEarth/src/main/templates/virtualEarth.jspx 2007-10-30 17:39:47 UTC (rev 3624)
@@ -25,7 +25,7 @@
<div id="#{clientId}" style="position:relative; width:400px; height:400px;#{style}" class="dr-ve rich-virtualEarth #{component.attributes['styleClass']}"
x:passThruWithExclusions="id, styleClass,style,class"
>
-<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5" />
+<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=#{component.attr...'version']}" />
<script type="text/javascript">
//<![CDATA[
Modified: branches/3.1.x/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java
===================================================================
--- branches/3.1.x/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java 2007-10-30 17:33:21 UTC (rev 3623)
+++ branches/3.1.x/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java 2007-10-30 17:39:47 UTC (rev 3624)
@@ -51,7 +51,7 @@
javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("script/virtualEarth.js");
- javaScripts.add("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5");
+ javaScripts.add("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx");
}
/**
17 years, 1 month
JBoss Rich Faces SVN: r3623 - in trunk/ui/virtualEarth/src: main/templates and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-10-30 13:33:21 -0400 (Tue, 30 Oct 2007)
New Revision: 3623
Modified:
trunk/ui/virtualEarth/src/main/config/component/virtualEarth.xml
trunk/ui/virtualEarth/src/main/templates/virtualEarth.jspx
trunk/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java
Log:
http://jira.jboss.com/jira/browse/RF-1264
Modified: trunk/ui/virtualEarth/src/main/config/component/virtualEarth.xml
===================================================================
--- trunk/ui/virtualEarth/src/main/config/component/virtualEarth.xml 2007-10-30 16:25:09 UTC (rev 3622)
+++ trunk/ui/virtualEarth/src/main/config/component/virtualEarth.xml 2007-10-30 17:33:21 UTC (rev 3623)
@@ -85,5 +85,13 @@
</description>
<defaultvalue>"Normal"</defaultvalue>
</property>
+ <property>
+ <name>version</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Virtual earth version, default - "6"
+ </description>
+ <defaultvalue>"6"</defaultvalue>
+ </property>
</component>
</components>
Modified: trunk/ui/virtualEarth/src/main/templates/virtualEarth.jspx
===================================================================
--- trunk/ui/virtualEarth/src/main/templates/virtualEarth.jspx 2007-10-30 16:25:09 UTC (rev 3622)
+++ trunk/ui/virtualEarth/src/main/templates/virtualEarth.jspx 2007-10-30 17:33:21 UTC (rev 3623)
@@ -25,7 +25,7 @@
<div id="#{clientId}" style="position:relative; width:400px; height:400px;#{style}" class="dr-ve rich-virtualEarth #{component.attributes['styleClass']}"
x:passThruWithExclusions="id, styleClass,style,class"
>
-<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5" />
+<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=#{component.attr...'version']}" />
<script type="text/javascript">
//<![CDATA[
Modified: trunk/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java
===================================================================
--- trunk/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java 2007-10-30 16:25:09 UTC (rev 3622)
+++ trunk/ui/virtualEarth/src/test/java/org/richfaces/component/VirtualEarthComponentTest.java 2007-10-30 17:33:21 UTC (rev 3623)
@@ -51,7 +51,7 @@
javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
javaScripts.add("script/virtualEarth.js");
- javaScripts.add("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5");
+ javaScripts.add("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx");
}
/**
17 years, 1 month
JBoss Rich Faces SVN: r3622 - in management/design: orderingList and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2007-10-30 12:25:09 -0400 (Tue, 30 Oct 2007)
New Revision: 3622
Added:
management/design/orderingList/
management/design/orderingList/FuncSpec - orderingList.doc
Log:
http://jira.jboss.com/jira/browse/RF-1183
Added: management/design/orderingList/FuncSpec - orderingList.doc
===================================================================
(Binary files differ)
Property changes on: management/design/orderingList/FuncSpec - orderingList.doc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 1 month
JBoss Rich Faces SVN: r3621 - trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-10-30 12:23:15 -0400 (Tue, 30 Oct 2007)
New Revision: 3621
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
Log:
RF-917
Modified: trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
===================================================================
--- trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-10-30 15:06:49 UTC (rev 3620)
+++ trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-10-30 16:23:15 UTC (rev 3621)
@@ -34,10 +34,6 @@
{pane: GridLayout_Enum.FOOTER, ref: this.client_id +"_" + "GridFooterTemplate"}
];
var grid = this;
-
- Event.onReady(function(){
- grid.init();
- });
Utils.execOnLoad(
function(){
grid.init();
17 years, 1 month
JBoss Rich Faces SVN: r3620 - in trunk/ui/tabPanel/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-10-30 11:06:49 -0400 (Tue, 30 Oct 2007)
New Revision: 3620
Modified:
trunk/ui/tabPanel/src/main/config/component/tabPanel.xml
trunk/ui/tabPanel/src/main/templates/tabHeader.jspx
Log:
add onlabelclick, onclabelmouse* and etc properties
Modified: trunk/ui/tabPanel/src/main/config/component/tabPanel.xml
===================================================================
--- trunk/ui/tabPanel/src/main/config/component/tabPanel.xml 2007-10-30 14:58:37 UTC (rev 3619)
+++ trunk/ui/tabPanel/src/main/config/component/tabPanel.xml 2007-10-30 15:06:49 UTC (rev 3620)
@@ -230,7 +230,49 @@
</description>
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
+
+ <property>
+ <name>onlabelkeypress</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabeldblclick</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabelkeyup</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabelclick</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabelkeydown</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabelmouseup</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabelmousedown</name>
+ <classname>java.lang.String</classname>
+ </property>
+
+ <property>
+ <name>onlabelmousemove</name>
+ <classname>java.lang.String</classname>
+ </property>
+
</component>
+
<renderer generate="true">
<template>tabHeader.jspx</template>
</renderer>
Modified: trunk/ui/tabPanel/src/main/templates/tabHeader.jspx
===================================================================
--- trunk/ui/tabPanel/src/main/templates/tabHeader.jspx 2007-10-30 14:58:37 UTC (rev 3619)
+++ trunk/ui/tabPanel/src/main/templates/tabHeader.jspx 2007-10-30 15:06:49 UTC (rev 3620)
@@ -22,9 +22,19 @@
<tr>
<td class="dr-tbpnl-tbbrdr rich-tabhdr-side-border"><img src="#{spacer}" width="1" height="1" alt="" border="0" /></td>
<td class="dr-tbpnl-tbtopbrdr rich-tabhdr-side-cell" style="#{this:encodeTabLabelWidth(context, component)}">
- <table style="height: 100%; width: 100%;" border="0" cellpadding="0" cellspacing="0">
+ <table style="height: 100%; width: 100%;" border="0" cellpadding="0" cellspacing="0" >
<tr>
- <td id="#{clientId}_lbl">
+ <td id="#{clientId}_lbl"
+ onclick="#{component.attributes['onlabelclick']}"
+ onkeypress="#{component.attributes['onlabelkeypress']}"
+ ondblclick="#{component.attributes['onlabeldblclick']}"
+ onkeyup="#{component.attributes['onlabelkeyup']}"
+ onkeydown="#{component.attributes['onlabelkeydown']}"
+ onmousedown="#{component.attributes['onlabelmousedown']}"
+ onmouseup="#{component.attributes['onlabelmouseup']}"
+ onmousemove="#{component.attributes['onlabelmousemove']}"
+ >
+
<f:call name="writeLabel" />
</td>
</tr>
17 years, 1 month
JBoss Rich Faces SVN: r3619 - in management/design: listShuttle and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2007-10-30 10:58:37 -0400 (Tue, 30 Oct 2007)
New Revision: 3619
Added:
management/design/listShuttle/
management/design/listShuttle/FuncSpec - ListShuttle.doc
Log:
http://jira.jboss.com/jira/browse/RF-1174
Added: management/design/listShuttle/FuncSpec - ListShuttle.doc
===================================================================
(Binary files differ)
Property changes on: management/design/listShuttle/FuncSpec - ListShuttle.doc
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 1 month
JBoss Rich Faces SVN: r3618 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-10-30 10:53:57 -0400 (Tue, 30 Oct 2007)
New Revision: 3618
Modified:
trunk/docs/userguide/en/src/main/docbook/included/tree.xml
Log:
http://jira.jboss.com/jira/browse/RF-1137 - improved description
Modified: trunk/docs/userguide/en/src/main/docbook/included/tree.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/tree.xml 2007-10-30 12:50:43 UTC (rev 3617)
+++ trunk/docs/userguide/en/src/main/docbook/included/tree.xml 2007-10-30 14:53:57 UTC (rev 3618)
@@ -45,9 +45,8 @@
<section>
<title>Creating the Component with a Page Tag</title>
<para>There are two cases for a tree definition: together with <emphasis role="bold">
- <property><rich:recursiveTreeNodesAdaptor></property>
- </emphasis>
- and without it. In the first case, it's possible to define it without <emphasis>
+ <property><rich:recursiveTreeNodesAdaptor></property>
+ </emphasis> and without it. In the first case, it's possible to define it without <emphasis>
<property>"value"</property>
</emphasis> and <emphasis>
<property>"var"</property>
@@ -63,8 +62,8 @@
</rich:tree>
...]]></programlisting>
- <para> In the second case, it's necessary to define it with these attributes as it's
- shown below: </para>
+ <para> In the second case, it's necessary to define it with these attributes as
+ it's shown below: </para>
<para>
<emphasis role="bold">Example:</emphasis>
@@ -89,31 +88,34 @@
HtmlTree myPanel = new HtmlTree();
...]]></programlisting>
</section>
- <section>
+ <section>
<title>Details of Usage</title>
- <para>As it has been mentioned <link linkend="tree">above</link> the tree component allows
+ <para>As it has been mentioned <link linkend="tree">above</link> the tree component allows
rendering any tree-like structure of data.</para>
<para>A bean property is passed into a tree <emphasis>
<property>"value"</property>
- </emphasis> attribute. The property keeps a structure of an <ulink
- url="http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..."
- >org.richfaces.component.TreeNode</ulink> type.</para>
- <para>There is a default class TreeNodeImpl which is used for TreeNode interface implementation.
- XmlTreeDataBuilder class allows transforming XML into structures of objects with XmlNodeData
- type which could be represented by the tree component. TreeNode has attribute <emphasis>
+ </emphasis> attribute. The property keeps a structure of
+ <property>"TreeNode"</property> type instances.</para>
+ <para>There is a default class <property>"TreeNodeImpl"</property>, which is a
+ default implementation for TreeNode interface. TreeNode has attribute <emphasis>
<property>"data"</property>
</emphasis> which value is available as request scope variable with name that is defined by <emphasis>
<property>"var"</property>
- </emphasis> attribute of tree component. </para>
+ </emphasis> attribute of tree component. <ulink
+ url="http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..."
+ >"XmlTreeDataBuilder" class</ulink> allows transforming XML into
+ structures of objects containing "XmlNodeData" instances as data, which
+ could be represented by the tree component. </para>
<para>For particular visual representation of data <emphasis role="bold">
<property><rich:tree></property>
</emphasis> selects one of the children treeNode components by type. The type is defined with
the <emphasis>
<property>"nodeFace"</property>
- </emphasis> attribute that contains a value of <emphasis>
+ </emphasis> attribute that corresponds to a value of <emphasis>
<property>"type"</property>
- </emphasis> attribute for treeNode. An example of definition is placed below: </para>
+ </emphasis> attribute for <property>treeNode</property>. An example of definition is placed
+ below: </para>
<para>
<emphasis role="bold">Example:</emphasis>
@@ -149,17 +151,20 @@
<para>In case when <emphasis>
<property>"nodeFace"</property>
</emphasis> attribute isn't defined or defined but its value isn't equal to
- any type of all children treeNode components or this value is equal to some type, but the
- value of <emphasis>
+ any type of all children <property>treeNode</property> components or this value is equal to
+ some type, but the value of <emphasis>
<property>"rendered"</property>
- </emphasis> attribute for this treeNode is not defined then default treeNode is used. </para>
+ </emphasis> attribute for this <property>treeNode</property> is
+ <property>"false"</property> then default <property>treeNode</property> is
+ used. </para>
- <para>Default treeNode is the first node (with not defined <emphasis>
+ <para>Default <property>treeNode</property> is the first node (with not defined <emphasis>
<property>"type"</property>
</emphasis> attribute and defined <emphasis>
<property>"rendered"</property>
- </emphasis> attribute) from all children nodes of the tree component. If such treeNode
- wasn't found, the following default interior presentation is used: </para>
+ </emphasis> attribute) from all children nodes of the tree component. If such
+ <property>treeNode</property> wasn't found, the following default interior
+ presentation is used: </para>
<para>
<emphasis role="bold">Example:</emphasis>
@@ -199,7 +204,7 @@
</h:form>
...]]></programlisting>
- <para> The example represents definition of two different treeNode components. The first
+ <para> The example represents definition of two different treeNode components. The first
specifies the album that's available for sale, the other specifies the album that is
not available. The result is shown on the following screenshot: </para>
@@ -233,7 +238,8 @@
<itemizedlist>
<listitem>Ajax - Ajax submission is used for switching </listitem>
<listitem>Server - regular form submition request is used</listitem>
- <listitem>Client - switching is done as a whole on a client, no interaction with the server presents</listitem>
+ <listitem>Client - switching is done as a whole on a client, no interaction with the server
+ presents</listitem>
</itemizedlist>
<para>If <emphasis>
@@ -285,10 +291,9 @@
<property>"value"</property>
</emphasis> and <emphasis>
<property>"var"</property>
- </emphasis>. Besides, visual representation shouldn't be defined right in the tree. There is
- possibility to use common attributes such as <emphasis>
- <property>"ajaxSubmitSelection"</property>
- </emphasis>, for instance. </para>
+ </emphasis>. Besides, visual representation shouldn't be defined right in the tree.
+ In this case tree tag is intended mainly for defining common attributes such as
+ <property>"ajaxSubmitSelection"</property>, for instance. </para>
</section>
<section>
@@ -448,8 +453,8 @@
<para>In order to redefine styles for all <emphasis role="bold">
<property><rich:tree></property>
- </emphasis> components on a page using CSS, it's enough to create a class with the same
- names and define necessary properties in them.</para>
+ </emphasis> components on a page using CSS, it's enough to create a class with the
+ same names and define necessary properties in them.</para>
<para>To change styles of particular <emphasis role="bold">
<property><rich:tree></property>
17 years, 1 month