JBoss Rich Faces SVN: r685 - in trunk/richfaces/suggestionbox/src/main: resources/org/richfaces/renderkit/html/templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-07 21:13:51 -0400 (Mon, 07 May 2007)
New Revision: 685
Modified:
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/popup.jspx
Log:
http://jira.jboss.com/jira/browse/RF-173 fixed
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-05-08 00:48:08 UTC (rev 684)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-05-08 01:13:51 UTC (rev 685)
@@ -628,6 +628,25 @@
}
/**
+ * Gets border size
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return border size if set, 0 if none
+ */
+ public final String getBorder(final FacesContext context,
+ final UIComponent component) {
+
+ String border = (String) component.getAttributes().get("border");
+ if (border == null || border.length() == 0) {
+ return "0";
+ }
+
+ return border;
+ }
+
+
+ /**
* Gets context identifier.
*
* @param context {@link javax.faces.context.FacesContext}
Modified: trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/popup.jspx
===================================================================
--- trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/popup.jspx 2007-05-08 00:48:08 UTC (rev 684)
+++ trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/templates/popup.jspx 2007-05-08 01:13:51 UTC (rev 685)
@@ -20,12 +20,15 @@
<f:call name="overflowSize"/>
</f:attribute>
- <table border="0">
+ <table>
<f:attribute name="id">
<f:call name="getContentId"/>
</f:attribute>
+ <f:attribute name="border">
+ <f:call name="getBorder"/>
+ </f:attribute>
<f:call name="utils.encodePassThruWithExclusions">
- <f:parameter value="onclick,onselect,width,height,rows"/>
+ <f:parameter value="onclick,onselect,width,height,rows,border"/>
</f:call>
<tbody>
</tbody>
17 years, 7 months
JBoss Rich Faces SVN: r684 - in trunk/richfaces: dataTable/src/main/config/component and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-07 20:48:08 -0400 (Mon, 07 May 2007)
New Revision: 684
Modified:
trunk/richfaces/dataFilterSlider/src/main/config/component/dataFilterSlider.xml
trunk/richfaces/dataTable/src/main/config/component/dataGrid.xml
trunk/richfaces/dataTable/src/main/config/component/dataList.xml
trunk/richfaces/dataTable/src/main/config/component/dataTable.xml
trunk/richfaces/dataTable/src/main/config/component/subTable.xml
trunk/richfaces/datascroller/src/main/config/component/datascroller.xml
trunk/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
trunk/richfaces/drag-drop/src/main/config/component/dragSupport.xml
trunk/richfaces/drag-drop/src/main/config/component/dropSupport.xml
trunk/richfaces/inputnumber-slider/src/main/config/component/inputNumberSlider.xml
trunk/richfaces/panelbar/src/main/config/component/panelbar.xml
trunk/richfaces/togglePanel/src/main/config/component/togglePanel.xml
trunk/richfaces/tree/src/main/config/component/tree.xml
Log:
RF-151 fixed
Modified: trunk/richfaces/dataFilterSlider/src/main/config/component/dataFilterSlider.xml
===================================================================
--- trunk/richfaces/dataFilterSlider/src/main/config/component/dataFilterSlider.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/dataFilterSlider/src/main/config/component/dataFilterSlider.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -178,6 +178,10 @@
Specifies if the component will store a UIData object (your table rows) in session.
</description>
</property>
+ <property hidden="true">
+ <name>active</name>
+ <classname>java.lang.String</classname>
+ </property>
</component>
&listeners;
</components>
Modified: trunk/richfaces/dataTable/src/main/config/component/dataGrid.xml
===================================================================
--- trunk/richfaces/dataTable/src/main/config/component/dataGrid.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/dataTable/src/main/config/component/dataGrid.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -103,13 +103,6 @@
</property>
-->
<property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>
- Attribute defines EL-variable for reference to visual state.
- </description>
- </property>
- <property>
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
Modified: trunk/richfaces/dataTable/src/main/config/component/dataList.xml
===================================================================
--- trunk/richfaces/dataTable/src/main/config/component/dataList.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/dataTable/src/main/config/component/dataList.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -54,11 +54,6 @@
<description>The current value for this component.</description>
</property>
<property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>Attribute defines EL-variable for reference to visual state.</description>
- </property>
- <property>
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
@@ -141,11 +136,6 @@
<description>The current value for this component.</description>
</property>
<property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>Attribute defines EL-variable for reference to visual state.</description>
- </property>
- <property>
<name>stateVar</name>
<classname>java.lang.String</classname>
<description>
@@ -235,11 +225,6 @@
<description>The attribute provides access to a component state on the client side.</description>
</property>
<property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>Attribute defines EL-variable for reference to visual state.</description>
- </property>
- <property>
<name>componentState</name>
<classname>java.lang.String</classname>
<description>It defines EL-binding for a component state for saving or redefinition.</description>
Modified: trunk/richfaces/dataTable/src/main/config/component/dataTable.xml
===================================================================
--- trunk/richfaces/dataTable/src/main/config/component/dataTable.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/dataTable/src/main/config/component/dataTable.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -96,13 +96,6 @@
<description>Space-separated list of CSS style class(es) that are be applied to footer for this component.
</description>
</property>
- <property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>
- Attribute defines EL-variable for reference to visual state.
- </description>
- </property>
<property>
<name>componentState</name>
Modified: trunk/richfaces/dataTable/src/main/config/component/subTable.xml
===================================================================
--- trunk/richfaces/dataTable/src/main/config/component/subTable.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/dataTable/src/main/config/component/subTable.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -43,13 +43,6 @@
</description>
</property>
<property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>
- Attribute defines EL-variable for reference to visual state.
- </description>
- </property>
- <property>
<name>componentState</name>
<classname>java.lang.String</classname>
<description>It defines EL-binding for a component state for saving or redefinition.</description>
Modified: trunk/richfaces/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/richfaces/datascroller/src/main/config/component/datascroller.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/datascroller/src/main/config/component/datascroller.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -92,13 +92,6 @@
</property>
<property>
- <name>page</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
-
- <property>
<name>rendered</name>
<classname>java.lang.String</classname>
<description>If "false", this component is not rendered.</description>
@@ -214,13 +207,6 @@
</description>
<defaultvalue>true</defaultvalue>
</property>
- <property>
- <name>renderCurrentAsText</name>
- <classname>boolean</classname>
- <description>
- </description>
- <defaultvalue>true</defaultvalue>
- </property>
<property>
<name>align</name>
<classname>java.lang.String</classname>
@@ -267,6 +253,12 @@
<description>The action method binding expression.</description>
</property>
+
+ <property hidden="true">
+ <name>firstRow</name>
+ <classname>java.lang.String</classname>
+ </property>
+
</component>
&listeners;
</components>
Modified: trunk/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
--- trunk/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2007-05-08 00:48:08 UTC (rev 684)
@@ -141,10 +141,6 @@
public abstract void setMaxPages(int maxPages);
- public abstract boolean isRenderCurrentAsText();
-
- public abstract void setRenderCurrentAsText(boolean renderCurrentAsText);
-
public abstract String getSelectedStyleClass();
public abstract void setSelectedStyleClass(String selectedStyleClass);
@@ -405,13 +401,6 @@
return row;
}
- /**
- * @return int
- */
- public int getRows() {
- return getRows(getDataTable());
- }
-
// facet getter methods
public UIComponent getFirst() {
return getFacet(FIRST_FACET_NAME);
@@ -441,27 +430,21 @@
return data.getFirst();
}
- /**
- * @return int
- */
- public int getFirstRow() {
- return getFirstRow(getDataTable());
- }
public void setControls(){
-
+ UIData dataTable = getDataTable();
int rowCount=getRowCount();
if (getBoundaryControls().equals("auto")){
- if (getFirstRow()==0){
+ if (getFirstRow(dataTable)==0){
first_rendered = false;
first_enabled = false;
}else{
first_enabled = true;
first_rendered = true;
}
- if ((rowCount - 1)<=(getFirstRow()+getRows())){
+ if ((rowCount - 1)<=(getFirstRow(dataTable)+getRows(dataTable))){
last_enabled = false;
last_rendered = false;
}
@@ -481,12 +464,12 @@
else if (getBoundaryControls().equals("show")){
first_rendered = true;
last_rendered = true;
- if (getFirstRow()==0){
+ if (getFirstRow(dataTable)==0){
first_enabled = false;
}else{
first_enabled = true;
}
- if ((rowCount - 1)<=(getFirstRow()+getRows())){
+ if ((rowCount - 1)<=(getFirstRow(dataTable)+getRows(dataTable))){
last_enabled = false;
}
else{
@@ -495,14 +478,14 @@
}
if (getFastControls().equals("auto")){
- if (getFirstRow()==0){
+ if (getFirstRow(dataTable)==0){
fast_rewind_rendered = false;
fast_rewind_enabled = false;
}else{
fast_rewind_rendered = true;
fast_rewind_enabled = true;
}
- if ((rowCount - 1)<=(getFirstRow()+getRows())){
+ if ((rowCount - 1)<=(getFirstRow(dataTable)+getRows(dataTable))){
fast_forward_rendered = false;
fast_forward_enabled = false;
}
@@ -522,12 +505,12 @@
else if (getFastControls().equals("show")){
fast_rewind_rendered = true;
fast_forward_rendered = true;
- if (getFirstRow()==0){
+ if (getFirstRow(dataTable)==0){
fast_rewind_enabled = false;
}else{
fast_rewind_enabled = true;
}
- if ((rowCount - 1)<=(getFirstRow()+getRows())){
+ if ((rowCount - 1)<=(getFirstRow(dataTable)+getRows(dataTable))){
fast_forward_enabled = false;
}
else{
@@ -538,7 +521,7 @@
}
if (getStepControls().equals("auto")){
- if (getFirstRow()==0){
+ if (getFirstRow(dataTable)==0){
previous_enabled = false;
previous_rendered = false;
@@ -546,7 +529,7 @@
previous_enabled = true;
previous_rendered = true;
}
- if ((rowCount - 1)<=(getFirstRow()+getRows())){
+ if ((rowCount - 1)<=(getFirstRow(dataTable)+getRows(dataTable))){
next_enabled = false;
next_rendered = false;
}
@@ -565,12 +548,12 @@
else if (getStepControls().equals("show")){
next_rendered = true;
previous_rendered = true;
- if (getFirstRow()==0){
+ if (getFirstRow(dataTable)==0){
previous_enabled = false;
}else{
previous_enabled = true;
}
- if ((rowCount - 1)<=(getFirstRow()+getRows())){
+ if ((rowCount - 1)<=(getFirstRow(dataTable)+getRows(dataTable))){
next_enabled = false;
}
else{
Modified: trunk/richfaces/drag-drop/src/main/config/component/dragSupport.xml
===================================================================
--- trunk/richfaces/drag-drop/src/main/config/component/dragSupport.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/drag-drop/src/main/config/component/dragSupport.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -61,12 +61,7 @@
JavaScript code for call before submission of ajax event
</description>
</property>
- <property>
- <name>parentProperties</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
+
</component>
Modified: trunk/richfaces/drag-drop/src/main/config/component/dropSupport.xml
===================================================================
--- trunk/richfaces/drag-drop/src/main/config/component/dropSupport.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/drag-drop/src/main/config/component/dropSupport.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -53,12 +53,6 @@
JavaScript code for call before submission of ajax event
</description>
</property>
- <property>
- <name>parentProperties</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
<!--
<property>
<name>param</name>
Modified: trunk/richfaces/inputnumber-slider/src/main/config/component/inputNumberSlider.xml
===================================================================
--- trunk/richfaces/inputnumber-slider/src/main/config/component/inputNumberSlider.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/inputnumber-slider/src/main/config/component/inputNumberSlider.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -240,5 +240,9 @@
<name>localValueSet</name>
<classname>boolean</classname>
</property>
+ <property hidden="true">
+ <name>valid</name>
+ <classname>java.lang.String</classname>
+ </property>
</component>
</components>
\ No newline at end of file
Modified: trunk/richfaces/panelbar/src/main/config/component/panelbar.xml
===================================================================
--- trunk/richfaces/panelbar/src/main/config/component/panelbar.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/panelbar/src/main/config/component/panelbar.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -103,6 +103,10 @@
<name>localValueSet</name>
<classname>boolean</classname>
</property>
+ <property hidden="true">
+ <name>switchType</name>
+ <classname>java.lang.String</classname>
+ </property>
&ui_component_attributes;
Modified: trunk/richfaces/togglePanel/src/main/config/component/togglePanel.xml
===================================================================
--- trunk/richfaces/togglePanel/src/main/config/component/togglePanel.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/togglePanel/src/main/config/component/togglePanel.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -347,7 +347,7 @@
</property>
<property hidden="true">
<name>localValueSet</name>
- <classname>boolean</classname>
+ <classname>java.lang.String</classname>
</property>
<!--
@@ -397,6 +397,10 @@
<name>reRender</name>
<classname>java.lang.Object</classname>
</property>
+ <property hidden="true">
+ <name>valid</name>
+ <classname>java.lang.String</classname>
+ </property>
<property>
<name>status</name>
Modified: trunk/richfaces/tree/src/main/config/component/tree.xml
===================================================================
--- trunk/richfaces/tree/src/main/config/component/tree.xml 2007-05-07 18:42:09 UTC (rev 683)
+++ trunk/richfaces/tree/src/main/config/component/tree.xml 2007-05-08 00:48:08 UTC (rev 684)
@@ -53,11 +53,6 @@
&ui_component_attributes;
&html_style_attributes;
- <property el="true" elonly="true" exist="true">
- <name>treeDataLocator</name>
- <classname>org.richfaces.component.preserve.TreeDataLocator</classname>
- <description></description>
- </property>
<property>
<name>stateVar</name>
<classname>java.lang.String</classname>
17 years, 7 months
JBoss Rich Faces SVN: r683 - trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:42:09 -0400 (Mon, 07 May 2007)
New Revision: 683
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
Log:
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-07 18:41:24 UTC (rev 682)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-07 18:42:09 UTC (rev 683)
@@ -34,9 +34,9 @@
<body>
- <sg:scrollable-grid value="#{selectionBean.dataModel}" var="issues" id="grid">
+ <sg:scrollable-grid value="#{selectionBean.dataModel}" var="issues" first="0" rows="30">
- <sg:column style="width: 200px" frozen="true">
+ <sg:column style="width: 100px" frozen="true">
<f:facet name="header">
<h:outputText value="Key"></h:outputText>
</f:facet>
@@ -45,7 +45,7 @@
<h:outputText value="footer1"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Summary"></h:outputText>
</f:facet>
@@ -54,7 +54,7 @@
<h:outputText value="footer2"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Assignee"></h:outputText>
</f:facet>
@@ -63,7 +63,7 @@
<h:outputText value="footer3"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Status"></h:outputText>
</f:facet>
@@ -72,7 +72,7 @@
<h:outputText value="footer4"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Reporter"></h:outputText>
</f:facet>
@@ -81,7 +81,7 @@
<h:outputText value="footer5"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Created"></h:outputText>
</f:facet>
@@ -90,7 +90,7 @@
<h:outputText value="footer6"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Updated"></h:outputText>
</f:facet>
@@ -99,7 +99,7 @@
<h:outputText value="footer7"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 200px">
+ <sg:column style="width: 100px">
<f:facet name="header">
<h:outputText value="Resolution"></h:outputText>
</f:facet>
17 years, 7 months
JBoss Rich Faces SVN: r682 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:41:24 -0400 (Mon, 07 May 2007)
New Revision: 682
Added:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ArrayDataModel.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/DataModel.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ArrayDataModel.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ArrayDataModel.js 2007-05-07 18:36:19 UTC (rev 681)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ArrayDataModel.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -27,9 +27,6 @@
getRow: function(index) {
return this.data[index];
},
- getRows: function(indexFrom, indexTo) {
- return $A(this.data.slice(indexFrom, indexTo));
- },
getCount: function() {
return this.data.length;
},
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/DataModel.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/DataModel.js 2007-05-07 18:36:19 UTC (rev 681)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/DataModel.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -31,11 +31,6 @@
return [];
},
- // interface method
- getRows: function(indexFrom, indexTo) {
- return [];
- },
-
// count of all data rows
getCount: function() {
return 0;
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-05-07 18:36:19 UTC (rev 681)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -302,6 +302,9 @@
},
invalidate: function(params) {
this.getBody().invalidate(params);
+ },
+ test: function() {
+ this.getBody().test();
}
})
Added: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -0,0 +1,312 @@
+/**
+ * Grid.js Date created: 6.04.2007
+ * Copyright (c) 2007 Exadel Inc.
+ * @author Denis Morozov <dmorozov(a)exadel.com>
+ */
+ClientUILib.declarePackage("ClientUI.controls.grid.Grid");
+
+ClientUILib.requireClass("ClientUI.common.box.Box");
+ClientUILib.requireClass("ClientUI.controls.grid.GridHeader");
+ClientUILib.requireClass("ClientUI.controls.grid.GridBody2");
+ClientUILib.requireClass("ClientUI.controls.grid.GridFooter");
+ClientUILib.requireClass("ClientUI.controls.grid.CellsStrip");
+
+/*
+ * grid.js - Grid library on top of Prototype
+ * by Denis Morozov <dmorozov(a)exadel.com> distributed under the BSD license.
+ *
+ * TODO: description of control
+ *
+ * TODO: usage description
+ * Usage:
+ * <script src="/javascripts/prototype.js" type="text/javascript"></script>
+ * <script src="/javascripts/extend.js" type="text/javascript"></script>
+ * <script src="/javascripts/grid.js" type="text/javascript"></script>
+ * <script type="text/javascript">
+ * // with valid DOM id
+ * var grid = new ClientUI.controls.grid.Grid('id_of_trigger_element', 'id_of_tooltip_to_show_element')
+ *
+ * // with text
+ * var grid = new ClientUI.controls.grid.Grid('id_of_trigger_element', 'a nice description')
+ * </script>
+ */
+ClientUI.controls.grid.Grid2 = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.Grid2',
+ parent: ClientUI.common.box.Box
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.Grid2.prototype, {
+ // Custom events
+ /**
+ * Occured when content header clicked
+ */
+ eventOnSort: {},
+
+ initialize: function(element, dataModel, templates, options) {
+ ClientUI.controls.grid.Grid2.parentClass.constructor().call(this, element);
+ if(!element || !element.id)
+ this.element.id = "ClientUI_Grid" + ClientUI_controls_grid_Grid_idGenerator++;
+
+ this.dataModel = dataModel;
+ this.templates = $A(templates);
+
+ this.eventOnSort = new ClientUI.common.utils.CustomEvent('OnSort');
+
+ // grid options
+ this.options = {
+ showIndexColumn: false,
+ indexColumnWidth: 30
+ };
+ if(options) { Object.extend(this.options, options); }
+
+ this.createControl();
+ },
+ createControl: function() {
+ var grid = this;
+ var layout = new ClientUI.layouts.GridLayoutManager(null, this.getElement());
+ this.layout = layout;
+
+ this.templates.each(function(item) {
+ switch(item.pane) {
+ case GridLayout_Enum.HEADER:
+ var header = new ClientUI.controls.grid.GridHeader($(item.ref), grid);
+ layout.addPane(GridLayout_Enum.HEADER, header);
+ break;
+ case GridLayout_Enum.BODY:
+ var body = new ClientUI.controls.grid.GridBody2($(item.ref), grid);
+ layout.addPane(GridLayout_Enum.BODY, body);
+ break;
+ case GridLayout_Enum.FOOTER:
+ var footer = new ClientUI.controls.grid.GridFooter($(item.ref), grid);
+ layout.addPane(GridLayout_Enum.FOOTER, footer);
+ break;
+ }
+ });
+
+ // create cells strips
+ this._columnsStrip = [];
+ var columns = this.getHeader().getColumns();
+ for(var i=0; i<columns.length; i++) {
+ this._columnsStrip[i] = new ClientUI.controls.grid.CellsStrip({
+ columnWidth: columns[i].object.getWidth(),
+ basePos: columns[i].object.getX(),
+ frozen: columns[i].frozen
+ });
+ }
+
+ this._parseRowAndAddToStrips("header", this.getHeader().getRow());
+ if(this.getFooter()) {
+ this._parseRowAndAddToStrips("footer", this.getFooter().getRow());
+ }
+
+ this.currentScrollPos = 0;
+ this.controlCreated = true;
+ this.updateLayout();
+ },
+ updateLayout: function() {
+ if(!this.controlCreated) {
+ return;
+ }
+ ClientUI.controls.grid.Grid2.parentClass.method("updateLayout").call(this);
+ if(this.layout) {
+ this.layout.updateLayout();
+ }
+ },
+ getHeader: function() {
+ return this.layout.getPane(GridLayout_Enum.HEADER);
+ },
+ getFooter: function() {
+ return this.layout.getPane(GridLayout_Enum.FOOTER);
+ },
+ getBody: function() {
+ return this.layout.getPane(GridLayout_Enum.BODY);
+ },
+ _getVisibleHeaderControls: function() {
+ var controls = [];
+ var columns = this.getHeader().getColumns();
+ columns.each(function(column){
+ var ctrls = $A(column.body.getElement().getElementsByTagName("select"));
+ ctrls.each(function(ctrl){
+ if(Element.visible(ctrl)) {
+ controls.push(ctrl);
+ }
+ });
+ });
+ return controls;
+ },
+ adjustColumnWidth: function(index, width) {
+ var oldWidth = this.getHeader().getColumns()[index].object.getWidth();
+
+ // 1. set new width
+ this._columnsStrip[index].setWidth(width);
+
+ // Hide controls in IE that flipped in other case
+ var ctrlsIE = [];
+ if(ClientUILib.isIE) {
+ ctrlsIE = this._getVisibleHeaderControls();
+ ctrlsIE.each(function(ctrl){
+ Element.hide(ctrl);
+ });
+ }
+
+ // 2. shift right side columns
+ if(index < this._columnsStrip.length-1) {
+ var count = this._columnsStrip.length;
+ if(this._columnsStrip[index].frozen) {
+ // if current column is frozen, lets find last frozen column index
+ var i=index+1;
+ while(this._columnsStrip[i].frozen && i<count) {
+ i++;
+ }
+ count = i;
+ }
+
+ var offset = width - oldWidth;
+ for(var i=index+1; i<count; i++) {
+ this._columnsStrip[i].setOffset(offset, true);
+ }
+ }
+
+ this.updateLayout();
+
+ if(ClientUILib.isIE) {
+ ctrlsIE.each(function(ctrl){
+ Element.show(ctrl);
+ });
+ }
+ },
+ adjustScrollPosition: function(pos) {
+ if(pos<0) {pos = 0;}
+ this.currentScrollPos = pos;
+ var i=0;
+ while(i<this._columnsStrip.lenth && this._columnsStrip[i].frozen) i++;
+ if(i<this._columnsStrip.length) {
+ while(i<this._columnsStrip.length) {
+ this._columnsStrip[i++].setOffset(pos, false, true);
+ }
+ }
+ this.getHeader().adjustScrollPosition(pos);
+ this.getBody().adjustScrollPosition(pos);
+ if(this.getFooter()) {this.getFooter().adjustScrollPosition(pos);}
+ },
+ loadData: function() {
+ this.getBody().adjustDataPosition(0);
+ },
+ frozeColumn: function(index, froze) {
+ if(index<0 || index>=this.getHeader().getColumns().length)
+ return false;
+ this.getHeader().getColumns()[index].frozen = froze;
+ },
+ setColumnMinWidth: function(index, width) {
+ if(index<0 || index>=this.getHeader().getColumns().length)
+ return false;
+ this.getHeader().getColumns()[index].minWidth = width;
+ return true;
+ },
+ _isSeparator: function(element) {
+ return Element.hasClassName(element, this.getHeader().CLASSDEF.sepStyleClass);
+ },
+ _isCell: function(element) {
+ return element.tagName && element.tagName.toLowerCase()!="iframe";
+ },
+ // helper method parse row of elements and add separately into rows and columns list
+ _parseRowAndAddToStrips: function(id, object) {
+ var i=0, j=0, cells, cell, count=0;
+ if(object.frozen && object.normal) {
+ // process frozen columns
+ cells = object.frozen.getElement().childNodes;
+ count = cells.length;
+ for(i=0, j=0; i<count; i++) {
+ cell = cells[i];
+ if(this._isCell(cell) && !this._isSeparator(cell)) {
+ this._columnsStrip[j].add(id, new ClientUI.controls.grid.ColumnCell(
+ cell,
+ this._columnsStrip[j]));
+ j++;
+ }
+ }
+ var sripIndex = j;
+ for(i=0, j=0; i<count; i++) { // process separators
+ cell = cells[i];
+ if(this._isSeparator(cell)) {
+ var columnCell = new ClientUI.controls.grid.ColumnCell(
+ cell,
+ this._columnsStrip[j]);
+ columnCell.separator = true;
+ this._columnsStrip[j].add(id, columnCell);
+ j++;
+ }
+ }
+
+ // process normal columns
+ i = sripIndex;
+ cells = object.normal.getElement().childNodes;
+ for(j=0; j<cells.length; j++) {
+ cell = cells[j];
+ if(this._isCell(cell) && !this._isSeparator(cell)) {
+ this._columnsStrip[i].add(id, new ClientUI.controls.grid.ColumnCell(
+ cell,
+ this._columnsStrip[i]));
+ i++;
+ }
+ }
+ i = sripIndex;
+ for(j=0; j<cells.length; j++) { // process separators
+ cell = cells[j];
+ if(this._isSeparator(cell)) {
+ var columnCell = new ClientUI.controls.grid.ColumnCell(
+ cell,
+ this._columnsStrip[i]);
+ columnCell.separator = true;
+ this._columnsStrip[i].add(id, columnCell);
+ i++;
+ }
+ }
+ }
+ },
+ _getParsedRowsCount: function() {
+ return this._columnsStrip[0].length();
+ },
+ _removeRowFromStrips: function(id) {
+ this._columnsStrip.each(function(strip){
+ strip.remove(id);
+ });
+ },
+ getColumnScrollX: function(index) {
+ if(index) {
+ return index<this._columnsStrip.length ? this._columnsStrip[index].currOffset : this.currentScrollPos;
+ }
+
+ return this.currentScrollPos;
+ },
+ getColumnsTotalWidth: function() {
+ var totalWidth = 0;
+ this.getHeader().getColumns().each(function(column){
+ totalWidth += column.object.getWidth();
+ });
+
+ return totalWidth;
+ },
+ getColumnsFrozenWidth: function() {
+ var totalWidth = 0;
+ var columns = this.getHeader().getColumns();
+ var i = 0;
+ while(i<columns.length && columns[i].frozen) {
+ totalWidth += columns[i++].object.getWidth();
+ }
+ return totalWidth;
+
+ },
+ invalidate: function(params) {
+ this.getBody().invalidate(params);
+ },
+ test: function() {
+ this.getBody().test();
+ }
+})
+
+var ClientUI_controls_grid_Grid_idGenerator = 0;
+
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-05-07 18:36:19 UTC (rev 681)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -74,13 +74,36 @@
this.setScrollPos(ypos);
this.adjustDataPosition(ypos);
},
+ test: function() {
+ ClientUILib.log(ClientUILogger.WARNING, "Perfomance test started....");
+ currTime = (new Date()).getTime();
+
+ var rows = [];
+ for(var i=0; i<100; i++) {
+ var row = this.createRow();
+ row.setRowIndex(i);
+ row.showEmpty();
+ rows.push(row);
+ }
+
+ ClientUILib.log(ClientUILogger.WARNING, "100 rows created over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
+ currTime = (new Date()).getTime();
+
+ for(var i=0; i<100; i++) {
+ var rowData = this.grid.dataModel.getRow(i);
+ rows[i].loadRowData(rows[i], i, rowData);
+ }
+
+ ClientUILib.log(ClientUILogger.WARNING, "100 rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
+ },
_onDataReady: function(options) {
- // load rows data
+ // load rows data
+ var currTime = (new Date()).getTime();
+
var loadRow = this.loadRow.bind(this);
var byIndex = options.indexes!==null;
var count = options.indexes!==null ? options.indexes.length : (options.ids!==null?options.ids.lenth : 0);
- var i;
- for(i=0; i<count; i++) {
+ for(var i=0; i<count; i++) {
loadRow(
options.indexes!==null ? options.indexes[i] : null,
options.ids!==null ? options.ids[i] : null);
@@ -90,7 +113,12 @@
if(ClientUILib.isIE && !ClientUILib.isIE7) {
this.setScrollPos(this.currentPos);
this.adjustScrollPosition(this.grid.getColumnScrollX());
- }
+ }
+
+ ClientUILib.log(ClientUILogger.WARNING, "data for "+count+" rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
+ ClientUILib.log(ClientUILogger.WARNING, "load data delta time: " + (this.taskStartTime - this.taskDefineTime));
+ ClientUILib.log(ClientUILogger.WARNING, "data prepare time: " + (this.taskStartLoadingTime - this.taskStartTime));
+ ClientUILib.log(ClientUILogger.INFO, "Load data indexes: " + options.ids.inspect());
},
registerEvents: function() {
Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
@@ -336,9 +364,8 @@
}
});
- //if(ClientUILib.isGecko) {
- headerRow.hide();
- //}
+ headerRow.hide();
+ headerFrozenRow.hide();
this.headerRowTemplate = headerRow;
this.headerFrozenRowTemplate = headerFrozenRow;
},
@@ -356,6 +383,9 @@
getId: function() {
return this.id;
},
+ getIdForCell: function(row, column) {
+ return "c_"+ row +"_" + column;
+ },
setId: function(id) {
this.id = id;
this.frozen.getElement().id = id;
@@ -366,17 +396,15 @@
var cnt = this.frozen.getElement().childNodes.length;
for(i=0; i<cnt; i++) {
cellObj = this.frozen.getElement().childNodes[i];
- cellObj.id = "c_"+ this.rowindex +"_" + index++;
- cB = document.getElementsByClassName("ClientUI_Grid_BCBody", cellObj);
- cB[0].id = "b"+ cellObj.id;
+ cellObj.id = this.getIdForCell(this.rowindex, index++);
+ cellObj.childNodes[0].id = "b"+ cellObj.id;
}
cnt = this.normal.getElement().childNodes.length;
for(i=0; i<cnt; i++) {
cellObj = this.normal.getElement().childNodes[i];
- cellObj.id = "c_"+ this.rowindex +"_" + index++;
- cB = document.getElementsByClassName("ClientUI_Grid_BCBody", cellObj);
- cB[0].id = "b"+ cellObj.id;
+ cellObj.id = this.getIdForCell(this.rowindex, index++);
+ cellObj.childNodes[0].id = "b"+ cellObj.id;
}
},
setRowIndex: function(index) {
@@ -441,23 +469,13 @@
},
showEmpty: function() {
this.moveToY(this.parent.defaultRowHeight * this.rowindex);
- if(!(ClientUILib.isIE && !ClientUILib.isIE7)) {
- this.setRowClass(this.rowindex%2 ? false : true);
- this.show();
- this.showWaitData(true);
- }
+ this.setRowClass(this.rowindex%2 ? false : true);
+ //this.show();
+ //this.showWaitData(true);
},
showNormal: function() {
this.show();
- if(ClientUILib.isIE && !ClientUILib.isIE7) {
- this.setRowClass(this.rowindex%2 ? false : true);
- if(this.parent.grid.options.showIndexColumn) {
- this.setCellValue(0, ""+this.rowindex);
- }
- }
- else {
- this.showWaitData(false);
- }
+ this.showWaitData(false);
},
loadRowData: function(row, index, rowData) {
@@ -478,11 +496,10 @@
return true;
},
getCellsToUpdate: function() {
- var fcs = $A(document.getElementsByClassName("ClientUI_Grid_BCBody", this.frozen.getElement()));
- var ncs = $A(document.getElementsByClassName("ClientUI_Grid_BCBody", this.normal.getElement()));
+ var count = this.parent.grid.getHeader().getColumns().length;
var ids = [];
- fcs.each(function (cell){ids.push(cell.id);});
- ncs.each(function (cell){ids.push(cell.id);});
+ for(var i=0; i<count; i++)
+ ids.push("b"+ this.getIdForCell(this.rowindex, i));
return ids;
}
};
@@ -561,17 +578,6 @@
if(this.dataViewHash) {
row = this.dataViewHash[index];
}
- if(row===null && index!==null) {
- row = this.dataView.findAll(function(item){return item && item.rowindex==index;});
- row = row && row.length && row.length>0 ? row[0] : null;
- }
- if(row===null && id!==null){
- var rowEl = document.getElementById(id);
- if(rowEl!==null) {
- index = rowEl.length ? rowEl[0].rowindex : rowEl.rowindex;
- row = this.dataView.findAll(function(item){return item && item.rowindex==index;});
- }
- }
if(row) {
var rowData = this.grid.dataModel.getRow(index);
if(rowData && rowData.length && rowData.length > 0) {
@@ -587,12 +593,7 @@
row.rowindex = -1;
this.rowsPool.push(row);
},
- adjustDataPosition: function (pos) {
- // small improvement
- if(this.dataView.length > 0 && Math.abs(this.currentPos - pos)/this.defaultRowHeigh < this.dataDelta/2) {
- return;
- }
-
+ adjustDataPosition: function (pos) {
// 1. calculate direction and range to load next data
var forwardDir = this.currentPos <= pos;
this.currentPos = pos;
@@ -606,133 +607,89 @@
var to = Math.min(first + this.dataVisible+this.dataDelta, this.grid.dataModel.getCount());
var range = $R(from, to);
- if(from === to) {
+ if(from >= to) {
ClientUILib.log(ClientUILogger.WARNING, "!!! GridBody: adjustDataPosition. Pos: " + pos + ", From:" + from + ", To:" + to);
return;
}
-
- // 3. hide invisible rows
- var dataViewHash = [];
- var deleteRow = this.deleteRow.bind(this);
- this.dataView.each(function(item) {
- if(item && item.rowindex>=0) {
- if(!range.include(item.rowindex)) {
- deleteRow(item);
- }
- else {
- dataViewHash[item.rowindex] = item;
- }
- }
- });
- // make some cleanup of deleted rows
- this.dataView = this.dataView.findAll(function(item) {
- return item && item.rowindex>=0;
- });
- // 4. show empty rows
- var rowIndex = 0;
- var rowsToLoad = [];
- var rowsToLoadIdx = [];
- var row, i;
- for(i=range.start; i<=range.end; i++) {
- if(!dataViewHash[i]) {
- row = this.getRow();
- row.setRowIndex(i);
- row.showEmpty();
- this.dataView.push(row);
- dataViewHash[i] = row;
- rowsToLoadIdx.push(i);
- rowsToLoad.push(row.getCellsToUpdate());
- rowIndex++
- }
- }
- this.dataViewHash = dataViewHash;
-
- if(rowIndex > 0) {
- // stop timed adjusting
- var task = this._getPendingTask();
- clearTimeout(task.timer);
+ // stop timed adjusting
+ var task = this._getPendingTask();
+ clearTimeout(task.timer);
+ if(to - from > 0) {
task.timer = null;
-
- while(task.rowsToLoadIdx.length) {
- var index = task.rowsToLoadIdx.pop();
- var ids = task.rowsToLoad.pop();
- if(dataViewHash[index]) {
- rowsToLoadIdx.push(index);
- rowsToLoad.push(ids);
- }
- }
-
- task.rowsToLoadIdx = rowsToLoadIdx;
- task.rowsToLoad = rowsToLoad;
+ task.from = from;
+ task.to = to;
this._setPendingTask(task);
- }
- },
+ }
+ },
_getPendingTask: function() {
if(!this.pendingTask) {
this.pendingTask = {
timer: null,
rowsToLoad: [],
- rowsToLoadIdx: []
+ rowsToLoadIdx: [],
+ from: 0,
+ to: 0
};
}
return this.pendingTask;
- },
+ },
_setPendingTask: function(task) {
// and plan other agjusting over the time
+ this.taskDefineTime = (new Date()).getTime();
task.timer = setTimeout(function() {
+ this.taskStartTime = (new Date()).getTime();
+ var range = $R(task.from, task.to);
- //ClientUILib.log(ClientUILogger.INFO, "Load data indexes: " + task.rowsToLoadIdx.inspect());
- //ClientUILib.log(ClientUILogger.INFO, "ViewSize: " + this.dataView.length);
- ClientUILib.log(ClientUILogger.INFO, "Load data indexes: " + task.rowsToLoad.inspect());
+ // 1. hide invisible rows
+ this.dataViewHash = [];
+ var newDataView = [];
+ var count = this.dataView.length;
+ for(var i=0; i<count; i++) {
+ var row = this.dataView[i];
+ if(!range.include(row.rowindex)) {
+ this.deleteRow(row);
+ }
+ else {
+ this.dataViewHash[row.rowindex] = this.dataView[i];
+ newDataView.push(row);
+ }
+ }
+ this.dataView = newDataView;
+ // 2. show empty rows
+ var rowsToLoad = [];
+ var rowsToLoadIdx = [];
+ var row, i;
+ for(i=task.from; i<=task.to; i++) {
+ if(!this.dataViewHash[i]) {
+ row = this.getRow();
+ row.setRowIndex(i);
+ row.showEmpty();
+ this.dataView.push(row);
+ this.dataViewHash[i] = row;
+ rowsToLoadIdx.push(i);
+ rowsToLoad.push(row.getCellsToUpdate());
+ }
+ }
+
+ this.taskStartLoadingTime = (new Date()).getTime();
// 4. start data loading
this.grid.dataModel.loadRows({
- indexes: task.rowsToLoadIdx,
- ids: task.rowsToLoad});
+ indexes: rowsToLoadIdx,
+ ids: rowsToLoad});
+ clearTimeout(task.timer);
task.timer = null;
- task.rowsToLoad = [];
- task.rowsToLoadIdx = [];
+ task.from = 0;
+ task.to = 0;
}.bind(this), this.grid.dataModel.getRequestDelay());
this.pendingTask = task;
- },
+ },
invalidate: function(options) {
- // load rows data
- var byIndex = options.indexes!==null;
- var count = options.indexes!==null ? options.indexes.length : (options.ids!==null?options.ids.lenth : 0);
- var i,index,id,row;
- for(i=0; i<count; i++) {
- index = options.indexes!==null ? options.indexes[i] : null;
- id = options.ids!==null ? options.ids[i] : null;
- row = null;
-
- if(index!==null) {
- if(this.dataViewHash) {
- row = this.dataViewHash[index];
- }
- if(!row) {
- row = this.dataView.findAll(function(item){return item && item.rowindex==index;});
- row = row && row.length && row.length>0 ? row[0] : null;
- }
- }
- if(row===null && id!==null){
- var rowEl = document.getElementById(id);
- if(rowEl!==null) {
- index = rowEl.length ? rowEl[0].rowindex : rowEl.rowindex;
- row = this.dataView.findAll(function(item){return item && item.rowindex==index;});
- }
- }
- if(row) {
- row.showNormal();
- }
- }
-
- // This trick to force IE rerender rows
- if(ClientUILib.isIE && !ClientUILib.isIE7) {
- this.setScrollPos(this.currentPos);
- this.adjustScrollPosition(this.grid.getColumnScrollX());
- }
- }
+ this.dataView.each(function(row) {
+ row.show();
+ });
+ }
});
Added: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -0,0 +1,639 @@
+/*
+ * TODO: Copyright (c) 2007 Denis Morozov <dmorozov(a)exadel.com>
+ *
+ * ...
+ */
+ClientUILib.declarePackage("ClientUI.controls.grid.GridBody2");
+
+ClientUILib.requireClass("ClientUI.common.box.Box");
+
+/*
+ * GridHeader.js - Grid control header pane
+ * TODO: add comments
+ */
+ClientUI.controls.grid.GridBody2 = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.GridBody2',
+ parent: ClientUI.common.box.Box
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.GridBody2.prototype, {
+ /**
+ * Count of rows can be viewed in the same time in grid
+ */
+ dataVisible: 50,
+
+ /**
+ * Count of rows loaded additianally to dataVisible rows
+ */
+ dataDelta: 5,
+
+ /**
+ * Contains loaded data
+ */
+ dataView: [],
+
+ /**
+ * Pool for rows. Targeted to improve perfomance
+ */
+ rowsPool: [],
+
+ /**
+ * Current data position
+ */
+ currentPos: 0,
+
+ /**
+ * Constructor
+ * @param {Object} template for Grid body row
+ * @param {Object} grid parent grid object
+ */
+ initialize: function(template, grid) {
+ this.grid = grid;
+ ClientUI.controls.grid.GridBody2.parentClass.constructor().call(this, null, grid.getElement());
+ this.element.id = this.grid.getElement().id + "_Body";
+
+ // declare event listeners
+ this._eventOnHScroll = this._onContentHScroll.bind(this);
+ this._eventOnVScroll = this._onContentVScroll.bind(this);
+ this._eventOnDataReady = this._onDataReady.bind(this);
+
+ this.createControl(template);
+ this.registerEvents();
+ this.updateLayout();
+ },
+ // event listeners
+ _onContentHScroll: function(xpos) {
+ this.grid.adjustScrollPosition(xpos);
+ },
+ _onContentVScroll: function(ypos) {
+ this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.setScrollPos(ypos);
+ this.adjustDataPosition(ypos);
+ },
+ _onDataReady: function(options) {
+ // load rows data
+ var currTime = (new Date()).getTime();
+
+ var loadRow = this.loadRow.bind(this);
+ var byIndex = options.indexes!==null;
+ var count = options.indexes!==null ? options.indexes.length : (options.ids!==null?options.ids.lenth : 0);
+ for(var i=0; i<count; i++) {
+ loadRow(
+ options.indexes!==null ? options.indexes[i] : null,
+ options.ids!==null ? options.ids[i] : null);
+ }
+
+ // This trick to force IE rerender rows
+ if(ClientUILib.isIE && !ClientUILib.isIE7) {
+ this.setScrollPos(this.currentPos);
+ this.adjustScrollPosition(this.grid.getColumnScrollX());
+ }
+
+ ClientUILib.log(ClientUILogger.WARNING, "data for "+count+" rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
+ ClientUILib.log(ClientUILogger.WARNING, "load data delta time: " + (this.taskStartTime - this.taskDefineTime));
+ ClientUILib.log(ClientUILogger.WARNING, "data prepare time: " + (this.taskStartLoadingTime - this.taskStartTime));
+ ClientUILib.log(ClientUILogger.INFO, "Load data indexes: " + options.ids.inspect());
+ },
+ registerEvents: function() {
+ Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
+ Event.observe(this.scrollBox.eventVScroll, "grid body vscroll", this._eventOnVScroll);
+ Event.observe(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
+ },
+ destroy: function() {
+ Event.stopObserving(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
+ Event.stopObserving(this.scrollBox.eventVScroll, "grid body vscroll", this._eventOnVScroll);
+ Event.stopObserving(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
+ },
+ createControl: function(template) {
+ // validate template
+ template.parentNode.removeChild(template);
+
+ // create scroll box
+ this.scrollBox = new ClientUI.common.box.ScrollableBox(null, this.getElement());
+ this.scrollBox.makeAbsolute();
+ this.sizeBox = new ClientUI.common.box.Box(null, this.scrollBox.getElement());
+ this.sizeBox.makeAbsolute();
+
+ var normal = null, frozen = null;
+ var childs = $(template).childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].id && childs[i].id == "FrozenBox") {
+ frozen = childs[i];
+ }
+ else if(childs[i].id && childs[i].id == "NormalBox"){
+ normal = childs[i];
+ }
+ }
+
+ if(normal) {
+ this.contentBox = new ClientUI.common.box.Box(normal);
+ this.contentBox.setParent(this.getElement());
+ this.contentBox.makeAbsolute();
+ }
+ if(frozen) {
+ this.frozenContentBox = new ClientUI.common.box.Box(frozen);
+ this.frozenContentBox.setParent(this.getElement());
+ this.frozenContentBox.makeAbsolute();
+ }
+
+ this.helpObject1 = new ClientUI.common.box.Box($(document.createElement("img")), this.contentBox.getElement());
+ this.helpObject1.setWidth(10);
+ this.helpObject1.setHeight(10);
+ this.helpObject1.makeAbsolute();
+ this.helpObject2 = new ClientUI.common.box.Box($(document.createElement("img")), this.frozenContentBox.getElement());
+ this.helpObject2.setWidth(10);
+ this.helpObject2.setHeight(10);
+ this.helpObject2.makeAbsolute();
+
+ // create row template
+ var ch = this.contentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.templNormal = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+ ch = this.frozenContentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.templFrozen = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+ this.parseTemplate(this.templFrozen.getElement(), this.templNormal.getElement());
+ this.updateColumns();
+
+ // control created
+ this.controlCreated = true;
+ },
+ parseTemplate: function(templFrozen, templNormal) {
+ if(!templNormal || !templNormal.rows || templNormal.rows.length===0) {
+ return false;
+ }
+
+ this.rowsCount = templNormal.rows.length;
+ this.defaultRowHeight = Element.getHeight(templNormal.rows[0].cells[0]);
+ if(ClientUILib.isGecko) {
+ this.defaultRowHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
+ }
+ return true;
+ },
+ updateColumns: function() {
+ var width = 0;
+ var columns = this.grid.getHeader().getColumns();
+ for(var i=0; i<columns.lenght; i++) {
+ width = columns[i].width;
+ if(ClientUILib.isGecko) {
+ width -= this.getBorderWidth("lr") + this.getPadding("lr");
+ }
+ this.adjustColumnWidth(i, width);
+ }
+ },
+ adjustColumnWidth: function(column, width) {
+ // TODO: implement adjustColumnWidth!!!
+ },
+ getColumns: function() {
+ return this._columns;
+ },
+ setScrollPos: function(pos) {
+ this.contentBox.getElement().scrollTop = pos;
+ this.frozenContentBox.getElement().scrollTop = pos;
+ if(ClientUILib.isIE && !ClientUILib.isIE7) {
+ this.contentBox.getElement().scrollTop = pos;
+ this.frozenContentBox.getElement().scrollTop = pos;
+ }
+ },
+ updateLayout: function() {
+ if(!this.controlCreated || !this.grid.controlCreated) {
+ return;
+ }
+ ClientUI.controls.grid.GridBody2.parentClass.method("updateLayout").call(this);
+ if(!this.scrollBox || !this.contentBox || !this.sizeBox) {
+ return;
+ }
+
+ var scrollLeft = this.contentBox.getElement().scrollLeft;
+ var height = this.scrollBox.getViewportHeight();
+ var fixH = this.grid.getFooter() ? this.grid.getFooter().getHeight() : 0;
+ if(fixH > height) fixH = 0;
+ var totalWidth = this.grid.getColumnsTotalWidth();
+ var frozenContentWidth = this.grid.getColumnsFrozenWidth();
+
+ this.scrollBox.moveTo(0, 0);
+ this.sizeBox.moveTo(0, 0);
+ this.frozenContentBox.moveTo(0, 0);
+ this.contentBox.moveTo(frozenContentWidth, 0);
+
+ this.sizeBox.setWidth(totalWidth);
+ this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
+ this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+
+ // NOTE: this needed to force this.scrollBox update scrolled area
+ this.scrollBox.setWidth(this.getWidth()+1);
+ this.scrollBox.setHeight(this.getHeight()+1);
+ this.scrollBox.setWidth(this.getWidth());
+ this.scrollBox.setHeight(this.getHeight());
+
+ this.contentBox.setWidth(this.scrollBox.getViewportWidth()-frozenContentWidth);
+ this.contentBox.setHeight(height - fixH);
+ this.frozenContentBox.setWidth(frozenContentWidth);
+ this.frozenContentBox.setHeight(height - fixH);
+
+ var scrollPos = Math.min(totalWidth - frozenContentWidth - this.contentBox.getWidth(), scrollLeft);
+ this.grid.adjustScrollPosition(scrollPos);
+
+ this.dataVisible = parseInt(this.contentBox.getHeight() / this.defaultRowHeight, 10) + 1;
+ if(height > 0) {
+ this.adjustDataPosition(this.currentPos);
+ }
+ },
+ adjustScrollPosition: function(pos) {
+ this.contentBox.getElement().scrollLeft = pos;
+ },
+ getScrollXPosition: function() {
+ return this.contentBox.getElement().scrollLeft;
+ },
+ getScrollYPosition: function() {
+ return this.contentBox.getElement().scrollTop;
+ },
+ _getRowDesc: function(parent, idPrefix, headerRow, headerFrozenRow) {
+ var rowDesc = {
+ id: headerRow.getElement().id,
+ idprefix: idPrefix,
+ parent: parent,
+ frozen: headerFrozenRow,
+ normal: headerRow,
+ moveToY: function(y) {
+ this.frozen.moveToY(y);
+ this.normal.moveToY(y);
+ },
+ getId: function() {
+ return this.id;
+ },
+ getIdForCell: function(row, column) {
+ return "c_"+ row +"_" + column;
+ },
+ setId: function(id) {
+ this.id = id;
+ this.frozen.getElement().id = id;
+ this.normal.getElement().id = id;
+
+ var cellObj, cB;
+ var i, index = 0;
+ var cnt = this.frozen.getElement().childNodes.length;
+ for(i=0; i<cnt; i++) {
+ cellObj = this.frozen.getElement().childNodes[i];
+ cellObj.id = this.getIdForCell(this.rowindex, index++);
+ cellObj.childNodes[0].id = "b"+ cellObj.id;
+
+ }
+ cnt = this.normal.getElement().childNodes.length;
+ for(i=0; i<cnt; i++) {
+ cellObj = this.normal.getElement().childNodes[i];
+ cellObj.id = this.getIdForCell(this.rowindex, index++);
+ cellObj.childNodes[0].id = "b"+ cellObj.id;
+ }
+ },
+ setRowIndex: function(index) {
+ this.rowindex = index;
+ this.frozen.getElement().rowindex = index;
+ this.normal.getElement().rowindex = index;
+ this.setId(this.idprefix + this.rowindex);
+ },
+ setRowClass: function(isOdd) {
+ if(isOdd) {
+ this.frozen.getElement().removeClassName("ClientUI_Grid_BREven");
+ this.normal.getElement().removeClassName("ClientUI_Grid_BREven");
+ this.frozen.getElement().addClassName("ClientUI_Grid_BROdd");
+ this.normal.getElement().addClassName("ClientUI_Grid_BROdd");
+ }
+ else {
+ this.frozen.getElement().removeClassName("ClientUI_Grid_BROdd");
+ this.normal.getElement().removeClassName("ClientUI_Grid_BROdd");
+ this.frozen.getElement().addClassName("ClientUI_Grid_BREven");
+ this.normal.getElement().addClassName("ClientUI_Grid_BREven");
+ }
+ },
+ setCellValue: function(index, newValue) {
+ var i = index;
+ var cnt1 = this.frozen.getElement().childNodes.length;
+ if(i < cnt1) {
+ var cellObj = this.frozen.getElement().childNodes[i];
+ Element.update(cellObj.firstChild, newValue);
+ return true;
+ }
+ i -= cnt1;
+ var cellObj = this.normal.getElement().childNodes[i];
+ Element.update(cellObj.firstChild, newValue);
+ return true;
+ },
+ show: function() {
+ this.frozen.show();
+ this.normal.show();
+ },
+ showWaitData: function(show) {
+ // process frozen
+ var cells = this.frozen.getElement().childNodes;
+ var i = 0, startIndex = 0;
+ if(this.parent.grid.options.showIndexColumn) {
+ startIndex = 1;
+ this.setCellValue(0, ""+this.rowindex);
+ }
+ var method = !show ? Element.show : Element.hide;
+ for(i=startIndex;i<cells.length; i++) {
+ method(cells[i]);
+ }
+
+ //process normal
+ cells = this.normal.getElement().childNodes;
+ for(i=0;i<cells.length; i++) {
+ method(cells[i]);
+ }
+ },
+ hide: function() {
+ this.frozen.hide();
+ this.normal.hide();
+ },
+ showEmpty: function() {
+ this.moveToY(this.parent.defaultRowHeight * this.rowindex);
+ this.setRowClass(this.rowindex%2 ? false : true);
+ //this.show();
+ //this.showWaitData(true);
+ },
+ showNormal: function() {
+ this.show();
+ this.showWaitData(false);
+ },
+ loadRowData: function(row, index, rowData) {
+
+ // replace data patterns in content with real data from row
+ var count = this.parent.grid.getHeader().getColumns().length;
+ var columns = this.parent.getColumns();
+ var i = this.parent.grid.options.showIndexColumn ? 1 : 0;
+ for(; i<count; i++) {
+ var value = this.parent.parseExpression(columns[i].value, rowData, {
+ row: index,
+ cid: row.getId() + ":" + i,
+ rid: row.getId()
+ });
+ this.setCellValue(i, value);
+ }
+
+ this.showNormal();
+ return true;
+ },
+ getCellsToUpdate: function() {
+ var count = this.parent.grid.getHeader().getColumns().length;
+ var ids = [];
+ for(var i=0; i<count; i++)
+ ids.push("b"+ this.getIdForCell(this.rowindex, i));
+ return ids;
+ }
+ };
+
+ return rowDesc;
+ },
+ createRow: function() {
+ var row = null;
+ var rowFrozen = null;
+ if(this.templateRow) { // use existing template to inherit cell's width & offset
+ row = this.templateRow.normal.getElement().cloneNode(true);
+ rowFrozen = this.templateRow.frozen.getElement().cloneNode(true);
+ }
+ else { // first time
+ row = this.headerRowTemplate.getElement().cloneNode(true);
+ rowFrozen = this.headerFrozenRowTemplate.getElement().cloneNode(true);
+ }
+
+ var headerRow = new ClientUI.common.box.InlineBox(row, this.contentBox.getElement(), true);
+ headerRow.setParent(this.contentBox.getElement());
+ var headerFrozenRow = new ClientUI.common.box.InlineBox(rowFrozen, this.frozenContentBox.getElement(), true);
+ headerFrozenRow.setParent(this.frozenContentBox.getElement());
+
+ var rowDesc = this._getRowDesc(this, this.getElement().id + "BR", headerRow, headerFrozenRow);
+
+ // create sample row that will be cloned
+ if(!this.templateRow) {
+ this.templateRow = rowDesc;
+ this.templateRow.setId("trow");
+ this.grid._parseRowAndAddToStrips(this.templateRow.id, this.templateRow);
+ this.templateRow.setRowIndex(-100);
+ this.templateRow.showEmpty();
+ this.templateRow.hide();
+ }
+
+ this.grid._parseRowAndAddToStrips("" + (this.grid._getParsedRowsCount()+1), rowDesc);
+ return rowDesc;
+ },
+ /**
+ * Parse values of cell's value and title
+ * Predefined patterns:
+ * - $(row) Index of current row
+ * - $(cid) Cell's DOM id
+ * - $(rid) Row's DOM id
+ * - $(N) Row Data index
+ * @param {Object} expr Value to parse. Can be defined over expression in next manner: "$(index_0) and $(index_4) will be over $(index_2) higher!". Where 1,5,3 - indexes in <code>data</code> array param.
+ * @param {Object} data Data to replace within expression.
+ */
+ parseExpression: function(expr, data, params) {
+ var pattern = /\$\(row\)/i;
+ var rez = expr.gsub(pattern, function(item) {
+ return params.row;
+ });
+ pattern = /\$\(cid\)/i;
+ rez = rez.gsub(pattern, function(item) {
+ return params.cid;
+ })
+ pattern = /\$\(rid\)/i;
+ rez = rez.gsub(pattern, function(item) {
+ return params.rid;
+ })
+
+ pattern = /\$\((\d*)\)/i;
+ rez = rez.gsub(pattern, function(item) {
+ if(!item || !item[1]) {
+ return "!ERROR!";
+ }
+ var index = parseFloat(item[1]);
+ return data.length > index ? data[index] : "!ERROR!";
+ });
+
+ return rez;
+ },
+ loadRow: function(index, id) {
+ var row = null;
+ if(this.dataViewHash) {
+ row = this.dataViewHash[index];
+ }
+ if(row) {
+ var rowData = this.grid.dataModel.getRow(index);
+ if(rowData && rowData.length && rowData.length > 0) {
+ row.loadRowData(row, index, rowData);
+ }
+ }
+ },
+ getRow: function() {
+ return this.rowsPool.length>0 ? this.rowsPool.pop() : this.createRow();
+ },
+ deleteRow: function(row) {
+ row.hide();
+ row.rowindex = -1;
+ this.rowsPool.push(row);
+ },
+ adjustDataPosition: function (pos) {
+
+ // 1. calculate direction and range to load next data
+ var forwardDir = this.currentPos <= pos;
+ this.currentPos = pos;
+
+ // first visible row index
+ var first = parseInt(pos / this.defaultRowHeight) - 1;
+ if(first < 0) first = 0;
+
+ // TODO: check direction and predict some next rows
+ var from = Math.max(first - this.dataDelta, 0);
+ var to = Math.min(first + this.dataVisible+this.dataDelta, this.grid.dataModel.getCount());
+ var range = $R(from, to);
+
+ if(from >= to) {
+ ClientUILib.log(ClientUILogger.WARNING, "!!! GridBody: adjustDataPosition. Pos: " + pos + ", From:" + from + ", To:" + to);
+ return;
+ }
+
+ // stop timed adjusting
+ var task = this._getPendingTask();
+ clearTimeout(task.timer);
+ if(to - from > 0) {
+ task.timer = null;
+ task.from = from;
+ task.to = to;
+ this._setPendingTask(task);
+ }
+ },
+ _getPendingTask: function() {
+ if(!this.pendingTask) {
+ this.pendingTask = {
+ timer: null,
+ rowsToLoad: [],
+ rowsToLoadIdx: [],
+ from: 0,
+ to: 0
+ };
+ }
+ return this.pendingTask;
+ },
+ _setPendingTask: function(task) {
+ // and plan other agjusting over the time
+ this.taskDefineTime = (new Date()).getTime();
+ task.timer = setTimeout(function() {
+ this.taskStartTime = (new Date()).getTime();
+
+ // 1. get previous range
+ if(!this.currRange) {
+ this.currRange = $R(-this.rowsCount,-1);
+ }
+
+ var range = $R(task.from, task.to);
+
+ // if we have intersepted ranges than rearrange rows
+ // in other case just move rows table to first position
+ var switchRows = true;
+ if(this.currRange.end < range.start
+ || this.currRange.start > range.end) {
+ switchRows = false;
+ }
+
+ if(!switchRows) {
+ this.prepareRows(0, range.end - range.start);
+ var pos = this.defaultRowHeight * range.start;
+ this.templFrozen.moveToY(pos);
+ this.templNormal.moveToY(pos);
+ }
+ else {
+ var rowsNeededCount = 0;
+ if(range.start > this.currRange.start
+ && range.start < this.currRange.end) {
+ // TODO: get rows from this.currRange.start to range.start
+ // and move them to end of table
+ // then move table to correct position
+ }
+ else {
+ // TODO: get rows from range.end to this.currRange.end
+ // and move them to begin of table
+ // then move table to correct position
+ }
+ }
+
+ /*
+ // 1. hide invisible rows
+ this.dataViewHash = [];
+ var newDataView = [];
+ var count = this.dataView.length;
+ for(var i=0; i<count; i++) {
+ var row = this.dataView[i];
+ if(!range.include(row.rowindex)) {
+ this.deleteRow(row);
+ }
+ else {
+ this.dataViewHash[row.rowindex] = this.dataView[i];
+ newDataView.push(row);
+ }
+ }
+ this.dataView = newDataView;
+
+ // 2. show empty rows
+ var rowsToLoad = [];
+ var rowsToLoadIdx = [];
+ var row, i;
+ for(i=task.from; i<=task.to; i++) {
+ if(!this.dataViewHash[i]) {
+ row = this.getRow();
+ row.setRowIndex(i);
+ row.showEmpty();
+ this.dataView.push(row);
+ this.dataViewHash[i] = row;
+ rowsToLoadIdx.push(i);
+ rowsToLoad.push(row.getCellsToUpdate());
+ }
+ }
+
+ this.taskStartLoadingTime = (new Date()).getTime();
+ // 4. start data loading
+ this.grid.dataModel.loadRows({
+ indexes: rowsToLoadIdx,
+ ids: rowsToLoad});
+ */
+
+ clearTimeout(task.timer);
+ task.timer = null;
+ task.from = 0;
+ task.to = 0;
+ this.currRange = range;
+
+ }.bind(this), this.grid.dataModel.getRequestDelay());
+
+ this.pendingTask = task;
+ },
+ invalidate: function(options) {
+ this.dataView.each(function(row) {
+ row.show();
+ });
+ },
+
+ /**
+ * prepare rows for data reload
+ * i.e. hide and set new ids for content elements
+ */
+ prepareRows: function(start, end, startIndex) {
+ // this.rowsCount
+ //this.templFrozen.moveToY(pos);
+ //this.templNormal.moveToY(pos);
+ }
+});
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js 2007-05-07 18:36:19 UTC (rev 681)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -97,7 +97,7 @@
var i = 0;
if(this.grid.options.showIndexColumn) {
columns[i++] = {
- innerHTML: " ",
+ innerHTML: " ",
styleClass: "",
id: "",
align: "",
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-05-07 18:36:19 UTC (rev 681)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-05-07 18:41:24 UTC (rev 682)
@@ -57,7 +57,7 @@
}
template.parentNode.removeChild(template);
- document.body.appendChild(template);
+ document.body.appendChild(this.template);
var errMsg = "";
if(!this.template) {
@@ -80,7 +80,7 @@
this.generateDOMTree();
// Remove template
- document.body.removeChild(template);
+ document.body.removeChild(this.template);
// Set dimensions
this.setHeight(this.defaultHeight);
@@ -100,7 +100,7 @@
if(this.grid.options.showIndexColumn) {
columns[i++] = {
width: this.grid.options.indexColumnWidth,
- innerHTML: " ",
+ innerHTML: " ",
styleClass: "",
id: "",
align: "",
@@ -118,7 +118,7 @@
var cells = $A(template.rows[0].cells);
cells.each(function(cell) {
columns[i++] = {
- width: Element.getWidth(cell),
+ width: parseInt(cell.width),/*Element.getWidth(cell),*/
innerHTML: cell.innerHTML,
styleClass: cell.className,
id: cell.id,
@@ -222,7 +222,9 @@
sb.append(columnDesc.innerHTML);
}
sb.append('</span></td><td><span class="sort-desc"></span><span class="sort-asc"></span></td></tr></tbody></table>');
- colBody.getElement().update(sb.toString());
+
+ var cellContent = sb.toString();
+ colBody.getElement().update(cellContent);
colBody.moveTo(0, 0);
var bodyWidth = width;
var bodyHeight = height;
17 years, 7 months
JBoss Rich Faces SVN: r681 - trunk/sandbox/scrollable-grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:36:19 -0400 (Mon, 07 May 2007)
New Revision: 681
Modified:
trunk/sandbox/scrollable-grid/generatescript.xml
Log:
Modified: trunk/sandbox/scrollable-grid/generatescript.xml
===================================================================
--- trunk/sandbox/scrollable-grid/generatescript.xml 2007-05-07 18:36:10 UTC (rev 680)
+++ trunk/sandbox/scrollable-grid/generatescript.xml 2007-05-07 18:36:19 UTC (rev 681)
@@ -36,10 +36,10 @@
<file name="/ClientUI/layouts/VLayoutManager.js"/>
<file name="/ClientUI/layouts/GridLayoutManager.js"/>
<file name="/ClientUI/controls/grid/GridHeader.js"/>
- <file name="/ClientUI/controls/grid/GridBody.js"/>
+ <file name="/ClientUI/controls/grid/GridBody2.js"/>
<file name="/ClientUI/controls/grid/GridFooter.js"/>
<file name="/ClientUI/controls/grid/CellsStrip.js"/>
- <file name="/ClientUI/controls/grid/Grid.js"/>
+ <file name="/ClientUI/controls/grid/Grid2.js"/>
</filelist>
</concat>
</target>
17 years, 7 months
JBoss Rich Faces SVN: r680 - trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:36:10 -0400 (Mon, 07 May 2007)
New Revision: 680
Modified:
trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-05-07 18:34:55 UTC (rev 679)
+++ trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-05-07 18:36:10 UTC (rev 680)
@@ -222,6 +222,9 @@
cursor: default;
height:21px !important;
border-right: 1px solid #f1efe2;
+ border-bottom: 1px solid #f1efe2;
+
+
}
.ClientUI_Grid_BCIndex {
background-color: #ebeadb;
@@ -264,10 +267,18 @@
}
.ClientUI_Grid_BCBody {
+
cursor: default;
font: normal 8pt arial;
padding: 3px 5px;
white-space: nowrap;
+ display: block;
+ overflow: hidden;
+ -o-text-overflow: ellipsis;
+ text-overflow: ellipsis;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+
}
17 years, 7 months
JBoss Rich Faces SVN: r679 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:34:55 -0400 (Mon, 07 May 2007)
New Revision: 679
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-05-07 18:34:32 UTC (rev 678)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-05-07 18:34:55 UTC (rev 679)
@@ -24,52 +24,82 @@
<script type="text/javascript">
//<![CDATA[
+
+ ClientUI.controls.grid.FakeArrayDataModel = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.FakeArrayDataModel',
+ parent: ClientUI.controls.grid.DataModel
+ }
+ });
+
+ Object.extend(ClientUI.controls.grid.FakeArrayDataModel.prototype, {
+ initialize: function(rows_count, columns_count) {
+ ClientUI.controls.grid.FakeArrayDataModel.parentClass.constructor().call(this);
+ this.data = [];
+ this.count = rows_count;
+ this.columns = columns_count;
+ },
+ getRow: function(index) {
+ if(!this.data[index]) {
+ this.data[index] = [];
+ for (var index2 = 0; index2 < 18; index2++) {
+ this.data[index][index2] = index2 + " : " + index;
+ }
+ this.data[index][6] = index%2 ? "value 1" : "value 2";
+ }
+
+ return this.data[index];
+ },
+ getCount: function() {
+ return this.count;
+ },
+ getRequestDelay: function() {
+ return 50;
+ }
+ });
+ // ]]>
+ </script>
+
+ <script type="text/javascript">
+ //<![CDATA[
+
+
var #{this:getJavaScriptVarName(context, component)} = function() {
return {
init : function() {
var currTime = (new Date()).getTime();
- ClientUILib.log(ClientUILogger.WARNING, "Document loaded over " + (currTime - ClientUILib.startTime) + " miliseconds.");
-
- var data = [];
- for (var index = 0; index < 100; index++) {
- data[index] = [];
- for (var index2 = 0; index2 < 6; index2++) {
- data[index][index2] = index2 + " : " + index;
- }
- data[index][6] = index%2 ? "value 1" : "value 2";
- }
-
- dataModel = new ClientUI.controls.grid.ArrayDataModel(data);
-
+ // ClientUILib.log(ClientUILogger.WARNING, "Document loaded over " + (currTime - ClientUILib.startTime) + " miliseconds.");
+
+ dataModel = new ClientUI.controls.grid.FakeArrayDataModel(1000, 18);
+
var templates = [
{pane: GridLayout_Enum.HEADER, ref: "GridHeaderTemplate"},
{pane: GridLayout_Enum.BODY, ref: "GridBodyTemplate"},
{pane: GridLayout_Enum.FOOTER, ref: "GridFooterTemplate"}
];
-
- ClientUILib.log(ClientUILogger.WARNING, "DataModel created over " + ((new Date()).getTime() - currTime) + " miliseconds.");
- currTime = (new Date()).getTime();
-
+
+ // ClientUILib.log(ClientUILogger.WARNING, "DataModel created over " + ((new Date()).getTime() - currTime) + " miliseconds.");
+ // currTime = (new Date()).getTime();
+
// create the Grid
- var grid = new ClientUI.controls.grid.Grid('GridContainer', dataModel, templates,
+ grid = new ClientUI.controls.grid.Grid2('GridContainer', dataModel, templates,
{
- showIndexColumn: true,
+ showIndexColumn: false,
indexColumnWidth: 40
}
);
- ClientUILib.log(ClientUILogger.WARNING, "Grid control created over " + ((new Date()).getTime() - currTime) + " miliseconds.");
-
- grid.updateLayout();
- Event.observe(grid.eventOnSort, "grid on sort", onSort);
-
- setTimeout(function() {
- currTime = (new Date()).getTime();
- grid.loadData();
- ClientUILib.log(ClientUILogger.WARNING, "Grid data loaded over " + ((new Date()).getTime() - currTime) + " miliseconds.");
- }.bind(this), 100);
-
- ClientUILib.log(ClientUILogger.WARNING, "Done.");
- }
+ // ClientUILib.log(ClientUILogger.WARNING, "Grid control created over " + ((new Date()).getTime() - currTime) + " miliseconds.");
+
+ grid.updateLayout();
+
+ setTimeout(function() {
+ currTime = (new Date()).getTime();
+ //grid.loadData();
+ }.bind(this), 100);
+
+ // ClientUILib.log(ClientUILogger.WARNING, "Done.");
+ }
+
}
}();
@@ -80,20 +110,22 @@
</script>
- <div id="GridContainer" style="width:60%; height:300px;" class="ClientUI_Grid">
+ <div id="GridContainer" style="width: 90%; height:500px;" class="ClientUI_Grid">
<div id="GridHeaderTemplate">
<table class="TestGridHeader" cellpadding="0" cellspacing="0" border="1">
- <f:call name="renderHeaders"/>
+ <tbody>
+ <f:call name="renderHeaders"/>
+ </tbody>
</table>
</div>
<div id="GridBodyTemplate">
- <table cellpadding="0" cellspacing="0">
- <vcp:body/>
- </table>
+ <vcp:body/>
</div>
<div id="GridFooterTemplate">
<table cellpadding="0" cellspacing="0">
- <f:call name="renderFooters"/>
+ <tbody>
+ <f:call name="renderFooters"/>
+ </tbody>
</table>
</div>
</div>
17 years, 7 months
JBoss Rich Faces SVN: r678 - trunk/sandbox/scrollable-grid/src/main/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:34:32 -0400 (Mon, 07 May 2007)
New Revision: 678
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js 2007-05-07 18:34:16 UTC (rev 677)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUILib.js 2007-05-07 18:34:32 UTC (rev 678)
@@ -145,7 +145,8 @@
Element.show(this.logElement);
this.logElement.setStyle({width: this.width + 'px'});
this.logElement.setStyle({height: this.height + 'px'});
- this.logElement.setStyle({top: (this.getWindowHeight() - this.height - 10) + 'px'});
+ //this.logElement.setStyle({top: (this.getWindowHeight() - this.height - 10) + 'px'});
+ this.logElement.setStyle({top: 10 + 'px'});
this.logElement.setStyle({left: (this.getWindowWidth() - this.width - 10) + 'px'});
}
},
17 years, 7 months
JBoss Rich Faces SVN: r677 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:34:16 -0400 (Mon, 07 May 2007)
New Revision: 677
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridRendererState.java
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnVisitor.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnVisitor.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnVisitor.java 2007-05-07 18:34:04 UTC (rev 676)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnVisitor.java 2007-05-07 18:34:16 UTC (rev 677)
@@ -9,6 +9,10 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.component.UIScrollableGridColumn;
+
/**
* @author Anton Belevich
*
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-07 18:34:04 UTC (rev 676)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-07 18:34:16 UTC (rev 677)
@@ -10,6 +10,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.component.UIScrollableGridColumn;
@@ -20,7 +21,7 @@
*/
public class ColumnWalker {
- static void iterateOverKids(FacesContext context, UIComponent component, ColumnVisitor visitor, ResponseWriter writer) throws IOException{
+ static void iterateOverHeadersFooters(FacesContext context, UIComponent component, ColumnVisitor visitor, ResponseWriter writer) throws IOException{
if(context == null || component == null){
throw new NullPointerException();
@@ -35,12 +36,13 @@
if(null != component.getChildren()){
writer.startElement(HTML.TR_ELEMENT, component);
writer.writeText("\n", null);
+
for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
if (kid instanceof UIScrollableGridColumn){
- visitor.visit(context, kid, writer);
+ visitor.visit(context, (UIScrollableGridColumn)kid, writer);
}
}
}
@@ -49,4 +51,13 @@
}
}
}
+
+ static void iterateOverBody(FacesContext context, UIComponent component, ColumnVisitor visitor, ResponseWriter writer) throws IOException{
+
+ if(component instanceof UIScrollableGrid){
+ if(null != component.getChildren()){
+ visitor.visit(context, component, writer);
+ }
+ }
+ }
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-07 18:34:04 UTC (rev 676)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-07 18:34:16 UTC (rev 677)
@@ -1,17 +1,18 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.richfaces.component.UIScrollableGrid;
+import org.richfaces.component.UIScrollableGridColumn;
import org.richfaces.renderkit.CompositeRenderer;
-import org.richfaces.utils.TemplateLoader;
/**
* @author Anton Belevich
@@ -24,30 +25,30 @@
private final String HEADER_PART = "header";
- //private final RendererBase cellTemplate = TemplateLoader.loadTemplate("org.richfaces.renderkit.html.ScrollableGridCellRenderer");
+
private final ColumnVisitor headerRenderer = new ColumnVisitor(){
public void visit(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException {
+
writer.startElement(HTML.td_ELEM, component);
getUtils().writeAttribute(writer, "frozen", component.getAttributes().get("frozen"));
getUtils().writeAttribute(writer, "style",component.getAttributes().get("style"));
writer.writeText("\n", null);
-
+
if(component.getFacet(HEADER_PART) != null){
component = component.getFacet(HEADER_PART);
renderChild(context, component);
}
writer.endElement(HTML.td_ELEM);
writer.writeText("\n", null);
- }
+ }
};
private final ColumnVisitor footerRenderer = new ColumnVisitor(){
public void visit(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException {
-
writer.startElement(HTML.td_ELEM, component);
getUtils().writeAttribute(writer, "style",component.getAttributes().get("style"));
writer.writeText("\n", null);
@@ -56,24 +57,122 @@
component = component.getFacet(FOOTER_PART);
renderChild(context, component);
}
-
+
writer.endElement(HTML.td_ELEM);
writer.writeText("\n", null);
- }
+ }
};
private final ColumnVisitor bodyRenderer = new ColumnVisitor(){
public void visit(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException {
- writer.startElement(HTML.td_ELEM, component);
+
+ UIScrollableGrid grid = (UIScrollableGrid)component;
+
+ writer.startElement(HTML.DIV_ELEM, grid);
+ getUtils().writeAttribute(writer, "class","GridDataColumns");
+ getUtils().writeAttribute(writer, "id","FrozenBox");
+ getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100px");
writer.writeText("\n", null);
- renderChildren(context, component);
- writer.endElement(HTML.td_ELEM);
+ writer.startElement("table", grid);
+ getUtils().writeAttribute(writer, "id","GridDataFrozen");
+ getUtils().writeAttribute(writer, "cellpadding","0");
+ getUtils().writeAttribute(writer, "cellspacing","0");
+ getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100%");
writer.writeText("\n", null);
+ writer.startElement("tbody", grid);
+
+
+ renderColumns(context, (UIScrollableGrid)grid, writer,true);
+
+ writer.endElement("tbody");
+ writer.endElement("table");
+ writer.endElement(HTML.DIV_ELEM);
+
+ writer.startElement(HTML.DIV_ELEM, grid);
+ getUtils().writeAttribute(writer, "class","GridDataColumns");
+ getUtils().writeAttribute(writer, "id","NormalBox");
+ getUtils().writeAttribute(writer, "style","position: absolute; left: 300px; top: 0px; display: block; width: 700px");
+ writer.writeText("\n", null);
+ writer.startElement("table", grid);
+ getUtils().writeAttribute(writer, "id","GridDataNormal");
+ getUtils().writeAttribute(writer, "cellpadding","0");
+ getUtils().writeAttribute(writer, "cellspacing","0");
+ getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100%");
+ writer.writeText("\n", null);
+
+ renderColumns(context, grid, writer, false);
+
+ writer.endElement("tbody");
+ writer.endElement("table");
+ writer.endElement(HTML.DIV_ELEM);
+ // end of normal columns rendering
}
};
+ private void renderColumns(FacesContext context, UIScrollableGrid grid,
+ ResponseWriter writer,boolean isFrozenColumn
+ ) throws IOException{
+ for(int i = grid.getFirst(); i < grid.getRows(); i++ ){
+
+ writer.startElement(HTML.TR_ELEMENT, grid);
+ getUtils().writeAttribute(writer, "id","row_"+ i);
+ getUtils().writeAttribute(writer, "class","ClientUI_Grid_BR");
+
+ List kidz = grid.getChildren();
+
+ int cellIndex = 0;
+ boolean processFrozen = false;
+
+ for (Iterator iter = kidz.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+
+ if(child instanceof UIScrollableGridColumn){
+ UIScrollableGridColumn column = (UIScrollableGridColumn)child;
+ boolean frozen = ((Boolean)child.getAttributes().get("frozen")).booleanValue();
+ if(isFrozenColumn){
+ if(frozen){
+ if(!processFrozen){
+ cellIndex = 0;
+ processFrozen = true;
+ }
+ renderCells(context, column, writer, cellIndex, i);
+ }
+
+ }else{
+ if(!frozen){
+ if(processFrozen){
+ cellIndex = 0;
+ processFrozen = false;
+ }
+ renderCells(context, column, writer, cellIndex,i);
+ }
+ }
+ cellIndex++;
+ }
+ }
+
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+ }
+
+ private void renderCells(FacesContext context, UIScrollableGridColumn column,
+ ResponseWriter writer, int cellIndex, int rowIndex) throws IOException{
+
+ writer.startElement(HTML.td_ELEM, column);
+ getUtils().writeAttribute(writer, "id","c_"+ rowIndex + "_" + cellIndex);
+ getUtils().writeAttribute(writer, "class","ClientUI_Grid_BC");
+ writer.startElement(HTML.SPAN_ELEM, column);
+ getUtils().writeAttribute(writer, "id","bc_"+ rowIndex + "_" + cellIndex);
+ getUtils().writeAttribute(writer,"style",column.getAttributes().get("style"));
+ getUtils().writeAttribute(writer,"class","ClientUI_Grid_BCBody");
+ renderChild(context, column);
+ writer.endElement(HTML.SPAN_ELEM);
+ writer.endElement(HTML.td_ELEM);
+
+ }
+
protected String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
String id = grid.getBaseClientId(context);
return "Richfaces_ScrollableGrid_" + id.replaceAll("[^A-Za-z0-9_]", "_");
@@ -87,22 +186,29 @@
return true;
}
- protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- ColumnWalker.iterateOverKids(context, component, bodyRenderer, writer);
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
+ UIComponent component) throws IOException {
+
+ ColumnWalker.iterateOverBody(context, component, bodyRenderer, writer);
}
- public void renderHeaders(FacesContext context, UIComponent component)throws IOException{
+ public void renderHeaders(FacesContext context, UIComponent component
+ )throws IOException{
+
ResponseWriter writer = context.getResponseWriter();
- ColumnWalker.iterateOverKids(context, component, headerRenderer, writer);
+ ColumnWalker.iterateOverHeadersFooters(context, component, headerRenderer, writer);
}
- public void renderFooters(FacesContext context, UIComponent component) throws IOException{
+ public void renderFooters(FacesContext context, UIComponent component
+ ) throws IOException{
+
ResponseWriter writer = context.getResponseWriter();
- ColumnWalker.iterateOverKids(context, component, footerRenderer, writer);
+ ColumnWalker.iterateOverHeadersFooters(context, component, footerRenderer, writer);
}
// for benchmark
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ public void encodeBegin(FacesContext context, UIComponent component
+ ) throws IOException {
if(AjaxContext.getCurrentInstance().isAjaxRequest()){
}else{
@@ -110,7 +216,8 @@
}
}
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+ public void encodeEnd(FacesContext context, UIComponent component
+ ) throws IOException {
if(AjaxContext.getCurrentInstance().isAjaxRequest()){
}else{
@@ -118,10 +225,10 @@
}
}
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ public void encodeChildren(FacesContext context, UIComponent component
+ ) throws IOException {
ResponseWriter writer = context.getResponseWriter();
-
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
if(ajaxContext.isAjaxRequest()){
writer.startElement("div", component);
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridRendererState.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridRendererState.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridRendererState.java 2007-05-07 18:34:16 UTC (rev 677)
@@ -0,0 +1,398 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.NamingContainer;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.ajax.AjaxContainer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.richfaces.component.UIScrollableGrid;
+
+/**
+ * bean to store current {@link com.exadel.vcp.components.datagrid.UIDataGrid } information
+ * in request map. For nested grids, it support push/pop state saving.
+ * In {@link javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)} method
+ * must be created instance of this bean , or, if it already exist in request map - push information.
+ * at the end of encodeEnd call, bean must be pop information or removed.
+ * @author shura
+ *
+ */
+public class ScrollableGridRendererState implements Serializable {
+
+ public static final String DATA_GRID_RENDERER_STATE = ScrollableGridRendererState.class.getName();
+
+ private int _rowIndex = 0;
+
+ private int _cellIndex = 0;
+
+ private int _columns = 0;
+
+ private UIScrollableGrid _grid;
+
+ private String _cachedClientId;
+
+ private ScrollableGridRendererState _previousState = null;
+
+ private AjaxContainer _region = null;
+
+ private boolean _rowSelected;
+
+ private Object rowKey;
+
+ private String prefix;
+
+ private String selectedClass;
+ private String activeClass;
+ private String focusedClass;
+ private String resizerClass;
+
+ private String [] columnClasses;
+ private String [] rowClasses;
+ private String [] headerColumnClasses;
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2129605586975025578L;
+
+ private Set _renderedAreas = null;
+
+
+ /**
+ * Get current grid state from JSF context
+ * @param context
+ * @return current data grid state, or null if not saved.
+ */
+ public static ScrollableGridRendererState getRendererState(FacesContext context) throws FacesException {
+ if(null == context){
+ throw new NullPointerException("Context for grid state is null");
+ }
+ ScrollableGridRendererState state = (ScrollableGridRendererState) context.getExternalContext().getRequestMap().get(DATA_GRID_RENDERER_STATE);
+// if( null == state){
+// throw new FacesException("State for current grid not stored in context");
+// }
+ return state;
+ }
+
+ /**
+ * Create new state for current grid. If state exist, store previsius in field of created.
+ * @param context
+ * @param grid
+ * @return new state for grid.
+ */
+ public static ScrollableGridRendererState createState(FacesContext context, UIScrollableGrid grid){
+ if(null == context){
+ throw new NullPointerException("Context for grid state is null");
+ }
+ ScrollableGridRendererState oldState = getRendererState(context);
+ ScrollableGridRendererState state = new ScrollableGridRendererState(context,oldState,grid);
+ context.getExternalContext().getRequestMap().put(DATA_GRID_RENDERER_STATE,state);
+ return state;
+ }
+
+ /**
+ * Restore previsius state for gred, or clear request parameter.
+ * @param context
+ */
+ public static void restoreState(FacesContext context) {
+ if (null == context) {
+ throw new NullPointerException("Context for grid state is null");
+ }
+ ScrollableGridRendererState state = getRendererState(context);
+ if (null == state) {
+ throw new FacesException(
+ "State for current grid not saved in context");
+ }
+ ScrollableGridRendererState previsiosState = state.getPreviousState();
+ if (null != previsiosState) {
+ context.getExternalContext().getRequestMap().put(DATA_GRID_RENDERER_STATE,
+ previsiosState);
+ } else {
+ context.getExternalContext().getRequestMap().remove(DATA_GRID_RENDERER_STATE);
+ }
+ }
+ /**
+ * Create state for current grig ( and store previsios state in field ).
+ * @param previsiosState
+ */
+ public ScrollableGridRendererState(FacesContext context, ScrollableGridRendererState previsiosState, UIScrollableGrid grid) {
+ super();
+ _grid = grid;
+ _cachedClientId = grid.getClientId(context);
+ _previousState = previsiosState;
+ if(AjaxRendererUtils.isAjaxRequest(context)){
+// _region = AjaxRendererUtils.getSubmittedAjaxContainer(context,null);
+// if(null != _region){
+// _renderedAreas = (Set) _region.getAjaxRenderedAreas();
+// }
+ }
+
+ Map attrs = grid.getAttributes();
+// activeClass = (String) attrs.get("activeClass");
+// selectedClass = (String) attrs.get("selectedClass");
+// if (selectedClass == null) {
+// selectedClass = DataGridBaseRenderer.DEAFAULT_SELECTED_CLASS;
+// }
+//
+// rowClasses = DataGridUtil.getAttributeArray((String) attrs.get("rowClasses"));
+// columnClasses = DataGridUtil.getAttributeArray((String) attrs.get("columnClasses"));
+// headerColumnClasses = DataGridUtil.getAttributeArray((String) attrs.get("headerColumnClasses"));
+//
+// if (headerColumnClasses.length == 0) {
+// headerColumnClasses = DataGridBaseRenderer.DEAFAULT_HEADER_COLUMN_CLASSES;
+// }
+//
+// resizerClass = (String) attrs.get("resizerClass");
+//
+// prefix = DataGridUtil.getClassPrefix(context, grid);
+ }
+
+
+ /**
+ * Append id of AJAX rendered area to current set ( if possible )
+ * @param id
+ */
+// public void addAjaxArea(String id){
+// if(null != _renderedAreas){
+// _renderedAreas.add(id);
+// }
+// }
+
+ /**
+ * Remove id of AJAX rendered area from current set ( if possible )
+ * @param id
+ */
+// public void removeAjaxArea(String id){
+// if(null != _renderedAreas){
+// _renderedAreas.remove(id);
+// }
+// }
+
+ public String getCurrentCellId(FacesContext context){
+ return getGrid().getClientId(context)+NamingContainer.SEPARATOR_CHAR+"row"+getRowIndex()+
+ NamingContainer.SEPARATOR_CHAR+"col"+getCellIndex();
+ }
+
+ /**
+ * @return Returns the cellIndex.
+ */
+ public int getCellIndex() {
+ return _cellIndex;
+ }
+
+ /**
+ * @param cellIndex The cellIndex to set.
+ */
+ public void setCellIndex(int cellIndex) {
+ _cellIndex = cellIndex;
+ }
+
+ /**
+ * Increment cells counter
+ * @return next cell number.
+ */
+
+ public int nextCell(){
+ return ++_cellIndex;
+ }
+
+
+ /**
+ * @return Returns the columns.
+ */
+ public int getColumns() {
+ return _columns;
+ }
+
+ /**
+ * @param columns The columns to set.
+ */
+ public void setColumns(int columns) {
+ _columns = columns;
+ }
+
+ /**
+ * @return Returns the grid.
+ */
+ public UIScrollableGrid getGrid() {
+ return _grid;
+ }
+
+ /**
+ * @param grid The grid to set.
+ */
+ public void setGrid(UIScrollableGrid grid) {
+ _grid = grid;
+ }
+
+ /**
+ * @return Returns the previsiosState.
+ */
+ public ScrollableGridRendererState getPreviousState() {
+ return _previousState;
+ }
+
+ /**
+ * @param previsiosState The previsiosState to set.
+ */
+ public void setPreviousState(ScrollableGridRendererState previsiosState) {
+ _previousState = previsiosState;
+ }
+
+ /**
+ * @return Returns the rowIndex.
+ */
+ public int getRowIndex() {
+ return _rowIndex;
+ }
+
+ /**
+ * Increment current row counter.
+ * @return new row number.
+ */
+ public int nextRow(){
+ return ++_rowIndex;
+ }
+
+ /**
+ * @param rowIndex The rowIndex to set.
+ */
+ public void setRowIndex(int rowIndex) {
+ _rowIndex = rowIndex;
+ }
+
+
+ public String getColumnClientId(FacesContext context) {
+ return getGrid().getClientId(context) + NamingContainer.SEPARATOR_CHAR + "_col" + getCellIndex();
+ }
+
+ /**
+ * @return the _cachedClientId
+ */
+ public String getCachedClientId() {
+ return _cachedClientId;
+ }
+
+
+ private StringBuffer buffer = new StringBuffer();
+
+ /**
+ * @return the buffer
+ */
+ public StringBuffer getBuffer() {
+ buffer.setLength(0);
+ return buffer;
+ }
+
+ public String getColumnWidthInputId() {
+ return
+ getBuffer()
+ .append(prefix)
+ .append("col_")
+ .append(getCellIndex())
+ .append("_width")
+ .toString();
+ }
+
+ public String getColumnHeaderCellId() {
+ return
+ getBuffer()
+ .append(getCachedClientId())
+ .append(NamingContainer.SEPARATOR_CHAR)
+ .append("header")
+ .append(NamingContainer.SEPARATOR_CHAR)
+ .append(getCellIndex())
+ .toString();
+ }
+ public String getBodyCellId() {
+ return
+ getBuffer()
+ .append(getCachedClientId())
+ .append(NamingContainer.SEPARATOR_CHAR)
+ .append("body")
+ .append(NamingContainer.SEPARATOR_CHAR)
+ .append(getRowKey())
+ .append(NamingContainer.SEPARATOR_CHAR)
+ .append(getCellIndex())
+ .toString();
+ }
+
+ public String getColumnClass() {
+ return "col_" + getCellIndex();
+ }
+
+ /**
+ * @return the _rowSelected
+ */
+ public boolean isRowSelected() {
+ return _rowSelected;
+ }
+
+ /**
+ * @param selected the _rowSelected to set
+ */
+ public void setRowSelected(boolean selected) {
+ _rowSelected = selected;
+ }
+
+ /**
+ * @return the rowKey
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /**
+ * @param rowKey the rowKey to set
+ */
+ public void setRowKey(Object rowKey) {
+ this.rowKey = rowKey;
+ }
+
+ public String getRowClass() {
+// return getBuffer()
+// .append(DataGridUtil.getAttributeValue(rowClasses, getRowIndex()))
+// .append(" ")
+// .append(isRowSelected() ? selectedClass : "")
+// .toString();
+ return null;
+ }
+
+ public String getCellClass() {
+ return null;
+// getBuffer()
+// .append(DataGridUtil.getAttributeValue(columnClasses, _cellIndex))
+// .toString();
+
+ }
+
+ public String getHeaderCellClass() {
+ return null;
+// getBuffer()
+// .append(DataGridUtil.getAttributeValue(headerColumnClasses, _cellIndex))
+// .toString();
+
+ }
+
+ /**
+ * @return the resizerClass
+ */
+ public String getResizerClass() {
+ return resizerClass;
+ }
+
+ /**
+ * @param resizerClass the resizerClass to set
+ */
+ public void setResizerClass(String resizerClass) {
+ this.resizerClass = resizerClass;
+ }
+}
17 years, 7 months
JBoss Rich Faces SVN: r676 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-07 14:34:04 -0400 (Mon, 07 May 2007)
New Revision: 676
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-05-07 15:33:02 UTC (rev 675)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-05-07 18:34:04 UTC (rev 676)
@@ -3,13 +3,49 @@
*/
package org.richfaces.component;
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+
import org.ajax4jsf.ajax.repeat.UIRepeat;
+import org.apache.commons.collections.iterators.IteratorChain;
/**
* @author Anton Belevich
*
*/
+
public class UIScrollableGrid extends UIRepeat{
-
+
+
+ protected Iterator dataChildren() {
+
+ IteratorChain chain = new IteratorChain();
+ chain.addIterator(getFacets().values().iterator());
+ for (Iterator i = getChildren().iterator(); i.hasNext(); ) {
+ UIComponent kid = (UIComponent)i.next();
+ if (kid instanceof UIScrollableGridColumn) {
+ UIScrollableGridColumn column = (UIScrollableGridColumn) kid;
+ chain.addIterator(column.getChildIterator());
+ }
+ }
+
+ return chain;
+ }
+
+ protected Iterator fixedChildren() {
+
+ IteratorChain chain = new IteratorChain(getFacets().values().iterator());
+ for (Iterator i = getChildren().iterator(); i.hasNext(); ) {
+ UIComponent kid = (UIComponent)i.next();
+ if (kid instanceof UIScrollableGridColumn) {
+ UIScrollableGridColumn column = (UIScrollableGridColumn) kid;
+ chain.addIterator(column.getFacetIterator());
+ }
+ }
+
+ return chain;
+ }
+
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java 2007-05-07 15:33:02 UTC (rev 675)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGridColumn.java 2007-05-07 18:34:04 UTC (rev 676)
@@ -3,6 +3,8 @@
*/
package org.richfaces.component;
+import java.util.Iterator;
+
/**
* @author Anton Belevich
*
@@ -24,5 +26,13 @@
// TODO Auto-generated method stub
}
-
+
+ public Iterator getChildIterator(){
+ return getChildren().iterator();
+ }
+
+ public Iterator getFacetIterator() {
+ return getFacets().values().iterator();
+ }
+
}
17 years, 7 months