JBoss Rich Faces SVN: r1157 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2007-06-13 11:19:25 -0400 (Wed, 13 Jun 2007)
New Revision: 1157
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/LayoutManager.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/VLayoutManager.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/LayoutManager.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/LayoutManager.js 2007-06-13 15:17:34 UTC (rev 1156)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/LayoutManager.js 2007-06-13 15:19:25 UTC (rev 1157)
@@ -15,7 +15,17 @@
CLASSDEF: {
name: 'ClientUI.layouts.LayoutManager',
parent: ClientUI.common.box.Box
- }
+ },
+
+ // Custom events
+ /**
+ * Occured before resizing
+ */
+ eventOnBeforeResize: {},
+ /**
+ * Occured after resizing
+ */
+ eventOnAfterResize: {}
});
@@ -31,6 +41,10 @@
// declare event listeners
this.eventContainerResize = this.containerResize.bindAsEventListener(this);
+ // Create custom event producers
+ this.eventOnBeforeResize = new ClientUI.common.utils.CustomEvent('OnBeforeResize');
+ this.eventOnAfterResize = new ClientUI.common.utils.CustomEvent('OnAfterResize');
+
this.registerEvents();
},
registerEvents: function() {
@@ -43,13 +57,20 @@
},
containerResize: function(event) {
//Event.stop(event);
- // TODO:
+ this.eventOnBeforeResize.fire();
this.updateLayout();
+ this.eventOnAfterResize.fire();
},
updateLayout: function() {
if(this.container) {
- this.setWidth(this.container.getWidth());
- this.setHeight(this.container.getHeight());
+ var w = this.container.getWidth();
+ var h = this.container.getWidth();
+ if(ClientUILib.isGecko) {
+ w -= this.container.getBorderWidth("lr") + this.container.getPadding("lr");
+ h -= this.container.getBorderWidth("tb") + this.container.getPadding("tb");
+ }
+ this.setWidth(w);
+ this.setHeight(h);
}
ClientUI.layouts.LayoutManager.parentClass.method("updateLayout").call(this);
},
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/VLayoutManager.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/VLayoutManager.js 2007-06-13 15:17:34 UTC (rev 1156)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/layouts/VLayoutManager.js 2007-06-13 15:19:25 UTC (rev 1157)
@@ -63,6 +63,10 @@
var parentBox = this.getContainer();
var height = parentBox.getViewportHeight();
var width = parentBox.getViewportWidth();
+ if(ClientUILib.isGecko) {
+ width -= parentBox.getBorderWidth("lr") + parentBox.getPadding("lr");
+ height -= parentBox.getBorderWidth("tb") + parentBox.getPadding("tb");
+ }
// NOTE: not implemented in this class
if(this.panels) {
17 years, 7 months
JBoss Rich Faces SVN: r1156 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 11:17:34 -0400 (Wed, 13 Jun 2007)
New Revision: 1156
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java 2007-06-13 15:17:14 UTC (rev 1155)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SortOrder.java 2007-06-13 15:17:34 UTC (rev 1156)
@@ -14,18 +14,12 @@
private boolean ascending;
private int sortColumn = -1;
-
- private int startRow = -1;
-
- private int dataIndex = -1;
-
- public SortOrder( int sortColumn, int startRow, int dataIndex, boolean ascending) {
+
+ public SortOrder( int sortColumn, boolean ascending) {
super();
this.sortColumn = sortColumn;
this.ascending = ascending;
- this.startRow = startRow;
- this.dataIndex = dataIndex;
}
public SortOrder() {
@@ -64,8 +58,6 @@
if (obj instanceof SortOrder) {
SortOrder sortOrder = (SortOrder) obj;
return sortColumn == sortOrder.sortColumn
- && startRow == sortOrder.startRow
- && dataIndex == sortOrder.dataIndex
&& ascending == sortOrder.ascending;
}
17 years, 7 months
JBoss Rich Faces SVN: r1155 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 11:17:14 -0400 (Wed, 13 Jun 2007)
New Revision: 1155
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-06-13 15:17:05 UTC (rev 1154)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-06-13 15:17:14 UTC (rev 1155)
@@ -187,7 +187,7 @@
<script id="#{clientId}_grid_create_scripts" type="text/javascript">
//<![CDATA[
- var #{this:getJavaScriptVarName(context, component)} = #{this:createClientScrollableGrid(context, component)};
+ #{this:getJavaScriptVarName(context, component)} = #{this:createClientScrollableGrid(context, component)};
#{this:getScriptContributions(context, component)};
Event.observe(window, 'load', #{this:getJavaScriptVarName(context, component)}.init2 );
17 years, 7 months
JBoss Rich Faces SVN: r1154 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 11:17:05 -0400 (Wed, 13 Jun 2007)
New Revision: 1154
Modified:
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/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-13 15:16:52 UTC (rev 1153)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-13 15:17:05 UTC (rev 1154)
@@ -25,6 +25,7 @@
import org.apache.commons.logging.LogFactory;
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.event.scroll.ScrollEvent;
import org.richfaces.event.sort.SortEvent;
import org.richfaces.renderkit.CompositeRenderer;
import org.richfaces.renderkit.RendererContributor;
@@ -525,42 +526,35 @@
if(parameters.containsKey(clientId + "_state_input") && !sorted){
String submitedState = (String)parameters.get(clientId + "_state_input");
- decodeScrolling(submitedState, grid);
- grid.queueEvent(new AjaxEvent(grid));
+
+ boolean isEmpty = true;
+
+
+ String [] values = submitedState.split(",");
+ for (int i = 0; i < values.length; i++) {
+ isEmpty = isEmpty && values[i].equals("");
+ }
+
+ int rows = 0;
+ int first = 0;
+
+ if(!isEmpty){
+ grid.getAttributes().put(GridUtils.CLIENT_ROW_KEY,Integer.valueOf(values[2]));
+ rows = Integer.parseInt(values[0]);
+ first = Integer.parseInt(values[1]);
+
+ }else{
+ grid.getAttributes().put(GridUtils.CLIENT_ROW_KEY, new Integer(0));
+ }
+
+ ScrollEvent scrollEvent = new ScrollEvent(grid,rows,first);
+ grid.queueEvent(scrollEvent);
}
}
}
- private void decodeScrolling(String submitedState, UIScrollableGrid grid){
-
- boolean isEmpty = true;
-
-
- String [] values = submitedState.split(",");
- for (int i = 0; i < values.length; i++) {
- isEmpty = isEmpty && values[i].equals("");
- }
-
- if(!isEmpty){
-
- grid.setRows(Integer.parseInt(values[0]));
- grid.setFirst(Integer.parseInt(values[1]));
- grid.getAttributes().put(GridUtils.CLIENT_ROW_KEY,Integer.valueOf(values[2]));
-
- }else{
- grid.getAttributes().put(GridUtils.CLIENT_ROW_KEY, new Integer(0));
- }
- if (log.isDebugEnabled()) {
- log.debug("");
- log.debug("row count: " + grid.getRows());
- log.debug("data index: " + grid.getFirst()) ;
- log.debug("start row: " + grid.getAttributes().get(GridUtils.CLIENT_ROW_KEY));
- }
- }
-
-
public void renderAjaxChildren(FacesContext context, UIComponent component)throws IOException{
UIScrollableGrid grid = (UIScrollableGrid)component;
17 years, 7 months
JBoss Rich Faces SVN: r1153 - in trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event: scroll and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 11:16:52 -0400 (Wed, 13 Jun 2007)
New Revision: 1153
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/scroll/
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
Log:
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/event/scroll/ScrollEvent.java 2007-06-13 15:16:52 UTC (rev 1153)
@@ -0,0 +1,51 @@
+/**
+ *
+ */
+package org.richfaces.event.scroll;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class ScrollEvent extends FacesEvent {
+
+ private static final long serialVersionUID = 3786221668771853810L;
+
+ private int rows;
+
+ private int first;
+
+ public ScrollEvent(UIComponent component, int rows, int first){
+ super(component);
+ this.rows = rows;
+ this.first = first;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ }
+
+ public int getFirst() {
+ return first;
+ }
+
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public int getRows() {
+ return rows;
+ }
+
+ public void setRows(int rows) {
+ this.rows = rows;
+ }
+
+}
17 years, 7 months
JBoss Rich Faces SVN: r1152 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-13 11:16:39 -0400 (Wed, 13 Jun 2007)
New Revision: 1152
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.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-06-13 14:54:31 UTC (rev 1151)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-13 15:16:39 UTC (rev 1152)
@@ -25,6 +25,7 @@
import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.apache.commons.collections.iterators.IteratorChain;
+import org.richfaces.event.scroll.ScrollEvent;
import org.richfaces.event.sort.SortEvent;
import org.richfaces.model.BufferedSequenceRange;
import org.richfaces.model.DataModelCache;
@@ -173,12 +174,15 @@
AjaxContext.getCurrentInstance().addComponentToAjaxRender(this);
}else if(event instanceof SortEvent){
processSortingChange(event);
- new AjaxEvent(this).queue();
+ // new AjaxEvent(this).queue();
+ }else if(event instanceof ScrollEvent){
+ // new AjaxEvent(this).queue();
+ processScrolling(event);
}
}
protected boolean broadcastLocal(FacesEvent event) {
- return super.broadcastLocal(event) || event instanceof SortEvent;
+ return super.broadcastLocal(event) || event instanceof SortEvent || event instanceof ScrollEvent;
}
public void queueEvent(FacesEvent event) {
@@ -186,34 +190,41 @@
if(event instanceof AjaxEvent){
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
}else if(event instanceof SortEvent){
+ new AjaxEvent(this).queue();
+
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ }else if(event instanceof ScrollEvent){
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ new AjaxEvent(this).queue();
}
-
super.queueEvent(event);
}
+ public void processScrolling(FacesEvent event){
+ ScrollEvent e = (ScrollEvent)event;
+ setRows(e.getRows());
+ setFirst(e.getFirst());
+ getFacesContext().renderResponse();
+ }
+
public void processSortingChange(FacesEvent event){
SortEvent e = (SortEvent)event;
int sortColumn = e.getSortColumn();
- int dataIndex = e.getDataIndex();
- int startRow = e.getStartRow();
boolean asc = true;
SortOrder sortOrder = getSortOrder();
if (sortOrder != null) {
-
if (sortOrder.getSortColumn() == sortColumn) {
asc = !sortOrder.isAscending();
}
-
}
-
- SortOrder newSortOrder = new SortOrder(sortColumn, startRow, dataIndex, asc);
+ SortOrder newSortOrder = new SortOrder(sortColumn,asc);
setSortOrder(newSortOrder);
resetDataModel();
+ getFacesContext().renderResponse();
}
public void walk(FacesContext context, DataVisitor visitor, Object argument) throws IOException {
17 years, 7 months
JBoss Rich Faces SVN: r1151 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2007-06-13 10:54:31 -0400 (Wed, 13 Jun 2007)
New Revision: 1151
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/CustomEvent.js
Log:
Fix multiple script including collisions
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/CustomEvent.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/CustomEvent.js 2007-06-13 10:38:45 UTC (rev 1150)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/CustomEvent.js 2007-06-13 14:54:31 UTC (rev 1151)
@@ -3,10 +3,11 @@
* Copyright (c) 2007 Exadel Inc.
* @author Denis Morozov <dmorozov(a)exadel.com>
*/
+ClientUILib.declarePackage("ClientUI.common.utils");
+
+if(!ClientUI.common.utils.CustomEvent) {
ClientUILib.declarePackage("ClientUI.common.utils.CustomEvent");
-if(!ClientUI.common.utils.CustomEvent.CLASSDEF) {
-
ClientUI.common.utils.CustomEvent = Class.create({
CLASSDEF: {
name: 'ClientUI.common.utils.CustomEvent'
17 years, 7 months
JBoss Rich Faces SVN: r1150 - trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-06-13 06:38:45 -0400 (Wed, 13 Jun 2007)
New Revision: 1150
Modified:
trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
http://jira.jboss.com/jira/browse/RF-61
Modified: trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
--- trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-06-13 09:11:12 UTC (rev 1149)
+++ trunk/richfaces/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2007-06-13 10:38:45 UTC (rev 1150)
@@ -201,8 +201,8 @@
this.initialized = true;
}
if (this.active) {
- this.wasScroll = false;
- this.wasBlur = false;
+ this.wasScroll = false;
+ this.wasBlur = false;
switch (event.keyCode) {
case Event.KEY_TAB:
case Event.KEY_RETURN:
@@ -212,6 +212,9 @@
this.hide();
this.active = false;
Event.stop(event);
+ if (this.isOpera) {
+ this.element.focus();
+ }
return;
case Event.KEY_LEFT:
case Event.KEY_RIGHT:
@@ -361,14 +364,14 @@
LOG.debug("Scroll = " + scroll.scrollTop
+ " , reallOffset= " + realOffset
+ " scrollHeight= " + scroll.offsetHeight);
-
- var entryOffsetHeight;
+
+ var entryOffsetHeight;
if ("SAFARI" == RichFaces.navigatorType()) {
var tdElement = document.getElementsByClassName("dr-sb-cell-padding", item)[0];
entryOffsetHeight = tdElement.offsetTop + tdElement.offsetHeight;
} else
entryOffsetHeight = entry.offsetHeight;
-
+
if (realOffset > scroll.scrollTop + scroll.clientHeight - entryOffsetHeight) {
scroll.scrollTop = realOffset - scroll.clientHeight + entryOffsetHeight;
} else if (realOffset < scroll.scrollTop) {
@@ -572,7 +575,7 @@
if (this.onsubmitFunction && ! this.onsubmitFunction()) {
return;
}
-
+
A4J.AJAX.Submit(this.containerId, this.actionUrl, event, this.options);
},
17 years, 7 months
JBoss Rich Faces SVN: r1149 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-06-13 05:11:12 -0400 (Wed, 13 Jun 2007)
New Revision: 1149
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
Log:
switched back to Denis' code
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-12 18:23:59 UTC (rev 1148)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-13 09:11:12 UTC (rev 1149)
@@ -51,36 +51,32 @@
this._clearAttributes(row);
this.copyAttributes(row, src);
- for (var td = src.firstChild; td; td = td.nextSibling) {
-
- var outer = td.xml;
- var openTag = outer.indexOf('>');
- var closeTag = outer.lastIndexOf('<');
-
- var inner = outer.substring(openTag + 1, closeTag);
-
- var cell = createEl(td.tagName.toUpperCase());
-
- cell.innerHTML = inner;
-
-
-
- this.copyAttributes(cell, td);
- row.insertBefore(cell, null);
- }
+ var tds = [];
+ var i = 0;
+ var pattern = '(?:<td.*?>)((\n|\r|.)*?)(?:<\/td>)';
+ var rez = src.xml.gsub(pattern, function(item) {
+ tds[i++] = item[1];
+ return ""; });
+
- src = row;
- target.parentNode.replaceChild(src, target);
+ var count = i, td;
+ for(i=0; i< count; i++) {
+ td = createEl("TD");
+ td.innerHTML = tds[i];
+ td.className = "ClientUI_Grid_BC";
+ row.insertBefore(td, null);
+ }
+ target.parentNode.replaceChild(row, target);
+
+ return row;
} else {
target.innerHTML = src.innerHTML;
this._clearAttributes(target);
this.copyAttributes(target, src);
- src = target;
+ return target;
}
-
- return src;
},
_clearAttributes : function(node) {
17 years, 7 months
JBoss Rich Faces SVN: r1148 - in trunk/sandbox/scrollable-grid/src: main/java/org/richfaces/renderkit/html and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-06-12 14:23:59 -0400 (Tue, 12 Jun 2007)
New Revision: 1148
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/renderkit/html/SelectionRendererContributorTest.java
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/model/selection/ClientSelectionTest.java
Log:
selection renderer contributor now supports reset and all instructions
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-06-12 18:08:46 UTC (rev 1147)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/ClientSelection.java 2007-06-12 18:23:59 UTC (rev 1148)
@@ -16,6 +16,10 @@
private static final long serialVersionUID = 5855157282287053681L;
+ public static final String FLAG_RESET = "x";
+
+ public static final String FLAG_ALL = "a";
+
private String selectionFlag;
private List ranges = new ArrayList();
@@ -94,7 +98,17 @@
}
+ private boolean reset = false;
+ public boolean isReset() {
+ return reset;
+ }
+
+ private boolean selectAll = false;
+ public boolean isSelectAll() {
+ return selectAll;
+ }
+
public String getSelectionFlag() {
return selectionFlag;
}
@@ -102,5 +116,14 @@
public void setSelectionFlag(String selectionFlag) {
this.selectionFlag = selectionFlag;
+
+ reset = false;
+ selectAll = false;
+
+ if (FLAG_ALL.equals(selectionFlag)) {
+ selectAll = true;
+ } else if (FLAG_RESET.equals(selectionFlag)) {
+ reset = true;
+ }
}
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-12 18:08:46 UTC (rev 1147)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2007-06-12 18:23:59 UTC (rev 1148)
@@ -37,4 +37,7 @@
return keys.contains(rowKey);
}
+ public void clear() {
+ keys.clear();
+ }
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-06-12 18:08:46 UTC (rev 1147)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/SelectionRendererContributor.java 2007-06-12 18:23:59 UTC (rev 1148)
@@ -75,8 +75,15 @@
state.setRowIndex(GridUtils.getClientRowIndex(grid));
- final SimpleSelection simpleSelection = grid.getSelection() == null ? new SimpleSelection() : (SimpleSelection) grid.getSelection();
+ final SimpleSelection simpleSelection = grid.getSelection() == null ? new SimpleSelection()
+ : (SimpleSelection) grid.getSelection();
+
+
+ if (clientSelection.isReset() || clientSelection.isSelectAll()) {
+ simpleSelection.clear();
+ }
+
try {
grid.walk(context,
new DataVisitor() {
@@ -169,13 +176,15 @@
//Decide whether to add new row to selection based on comparison with old one
- private boolean shouldAddToSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
- return newSelection.isSelected(i) && !oldSelection.isSelected(i);
+ public boolean shouldAddToSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
+
+ return newSelection.isSelectAll() ||
+ (newSelection.isSelected(i) && (!oldSelection.isSelected(i) || newSelection.isReset())) ;
}
//Decide whether to remove new row to selection based on comparison with old one
- private boolean shouldRemoveFromSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
- return !newSelection.isSelected(i) && oldSelection.isSelected(i);
+ public boolean shouldRemoveFromSelection(int i, ClientSelection oldSelection, ClientSelection newSelection) {
+ return !newSelection.isReset() && (!newSelection.isSelectAll() && (!newSelection.isSelected(i) && oldSelection.isSelected(i)));
}
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-12 18:08:46 UTC (rev 1147)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-12 18:23:59 UTC (rev 1148)
@@ -1,45 +1,8 @@
var Utils = {
DOM: {
-
- importNode: function(node, bKids) {
-
- var nodeName = node.nodeName.toUpperCase();
-
- //LOG.debug("Importing node " + Utils.DOM._formatNode(node));
-
- switch(nodeName) {
- case "TBODY":
- case "TR":
- case "TD":
- {
- //LOG.debug("Creating new node ");
- var imported = document.createElement(nodeName);
-
- this.copyAttributes(imported, node);
-
- if (bKids) {
-
- for(var kid = node.firstChild; kid;
- kid = kid.nextSibling) {
-
- var importedKid = this.importNode(kid, true);
-
- imported.insertBefore(importedKid, null);
- }
- }
- return imported;
- }
- default: {
- var imported = document.createElement(nodeName);
- imported.outerHTML = node.xml;
- return imported;
- }
- }
- },
-
copyAttributes : function(target, source, opts) {
- //LOG.debug("Copying attributes from " + Utils.DOM._formatNode(source) + " to " + Utils.DOM._formatNode(target) );
+ //LOG.debug("copyAttributes");
var attrs = source.attributes;
var exclusions = (opts && opts.exclude) ? opts.exclude : [];
@@ -50,7 +13,16 @@
var nodeName = attributeNode.nodeName;
var nodeValue = attributeNode.nodeValue;
- if(attributeNode.specified && nodeValue && nodeValue.length > 0 && exclusions.indexOf(nodeName) < 0) {
+ var shouldCheckAttribute =
+ nodeValue &&
+ nodeValue.length > 0 &&
+ exclusions.indexOf(nodeName) < 0;
+
+ if (ClientUILib.isIE) {
+ shouldCheckAttribute &= attributeNode.specified;
+ }
+
+ if(shouldCheckAttribute) {
//LOG.debug("Copying attribute " + attributeNode.nodeName + "=" + attributeNode.nodeValue);
@@ -62,7 +34,7 @@
}
}
-
+ //LOG.debug("/copyAttributes");
},
replaceNode : function(id, request) {
@@ -71,12 +43,12 @@
Utils.DOM.Event.removeListeners(target);
-
if (ClientUILib.isIE) {
var theDoc = document;
var createEl = theDoc.createElement;
var row = target.cloneNode(false);
+ this._clearAttributes(row);
this.copyAttributes(row, src);
for (var td = src.firstChild; td; td = td.nextSibling) {
@@ -102,22 +74,26 @@
} else {
target.innerHTML = src.innerHTML;
+ this._clearAttributes(target);
+ this.copyAttributes(target, src);
src = target;
- //src = document.importNode(src, true);
}
-
- //var importProvider = ClientUILib.isIE ? this : document;
-
- //src = importProvider.importNode(src, true);
-
-
-
-
return src;
},
+ _clearAttributes : function(node) {
+ var attrs = node.attributes;
+ if (node.clearAttributes) {
+ node.clearAttributes();
+ } else {
+ while(node.attributes.length > 0) {
+ node.removeAttributeNode(node.attributes[0]);
+ }
+ }
+ },
+
_formatNode : function(node) {
var sb = new StringBuilder();
Modified: trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/renderkit/html/SelectionRendererContributorTest.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/renderkit/html/SelectionRendererContributorTest.java 2007-06-12 18:08:46 UTC (rev 1147)
+++ trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/component/renderkit/html/SelectionRendererContributorTest.java 2007-06-12 18:23:59 UTC (rev 1148)
@@ -12,6 +12,7 @@
import org.apache.shale.test.mock.MockExternalContext;
import org.richfaces.component.UIScrollableGrid;
import org.richfaces.model.selection.ClientSelection;
+import org.richfaces.model.selection.SelectionRange;
import org.richfaces.renderkit.html.ScrollableGridBaseRenderer;
import org.richfaces.renderkit.html.SelectionRendererContributor;
@@ -71,5 +72,126 @@
Object selection = component.getSelection();
}
+
+ public void testShouldAddToSelection() {
+
+ ClientSelection oldSelection = new ClientSelection();
+ oldSelection.addRange(new SelectionRange(10, 15));
+ oldSelection.addRange(new SelectionRange(16, 20));
+
+ ClientSelection newSelection = new ClientSelection();
+ newSelection.addRange(new SelectionRange(20, 40));
+
+ newSelection.setSelectionFlag(ClientSelection.FLAG_ALL);
+
+ for(int i = 0; i < 100; i++) {
+ assertTrue(
+ "Contributor was supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+
+ newSelection.setSelectionFlag(null);
+
+ for (int i = 0; i < 21; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+ for (int i = 21; i < 41; i++) {
+ assertTrue(
+ "Contributor was supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+ for (int i = 41; i < 100; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+
+ newSelection.setSelectionFlag(ClientSelection.FLAG_RESET);
+
+
+ for (int i = 0; i < 20; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+ for (int i = 21; i < 41; i++) {
+ assertTrue(
+ "Contributor was supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+ for (int i = 41; i < 100; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to add " + i,
+ contributor.shouldAddToSelection(i, oldSelection, newSelection)
+ );
+ }
+
+
+
+ }
+
+
+ public void testShouldRemoveFromSelection() {
+ ClientSelection oldSelection = new ClientSelection();
+ oldSelection.addRange(new SelectionRange(10, 15));
+ oldSelection.addRange(new SelectionRange(16, 20));
+
+ ClientSelection newSelection = new ClientSelection();
+ newSelection.addRange(new SelectionRange(20, 40));
+
+ for (int i = 0; i < 10; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to remove " + i,
+ contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+ );
+ }
+ for (int i = 10; i < 20; i++) {
+ assertTrue(
+ "Contributor was supposed to remove " + i,
+ contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+ );
+ }
+
+ for (int i = 21; i < 100; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to remove " + i,
+ contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+ );
+ }
+
+
+ newSelection.setSelectionFlag(ClientSelection.FLAG_ALL);
+
+ for (int i = 0; i < 100; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to remove " + i,
+ contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+ );
+ }
+
+ newSelection.setSelectionFlag(ClientSelection.FLAG_RESET);
+
+ for (int i = 0; i < 100; i++) {
+ assertFalse(
+ "Contributor wasn't supposed to remove " + i,
+ contributor.shouldRemoveFromSelection(i, oldSelection, newSelection)
+ );
+ }
+ }
+
}
Modified: trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/model/selection/ClientSelectionTest.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/model/selection/ClientSelectionTest.java 2007-06-12 18:08:46 UTC (rev 1147)
+++ trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/model/selection/ClientSelectionTest.java 2007-06-12 18:23:59 UTC (rev 1148)
@@ -70,4 +70,24 @@
}
+ public void testSetSelectionFlag() {
+ clientSelection.setSelectionFlag(null);
+ assertFalse(clientSelection.isReset());
+ assertFalse(clientSelection.isSelectAll());
+
+ clientSelection.setSelectionFlag(ClientSelection.FLAG_ALL);
+ assertFalse(clientSelection.isReset());
+ assertTrue(clientSelection.isSelectAll());
+
+ clientSelection.setSelectionFlag(ClientSelection.FLAG_RESET);
+ assertTrue(clientSelection.isReset());
+ assertFalse(clientSelection.isSelectAll());
+
+ clientSelection.setSelectionFlag("zzzzzz");
+ assertFalse(clientSelection.isReset());
+ assertFalse(clientSelection.isSelectAll());
+
+ }
+
+
}
17 years, 7 months