JBoss Rich Faces SVN: r3733 - in branches/3.1.x/ui/tree/src/main: resources/org/richfaces/renderkit/html/css and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2007-11-02 13:23:52 -0400 (Fri, 02 Nov 2007)
New Revision: 3733
Modified:
branches/3.1.x/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
branches/3.1.x/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss
Log:
RF-1131
Modified: branches/3.1.x/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- branches/3.1.x/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-11-02 17:23:06 UTC (rev 3732)
+++ branches/3.1.x/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-11-02 17:23:52 UTC (rev 3733)
@@ -256,7 +256,7 @@
nodeFacet.getAttributes().put("isLastElement", new Boolean(isLastElement));
nodeFacet.getAttributes().put("isAjaxUpdateRoot", new Boolean(floatingKey != null && floatingKey.equals(rowKey)));
ResponseWriter writer = context.getResponseWriter();
- if (isLastElement) {
+ if (isLastElement && this.navigator.showLines) {
writer.startElement("p", tree);
writer.writeAttribute("class", "dr-tree-last-node-marker", null);
writer.endElement("p");
Modified: branches/3.1.x/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss
===================================================================
--- branches/3.1.x/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss 2007-11-02 17:23:06 UTC (rev 3732)
+++ branches/3.1.x/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss 2007-11-02 17:23:52 UTC (rev 3733)
@@ -121,7 +121,7 @@
<f:resource f:key="org.richfaces.renderkit.html.images.TreeLineLastImage"/>
</u:style>
</u:selector>
-<u:selector name="p.dr-tree-last-node-marker+*.rich-tree-node-handleicon">
+<u:selector name="p.dr-tree-last-node-marker+* .dr-tree-h-ic-line-node">
<u:style name="background-image">
<f:resource f:key="org.richfaces.renderkit.html.images.TreeLineLastImage"/>
</u:style>
16 years, 6 months
JBoss Rich Faces SVN: r3730 - in trunk/sandbox/samples/orderingListDemo: src/main/java/org/richfaces and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-11-02 13:21:27 -0400 (Fri, 02 Nov 2007)
New Revision: 3730
Modified:
trunk/sandbox/samples/orderingListDemo/pom.xml
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java
trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java
trunk/sandbox/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp
Log:
Demo application for ordering list component.
Modified: trunk/sandbox/samples/orderingListDemo/pom.xml
===================================================================
--- trunk/sandbox/samples/orderingListDemo/pom.xml 2007-11-02 17:06:25 UTC (rev 3729)
+++ trunk/sandbox/samples/orderingListDemo/pom.xml 2007-11-02 17:21:27 UTC (rev 3730)
@@ -19,5 +19,10 @@
<artifactId>orderingList</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.samples</groupId>
+ <artifactId>skins</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java
===================================================================
--- trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java 2007-11-02 17:06:25 UTC (rev 3729)
+++ trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OptionItem.java 2007-11-02 17:21:27 UTC (rev 3730)
@@ -1,5 +1,9 @@
package org.richfaces;
+import java.lang.reflect.Method;
+
+import javax.faces.context.FacesContext;
+
public class OptionItem {
private String name;
private int price;
@@ -18,7 +22,11 @@
return price;
}
- public void action() {
- System.out.println("OptionItem.action(): " + name + " " + price);
+ public String action() {
+ String actionResult = "OptionItem.action(): " + name + ", " + price;
+ System.out.println(actionResult);
+ FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("actionResult", actionResult);
+
+ return null;
}
}
Modified: trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java
===================================================================
--- trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java 2007-11-02 17:06:25 UTC (rev 3729)
+++ trunk/sandbox/samples/orderingListDemo/src/main/java/org/richfaces/OrderingListDemoBean.java 2007-11-02 17:21:27 UTC (rev 3730)
@@ -4,10 +4,23 @@
import java.util.List;
import java.util.Random;
+import javax.faces.context.FacesContext;
+
public class OrderingListDemoBean {
private List<OptionItem> items = new ArrayList<OptionItem>();
+ private String [] items2 = new String [] {
+ "First", "Second", "Third", "Fourth"
+ };
+ private String controlsType = "button";
+ private String controlsHorizontalAlign = "right";
+ private String controlsVerticalAlign = "center";
+ private String headerLabel = "headerLabel";
+
+ private boolean orderControlsVisible = true;
+ private boolean fastOrderControlsVisible = true;
+
public OrderingListDemoBean() {
for (int i = 0; i < 10; i++) {
items.add(new OptionItem("Item " + i, new Random().nextInt(200)));
@@ -17,4 +30,65 @@
public List<OptionItem> getItems() {
return items;
}
+
+ public String[] getItems2() {
+ return items2;
+ }
+
+ public void setItems2(String[] items2) {
+ this.items2 = items2;
+ }
+
+ public String getControlsType() {
+ return controlsType;
+ }
+
+ public void setControlsType(String controlsType) {
+ this.controlsType = controlsType;
+ }
+
+ public String getControlsHorizontalAlign() {
+ return controlsHorizontalAlign;
+ }
+
+ public void setControlsHorizontalAlign(String controlsHorizontalAlign) {
+ this.controlsHorizontalAlign = controlsHorizontalAlign;
+ }
+
+ public String getControlsVerticalAlign() {
+ return controlsVerticalAlign;
+ }
+
+ public void setControlsVerticalAlign(String controlsVerticalAlign) {
+ this.controlsVerticalAlign = controlsVerticalAlign;
+ }
+
+ public String getHeaderLabel() {
+ return headerLabel;
+ }
+
+ public void setHeaderLabel(String headerLabel) {
+ this.headerLabel = headerLabel;
+ }
+
+ public boolean isOrderControlsVisible() {
+ return orderControlsVisible;
+ }
+
+ public void setOrderControlsVisible(boolean orderControlsVisible) {
+ this.orderControlsVisible = orderControlsVisible;
+ }
+
+ public boolean isFastOrderControlsVisible() {
+ return fastOrderControlsVisible;
+ }
+
+ public void setFastOrderControlsVisible(boolean fastOrderControlsVisible) {
+ this.fastOrderControlsVisible = fastOrderControlsVisible;
+ }
+
+ public Object getActionResult() {
+ return FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("actionResult");
+ }
+
}
Modified: trunk/sandbox/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-11-02 17:06:25 UTC (rev 3729)
+++ trunk/sandbox/samples/orderingListDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-11-02 17:21:27 UTC (rev 3730)
@@ -1,15 +1,24 @@
-<?xml version="1.0"?>
+<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
- <managed-bean>
- <managed-bean-name>bean</managed-bean-name>
- <managed-bean-class>org.richfaces.Bean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- </managed-bean>
- <managed-bean>
- <managed-bean-name>demoBean</managed-bean-name>
- <managed-bean-class>org.richfaces.OrderingListDemoBean</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- </managed-bean>
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>org.richfaces.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>demoBean</managed-bean-name>
+ <managed-bean-class>
+ org.richfaces.OrderingListDemoBean
+ </managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>skinBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-11-02 17:06:25 UTC (rev 3729)
+++ trunk/sandbox/samples/orderingListDemo/src/main/webapp/pages/index.jsp 2007-11-02 17:21:27 UTC (rev 3730)
@@ -1,23 +1,114 @@
-<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/ui/orderingList" prefix="ol" %>
-
-<html>
- <head>
- <title></title>
- </head>
- <body>
- <f:view>
- <h:form>
- <ol:orderingList value="#{demoBean.items}" var="item">
- <h:column>
- <h:outputText value="#{item.name}" />
- </h:column>
- <h:column>
- <h:outputText value="#{item.price}" />
- </h:column>
- </ol:orderingList>
- </h:form>
- </f:view>
- </body>
-</html>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/ui/orderingList" prefix="ol" %>
+<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
+
+<html>
+ <head>
+ <style type="text/css">
+ .columnClass {
+ vertical-align: top;
+ }
+ </style>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <h:selectOneRadio binding="#{skinBean.component}" />
+ <h:commandLink action="#{skinBean.change}" value="set skin" />
+
+ <h:panelGrid columns="2" columnClasses="columnClass">
+ <h:panelGroup>
+ <ol:orderingList id="orderingList1"
+ value="#{demoBean.items}" var="item"
+ headerLabel="#{demoBean.headerLabel}"
+ controlsType="#{demoBean.controlsType}"
+ controlsHorizontalAlign="#{demoBean.controlsHorizontalAlign}"
+ controlsVerticalAlign="#{demoBean.controlsVerticalAlign}"
+ orderControlsVisible="#{demoBean.orderControlsVisible}"
+ fastOrderControlsVisible="#{demoBean.fastOrderControlsVisible}" >
+ <f:facet name="header">
+ <h:column>
+ <h:outputText value="Name" />
+ </h:column>
+ <h:column>
+ <h:outputText value="Price" />
+ </h:column>
+ </f:facet>
+ <h:column>
+ <h:outputText value="#{item.name}" />
+ </h:column>
+ <h:column>
+ <h:outputText value="#{item.price}" />
+ </h:column>
+ <h:column>
+ <a4j:commandButton value="Ajax Action" reRender="actionResult"
+ action="#{item.action}" />
+ </h:column>
+ <h:column>
+ <h:commandLink value="Server Action" action="#{item.action}" />
+ </h:column>
+ </ol:orderingList>
+
+ <h:panelGrid columns="2">
+ <h:outputText value="Item Clicked: " />
+ <h:outputText value="#{demoBean.actionResult}" id="actionResult" />
+
+ <h:outputText value="Header Label" />
+ <h:inputText value="#{demoBean.headerLabel}" >
+ <a4j:support event="onchange" reRender="orderingList1" />
+ </h:inputText>
+
+ <h:outputText value="Controls Type" />
+ <h:selectOneRadio value="#{demoBean.controlsType}" >
+ <f:selectItem itemValue="button" itemLabel="button" />
+ <f:selectItem itemValue="link" itemLabel="link" />
+ <f:selectItem itemValue="none" itemLabel="none" />
+ <a4j:support event="onchange" reRender="orderingList1" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Controls Horizontal Align" />
+ <h:selectOneRadio value="#{demoBean.controlsHorizontalAlign}" >
+ <f:selectItem itemValue="left" itemLabel="left" />
+ <f:selectItem itemValue="right" itemLabel="right" />
+ <a4j:support event="onchange" reRender="orderingList1" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Controls Vertical Align" />
+ <h:selectOneRadio value="#{demoBean.controlsVerticalAlign}" >
+ <f:selectItem itemValue="top" itemLabel="top" />
+ <f:selectItem itemValue="bottom" itemLabel="bottom" />
+ <f:selectItem itemValue="center" itemLabel="center" />
+ <a4j:support event="onchange" reRender="orderingList1" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Order Controls Visible" />
+ <h:selectOneRadio value="#{demoBean.orderControlsVisible}" >
+ <f:selectItem itemValue="true" itemLabel="true" />
+ <f:selectItem itemValue="false" itemLabel="false" />
+ <a4j:support event="onchange" reRender="orderingList1" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Fast Order Controls Visible" />
+ <h:selectOneRadio value="#{demoBean.fastOrderControlsVisible}" >
+ <f:selectItem itemValue="true" itemLabel="true" />
+ <f:selectItem itemValue="false" itemLabel="false" />
+ <a4j:support event="onchange" reRender="orderingList1" />
+ </h:selectOneRadio>
+
+ <h:commandButton value="Submit" />
+ </h:panelGrid>
+ </h:panelGroup>
+ <h:panelGroup>
+ <ol:orderingList value="#{demoBean.items2}" var="item" >
+ <h:column>
+ <h:outputText value="#{item}" />
+ </h:column>
+ </ol:orderingList>
+ </h:panelGroup>
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+ </body>
+</html>
16 years, 6 months
JBoss Rich Faces SVN: r3729 - in trunk/sandbox/samples/columnsDemo/src/main: webapp/pages and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-11-02 13:06:25 -0400 (Fri, 02 Nov 2007)
New Revision: 3729
Modified:
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java
trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp
Log:
RF-1204
Modified: trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2007-11-02 17:05:49 UTC (rev 3728)
+++ trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2007-11-02 17:06:25 UTC (rev 3729)
@@ -20,10 +20,30 @@
*/
package org.richfaces.sandbox.samples;
+
+import java.util.ArrayList;
+import java.util.List;
+
/**
- * @author $Autor$
+ * @author k
*
*/
public class Bean {
+ private List<String> model = new ArrayList<String>();
+
+ public Bean() {
+ for (int i = 0; i < 1000; i++) {
+ model.add(Integer.toString(i));
+ }
+ }
+
+ public List<String> getModel() {
+ return model;
+ }
+
+ public void setModel(List<String> model) {
+ this.model = model;
+ }
+
}
\ No newline at end of file
Modified: trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp 2007-11-02 17:05:49 UTC (rev 3728)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp 2007-11-02 17:06:25 UTC (rev 3729)
@@ -1,12 +1,24 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/dataTable" prefix="dt"%>
<html>
<head>
<title></title>
</head>
<body>
<f:view>
-
+ <dt:dataTable id="table" value="#{bean.model}" var="issues"
+ first="0" rows="40" width="100%">
+ <dt:column width="200px">
+ <f:facet name="header">
+ <h:outputText value="header"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{issues}"></h:outputText>
+ <f:facet name="footer">
+ <h:outputText value="footer"></h:outputText>
+ </f:facet>
+ </dt:column>
+ </dt:dataTable>
</f:view>
</body>
</html>
16 years, 6 months
JBoss Rich Faces SVN: r3728 - trunk/ui/dataTable/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-11-02 13:05:49 -0400 (Fri, 02 Nov 2007)
New Revision: 3728
Modified:
trunk/ui/dataTable/src/main/config/component/dataList.xml
trunk/ui/dataTable/src/main/config/component/dataTable.xml
trunk/ui/dataTable/src/main/config/component/subTable.xml
Log:
small fix
Modified: trunk/ui/dataTable/src/main/config/component/dataList.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataList.xml 2007-11-02 16:15:46 UTC (rev 3727)
+++ trunk/ui/dataTable/src/main/config/component/dataList.xml 2007-11-02 17:05:49 UTC (rev 3728)
@@ -50,7 +50,7 @@
<property>
<name>value</name>
- <classname>java.lang.String</classname>
+ <classname>java.lang.Object</classname>
<description>The current value for this component</description>
</property>
<property>
@@ -132,7 +132,7 @@
</property>
<property>
<name>value</name>
- <classname>java.lang.String</classname>
+ <classname>java.lang.Object</classname>
<description>The current value for this component</description>
</property>
<property>
@@ -216,7 +216,7 @@
</property>
<property>
<name>value</name>
- <classname>java.lang.String</classname>
+ <classname>java.lang.Object</classname>
<description>The current value for this component</description>
</property>
<property>
Modified: trunk/ui/dataTable/src/main/config/component/dataTable.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataTable.xml 2007-11-02 16:15:46 UTC (rev 3727)
+++ trunk/ui/dataTable/src/main/config/component/dataTable.xml 2007-11-02 17:05:49 UTC (rev 3728)
@@ -123,7 +123,7 @@
</property>
<property>
<name>value</name>
- <classname>java.lang.String</classname>
+ <classname>java.lang.Object</classname>
<description>
The current value for this component
</description>
Modified: trunk/ui/dataTable/src/main/config/component/subTable.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/subTable.xml 2007-11-02 16:15:46 UTC (rev 3727)
+++ trunk/ui/dataTable/src/main/config/component/subTable.xml 2007-11-02 17:05:49 UTC (rev 3728)
@@ -75,7 +75,7 @@
</property>
<property>
<name>value</name>
- <classname>java.lang.String</classname>
+ <classname>java.lang.Object</classname>
<description>
The current value for this component
</description>
16 years, 6 months
JBoss Rich Faces SVN: r3727 - trunk/ui/tree/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-11-02 12:15:46 -0400 (Fri, 02 Nov 2007)
New Revision: 3727
Removed:
trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java
Modified:
trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
Log:
http://jira.jboss.com/jira/browse/RF-864
Deleted: trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-11-02 16:15:46 UTC (rev 3727)
@@ -1,147 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.richfaces.model.LastElementAware;
-import org.richfaces.model.TreeDataModel;
-import org.richfaces.model.TreeNode;
-import org.richfaces.model.TreeNodeImpl;
-import org.richfaces.model.TreeRowKey;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com created 08.01.2007
- *
- */
-public class CacheableTreeDataModel<T> extends TreeDataModel<T> {
-
- private final class Visitor implements DataVisitor, LastElementAware {
- private final DataVisitor visitor;
-
- private Visitor(DataVisitor visitor) {
- this.visitor = visitor;
- }
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
- TreeRowKey treeRowKey = (TreeRowKey) rowKey;
- treeDataModel.setRowKey(treeRowKey);
- nodeAdaptor.setRowData(locateTreeNode(treeRowKey, true), treeDataModel.getRowData());
-
- if (visitor != null) {
- visitor.process(context, rowKey, argument);
- }
- }
-
- public void resetLastElement() {
- if (visitor instanceof LastElementAware) {
- ((LastElementAware) visitor).resetLastElement();
-
- }
- }
-
- public void setLastElement() {
- if (visitor instanceof LastElementAware) {
- ((LastElementAware) visitor).setLastElement();
-
- }
- }
- }
-
- private TreeDataModel<T> treeDataModel;
-
- public boolean isLeaf() {
- TreeRowKey rowKey = (TreeRowKey) getRowKey();
- T treeNode = locateTreeNode(rowKey);
- if (treeNode != null && !nodeAdaptor.isLeaf(treeNode)) {
- return false;
- }
-
- treeNode = treeDataModel.locateTreeNode(rowKey);
- if (treeNode != null) {
- return nodeAdaptor.isLeaf(treeNode);
- }
-
- return false;
- }
-
- public CacheableTreeDataModel(TreeDataModel<T> model) {
- super(model.getClazz(), model.getNodeAdaptor());
- setWrappedData(new TreeNodeImpl());
- setTreeDataModel(model);
- }
-
- public void walkModel(FacesContext context, DataVisitor visitor,
- Range range, Object key, Object argument, boolean last)
- throws IOException {
- treeDataModel.walkModel(context, new Visitor(visitor), range, key,
- argument, last);
- }
-
- public void setTreeDataModel(TreeDataModel<T> treeDataModel) {
- this.treeDataModel = treeDataModel;
- }
-
- public TreeDataModel<T> getTreeDataModel() {
- return treeDataModel;
- }
-
- public void walk(FacesContext context, final DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last)
- throws IOException {
-
- T cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
- T treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
-
- if (treeNode != null) {
- if (cachedTreeNode == null || (nodeAdaptor.isLeaf(cachedTreeNode) && !nodeAdaptor.isLeaf(treeNode))) {
- //fill cache
- treeDataModel.walk(context, new Visitor(dataVisitor), range,
- rowKey, argument, last);
- } else {
- super.walk(context, dataVisitor, range, rowKey, argument, last);
- }
- }
- }
-
- public boolean isTransient() {
- return true;
- }
-
- public void setTransient(boolean newTransientValue) {
- if (!newTransientValue) {
- throw new IllegalArgumentException(
- "ReplaceableTreeDataModel shouldn't be transient!");
- }
- }
-
- @Override
- public TreeNode getTreeNode() {
- // TODO Auto-generated method stub
- return null;
- }
-}
Deleted: trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java 2007-11-02 16:15:46 UTC (rev 3727)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import org.richfaces.model.TreeDataModel;
-
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 06.04.2007
- *
- */
-public class CacheableTreeRequestDataModel extends CacheableTreeDataModel {
-
- public CacheableTreeRequestDataModel(TreeDataModel model) {
- super(model);
- }
-
- public boolean isTransient() {
- return true;
- }
-}
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2007-11-02 16:15:41 UTC (rev 3726)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2007-11-02 16:15:46 UTC (rev 3727)
@@ -62,9 +62,12 @@
import org.richfaces.event.NodeSelectedListener;
import org.richfaces.event.TreeListenerEventsProducer;
import org.richfaces.model.AbstractTreeDataModel;
+import org.richfaces.model.CacheableTreeDataModel;
+import org.richfaces.model.ClassicCacheableTreeDataModel;
import org.richfaces.model.ClassicTreeDataModel;
import org.richfaces.model.StackingTreeModel;
import org.richfaces.model.StackingTreeModelProvider;
+import org.richfaces.model.SwingCacheableTreeDataModel;
import org.richfaces.model.SwingTreeDataModel;
import org.richfaces.model.TreeDataModel;
import org.richfaces.model.TreeModelVisualComponentProvider;
@@ -515,14 +518,18 @@
treeDataModel.setWrappedData(value);
if (allowCached && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
- treeDataModel = new CacheableTreeDataModel<TreeNode>(treeDataModel);
+ treeDataModel = new ClassicCacheableTreeDataModel(treeDataModel);
}
return treeDataModel;
} else {
- SwingTreeDataModel swingTreeDataModel = new SwingTreeDataModel();
+ TreeDataModel<javax.swing.tree.TreeNode> swingTreeDataModel = new SwingTreeDataModel();
swingTreeDataModel.setWrappedData(value);
+ if (allowCached && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
+ swingTreeDataModel = new SwingCacheableTreeDataModel(swingTreeDataModel);
+ }
+
return swingTreeDataModel;
}
} else {
16 years, 6 months
JBoss Rich Faces SVN: r3726 - trunk/framework/api/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-11-02 12:15:41 -0400 (Fri, 02 Nov 2007)
New Revision: 3726
Added:
trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java
Log:
http://jira.jboss.com/jira/browse/RF-864
Added: trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -0,0 +1,138 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+
+/**
+ * Extension of {@link TreeDataModel} supporting lazy data fetching for caching
+ *
+ * created 08.01.2007
+ *
+ * @author Nick - mailto:nbelaevski@exadel.com
+ */
+public abstract class CacheableTreeDataModel<T> extends TreeDataModel<T> {
+
+ private final class Visitor implements DataVisitor, LastElementAware {
+ private final DataVisitor visitor;
+
+ private Visitor(DataVisitor visitor) {
+ this.visitor = visitor;
+ }
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+ TreeRowKey treeRowKey = (TreeRowKey) rowKey;
+ treeDataModel.setRowKey(treeRowKey);
+ setDefaultNodeData(locateTreeNode(treeRowKey, true), treeDataModel.getRowData());
+
+ if (visitor != null) {
+ visitor.process(context, rowKey, argument);
+ }
+ }
+
+ public void resetLastElement() {
+ if (visitor instanceof LastElementAware) {
+ ((LastElementAware) visitor).resetLastElement();
+
+ }
+ }
+
+ public void setLastElement() {
+ if (visitor instanceof LastElementAware) {
+ ((LastElementAware) visitor).setLastElement();
+
+ }
+ }
+ }
+
+ private TreeDataModel<T> treeDataModel;
+
+ public boolean isLeaf() {
+ TreeRowKey rowKey = (TreeRowKey) getRowKey();
+ T treeNode = locateTreeNode(rowKey);
+ if (treeNode != null && !nodeAdaptor.isLeaf(treeNode)) {
+ return false;
+ }
+
+ treeNode = treeDataModel.locateTreeNode(rowKey);
+ if (treeNode != null) {
+ return nodeAdaptor.isLeaf(treeNode);
+ }
+
+ return false;
+ }
+
+ public CacheableTreeDataModel(TreeDataModel<T> model) {
+ super(model.getClazz(), model.getNodeAdaptor());
+ setWrappedData(createDefaultNode());
+ setTreeDataModel(model);
+ }
+
+ public void walkModel(FacesContext context, DataVisitor visitor,
+ Range range, Object key, Object argument, boolean last)
+ throws IOException {
+ treeDataModel.walkModel(context, new Visitor(visitor), range, key,
+ argument, last);
+ }
+
+ public void setTreeDataModel(TreeDataModel<T> treeDataModel) {
+ this.treeDataModel = treeDataModel;
+ }
+
+ public TreeDataModel<T> getTreeDataModel() {
+ return treeDataModel;
+ }
+
+ public void walk(FacesContext context, final DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last)
+ throws IOException {
+
+ T cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
+ T treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
+
+ if (treeNode != null) {
+ if (cachedTreeNode == null || (nodeAdaptor.isLeaf(cachedTreeNode) && !nodeAdaptor.isLeaf(treeNode))) {
+ //fill cache
+ treeDataModel.walk(context, new Visitor(dataVisitor), range,
+ rowKey, argument, last);
+ } else {
+ super.walk(context, dataVisitor, range, rowKey, argument, last);
+ }
+ }
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ if (!newTransientValue) {
+ throw new IllegalArgumentException(
+ "ReplaceableTreeDataModel shouldn't be transient!");
+ }
+ }
+
+ protected abstract void setDefaultNodeData(T node, Object data);
+
+}
Added: trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * {@link CacheableTreeDataModel} implementation for classic {@link TreeNode} instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class ClassicCacheableTreeDataModel extends CacheableTreeDataModel<TreeNode> {
+
+ public ClassicCacheableTreeDataModel(TreeDataModel<TreeNode> model) {
+ super(model);
+ }
+
+ @Override
+ protected TreeNode createDefaultNode() {
+ return new TreeNodeImpl();
+ }
+
+ @Override
+ protected void setDefaultNodeData(TreeNode node, Object data) {
+ ((TreeNodeImpl) node).setData(data);
+ }
+
+ @Override
+ protected void addChild(TreeNode parent, Object key, TreeNode node) {
+ parent.addChild(key, node);
+ }
+
+}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2007-11-02 15:43:03 UTC (rev 3725)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -22,7 +22,10 @@
package org.richfaces.model;
/**
+ * {@link TreeDataModel} implementation for classic {@link TreeNode} instances
+ *
* Created 01.11.2007
+ *
* @author Nick Belaevski
* @since 3.2
*/
@@ -42,4 +45,14 @@
"No tree element available or row key not set!");
}
+ @Override
+ protected void addChild(TreeNode parent, Object key, TreeNode node) {
+ parent.addChild(key, node);
+ }
+
+ @Override
+ protected TreeNode createDefaultNode() {
+ throw new UnsupportedOperationException();
+ }
+
}
Added: trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java (rev 0)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import javax.swing.tree.TreeNode;
+
+/**
+ * {@link CacheableTreeDataModel} implementation for Swing {@link TreeNode} instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class SwingCacheableTreeDataModel extends CacheableTreeDataModel<TreeNode> {
+
+ public SwingCacheableTreeDataModel(TreeDataModel<TreeNode> model) {
+ super(model);
+ }
+
+ @Override
+ protected TreeNode createDefaultNode() {
+ return new SwingTreeNodeImpl();
+ }
+
+ @Override
+ protected void setDefaultNodeData(TreeNode node, Object data) {
+ ((SwingTreeNodeImpl) node).setData(data);
+ }
+
+ @Override
+ protected void addChild(TreeNode parent, Object key, TreeNode node) {
+ SwingTreeNodeImpl parentNode = (SwingTreeNodeImpl) parent;
+ SwingTreeNodeImpl childNode = (SwingTreeNodeImpl) node;
+
+ parentNode.addChild(key, node);
+ childNode.setParent(parentNode);
+ }
+
+}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2007-11-02 15:43:03 UTC (rev 3725)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -27,7 +27,10 @@
import javax.swing.tree.TreeNode;
/**
+ * {@link TreeDataModel} implementation for classic {@link TreeNode} instances
+ *
* Created 01.11.2007
+ *
* @author Nick Belaevski
* @since 3.2
*/
@@ -49,21 +52,22 @@
public void setWrappedData(Object data) {
if (data != null) {
SwingTreeNodeImpl treeNodeImpl = new SwingTreeNodeImpl();
+ int counter = 0;
if (data instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) data;
for (Iterator<?> iterator = collection.iterator(); iterator
.hasNext();) {
- treeNodeImpl.addChild((TreeNode) iterator.next());
+ treeNodeImpl.addChild(Integer.valueOf(counter++), (TreeNode) iterator.next());
}
} else if (data.getClass().isArray()) {
Object[] nodes = (Object[]) data;
for (int i = 0; i < nodes.length; i++) {
- treeNodeImpl.addChild((TreeNode) nodes[i]);
+ treeNodeImpl.addChild(Integer.valueOf(counter++), (TreeNode) nodes[i]);
}
} else {
- treeNodeImpl.addChild((TreeNode) data);
+ treeNodeImpl.addChild(Integer.valueOf(counter++), (TreeNode) data);
}
this.treeNode = treeNodeImpl;
@@ -73,13 +77,15 @@
super.setWrappedData(data);
}
-
- /* (non-Javadoc)
- * @see org.richfaces.model.AbstractTreeDataModel#getTreeNode()
- */
+
@Override
- public org.richfaces.model.TreeNode getTreeNode() {
- return null;
+ protected void addChild(TreeNode parent, Object key, TreeNode node) {
+ throw new UnsupportedOperationException();
}
+ @Override
+ protected TreeNode createDefaultNode() {
+ throw new UnsupportedOperationException();
+ }
+
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2007-11-02 15:43:03 UTC (rev 3725)
+++ trunk/framework/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -21,26 +21,45 @@
package org.richfaces.model;
+import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.Vector;
+import java.util.Iterator;
+import java.util.List;
import javax.swing.tree.TreeNode;
/**
+ * Map-based Swing {@link TreeNode} implementation
+ *
* Created 01.11.2007
+ *
* @author Nick Belaevski
* @since 3.2
*/
public class SwingTreeNodeImpl implements TreeNode {
- private Vector<TreeNode> children = new Vector<TreeNode>();
+ private List<TreeNode> children = new ArrayList<TreeNode>();
+ private TreeNode parent;
+
+ private Object data;
+
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#children()
*/
public Enumeration children() {
- return children.elements();
+ return new Enumeration() {
+ private Iterator<?> iterator = children.iterator();
+
+ public boolean hasMoreElements() {
+ return iterator.hasNext();
+ }
+
+ public Object nextElement() {
+ return iterator.next();
+ }
+ };
}
/* (non-Javadoc)
@@ -74,16 +93,31 @@
* @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
*/
public int getIndex(TreeNode node) {
- return children.indexOf(node);
+ if (node != null) {
+ int counter = 0;
+ for (Iterator<TreeNode> iterator = children.iterator(); iterator.hasNext();) {
+ if (node.equals(iterator.next())) {
+ return counter;
+ }
+
+ counter++;
+ }
+ }
+
+ return -1;
}
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#getParent()
*/
public TreeNode getParent() {
- return null;
+ return parent;
}
+ public void setParent(TreeNode parent) {
+ this.parent = parent;
+ }
+
/* (non-Javadoc)
* @see javax.swing.tree.TreeNode#isLeaf()
*/
@@ -91,8 +125,20 @@
return children.isEmpty();
}
- public void addChild(TreeNode node) {
- children.add(node);
+ public void addChild(Object key, TreeNode node) {
+ if (Integer.valueOf(children.size()).equals(key)) {
+ children.add(node);
+ } else {
+ throw new IllegalArgumentException();
+ }
}
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2007-11-02 15:43:03 UTC (rev 3725)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -45,6 +45,7 @@
private TreeRowKey oldRowKey;
+ private Boolean rowAvailable = Boolean.FALSE;
private T rowTreeData;
protected final TreeDataModelNodeAdaptor<T> nodeAdaptor;
@@ -70,10 +71,12 @@
if (rowKey != null) {
ListRowKey newRowKey = (ListRowKey) rowKey;
this.currentRowKey = newRowKey;
+ this.rowAvailable = null;
} else {
this.currentRowKey = null;
this.oldRowKey = null;
this.rowTreeData = null;
+ this.rowAvailable = Boolean.FALSE;
}
}
@@ -201,9 +204,11 @@
if (childRowTreeData == null) {
if (!allowCreate) {
+ //TODO nick - reset rowTreeData
return null;
} else {
- childRowTreeData = nodeAdaptor.addChild(rowTreeData, pathSegment);
+ childRowTreeData = createDefaultNode();
+ addChild(rowTreeData, pathSegment, childRowTreeData);
}
}
@@ -220,6 +225,10 @@
}
public boolean isRowAvailable() {
+ if (Boolean.FALSE.equals(rowAvailable)) {
+ return false;
+ }
+
T data = locateTreeNode(this.currentRowKey);
if (data != null) {
@@ -273,4 +282,13 @@
protected T getData() {
return clazz.cast(wrappedData);
}
+
+ public TreeNode getTreeNode() {
+ return null;
+ }
+
+ protected abstract T createDefaultNode();
+
+ protected abstract void addChild(T parent, Object key, T node);
+
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java 2007-11-02 15:43:03 UTC (rev 3725)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java 2007-11-02 16:15:41 UTC (rev 3726)
@@ -29,7 +29,11 @@
import javax.swing.tree.TreeNode;
/**
+ * {@link TreeDataModel} adaptor for generic types. Contains adaptors for Swing & classic ({@link TreeNode})
+ * tree node types embedded into this interface as static instances
+ *
* Created 01.11.2007
+ *
* @author Nick Belaevski
* @since 3.2
*/
@@ -39,28 +43,18 @@
public boolean isLeaf(T node);
- public T addChild(T node, Object key);
-
public T getChild(T node, Object key);
public Iterator<Map.Entry<Object, T>> getChildren(T node);
public Object getRowData(T node);
- public void setRowData(T node, Object rowData);
-
+ /**
+ * Instance of {@link TreeDataModelNodeAdaptor} for {@link org.richfaces.model.TreeNode} nodes handling
+ */
public static final TreeDataModelNodeAdaptor<org.richfaces.model.TreeNode> classicTreeNodeAdaptor =
new TreeDataModelNodeAdaptor<org.richfaces.model.TreeNode>() {
- public org.richfaces.model.TreeNode addChild(org.richfaces.model.TreeNode node,
- Object key) {
- //TODO nick - review implementation usage inside interface
- TreeNodeImpl impl = new TreeNodeImpl();
- node.addChild(key, impl);
-
- return impl;
- }
-
public org.richfaces.model.TreeNode getChild(org.richfaces.model.TreeNode node, Object key) {
return node.getChild(key);
}
@@ -82,13 +76,11 @@
return node.isLeaf();
}
- public void setRowData(org.richfaces.model.TreeNode node,
- Object rowData) {
- node.setData(rowData);
- }
-
};
+ /**
+ * Instance of {@link TreeDataModelNodeAdaptor} for {@link javax.swing.tree.TreeNode} nodes handling
+ */
public static final TreeDataModelNodeAdaptor<javax.swing.tree.TreeNode> swingTreeNodeAdaptor =
new TreeDataModelNodeAdaptor<javax.swing.tree.TreeNode>() {
@@ -119,17 +111,15 @@
};
- public javax.swing.tree.TreeNode addChild(
- javax.swing.tree.TreeNode node, Object key) {
-
- throw new UnsupportedOperationException();
- }
-
public javax.swing.tree.TreeNode getChild(
javax.swing.tree.TreeNode node, Object key) {
- Integer intKey = (Integer) key;
- return node.getChildAt(intKey.intValue());
+ int intKey = ((Integer) key).intValue();
+ if (intKey < node.getChildCount() && intKey >= 0) {
+ return node.getChildAt(intKey);
+ }
+
+ return null;
}
public Iterator<Entry<Object, javax.swing.tree.TreeNode>> getChildren(
@@ -174,10 +164,5 @@
public boolean isLeaf(javax.swing.tree.TreeNode node) {
return !node.getAllowsChildren() || node.isLeaf();
}
-
- public void setRowData(TreeNode node, Object rowData) {
- throw new UnsupportedOperationException();
- }
-
};
}
16 years, 6 months
JBoss Rich Faces SVN: r3725 - trunk/ui/dataTable/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-11-02 11:43:03 -0400 (Fri, 02 Nov 2007)
New Revision: 3725
Modified:
trunk/ui/dataTable/src/main/config/component/dataGrid.xml
Log:
dataGrid config file type corrected
Modified: trunk/ui/dataTable/src/main/config/component/dataGrid.xml
===================================================================
--- trunk/ui/dataTable/src/main/config/component/dataGrid.xml 2007-11-02 15:42:09 UTC (rev 3724)
+++ trunk/ui/dataTable/src/main/config/component/dataGrid.xml 2007-11-02 15:43:03 UTC (rev 3725)
@@ -123,7 +123,7 @@
</property>
<property>
<name>value</name>
- <classname>java.lang.String</classname>
+ <classname>java.lang.Object</classname>
<description>
The current value for this component
</description>
16 years, 6 months
JBoss Rich Faces SVN: r3724 - in trunk/sandbox/ui/orderingList/src/main: java/org/richfaces/renderkit and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2007-11-02 11:42:09 -0400 (Fri, 02 Nov 2007)
New Revision: 3724
Added:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
Modified:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
layoutManager for OrderingList was added, fixed table header,
css styles for header and content tables
Modified: trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-02 15:27:22 UTC (rev 3723)
+++ trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-11-02 15:42:09 UTC (rev 3724)
@@ -3,12 +3,16 @@
import java.util.Iterator;
import java.util.List;
+import javax.faces.component.UIColumn;
+
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.RepeatState;
import org.ajax4jsf.model.SequenceDataModel;
+import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.EmptyIterator;
+import org.apache.commons.collections.iterators.FilterIterator;
public abstract class UIOrderingList extends UIDataAdaptor {
@@ -18,6 +22,14 @@
private Object activeItem;
+ public static final Predicate isColumn = new ColumnPredicate();
+
+ private static final class ColumnPredicate implements Predicate {
+ public boolean evaluate(Object input) {
+ return (input instanceof UIColumn || input instanceof Column);
+ }
+ }
+
@Override
protected DataComponentState createComponentState() {
return new RepeatState();
@@ -69,4 +81,8 @@
public void setActiveItem(Object activeItem) {
this.activeItem = activeItem;
}
+
+ public Iterator columns() {
+ return new FilterIterator(getChildren().iterator(), isColumn);
+ }
}
Modified: trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-02 15:27:22 UTC (rev 3723)
+++ trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-02 15:42:09 UTC (rev 3724)
@@ -12,8 +12,14 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.component.SequenceDataAdaptor;
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.iterators.FilterIterator;
+import org.richfaces.component.Column;
+import org.richfaces.component.Row;
+import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIOrderingList;
public abstract class OrderingListRendererBase extends AbstractRowsRenderer {
@@ -34,6 +40,75 @@
return true;
}
+ public void encodeOrderingListStructure(FacesContext context, UIOrderingList orderingList)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ //encodeCaption(context, orderingList);
+ encodeHeader(context, orderingList);
+ //encodeFooter(context, orderingList);
+
+ }
+
+ protected Iterator columnFacets(UIOrderingList orderingList, final String name){
+ return new FilterIterator(orderingList.columns(), new Predicate() {
+
+ public boolean evaluate(Object input) {
+ UIComponent component = (UIComponent) input;
+ // accept only columns with corresponding facets.
+ if (component instanceof Column || component instanceof UIColumn) {
+ return component.isRendered()&&(component.getFacet(name) != null);
+ }
+ else{
+ return false;
+ }
+ }});
+ }
+
+ public void encodeHeader(FacesContext context, UIOrderingList orderingList)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ //UIComponent header = orderingList.getHeader();
+ Iterator headers = columnFacets(orderingList,"header");
+
+ if (headers.hasNext()) {
+ writer.startElement("thead", orderingList);
+ String headerClass = (String) orderingList.getAttributes().get("headerClass");
+
+ writer.startElement("tr", orderingList);
+ encodeStyleClass(writer, null, "dr-table-subheader rich-table-subheader", null, headerClass);
+ encodeHeaderFacets(context, writer, headers, "ol_col rich-table-subheadercell", headerClass, "header", "th");
+
+ writer.endElement("tr");
+ }
+ writer.endElement("thead");
+ }
+
+ protected void encodeHeaderFacets(FacesContext context,
+ ResponseWriter writer, Iterator headers, String skinCellClass,
+ String headerClass, String facetName, String element)
+ throws IOException {
+ while (headers.hasNext()) {
+ UIComponent column = (UIComponent) headers.next();
+ String classAttribute = facetName + "Class";
+ String columnHeaderClass = (String) column.getAttributes().get(classAttribute);
+
+ writer.startElement(element, column);
+ if (!headers.hasNext()) {
+ skinCellClass = "ol_endcol rich-table-subheadercell";
+ }
+ encodeStyleClass(writer, null, skinCellClass, headerClass, columnHeaderClass);
+ writer.writeAttribute("scope", "col", null);
+ getUtils().encodeAttribute(context, column, "colspan");
+ UIComponent facet = column.getFacet(facetName);
+ if (facet != null) {
+ renderChild(context, facet);
+ }
+
+ writer.endElement(element);
+ }
+ }
+
@Override
public void encodeOneRow(FacesContext context, TableHolder holder)
throws IOException {
Modified: trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-02 15:27:22 UTC (rev 3723)
+++ trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-02 15:42:09 UTC (rev 3724)
@@ -21,7 +21,6 @@
}
.ol_list {
- overflow : auto;
width : 200px;
height : 150px;
background : #FFFFFF;
@@ -29,6 +28,18 @@
margin : 0px 8px 8px 8px;
}
+.ol_list_content {
+ overflow : auto;
+ width: 200px;
+ height: 132px;
+}
+
+.ol_list_header {
+ overflow: hidden;
+ width: 200px;
+ height: 18px;
+}
+
.ol_button_layout {
padding : 15px 8px 15px 0px;
vertical-align : top;
@@ -56,6 +67,26 @@
padding : 2px 0px 0px 2px;
}
+#internal_header_tab {
+ width : 100%;
+}
+
+#internal_header_tab th {
+ background : #4A75B5;
+ color : #FFFFFF;
+
+ font-family : Arial;
+ font-size :11px;
+ font-weight : normal;
+ border-bottom : 1px solid #bfbfc0;
+ border-right : 1px solid #bfbfc0;
+ padding : 2px;
+}
+
+#internal_header_tab .ol_endcol {
+ border-right : 0px;
+}
+
#internal_tab {
width : 100%;
}
@@ -73,17 +104,6 @@
padding : 2px;
}
-#internal_tab th {
- background : #4A75B5;
- color : #FFFFFF;
-
- font-family : Arial;
- font-size :11px;
- font-weight : normal;
- border-bottom : 1px solid #bfbfc0;
- border-right : 1px solid #bfbfc0;
- padding : 2px;
-}
#internal_tab tr.ol_select {
background : #EAF0F8;
Added: trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js (rev 0)
+++ trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/LayoutManager.js 2007-11-02 15:42:09 UTC (rev 3724)
@@ -0,0 +1,18 @@
+LayoutManager = function(headerId, contentId) {
+ this.headerTable = document.getElementById(headerId);
+ this.contentTable = document.getElementById(contentId);
+}
+
+LayoutManager.scrollWidth = 17;
+
+LayoutManager.prototype.widthSynchronization = function() {
+ var contentCells = this.contentTable.tBodies[0].rows[0].cells;
+ var headerCells = this.headerTable.tHead.rows[0].cells;
+ for (var i = 0; i < contentCells.length; i++) {
+ if (i == contentCells.length - 1) {
+ headerCells[i].style.width = contentCells[i].offsetWidth + LayoutManager.scrollWidth;
+ } else {
+ headerCells[i].style.width = contentCells[i].offsetWidth;
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-02 15:27:22 UTC (rev 3723)
+++ trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-02 15:42:09 UTC (rev 3724)
@@ -12,13 +12,15 @@
<h:styles>css/orderingList.xcss</h:styles>
<h:scripts>
- scripts/SelectItem.js,scripts/OrderingList.js
+ scripts/SelectItem.js,scripts/OrderingList.js,scripts/LayoutManager.js
</h:scripts>
<f:clientid var="clientId"/>
<script type="text/javascript">
function init() {
var shuttle = new Shuttle('#{clientId}', 'internal_tab', '#{clientId}focusKeeper', '#{clientId}valueKeeper');
+ var layoutManager = new LayoutManager('internal_header_tab', 'internal_tab');
+ layoutManager.widthSynchronization();
Shuttle.setFocus('#{clientId}focusKeeper');
document.getElementById('up').onclick = function() {shuttle.moveSelectedItems('up');};
document.getElementById('down').onclick = function() {shuttle.moveSelectedItems('down');};
@@ -36,13 +38,20 @@
<tr>
<td>
<div class="ol_list">
- <table id="internal_tab" cellpadding="0" cellspacing="0" class="">
- <tbody id="#{clientId}tbody">
- <vcp:body>
- <f:call name="renderChildren" />
- </vcp:body>
- </tbody>
- </table>
+ <div class="ol_list_header">
+ <table id="internal_header_tab" cellpadding="0" cellspacing="0">
+ <f:call name="encodeOrderingListStructure"/>
+ </table>
+ </div>
+ <div class="ol_list_content">
+ <table id="internal_tab" cellpadding="0" cellspacing="0">
+ <tbody id="#{clientId}tbody">
+ <vcp:body>
+ <f:call name="renderChildren" />
+ </vcp:body>
+ </tbody>
+ </table>
+ </div>
</div>
</td>
</tr>
16 years, 6 months