JBoss Rich Faces SVN: r20839 - in trunk/ui/output/ui/src/main: java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-12-29 10:03:28 -0500 (Wed, 29 Dec 2010)
New Revision: 20839
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
Log:
RF-9435
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java 2010-12-29 14:01:34 UTC (rev 20838)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java 2010-12-29 15:03:28 UTC (rev 20839)
@@ -23,8 +23,8 @@
package org.richfaces.component.html;
import org.richfaces.component.UICollapsiblePanel;
+
import javax.faces.component.behavior.ClientBehaviorHolder;
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -53,6 +53,11 @@
public enum PropertyKeys {
+ leftCollapsedIcon,
+ leftExpandedIcon,
+ rightCollapsedIcon,
+ rightExpandedIcon,
+
bodyClass,
headerClass,
headerControlClass,
@@ -83,6 +88,38 @@
return COMPONENT_FAMILY;
}
+ public String getLeftCollapsedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.leftCollapsedIcon);
+ }
+
+ public void setLeftCollapsedIcon(String leftCollapsedIcon) {
+ getStateHelper().put(PropertyKeys.leftCollapsedIcon, leftCollapsedIcon);
+ }
+
+ public String getLeftExpandedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.leftExpandedIcon);
+ }
+
+ public void setLeftExpandedIcon(String leftExpandedIcon) {
+ getStateHelper().put(PropertyKeys.leftExpandedIcon, leftExpandedIcon);
+ }
+
+ public String getRightCollapsedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.rightCollapsedIcon);
+ }
+
+ public void setRightCollapsedIcon(String rightCollapsedIcon) {
+ getStateHelper().put(PropertyKeys.rightCollapsedIcon, rightCollapsedIcon);
+ }
+
+ public String getRightExpandedIcon() {
+ return (String) getStateHelper().eval(PropertyKeys.rightExpandedIcon);
+ }
+
+ public void setRightExpandedIcon(String rightExpandedIcon) {
+ getStateHelper().put(PropertyKeys.rightExpandedIcon, rightExpandedIcon);
+ }
+
public String getBodyClass() {
return (String) getStateHelper().eval(PropertyKeys.bodyClass);
}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TableIconsRendererHelper.java 2010-12-29 15:03:28 UTC (rev 20839)
@@ -0,0 +1,112 @@
+package org.richfaces.renderkit.html;
+
+import org.richfaces.component.html.HtmlPanelMenuGroup;
+import org.richfaces.renderkit.RenderKitUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.renderkit.HtmlConstants.*;
+import static org.richfaces.renderkit.html.DivPanelRenderer.styleElement;
+
+public class TableIconsRendererHelper {
+
+ public void encodeHeaderGroup(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ writer.startElement(TABLE_ELEMENT, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-gr", null);
+ writer.startElement(TBODY_ELEMENT, null);
+ writer.startElement(TR_ELEMENT, null);
+
+ encodeHeaderGroupIconLeft(writer, context, menuItem, classPrefix);
+
+ writer.startElement(TD_ELEM, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, classPrefix + "-lbl", null);
+
+ UIComponent headerFacet = menuItem.getFacet("label");
+ if (headerFacet != null && headerFacet.isRendered()) {
+ headerFacet.encodeAll(context);
+ } else {
+ Object label = menuItem.getLabel();
+ if (label != null && !label.equals("")) {
+ writer.writeText(label, null);
+ }
+ }
+
+ writer.endElement(TD_ELEM);
+
+ encodeHeaderGroupIconRight(writer, context, menuItem, classPrefix);
+
+ writer.endElement(TR_ELEMENT);
+ writer.endElement(TBODY_ELEMENT);
+ writer.endElement(TABLE_ELEMENT);
+ }
+
+ public void encodeHeaderGroupIconLeft(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuGroup, String classPrefix) throws IOException {
+ String iconCollapsed = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftCollapsed();
+ String iconExpanded = menuGroup.isDisabled() ? menuGroup.getIconLeftDisabled() : menuGroup.getIconLeftExpanded();
+
+ encodeTdIcon(writer, context, classPrefix + "-ico", menuGroup.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ public void encodeHeaderGroupIconRight(ResponseWriter writer, FacesContext context, HtmlPanelMenuGroup menuItem, String classPrefix) throws IOException {
+ String iconCollapsed = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightCollapsed();
+ String iconExpanded = menuItem.isDisabled() ? menuItem.getIconRightDisabled() : menuItem.getIconRightExpanded();
+
+ //TODO nick - should this be "-ico-exp"? also why expanded icon state is connected with right icon alignment?
+ encodeTdIcon(writer, context, classPrefix + "-exp-ico", menuItem.isExpanded(), iconCollapsed, iconExpanded);
+ }
+
+ public void encodeTdIcon(ResponseWriter writer, FacesContext context, String cssClass, boolean isExpanded, String attrIconCollapsedValue, String attrIconExpandedValue) throws IOException {
+ writer.startElement(TD_ELEM, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, cssClass, null);
+
+ encodeIdIcon(writer, context, isExpanded, attrIconCollapsedValue, "rf-pm-ico-colps");
+ encodeIdIcon(writer, context, !isExpanded, attrIconExpandedValue, "rf-pm-ico-exp");
+
+ writer.endElement(TD_ELEM);
+ }
+
+ public void encodeIdIcon(ResponseWriter writer, FacesContext context, boolean isExpanded, String attrIconValue, String styleClass) throws IOException {
+ if (attrIconValue == null || attrIconValue.trim().length() <= 0) {
+ encodeDivIcon(writer, isExpanded, PanelMenuIcons.none, styleClass);
+ } else {
+ PanelMenuIcons icon = getIcon(attrIconValue);
+ if (icon != null) {
+ encodeDivIcon(writer, isExpanded, icon, styleClass);
+ } else {
+ encodeImage(writer, context, attrIconValue);
+ }
+ }
+ }
+
+ public PanelMenuIcons getIcon(String attrIconCollapsedValue) {
+ if (attrIconCollapsedValue == null) {
+ return null;
+ }
+
+ try {
+ return PanelMenuIcons.valueOf(attrIconCollapsedValue);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ public void encodeDivIcon(ResponseWriter writer, boolean isDisplay, PanelMenuIcons icon, String styleClass) throws IOException {
+ writer.startElement(DIV_ELEM, null);
+ writer.writeAttribute(CLASS_ATTRIBUTE, concatClasses(styleClass, icon.cssClass()), null);
+ writer.writeAttribute(STYLE_ATTRIBUTE, styleElement("display", isDisplay ? "none" : "block"), null);
+ writer.endElement(DIV_ELEM);
+ }
+
+ public void encodeImage(ResponseWriter writer, FacesContext context, String attrIconValue) throws IOException {
+ writer.startElement(IMG_ELEMENT, null);
+ writer.writeAttribute(ALT_ATTRIBUTE, "", null);
+ writer.writeURIAttribute(SRC_ATTRIBUTE, RenderKitUtils.getResourceURL(attrIconValue, context), null);
+ writer.endElement(IMG_ELEMENT);
+ }
+
+
+}
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-29 14:01:34 UTC (rev 20838)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-29 15:03:28 UTC (rev 20839)
@@ -939,6 +939,22 @@
<component-type>org.richfaces.CollapsiblePanel</component-type>
<component-class>org.richfaces.component.html.HtmlCollapsiblePanel</component-class>
<property>
+ <property-name>leftCollapsedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>leftExpandedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>rightExpandedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>rightCollapsedIcon</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
<description></description>
<property-name>switchType</property-name>
<property-class>org.richfaces.component.SwitchType</property-class>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-29 14:01:34 UTC (rev 20838)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-29 15:03:28 UTC (rev 20839)
@@ -1047,6 +1047,22 @@
<renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
<handler-class>org.richfaces.view.facelets.html.CollapsiblePanelTagHandler</handler-class>
</component>
+ <attribute>
+ <name>leftCollapsedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>leftExpandedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>rightExpandedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>rightCollapsedIcon</name>
+ <type>java.lang.String</type>
+ </attribute>
<attribute>
<name>switchType</name>
<type>org.richfaces.component.SwitchType</type>
14 years
JBoss Rich Faces SVN: r20838 - in trunk/ui: misc/ui/src/main/java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-29 09:01:34 -0500 (Wed, 29 Dec 2010)
New Revision: 20838
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java
trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
trunk/ui/misc/ui/src/main/java/org/richfaces/taglib/ComponentControlHandler.java
Log:
RF-9639 hashParam: not works properly with popupPanel (seems need to revise in general)
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java 2010-12-29 13:18:33 UTC (rev 20837)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java 2010-12-29 14:01:34 UTC (rev 20838)
@@ -146,6 +146,33 @@
}
}
+ /**
+ * Returns value of the parameter. If parameter is instance of
+ * <code>JavaScriptParameter</code>, <code>NoEcape</code> attribute is applied.
+ * @param parameter instance of <code>UIParameter</code>
+ * @return <code>Object</code> parameter value
+ */
+ public Object createParameterValue(UIParameter parameter) {
+ Object value = parameter.getValue();
+ boolean escape = true;
+
+ if (parameter instanceof JavaScriptParameter) {
+ JavaScriptParameter actionParam = (JavaScriptParameter) parameter;
+
+ escape = !actionParam.isNoEscape();
+ }
+
+ if (escape) {
+ if (value == null) {
+ value = "";
+ }
+ } else {
+ value = new JSReference(value.toString());
+ }
+
+ return value;
+ }
+
public Map<String, Object> createParametersMap(FacesContext context, UIComponent component) {
Map<String, Object> parameters = new LinkedHashMap<String, Object>();
@@ -154,33 +181,12 @@
if (child instanceof UIParameter) {
UIParameter parameter = (UIParameter) child;
String name = parameter.getName();
- Object value = parameter.getValue();
+ Object value = createParameterValue(parameter);
if (null == name) {
throw new IllegalArgumentException(Messages.getMessage(Messages.UNNAMED_PARAMETER_ERROR,
component.getClientId(context)));
}
-
- boolean escape = true;
-
- if (child instanceof JavaScriptParameter) {
- JavaScriptParameter actionParam = (JavaScriptParameter) child;
-
- escape = !actionParam.isNoEscape();
- }
-
- if (escape) {
- if (value == null) {
- value = "";
- }
- } else {
- value = new JSReference(value.toString());
-
- // if(it.hasNext()){onEvent.append(',');};
- // renderAjaxLinkParameter( name,
- // value, onClick, jsForm, nestingForm);
- }
-
parameters.put(name, value);
}
}
Modified: trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
===================================================================
--- trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2010-12-29 13:18:33 UTC (rev 20837)
+++ trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2010-12-29 14:01:34 UTC (rev 20838)
@@ -125,8 +125,8 @@
for (UIComponent child : children) {
if (child instanceof UIParameter) {
UIParameter parameter = (UIParameter) child;
- Object value = parameter.getValue();
-
+ Object value = RendererUtils.getInstance().createParameterValue(parameter);
+
if (value != null) {
elements.add(value);
}
@@ -135,7 +135,9 @@
if (child instanceof UIHashParameter) {
UIHashParameter parameter = (UIHashParameter) child;
String name = parameter.getName();
- Map<String, Object> value = parameter.getValue();
+
+ Map<String, Object> value =
+ RendererUtils.getInstance().createParametersMap(FacesContext.getCurrentInstance(), child);
if (value != null) {
if (name != null) {
Modified: trunk/ui/misc/ui/src/main/java/org/richfaces/taglib/ComponentControlHandler.java
===================================================================
--- trunk/ui/misc/ui/src/main/java/org/richfaces/taglib/ComponentControlHandler.java 2010-12-29 13:18:33 UTC (rev 20837)
+++ trunk/ui/misc/ui/src/main/java/org/richfaces/taglib/ComponentControlHandler.java 2010-12-29 14:01:34 UTC (rev 20838)
@@ -38,6 +38,7 @@
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.FaceletHandler;
+import org.richfaces.component.AbstractParameter;
import org.richfaces.component.UIHashParameter;
import org.richfaces.component.behavior.ComponentControlBehavior;
import org.richfaces.view.facelets.html.CustomBehaviorHandler;
@@ -108,7 +109,9 @@
}
private boolean isUIParameter(String type) {
- return (UIParameter.COMPONENT_TYPE.equals(type) || UIHashParameter.COMPONENT_TYPE.equals(type));
+ return (UIParameter.COMPONENT_TYPE.equals(type) ||
+ UIHashParameter.COMPONENT_TYPE.equals(type) ||
+ AbstractParameter.COMPONENT_TYPE.equals(type));
}
@Override
14 years
JBoss Rich Faces SVN: r20837 - in trunk/ui/iteration/ui/src/main: resources/META-INF/cdk/attributes and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-12-29 08:18:33 -0500 (Wed, 29 Dec 2010)
New Revision: 20837
Removed:
trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
Log:
Revert RF-10041
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-29 13:07:44 UTC (rev 20836)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-29 13:18:33 UTC (rev 20837)
@@ -92,7 +92,7 @@
family = AbstractTree.COMPONENT_FAMILY,
tag = @Tag(name = "tree", handler = "org.richfaces.view.facelets.TreeHandler"),
renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
- attributes = {"ajax-props.xml", "events-props.xml", "core-props.xml", "i18n-props.xml", "tree-common-props.xml"}
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
)
//TODO add rowData caching for wrapper events
public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentResolver, MetaComponentEncoder, TreeSelectionChangeSource, TreeToggleSource {
@@ -165,15 +165,24 @@
return treeRange;
}
- @Attribute
public abstract Object getValue();
- @Attribute
public abstract boolean isImmediate();
- @Attribute
+ public abstract String getIconLeaf();
+
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
public abstract String getNodeClass();
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
@Attribute(events = @EventName("nodetoggle"))
public abstract String getOnnodetoggle();
@@ -192,12 +201,27 @@
@Attribute
public abstract SwitchType getSelectionType();
- @Attribute
public abstract String getNodeType();
- @Attribute
public abstract String getToggleNodeEvent();
+ public abstract Object getExecute();
+
+ public abstract Object getRender();
+
+ public abstract boolean isLimitRender();
+
+ @Attribute(events = @EventName("begin"))
+ public abstract String getOnbegin();
+
+ @Attribute(events = @EventName("beforedomupdate"))
+ public abstract String getOnbeforedomupdate();
+
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
+
+ public abstract String getStatus();
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-12-29 13:07:44 UTC (rev 20836)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-12-29 13:18:33 UTC (rev 20837)
@@ -58,7 +58,7 @@
family = AbstractTreeNode.COMPONENT_FAMILY,
tag = @Tag(name = "treeNode", handler = "org.richfaces.view.facelets.TreeNodeHandler"),
renderer = @JsfRenderer(type = "org.richfaces.TreeNodeRenderer"),
- attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml", "tree-common-props.xml"}
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
)
public abstract class AbstractTreeNode extends UIComponentBase implements MetaComponentResolver, MetaComponentEncoder, IterationStateHolder, TreeToggleSource {
@@ -87,9 +87,20 @@
@Attribute
public abstract boolean isImmediate();
- @Attribute
public abstract String getType();
+ public abstract String getIconLeaf();
+
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
@Attribute(events = @EventName("toggle"))
public abstract String getOntoggle();
@@ -100,7 +111,6 @@
return (Boolean) getStateHelper().get(PropertyKeys.expanded);
}
- @Attribute
public boolean isExpanded() {
FacesContext context = getFacesContext();
Boolean localExpandedValue = getLocalExpandedValue(context);
Deleted: trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml 2010-12-29 13:07:44 UTC (rev 20836)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml 2010-12-29 13:18:33 UTC (rev 20837)
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- JBoss, Home of Professional Open Source Copyright ${year}, Red Hat,
- Inc. and individual contributors by the @authors tag. See the copyright.txt
- in the distribution for a full listing of individual contributors. This is
- free software; you can redistribute it and/or modify it under the terms of
- the GNU Lesser General Public License as published by the Free Software Foundation;
- either version 2.1 of the License, or (at your option) any later version.
- This software is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- details. You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the
- FSF site: http://www.fsf.org. -->
-<cdk:properties xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee">
-
- <property>
- <property-name>iconLeaf</property-name>
- <property-class>java.lang.String</property-class>
- </property>
- <property>
- <property-name>iconExpanded</property-name>
- <property-class>java.lang.String</property-class>
- </property>
- <property>
- <property-name>iconCollapsed</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
- <property>
- <property-name>handleClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
- <property>
- <property-name>iconClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
- <property>
- <property-name>labelClass</property-name>
- <property-class>java.lang.String</property-class>
- </property>
-
-</cdk:properties>
14 years
JBoss Rich Faces SVN: r20836 - in trunk: examples/output-demo/src/main/webapp/qunit and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-12-29 08:07:44 -0500 (Wed, 29 Dec 2010)
New Revision: 20836
Modified:
trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js
trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java
trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js
Log:
Modified: trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-12-29 13:07:44 UTC (rev 20836)
@@ -28,7 +28,8 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:pn="http://richfaces.org/pn"
- xmlns:rich="http://richfaces.org/output">
+ xmlns:rich="http://richfaces.org/output"
+ xmlns:a4j="http://richfaces.org/a4j">
<body>
<ui:composition template="/templates/template.xhtml">
@@ -47,7 +48,7 @@
<p>Here you can see <b>default client-side</b> tool-tip</p>
<pn:tooltip id="tt1" styleClass="tooltip">
<span style="white-space: nowrap"> This tool-tip content was
- <strong>pre-rendered</strong> to the page.<br/>
+ <strong>pre-rendered</strong> to the page.\n
Also the tooltip following mouse by default </span>
</pn:tooltip>
</rich:panel>
@@ -58,7 +59,7 @@
<pn:tooltip followMouse="false" showDelay="1500"
styleClass="tooltip-custom-body">
<span style="white-space: nowrap"> This tool-tip content also
- <strong>pre-rendered</strong> to the page.<br/>
+ <strong>pre-rendered</strong> to the page.
</span>
</pn:tooltip>
</rich:panel>
@@ -95,13 +96,55 @@
<h:panelGrid columns="2">
<h:outputText style="white-space:nowrap"
value="tooltips requested:"/>
- <h:outputText value="#{tooltipData.tooltipCounter}"
+ <h:outputText value="#{tooltipBean.tooltipCounter}"
styleClass="tooltipData"/>
</h:panelGrid>
</pn:tooltip>
</rich:panel>
</h:form>
- </h:panelGrid>
+ </h:panelGrid>
+ <br /><br />
+ <h:form>
+ <rich:panel id="tooltip" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip rendered on server <b>in separate request</b>.
+ </p>
+ <pn:tooltip styleClass="tooltip" layout="block"
+ jointPoint="#{tooltipBean.jointPoint}"
+ direction="#{tooltipBean.direction}"
+ horizontalOffset="#{tooltipBean.horizontalOffset}"
+ verticalOffset="#{tooltipBean.verticalOffset}">
+ Sample tooltip to test attributes:
+ <ul>
+ <li>jointPoint</li>
+ <li>direction</li>
+ <li>horizontalOffset</li>
+ <li>verticalOffset</li>
+ </ul>
+ </pn:tooltip>
+ </rich:panel>
+ <h:panelGrid columns="2">
+ <h:outputText value="Select joint point:" />
+ <h:selectOneMenu value="#{tooltipBean.jointPoint}">
+ <a4j:ajax execute="@form" event="change" render="tooltip @this" />
+ <f:selectItems value="#{tooltipBean.positioningValues}" var="v" itemLabel="#{v}" itemValue="#{v}"/>
+ </h:selectOneMenu>
+ <h:outputText value="Select direction:" />
+ <h:selectOneMenu value="#{tooltipBean.direction}">
+ <f:ajax execute="@form" event="change" render="tooltip @this" />
+ <f:selectItems value="#{tooltipBean.positioningValues}" var="v" itemLabel="#{v}" itemValue="#{v}"/>
+ </h:selectOneMenu>
+ <h:outputText value="Horisontal offset:" />
+ <h:inputText value="#{tooltipBean.horizontalOffset}">
+ <a4j:ajax execute="@form" event="change" render="tooltip @this" />
+ </h:inputText>
+ <h:outputText value="Vertical offset:" />
+ <h:inputText value="#{tooltipBean.verticalOffset}">
+ <f:ajax execute="@form" event="change" render="tooltip @this" />
+ </h:inputText>
+ </h:panelGrid>
+ <a4j:outputPanel ajaxRendered="true"><h:messages></h:messages></a4j:outputPanel>
+ </h:form>
</ui:define>
</ui:composition>
</body>
Modified: trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml 2010-12-29 13:07:44 UTC (rev 20836)
@@ -49,7 +49,7 @@
<div id="myRectangle" style="border: 2px solid red; background-color: #adff2f; width:300px; height:300px">
Tooltip apeared under green rectangle.
- <pn:tooltip id="tooltip" target="myRectangle" mode="ajax" showDelay="500">
+ <pn:tooltip id="tooltip" target="myRectangle" mode="client" showDelay="500">
New Tooltip Yo!!!
</pn:tooltip>
</div>
@@ -63,7 +63,7 @@
<div id="testDiv" style="margin-top:10px; border:1px solid #a0a0a0">Main Test Div</div>
</div>
- <!--<h:outputScript name="tests/richfaces-tooltip-qunit.js" />-->
+ <h:outputScript name="tests/richfaces-tooltip-qunit.js" />
</ui:define>
</ui:composition>
</body>
Modified: trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js 2010-12-29 13:07:44 UTC (rev 20836)
@@ -43,15 +43,15 @@
equals(c.id, TOOLTIP_ID, "id");
// test default options
- same(c.options.direction, RichFaces.ui.TooltipDirection.DEFAULT, "Direction");
+ same(c.options.direction, "AA", "Direction");
same(c.options.attached, true, "Attached");
- same(c.options.offset, {}, "Offset");
+ same(c.options.offset, [10,10], "Offset");
same(c.options.mode, RichFaces.ui.TooltipMode.DEFAULT, "Mode");
same(c.options.disabled, false, "Disabled");
same(c.options.hideDelay, 0, "Hide Delay");
- same(c.options.hideEvent, "leave", "Hide Event");
- same(c.options.showDelay, 0, "Show Delay");
- same(c.options.showEvent, "enter", "Show Event");
+ same(c.options.hideEvent, "mouseleave", "Hide Event");
+ same(c.options.showDelay, 500, "Show Delay");
+ same(c.options.showEvent, "mouseenter", "Show Event");
same(c.options.followMouse, true, "Follow Mouse");
});
Modified: trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java
===================================================================
--- trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/ui/common/api/src/main/java/org/richfaces/component/Positioning.java 2010-12-29 13:07:44 UTC (rev 20836)
@@ -4,18 +4,18 @@
* @author amarkhel
*/
public enum Positioning {
+ auto("AA"),
+ topLeft("LT"),
topRight("RT"),
- topLeft("LT"),
- bottomRight("BR"),
- bottomLeft("BL"),
+ bottomLeft("LB"),
+ bottomRight("RB"),
- auto("AA"),
+ autoLeft("LA"),
+ autoRight("RA"),
topAuto("AT"),
- bottomAuto("AB"),
- autoRight("RA"),
- autoLeft("LA");
+ bottomAuto("AB");
- public static final Positioning DEFAULT = bottomRight;
+ public static final Positioning DEFAULT = auto;
String value;
Modified: trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
===================================================================
--- trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/ui/common/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-12-29 13:07:44 UTC (rev 20836)
@@ -25,15 +25,17 @@
rf.ui = rf.ui || {};
rf.ui.Popup = function(id, options) {
- this.id = id;
+ $super.constructor.call(this, id);
+ this.options = $.extend({}, defaultOptions, options);
+ this.positionOptions = {type: this.options.positionType, from:this.options.jointPoint, to:this.options.direction, offset: this.options.positionOffset};
+
this.popup = $(document.getElementById(id));
- var mergedOptions = $.extend({}, defaultOptions, options);
- this.visible = mergedOptions.visible;
- this.attachTo = mergedOptions.attachTo;
- this.attachToBody = mergedOptions.attachToBody;
- this.positionType = mergedOptions.positionType;
- this.positionOffset = mergedOptions.positionOffset;
+ this.visible = this.options.visible;
+ this.attachTo = this.options.attachTo;
+ this.attachToBody = this.options.attachToBody;
+ this.positionType = this.options.positionType;
+ this.positionOffset = this.options.positionOffset;
};
rf.BaseComponent.extend(rf.ui.Popup);
@@ -56,7 +58,7 @@
this.visible = true;
}
- this.popup.setPosition(event || {id: this.attachTo}, {type: this.positionType , offset: this.positionOffset}).show();
+ this.popup.setPosition(event || {id: this.attachTo}, this.positionOptions).show();
},
hide: function() {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java 2010-12-29 13:07:44 UTC (rev 20836)
@@ -37,6 +37,7 @@
value,
layout,
attached,
+ jointPoint,
direction,
disabled,
followMouse,
@@ -86,7 +87,15 @@
public void setAttached(boolean attached) {
getStateHelper().put(PropertyKeys.attached, attached);
}
+
+ public Positioning getJointPoint() {
+ return (Positioning) getStateHelper().eval(PropertyKeys.jointPoint, Positioning.DEFAULT);
+ }
+ public void setJointPoint(Positioning jointPoint) {
+ getStateHelper().put(PropertyKeys.jointPoint, jointPoint);
+ }
+
public Positioning getDirection() {
return (Positioning) getStateHelper().eval(PropertyKeys.direction, Positioning.DEFAULT);
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-12-29 13:07:44 UTC (rev 20836)
@@ -160,7 +160,8 @@
Map<String, Object> options = new HashMap<String, Object>();
options.put("ajax", getAjaxOptions(context, tooltip));
- options.put("direction", tooltip.getDirection());
+ options.put("jointPoint", tooltip.getJointPoint().getValue());
+ options.put("direction", tooltip.getDirection().getValue());
options.put("attached", tooltip.isAttached());
options.put("offset", getOffset(tooltip));
options.put("mode", tooltip.getMode());
@@ -181,7 +182,7 @@
}
public Integer[] getOffset(HtmlTooltip tooltip) {
- return new Integer[] {tooltip.getHorizontalOffset(), tooltip.getHorizontalOffset()};
+ return new Integer[] {tooltip.getHorizontalOffset(), tooltip.getVerticalOffset()};
}
private void encodeContentEnd(ResponseWriter writer, FacesContext context, AbstractTooltip tooltip) throws IOException {
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js 2010-12-29 00:53:56 UTC (rev 20835)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.js 2010-12-29 13:07:44 UTC (rev 20836)
@@ -25,17 +25,6 @@
rf.ui = rf.ui || {};
- rf.ui.TooltipDirection = {
- topRight : "topRight",
- topLeft : "topLeft",
- bottomRight : "bottomRight",
- bottomLeft : "bottomLeft",
- auto : "auto",
-
- DEFAULT: "bottomRight"
- };
- var TooltipDirection = rf.ui.TooltipDirection;
-
rf.ui.TooltipMode = {
client : "client",
ajax : "ajax",
@@ -45,7 +34,9 @@
var TooltipMode = rf.ui.TooltipMode;
var DEFAULT_OPTIONS = {
- direction : TooltipDirection.DEFAULT,
+ jointPoint : "AA",
+ direction : "AA",
+ offset: [0,0],
attached : true,
offset : [10, 10],
mode : TooltipMode.DEFAULT,
@@ -132,7 +123,9 @@
attachTo: this.target,
attachToBody: false,
positionType: "TOOLTIP",
- positionOffset: this.options.offset
+ positionOffset: this.options.offset,
+ jointPoint: this.options.jointPoint,
+ direction: this.options.direction
});
var tooltip = this;
14 years
JBoss Rich Faces SVN: r20835 - in branches/RF-9323/cdk/generator/src: main/java/org/richfaces/cdk/model/validator and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-28 19:53:56 -0500 (Tue, 28 Dec 2010)
New Revision: 20835
Added:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/PropertyImpl.java
Modified:
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsPropertiesTest.java
Log:
CODING IN PROGRESS - issue RF-9323: CDK annotation @RendererSpecificComponent.attributes doesn't work
https://issues.jboss.org/browse/RF-9323
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-12-28 22:22:16 UTC (rev 20834)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/AptSourceUtils.java 2010-12-29 00:53:56 UTC (rev 20835)
@@ -2,15 +2,12 @@
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
-import java.util.Map.Entry;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
@@ -24,25 +21,43 @@
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.ElementKindVisitor6;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.Logger;
import org.richfaces.cdk.model.ClassName;
-import org.richfaces.cdk.model.InvalidNameException;
import org.richfaces.cdk.util.PropertyUtils;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
+/**
+ * <p class="changed_added_4_0">
+ * Implementation to use in annotation processor.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
public class AptSourceUtils implements SourceUtils {
- private static final Set<String> PROPERTIES =
- new HashSet<String>(Arrays.asList("getEventNames", "getDefaultEventName", "getClientBehaviors", "getFamily"));
+ private static final String IS = "is";
- private static final Predicate<Element> BEAN_PROPERTY_PREDICATE = new BeanPropertyMethodPredicate();
+ private static final int IS_LENGTH = IS.length();
+
+ private static final String GET = "get";
+
+ private static final String SET = "set";
+
+ private static final int SET_LENGTH = SET.length();
+
+ private static final int GET_LENGTH = GET.length();
+
+ private static final ImmutableSet<String> HIDDEN_PROPERTIES = ImmutableSet.of("eventNames", "defaultEventName",
+ "clientBehaviors", "family", "class");
+
private final ProcessingEnvironment processingEnv;
@Inject
@@ -69,210 +84,140 @@
*/
public Set<BeanProperty> getBeanPropertiesAnnotatedWith(Class<? extends Annotation> annotation, TypeElement type) {
Set<BeanProperty> properties = new HashSet<BeanProperty>();
- List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(type);
-
- // Get all methods and fields annotated by annotation.
- for (Element childElement : members) {
- boolean annotated = null != childElement.getAnnotation(annotation);
- if (!annotated) {
- continue;
+ Map<String, AptBeanProperty> beanProperties = getBeanProperties(type);
+ for (BeanProperty beanProperty : beanProperties.values()) {
+ if (beanProperty.isAnnotationPresent(annotation)) {
+ properties.add(beanProperty);
}
-
- // Have an annotation, infer property name.
- if (ElementKind.METHOD.equals(childElement.getKind())) {
- processMethod(properties, childElement, annotated);
- } else if (ElementKind.FIELD.equals(childElement.getKind())) {
-// processFiled(properties, childElement);
- }
-
- // TODO - merge properties with same name ?
}
-
return properties;
}
public Set<BeanProperty> getAbstractBeanProperties(TypeElement type) {
- log.debug("AptSourceUtils.getAbstractBeanProperties");
- log.debug(" - type = " + type);
-
Set<BeanProperty> properties = new HashSet<BeanProperty>();
- List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(type);
-
- Map<String, List<ExecutableElement>> props = groupMethodsBySignature(members);
- removeNotAbstractGroups(props);
-
- for (List<ExecutableElement> methods : props.values()) {
- ExecutableElement method = methods.get(0);
-
- if (ElementKind.METHOD.equals(method.getKind()) && !PROPERTIES.contains(method.getSimpleName().toString())) {
- processMethod(properties, method, false);
+ Map<String, AptBeanProperty> beanProperties = getBeanProperties(type);
+ for (BeanProperty beanProperty : beanProperties.values()) {
+ if (!beanProperty.isExists()) {
+ properties.add(beanProperty);
}
-
- // TODO - merge properties with same name ?
}
-
return properties;
}
@Override
- public BeanProperty getBeanProperty(TypeElement type, String name) {
- List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(type);
- return null;
+ public BeanProperty getBeanProperty(ClassName type, final String name) {
+ return getBeanProperty(asTypeElement(type), name);
}
+ @Override
+ public BeanProperty getBeanProperty(TypeElement type, final String name) {
+ Map<String, AptBeanProperty> beanProperties = getBeanProperties(type);
+ if (beanProperties.containsKey(name)) {
+ return beanProperties.get(name);
+ } else {
+ return new PropertyImpl(name);
+ }
+ }
+
/**
- * <p class="changed_added_4_0">Utility method to get all bean properties, similar to Introspector</p>
+ * <p class="changed_added_4_0">
+ * Utility method to get all bean properties, similar to Introspector
+ * </p>
+ *
* @param type
* @return
*/
- Map<String,BeanProperty> getBeanProperties(TypeElement type){
+ Map<String, AptBeanProperty> getBeanProperties(TypeElement type) {
List<? extends Element> members = this.processingEnv.getElementUtils().getAllMembers(type);
// extract all getters/setters.
- Map<String,BeanProperty> result = Maps.newHashMap();
+ Map<String, AptBeanProperty> result = Maps.newHashMap();
for (Element element : members) {
- if (ElementKind.METHOD.equals(element.getKind())){
+ if (ElementKind.METHOD.equals(element.getKind())) {
ExecutableElement method = (ExecutableElement) element;
- if(isPublicNonStatic(method)){
- if(isGetter(method)){
- String propertyName = PropertyUtils.methodToName(method.getSimpleName().toString());
- if(result.containsKey(propertyName)){
- // Merge property with existed one.
- BeanProperty beanProperty = result.get(propertyName);
-// processingEnv.getElementUtils().
- } else {
-
- }
- } else if (isSetter(method)) {
-
- }
- }
+ processMethod(type, result, method);
}
}
return result;
}
-
- private void removeNotAbstractGroups(Map<String, List<ExecutableElement>> props) {
- List<String> removeKeys = new ArrayList<String>();
- for (Map.Entry<String, List<ExecutableElement>> entry : props.entrySet()) {
- List<ExecutableElement> value = entry.getValue();
- for (ExecutableElement element : value) {
- if (!isAbstract(element)) {
- removeKeys.add(entry.getKey());
- }
+
+ private void processMethod(TypeElement type, Map<String, AptBeanProperty> result, ExecutableElement method) {
+ if (isPublicNonStatic(method)) {
+ if (isGetter(method)) {
+ processBeanPropertyAccessor(type, result, method, false);
+ } else if (isSetter(method)) {
+ processBeanPropertyAccessor(type, result, method, true);
}
}
-
- for (String removeKey : removeKeys) {
- props.remove(removeKey);
- }
}
- private Map<String, List<ExecutableElement>> groupMethodsBySignature(List<? extends Element> members) {
- Map<String, List<ExecutableElement>> props = new HashMap<String, List<ExecutableElement>>();
- for (Element element : members) {
- if (ElementKind.METHOD.equals(element.getKind())
- && !PROPERTIES.contains(element.getSimpleName().toString())) {
-
- ExecutableElement method = (ExecutableElement) element;
-
- String signature = getSignature(method);
-
- List<ExecutableElement> methods = props.get(signature);
- if (methods == null) {
- methods = new ArrayList<ExecutableElement>(5);
- props.put(signature, methods);
+ private void processBeanPropertyAccessor(TypeElement type, Map<String, AptBeanProperty> result,
+ ExecutableElement method, boolean setter) {
+ String propertyName = getPropertyName(method);
+ if (!HIDDEN_PROPERTIES.contains(propertyName)) {
+ ClassName propertyType = asClassDescription(method.getReturnType());
+ if (result.containsKey(propertyName)) {
+ // Merge property with existed one.
+ AptBeanProperty beanProperty = result.get(propertyName);
+ if (null != beanProperty.getter) {
+ log.warn("Two " + (setter ? "setter" : "getter") + " methods for the same bean property "
+ + propertyName + " in the class " + type.getQualifiedName());
}
-
- methods.add(method);
+ checkPropertyType(type, propertyName, propertyType, beanProperty);
+ beanProperty.setAccessMethod(method, setter);
+ } else {
+ AptBeanProperty beanProperty = new AptBeanProperty(propertyName);
+ beanProperty.setAccessMethod(method, setter);
+ beanProperty.type = propertyType;
+ result.put(propertyName, beanProperty);
}
+
}
- return props;
}
- private String getSignature(ExecutableElement method) {
- String name = method.getSimpleName().toString();
- List<? extends VariableElement> methodParams = method.getParameters();
- StringBuilder builder = new StringBuilder(name);
- for (VariableElement methodParam : methodParams) {
- builder.append(":").append(methodParam.getKind().name());
- }
- return builder.toString();
+ private String getPropertyName(ExecutableElement method) {
+ return PropertyUtils.methodToName(method.getSimpleName().toString());
}
- private void processMethod(Set<BeanProperty> properties, Element childElement, boolean annotated) {
- ExecutableElement method = (ExecutableElement) childElement;
- boolean exists = !isAbstract(method);
- if (!annotated && exists) {
- log.debug(" - " + childElement.getSimpleName() + " : didn't annotated and didn't abstract.");
- return;
+ private void checkPropertyType(TypeElement type, String propertyName, ClassName propertyType,
+ AptBeanProperty beanProperty) {
+ if (!propertyType.equals(beanProperty.type)) {
+ log.warn("Unambiguious type for bean property " + propertyName + " in the class " + type.getQualifiedName());
}
-
- TypeMirror propertyType = method.getReturnType();
- List<? extends VariableElement> parameters = method.getParameters();
- if (TypeKind.VOID.equals(propertyType.getKind()) && 1 == parameters.size()) {
-
- // That is setter method, get type from parameter.
- propertyType = parameters.get(0).asType();
- } else if (!parameters.isEmpty()) {
- // TODO Invalid method signature for a bean property,
- // throw exception ?
- log.debug(" - " + childElement.getSimpleName() + " : Invalid method signature for a bean property.");
- return;
- }
-
- try {
- String name = PropertyUtils.methodToName(childElement.getSimpleName().toString());
- AptBeanProperty property = new AptBeanProperty(name);
-
- property.type = asClassDescription(propertyType);
- property.getter = (ExecutableElement) childElement;
- property.exists = exists;
-
- properties.add(property);
- log.debug(" - " + childElement.getSimpleName() + " : was added.");
-
- } catch (InvalidNameException e) {
- log.debug(" - " + childElement.getSimpleName() + " : Invalid method name for a bean property, throw.");
-
- // TODO Invalid method name for a bean property, throw
- // exception ?
- }
}
private boolean isAbstract(ExecutableElement method) {
return method.getModifiers().contains(Modifier.ABSTRACT);
}
- private boolean isPublicNonStatic(ExecutableElement method){
+ private boolean isPublicNonStatic(ExecutableElement method) {
Set<Modifier> modifiers = method.getModifiers();
return modifiers.contains(Modifier.PUBLIC) && !modifiers.contains(Modifier.STATIC);
}
-
+
private boolean isGetter(ExecutableElement e) {
String methodName = e.getSimpleName().toString();
- return (isGetterName(methodName)||isBooleanGetterName(methodName)) && 0 == e.getParameters().size();
+ return (isGetterName(methodName) || isBooleanGetterName(methodName)) && 0 == e.getParameters().size();
}
private boolean isGetterName(String methodName) {
- return methodName.startsWith("get") && methodName.length()>3 && Character.isUpperCase(methodName.charAt(3));
+ return methodName.startsWith(GET) && methodName.length() > GET_LENGTH
+ && Character.isUpperCase(methodName.charAt(GET_LENGTH));
}
-
- private boolean isBooleanGetter(ExecutableElement e) {
- String methodName = e.getSimpleName().toString();
- return isBooleanGetterName(methodName) && 0 == e.getParameters().size() && TypeKind.BOOLEAN.equals(e.getReturnType().getKind());
- }
private boolean isBooleanGetterName(String methodName) {
- return methodName.startsWith("is") && methodName.length()>2 && Character.isUpperCase(methodName.charAt(2));
+ return methodName.startsWith(IS) && methodName.length() > IS_LENGTH
+ && Character.isUpperCase(methodName.charAt(IS_LENGTH));
}
-
+
private boolean isSetter(ExecutableElement e) {
String methodName = e.getSimpleName().toString();
- return isSetterName(methodName) && 1 == e.getParameters().size() && !e.isVarArgs() && TypeKind.VOID.equals(e.getReturnType().getKind());
+ return isSetterName(methodName) && 1 == e.getParameters().size() && !e.isVarArgs()
+ && TypeKind.VOID.equals(e.getReturnType().getKind());
}
private boolean isSetterName(String methodName) {
- return methodName.startsWith("set") && methodName.length()>3 && Character.isUpperCase(methodName.charAt(3));
+ return methodName.startsWith(SET) && methodName.length() > SET_LENGTH
+ && Character.isUpperCase(methodName.charAt(SET_LENGTH));
}
private ClassName asClassDescription(TypeMirror type) {
@@ -302,12 +247,12 @@
return null != element.getAnnotation(annotationType);
}
-
@Override
- public boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName){
- return Iterables.any(getAnnotationValuesMap(annotation).entrySet(), new AnnotationAttributePredicate(propertyName));
+ public boolean isAnnotationPropertyPresent(AnnotationMirror annotation, final String propertyName) {
+ return Iterables.any(getAnnotationValuesMap(annotation).entrySet(), new AnnotationAttributePredicate(
+ propertyName));
}
-
+
@Override
public boolean isDefaultValue(AnnotationMirror annotation, String propertyName) {
Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry =
@@ -315,7 +260,6 @@
return !annotation.getElementValues().containsKey(attributeEntry.getKey());
}
- @SuppressWarnings("unchecked")
@Override
public <T> T getAnnotationValue(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry =
@@ -324,6 +268,7 @@
return convertAnnotationValue(expectedType, annotationValue);
}
+ @SuppressWarnings("unchecked")
private <T> T convertAnnotationValue(Class<T> expectedType, AnnotationValue annotationValue) {
if (Enum.class.isAssignableFrom(expectedType)) {
VariableElement variable = (VariableElement) annotationValue.getValue();
@@ -335,7 +280,6 @@
AnnotationMirror value = (AnnotationMirror) annotationValue.getValue();
return (T) value;
} else {
- // TODO - check value for expected type.
return (T) annotationValue.getValue();
}
}
@@ -345,7 +289,8 @@
public <T> List<T> getAnnotationValues(AnnotationMirror annotation, String propertyName, Class<T> expectedType) {
Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> attributeEntry =
findAnnotationProperty(annotation, propertyName);
- List<? extends AnnotationValue>annotationValues = (List<? extends AnnotationValue>) attributeEntry.getValue().getValue();
+ List<? extends AnnotationValue> annotationValues =
+ (List<? extends AnnotationValue>) attributeEntry.getValue().getValue();
List<T> values = Lists.newArrayList();
for (AnnotationValue annotationValue : annotationValues) {
values.add(convertAnnotationValue(expectedType, annotationValue));
@@ -356,43 +301,57 @@
private Entry<? extends ExecutableElement, ? extends AnnotationValue> findAnnotationProperty(
AnnotationMirror annotation, final String propertyName) {
try {
- return Iterables.find(getAnnotationValuesMap(annotation).entrySet(),
- new AnnotationAttributePredicate(propertyName));
+ return Iterables.find(getAnnotationValuesMap(annotation).entrySet(), new AnnotationAttributePredicate(
+ propertyName));
} catch (NoSuchElementException e) {
throw new CdkException("Attribute " + propertyName + " not found for annotation "
+ annotation.getAnnotationType().toString());
}
}
- private Map<? extends ExecutableElement, ? extends AnnotationValue> getAnnotationValuesMap(AnnotationMirror annotation) {
+ private Map<? extends ExecutableElement, ? extends AnnotationValue> getAnnotationValuesMap(
+ AnnotationMirror annotation) {
return processingEnv.getElementUtils().getElementValuesWithDefaults(annotation);
}
/**
- * <p class="changed_added_4_0">Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value.</p>
- * @param model Model object.
- * @param annotation annotation to copy property from.
- * @param modelProperty bean attribute name in the model and annotation.
+ * <p class="changed_added_4_0">
+ * Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value.
+ * </p>
+ *
+ * @param model
+ * Model object.
+ * @param annotation
+ * annotation to copy property from.
+ * @param modelProperty
+ * bean attribute name in the model and annotation.
*/
@Override
public void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty) {
- setModelProperty(model, annotation, modelProperty, modelProperty);
+ setModelProperty(model, annotation, modelProperty, modelProperty);
}
/**
- * <p class="changed_added_4_0">Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value.</p>
- * @param model Model object.
- * @param annotation annotation to copy property from.
- * @param modelProperty bean attribute name in model.
- * @param annotationAttribute annotation attribute name.
+ * <p class="changed_added_4_0">
+ * Set model property to the corresponding annotation attribute, if annotation attribute set to non-default value.
+ * </p>
+ *
+ * @param model
+ * Model object.
+ * @param annotation
+ * annotation to copy property from.
+ * @param modelProperty
+ * bean attribute name in model.
+ * @param annotationAttribute
+ * annotation attribute name.
*/
@Override
- public void setModelProperty(Object model, AnnotationMirror annotation,
- String modelProperty, String annotationAttribute) {
+ public void setModelProperty(Object model, AnnotationMirror annotation, String modelProperty,
+ String annotationAttribute) {
if (!isDefaultValue(annotation, annotationAttribute)) {
PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(model, modelProperty);
- PropertyUtils.setPropertyValue(model, modelProperty, getAnnotationValue(annotation,
- annotationAttribute, propertyDescriptor.getPropertyType()));
+ PropertyUtils.setPropertyValue(model, modelProperty,
+ getAnnotationValue(annotation, annotationAttribute, propertyDescriptor.getPropertyType()));
}
}
@@ -424,11 +383,14 @@
visitor.visit(type);
}
- @Override
- public TypeElement asTypeElement(ClassName type) {
+ private TypeElement asTypeElement(ClassName type) {
return processingEnv.getElementUtils().getTypeElement(type.toString());
}
+ public boolean isClassExists(ClassName type){
+ return null != asTypeElement(type);
+ }
+
@Override
public TypeElement asTypeElement(TypeMirror mirror) {
if (TypeKind.DECLARED.equals(mirror.getKind())) {
@@ -438,45 +400,13 @@
}
}
- private static final class BeanPropertyMethodPredicate extends ElementKindVisitor6<Boolean, Boolean> implements Predicate<Element> {
-
- public BeanPropertyMethodPredicate() {
- super(Boolean.FALSE);
- }
-
- @Override
- public Boolean visitExecutableAsMethod(ExecutableElement e, Boolean p) {
- Set<Modifier> modifiers = e.getModifiers();
- // bean accessors have to be publis, non-static.
- if(modifiers.contains(Modifier.PUBLIC) && !modifiers.contains(Modifier.STATIC)){
- if(isGetter(e)||isBooleanGetter(e)||isSetter(e)){
- return Boolean.TRUE;
- }
- }
- return DEFAULT_VALUE;
- }
-
- private boolean isGetter(ExecutableElement e) {
- String methodName = e.getSimpleName().toString();
- return methodName.startsWith("get") && methodName.length()>3 && Character.isUpperCase(methodName.charAt(3)) && 0 == e.getParameters().size();
- }
-
- private boolean isBooleanGetter(ExecutableElement e) {
- String methodName = e.getSimpleName().toString();
- return methodName.startsWith("is") && methodName.length()>2 && Character.isUpperCase(methodName.charAt(2)) && 0 == e.getParameters().size() && TypeKind.BOOLEAN.equals(e.getReturnType().getKind());
- }
-
- private boolean isSetter(ExecutableElement e) {
- String methodName = e.getSimpleName().toString();
- return methodName.startsWith("set") && methodName.length()>3 && Character.isUpperCase(methodName.charAt(3)) && 1 == e.getParameters().size() && !e.isVarArgs() && TypeKind.VOID.equals(e.getReturnType().getKind());
- }
-
- @Override
- public boolean apply(Element input) {
- return visit(input);
- }
- }
-
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
private static final class AnnotationAttributePredicate implements
Predicate<Map.Entry<? extends ExecutableElement, ? extends AnnotationValue>> {
private final String propertyName;
@@ -502,9 +432,6 @@
protected final class AptBeanProperty implements BeanProperty {
private ExecutableElement getter;
private ExecutableElement setter;
- private String docComment;
- private Map<Class<? extends Annotation>,AnnotationMirror> annotations = Maps.newHashMap();
- private boolean exists;
private final String name;
private ClassName type;
@@ -518,6 +445,103 @@
this.name = name;
}
+ void setAccessMethod(ExecutableElement method, boolean setter) {
+ if (setter) {
+ this.setter = method;
+ } else {
+ this.getter = method;
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Get JavaDoc comment of appropriate bean property element.
+ * </p>
+ *
+ * @return
+ */
+ public String getDocComment() {
+ String comment = getMethodComment(getter);
+ if (null == comment) {
+ comment = getMethodComment(setter);
+ }
+ return comment;
+ }
+
+ private String getMethodComment(ExecutableElement method) {
+ if (null != method) {
+ return processingEnv.getElementUtils().getDocComment(method);
+ } else {
+ return null;
+ }
+ }
+
+ public ClassName getType() {
+ return type;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the exists
+ */
+ public boolean isExists() {
+ return !(isAbstract(getter) || isAbstract(setter));
+ }
+
+ private boolean isAbstract(ExecutableElement method) {
+ return null != method && method.getModifiers().contains(Modifier.ABSTRACT);
+ }
+
+ public AnnotationMirror getAnnotationMirror(Class<? extends Annotation> annotationType) {
+ if (isAnnotationPresent(getter, annotationType)) {
+ return AptSourceUtils.this.getAnnotationMirror(getter, annotationType);
+ } else if (isAnnotationPresent(setter, annotationType)) {
+ return AptSourceUtils.this.getAnnotationMirror(setter, annotationType);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+ return isAnnotationPresent(getter, annotationType) || isAnnotationPresent(setter, annotationType);
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ if (isAnnotationPresent(getter, annotationType)) {
+ return getter.getAnnotation(annotationType);
+ } else if (isAnnotationPresent(setter, annotationType)) {
+ return setter.getAnnotation(annotationType);
+ }
+ return null;
+ }
+
+ private <T extends Annotation> boolean isAnnotationPresent(ExecutableElement method, Class<T> annotationType) {
+ return null != method && null != method.getAnnotation(annotationType);
+ }
+
+ @Override
+ public ACCESS_TYPE getAccessType() {
+ if (null != getter && null != setter) {
+ return ACCESS_TYPE.readWrite;
+ } else if (null == setter) {
+ return ACCESS_TYPE.readOnly;
+ }
+ return ACCESS_TYPE.writeOnly;
+ }
+
/*
* (non-Javadoc)
*
@@ -565,45 +589,10 @@
return true;
}
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the name
- */
- public String getName() {
- return name;
+ @Override
+ public String toString() {
+ return name + "[" + getType() + "]";
}
-
- /**
- * <p class="changed_added_4_0">
- * Get JavaDoc comment of appropriate bean property element.
- * </p>
- *
- * @return
- */
- public String getDocComment() {
- return processingEnv.getElementUtils().getDocComment(getter);
- }
-
- public ClassName getType() {
- return type;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the exists
- */
- public boolean isExists() {
- return exists;
- }
-
- public AnnotationMirror getAnnotationMirror(Class<? extends Annotation> annotationType) {
- return AptSourceUtils.this.getAnnotationMirror(getter, annotationType);
- }
-
}
}
Added: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/PropertyImpl.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/PropertyImpl.java (rev 0)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/PropertyImpl.java 2010-12-29 00:53:56 UTC (rev 20835)
@@ -0,0 +1,57 @@
+package org.richfaces.cdk.apt;
+
+import java.lang.annotation.Annotation;
+
+import javax.lang.model.element.AnnotationMirror;
+
+import org.richfaces.cdk.apt.SourceUtils.ACCESS_TYPE;
+import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
+import org.richfaces.cdk.model.ClassName;
+
+public final class PropertyImpl implements BeanProperty {
+ private final String name;
+
+ public PropertyImpl(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean isExists() {
+ return false;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+ return false;
+ }
+
+ @Override
+ public ClassName getType() {
+ return ClassName.get(Object.class);
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public String getDocComment() {
+ return null;
+ }
+
+ @Override
+ public AnnotationMirror getAnnotationMirror(Class<? extends Annotation> annotationType) {
+ return null;
+ }
+
+ @Override
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
+ return null;
+ }
+
+ @Override
+ public ACCESS_TYPE getAccessType() {
+ return ACCESS_TYPE.readWrite;
+ }
+}
\ No newline at end of file
Property changes on: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/PropertyImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-12-28 22:22:16 UTC (rev 20834)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/ReflectionUtils.java 2010-12-29 00:53:56 UTC (rev 20835)
@@ -49,9 +49,8 @@
}
@Override
- public TypeElement asTypeElement(ClassName type) {
- // TODO Auto-generated method stub
- return null;
+ public boolean isClassExists(ClassName type) {
+ return true;
}
@Override
@@ -68,6 +67,11 @@
@Override
public BeanProperty getBeanProperty(TypeElement type, String name) {
+ return getBeanProperty(type, name);
+ }
+
+ @Override
+ public BeanProperty getBeanProperty(ClassName type, String name) {
// TODO Auto-generated method stub
return null;
}
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-12-28 22:22:16 UTC (rev 20834)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/apt/SourceUtils.java 2010-12-29 00:53:56 UTC (rev 20835)
@@ -59,6 +59,11 @@
void visit(TypeMirror type);
}
+ enum ACCESS_TYPE {
+ readOnly,
+ writeOnly,
+ readWrite
+ }
/**
* <p class="changed_added_4_0">
* </p>
@@ -85,18 +90,28 @@
*/
String getDocComment();
+ /**
+ * <p class="changed_added_4_0">Bean property type</p>
+ * @return
+ */
ClassName getType();
/**
- * <p class="changed_added_4_0">
+ * <p class="changed_added_4_0">Is this property implementted by component
* </p>
*
* @return the exists
*/
boolean isExists();
+
+ boolean isAnnotationPresent(Class<? extends Annotation> annotationType);
AnnotationMirror getAnnotationMirror(Class<? extends Annotation> annotationType);
+ <T extends Annotation> T getAnnotation(Class<T> annotationType);
+
+ ACCESS_TYPE getAccessType();
+
}
/**
@@ -129,6 +144,14 @@
BeanProperty getBeanProperty(TypeElement type, String name);
/**
+ * <p class="changed_added_4_0">Get bean property descriptor for particular type.</p>
+ * @param type
+ * @param name
+ * @return
+ */
+ BeanProperty getBeanProperty(ClassName type, String name);
+
+ /**
* <p class="changed_added_4_0">
* Get JavaDoc comments associated with given element.
* </p>
@@ -245,8 +268,8 @@
* </p>
*
* @param type
- * @return TypeElement for given type, or null if corresponding name does not exist.
+ * @return true if class already exist in project source or dependent libraries.
*/
- TypeElement asTypeElement(ClassName type);
+ boolean isClassExists(ClassName type);
}
Modified: branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java
===================================================================
--- branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-28 22:22:16 UTC (rev 20834)
+++ branches/RF-9323/cdk/generator/src/main/java/org/richfaces/cdk/model/validator/ValidatorImpl.java 2010-12-29 00:53:56 UTC (rev 20835)
@@ -51,6 +51,7 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.InvalidNameException;
+import org.richfaces.cdk.model.ModelElement;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
@@ -232,7 +233,7 @@
// TODO - infer listener interface name.
}
SourceUtils sourceUtils = sourceUtilsProvider.get();
- event.setGenerateListener(null == sourceUtils.asTypeElement(listenerInterface));
+ event.setGenerateListener(!sourceUtils.isClassExists(listenerInterface));
String methodName = event.getListenerMethod();
if (null == methodName) {
// TODO infer listener method name.
@@ -243,7 +244,7 @@
if (null == sourceInterface) {
// TODO - infer source interface.
}
- event.setGenerateSource(null == sourceUtils.asTypeElement(sourceInterface));
+ event.setGenerateSource(!sourceUtils.isClassExists(listenerInterface));
// Propagate event to corresponding components.
for (ComponentModel component : library.getComponents()) {
for (EventModel componentEvent : component.getEvents()) {
@@ -376,7 +377,7 @@
} // Check attributes.
for (PropertyBase attribute : component.getAttributes()) {
- verifyAttribute(attribute, component.getGenerate());
+ verifyAttribute(attribute, component);
}
// compact(component.getAttributes());
// Check renderers.
@@ -461,7 +462,7 @@
}
}
// Check classes.
- if (component.getGenerate()) {
+ if (Boolean.TRUE.equals(component.getGenerate())) {
if (null == component.getBaseClass()) {
component.setBaseClass(callback.getDefaultBaseClass());
// return;
@@ -482,7 +483,7 @@
return true;
}
- protected void verifyAttribute(PropertyBase attribute, boolean generatedComponent) {
+ protected void verifyAttribute(PropertyBase attribute, FacesComponent component) {
// Check name.
if (Strings.isEmpty(attribute.getName())) {
log.error("No name for attribute " + attribute);
@@ -509,7 +510,7 @@
// log.error("Signature for method expression attribute "+attribute.getName()+" has not been set");
// }
// Check "generate" flag.
- if (generatedComponent) {
+ if (Boolean.TRUE.equals(component.getGenerate())) {
// TODO Attribute should be only generated if it does not exist or abstract in the base class.
// Step one - check base class
} else {
Modified: branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsPropertiesTest.java
===================================================================
--- branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsPropertiesTest.java 2010-12-28 22:22:16 UTC (rev 20834)
+++ branches/RF-9323/cdk/generator/src/test/java/org/richfaces/cdk/apt/AptSourceUtilsPropertiesTest.java 2010-12-29 00:53:56 UTC (rev 20835)
@@ -160,7 +160,7 @@
public void process(SourceUtils utils, RoundEnvironment roundEnv) {
AptSourceUtils aptUtils = (AptSourceUtils) utils;
TypeElement subClassType = (TypeElement) findElement(roundEnv, TEST_SUB_CLASS);
- assertEquals(5, aptUtils.getBeanProperties(subClassType).size());
+ assertEquals(6, aptUtils.getBeanProperties(subClassType).size());
}
});
}
14 years
JBoss Rich Faces SVN: r20834 - in trunk/ui/iteration/ui/src/main: resources/META-INF and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-28 17:22:16 -0500 (Tue, 28 Dec 2010)
New Revision: 20834
Added:
trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/
trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/
trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
Log:
https://issues.jboss.org/browse/RF-10041
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-28 20:16:31 UTC (rev 20833)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-28 22:22:16 UTC (rev 20834)
@@ -92,7 +92,7 @@
family = AbstractTree.COMPONENT_FAMILY,
tag = @Tag(name = "tree", handler = "org.richfaces.view.facelets.TreeHandler"),
renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
- attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
+ attributes = {"ajax-props.xml", "events-props.xml", "core-props.xml", "i18n-props.xml", "tree-common-props.xml"}
)
//TODO add rowData caching for wrapper events
public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentResolver, MetaComponentEncoder, TreeSelectionChangeSource, TreeToggleSource {
@@ -165,24 +165,15 @@
return treeRange;
}
+ @Attribute
public abstract Object getValue();
+ @Attribute
public abstract boolean isImmediate();
- public abstract String getIconLeaf();
-
- public abstract String getIconExpanded();
-
- public abstract String getIconCollapsed();
-
+ @Attribute
public abstract String getNodeClass();
- public abstract String getHandleClass();
-
- public abstract String getIconClass();
-
- public abstract String getLabelClass();
-
@Attribute(events = @EventName("nodetoggle"))
public abstract String getOnnodetoggle();
@@ -201,27 +192,12 @@
@Attribute
public abstract SwitchType getSelectionType();
+ @Attribute
public abstract String getNodeType();
+ @Attribute
public abstract String getToggleNodeEvent();
- public abstract Object getExecute();
-
- public abstract Object getRender();
-
- public abstract boolean isLimitRender();
-
- @Attribute(events = @EventName("begin"))
- public abstract String getOnbegin();
-
- @Attribute(events = @EventName("beforedomupdate"))
- public abstract String getOnbeforedomupdate();
-
- @Attribute(events = @EventName("complete"))
- public abstract String getOncomplete();
-
- public abstract String getStatus();
-
@Override
public String getFamily() {
return COMPONENT_FAMILY;
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-12-28 20:16:31 UTC (rev 20833)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTreeNode.java 2010-12-28 22:22:16 UTC (rev 20834)
@@ -58,7 +58,7 @@
family = AbstractTreeNode.COMPONENT_FAMILY,
tag = @Tag(name = "treeNode", handler = "org.richfaces.view.facelets.TreeNodeHandler"),
renderer = @JsfRenderer(type = "org.richfaces.TreeNodeRenderer"),
- attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml", "tree-common-props.xml"}
)
public abstract class AbstractTreeNode extends UIComponentBase implements MetaComponentResolver, MetaComponentEncoder, IterationStateHolder, TreeToggleSource {
@@ -87,20 +87,9 @@
@Attribute
public abstract boolean isImmediate();
+ @Attribute
public abstract String getType();
- public abstract String getIconLeaf();
-
- public abstract String getIconExpanded();
-
- public abstract String getIconCollapsed();
-
- public abstract String getHandleClass();
-
- public abstract String getIconClass();
-
- public abstract String getLabelClass();
-
@Attribute(events = @EventName("toggle"))
public abstract String getOntoggle();
@@ -111,6 +100,7 @@
return (Boolean) getStateHelper().get(PropertyKeys.expanded);
}
+ @Attribute
public boolean isExpanded() {
FacesContext context = getFacesContext();
Boolean localExpandedValue = getLocalExpandedValue(context);
Added: trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml (rev 0)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/cdk/attributes/tree-common-props.xml 2010-12-28 22:22:16 UTC (rev 20834)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- JBoss, Home of Professional Open Source Copyright ${year}, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the copyright.txt
+ in the distribution for a full listing of individual contributors. This is
+ free software; you can redistribute it and/or modify it under the terms of
+ the GNU Lesser General Public License as published by the Free Software Foundation;
+ either version 2.1 of the License, or (at your option) any later version.
+ This software is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details. You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the
+ FSF site: http://www.fsf.org. -->
+<cdk:properties xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee">
+
+ <property>
+ <property-name>iconLeaf</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>iconExpanded</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>iconCollapsed</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <property-name>handleClass</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>iconClass</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <property-name>labelClass</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+</cdk:properties>
14 years
JBoss Rich Faces SVN: r20833 - in trunk: examples/input-demo/src/main/webapp/examples and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-28 15:16:31 -0500 (Tue, 28 Dec 2010)
New Revision: 20833
Modified:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
trunk/ui/input/ui/src/main/templates/fileupload.template.xml
Log:
RF-10082
Modified: trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-28 20:02:52 UTC (rev 20832)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-28 20:16:31 UTC (rev 20833)
@@ -39,7 +39,7 @@
public class FileUploadBean {
private String acceptedTypes;
- private boolean enabled = true;
+ private boolean disabled = false;
private boolean noDuplicate = false;
private UploadedFile file;
@@ -55,12 +55,12 @@
file = event.getUploadedFile();
}
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
}
- public boolean isEnabled() {
- return enabled;
+ public boolean isDisabled() {
+ return disabled;
}
public void setNoDuplicate(boolean noDuplicate) {
Modified: trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml 2010-12-28 20:02:52 UTC (rev 20832)
+++ trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml 2010-12-28 20:16:31 UTC (rev 20833)
@@ -65,7 +65,7 @@
};
//-->
</script>
- <fu:fileUpload id="fu" acceptedTypes="#{fileUploadBean.acceptedTypes}" enabled="#{fileUploadBean.enabled}"
+ <fu:fileUpload id="fu" acceptedTypes="#{fileUploadBean.acceptedTypes}" disabled="#{fileUploadBean.disabled}"
fileUploadListener="#{fileUploadBean.listener}" noDuplicate="#{fileUploadBean.noDuplicate}"
onfilesubmit="onfilesubmit(event)" onuploadcomplete="onuploadcomplete(event)"/>
<h:outputText value="File name:" />
@@ -84,8 +84,8 @@
<f:ajax render="fu"/>
</h:inputText>
<br />
- <h:outputText value="Enabled: " />
- <h:selectBooleanCheckbox value="#{fileUploadBean.enabled}">
+ <h:outputText value="Disabled: " />
+ <h:selectBooleanCheckbox value="#{fileUploadBean.disabled}">
<f:ajax render="fu"/>
</h:selectBooleanCheckbox>
<br />
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-28 20:02:52 UTC (rev 20832)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-28 20:16:31 UTC (rev 20833)
@@ -53,8 +53,8 @@
@Attribute
public abstract String getAcceptedTypes();
- @Attribute(defaultValue = "true")
- public abstract boolean isEnabled();
+ @Attribute(defaultValue = "false")
+ public abstract boolean isDisabled();
@Attribute(defaultValue = "false")
public abstract boolean isNoDuplicate();
Modified: trunk/ui/input/ui/src/main/templates/fileupload.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/fileupload.template.xml 2010-12-28 20:02:52 UTC (rev 20832)
+++ trunk/ui/input/ui/src/main/templates/fileupload.template.xml 2010-12-28 20:16:31 UTC (rev 20833)
@@ -39,14 +39,14 @@
</cc:interface>
<cc:implementation>
<cdk:object name="attributes" value="#{component.attributes}"/>
- <cdk:object name="enabled" value="#{attributes['enabled']}"/>
+ <cdk:object name="disabled" value="#{attributes['disabled']}"/>
<div id="#{clientId}" class="rf-fu #{attributes['styleClass']}"
cdk:passThroughWithExclusions="">
<div class="rf-fu-hdr">
<span class="rf-fu-btns-lft">
- <span class="rf-fu-btn-add#{enabled ? '' : '-dis'}">
- <span class="rf-fu-btn-cnt-add#{enabled ? '' : '-dis'}">
- <c:if test="#{enabled}">
+ <span class="rf-fu-btn-add#{disabled ? '-dis' : ''}">
+ <span class="rf-fu-btn-cnt-add#{disabled ? '-dis' : ''}">
+ <c:if test="#{!disabled}">
<span class="rf-fu-inp-cntr"> <!-- This span is needed for IE7 only. -->
<input type="file" class="rf-fu-inp"/>
</span>
@@ -55,14 +55,14 @@
#{addLabel != null ? addLabel : 'Add...'}
</span>
</span>
- <c:if test="#{enabled}">
+ <c:if test="#{!disabled}">
<span class="rf-fu-btn-upl">
<cdk:object name="uploadLabel" value="#{attributes['uploadLabel']}"/>
<span class="rf-fu-btn-cnt-upl">#{uploadLabel != null ? uploadLabel : 'Upload'}</span>
</span>
</c:if>
</span>
- <c:if test="#{enabled}">
+ <c:if test="#{!disabled}">
<span class="rf-fu-btns-rgh">
<span class="rf-fu-btn-clr">
<cdk:object name="clearAllLabel" value="#{attributes['clearAllLabel']}"/>
@@ -72,7 +72,7 @@
</c:if>
</div>
<div class="rf-fu-lst"/>
- <c:if test="#{enabled}">
+ <c:if test="#{!disabled}">
<div class="rf-fu-cntr-hdn">
<iframe name="#{clientId}"/>
<cdk:object name="progressBar" value="#{component.facets['progress']}"/>
14 years
JBoss Rich Faces SVN: r20832 - in trunk: ui/core/ui/src/main/java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-28 15:02:52 -0500 (Tue, 28 Dec 2010)
New Revision: 20832
Modified:
trunk/examples/core-demo/src/main/webapp/mediaOutput.xhtml
trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java
trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java
Log:
https://issues.jboss.org/browse/RF-8330
Modified: trunk/examples/core-demo/src/main/webapp/mediaOutput.xhtml
===================================================================
--- trunk/examples/core-demo/src/main/webapp/mediaOutput.xhtml 2010-12-28 19:51:29 UTC (rev 20831)
+++ trunk/examples/core-demo/src/main/webapp/mediaOutput.xhtml 2010-12-28 20:02:52 UTC (rev 20832)
@@ -13,7 +13,7 @@
element="img" /><br />
<h:form>
<a4j:mediaOutput createContent="#{mediaOutputBean.createContent}" value="richfaces-twitter.jpg"
- element="img" >
+ element="img" cacheable="true" fileName="richfaces-twitter.jpg">
<f:ajax event="dblclick" listener="#{commandBean.listener}" />
</a4j:mediaOutput><br />
</h:form>
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-12-28 19:51:29 UTC (rev 20831)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-12-28 20:02:52 UTC (rev 20832)
@@ -164,6 +164,9 @@
@Attribute
public abstract String getVspace();
+ @Attribute
+ public abstract String getFileName();
+
@Attribute(events = @EventName("blur"))
public abstract String getOnblur();
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-12-28 19:51:29 UTC (rev 20831)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-12-28 20:02:52 UTC (rev 20832)
@@ -26,6 +26,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
@@ -36,6 +38,8 @@
import org.richfaces.component.AbstractMediaOutput;
+import com.google.common.base.Strings;
+
/**
* @author Nick Belaevski
* @since 4.0
@@ -60,6 +64,8 @@
private ValueExpression timeToLiveExpression;
private Object userData;
+ private String fileName;
+
public void encode(FacesContext facesContext) throws IOException {
OutputStream outStream = facesContext.getExternalContext().getResponseOutputStream();
contentProducer.invoke(facesContext.getELContext(), new Object[] {outStream, userData});
@@ -74,13 +80,14 @@
}
public Object saveState(FacesContext context) {
- Object[] state = new Object[4];
+ Object[] state = new Object[5];
// parent fields state saving
state[0] = isCacheable(context) ? Boolean.TRUE : Boolean.FALSE;
state[1] = getContentType();
state[2] = UIComponentBase.saveAttachedState(context, userData);
state[3] = UIComponentBase.saveAttachedState(context, contentProducer);
+ state[4] = fileName;
return state;
}
@@ -92,6 +99,7 @@
setContentType((String) state[1]);
userData = UIComponentBase.restoreAttachedState(context, state[2]);
contentProducer = (MethodExpression) UIComponentBase.restoreAttachedState(context, state[3]);
+ fileName = (String) state[4];
}
/**
@@ -109,6 +117,7 @@
this.lastModifiedExpression = uiMediaOutput.getValueExpression("lastModfied");
this.expiresExpression = uiMediaOutput.getValueExpression("expires");
this.timeToLiveExpression = uiMediaOutput.getValueExpression("timeToLive");
+ this.fileName = uiMediaOutput.getFileName();
}
public boolean isCacheable(FacesContext context) {
@@ -139,4 +148,14 @@
this.contentType = contentType;
}
+ @Override
+ public Map<String, String> getResponseHeaders() {
+ Map<String, String> headers = new HashMap<String, String>(2);
+
+ if (!Strings.isNullOrEmpty(fileName)) {
+ headers.put("Content-Disposition", "inline; filename=\"" + fileName + "\"");
+ }
+
+ return headers;
+ }
}
14 years
JBoss Rich Faces SVN: r20831 - trunk/core/impl/src/main/java/org/richfaces/util.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-28 14:51:29 -0500 (Tue, 28 Dec 2010)
New Revision: 20831
Modified:
trunk/core/impl/src/main/java/org/richfaces/util/Util.java
Log:
Fixed NPE in Util.java for null contentType
Modified: trunk/core/impl/src/main/java/org/richfaces/util/Util.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/util/Util.java 2010-12-28 15:07:08 UTC (rev 20830)
+++ trunk/core/impl/src/main/java/org/richfaces/util/Util.java 2010-12-28 19:51:29 UTC (rev 20831)
@@ -624,9 +624,11 @@
public static Charset getCharsetFromContentType(String contentType) {
String charsetName = null;
- Matcher matcher = CHARSET_IN_CONTENT_TYPE_PATTERN.matcher(contentType);
- if (matcher.find()) {
- charsetName = matcher.group(1);
+ if (contentType != null) {
+ Matcher matcher = CHARSET_IN_CONTENT_TYPE_PATTERN.matcher(contentType);
+ if (matcher.find()) {
+ charsetName = matcher.group(1);
+ }
}
return Strings.isNullOrEmpty(charsetName) ? Charset.defaultCharset() : Charset.forName(charsetName);
14 years
JBoss Rich Faces SVN: r20830 - trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-28 10:07:08 -0500 (Tue, 28 Dec 2010)
New Revision: 20830
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.js
Log:
https://issues.jboss.org/browse/RF-9741 Popup panel: attribute onhide doesn't work
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.js 2010-12-28 15:03:21 UTC (rev 20829)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/popupPanel.js 2010-12-28 15:07:08 UTC (rev 20830)
@@ -51,7 +51,7 @@
richfaces.ui.PopupPanel = function(id, options) {
- $super.constructor.call(this,id);
+ $super.constructor.call(this,id);
this.markerId = id;
this.attachToDom(this.markerId);
this.options = $.extend(this.options, defaultOptions, options || {});
@@ -499,9 +499,9 @@
var event = {};
event.parameters = opts || {};
- if (this.options && this.options.onhide) {
- this.options.onhide(event);
- }
+// if (this.options && this.options.onhide) {
+// this.options.onhide(event);
+// }
var forms = $("form", element);
if (this.options.keepVisualState && forms) {
@@ -754,12 +754,11 @@
$.extend(richfaces.ui.PopupPanel, {
showPopupPanel : function (id, opts, event) {
-
- $(document).ready(richfaces.$(id).show());
+ richface.Event.ready(richfaces.$(id).show());
},
hidePopupPanel : function (id, opts, event) {
- $(document).ready(richfaces.$(id).hide());
+ richface.Event.ready(richfaces.$(id).hide());
}
});
14 years