Author: nbelaevski
Date: 2008-01-21 15:14:22 -0500 (Mon, 21 Jan 2008)
New Revision: 5514
Modified:
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1659
Modified:
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
---
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-01-21
20:14:22 UTC (rev 5514)
@@ -198,7 +198,7 @@
addItem : function(component, item) {
//var newItem = Object.clone(item);
- item.doNormal();
+ item.doNormal(Richfaces.getExternalClass(item.rowIndex), component.columnsClasses);
component.shuttleTbody.insertBefore(item._node, null);
component.shuttleItems.push(item);
Modified:
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
---
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2008-01-21
20:14:22 UTC (rev 5514)
@@ -191,8 +191,8 @@
var sourceLayoutManager = new
LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
var targetLayoutManager = new
LayoutManager('#{clientId}tlInternal_header_tab',
'#{clientId}tlInternal_tab');
- var listShuttle = new Richfaces.ListShuttle(new
Richfaces.ListShuttle.Target('#{clientId}', '#{clientId}tlInternal_tab',
'#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper',
cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context,
component, "onorderchanged")}, Richfaces.ListShuttle.Target.SelectItem),
- new Richfaces.ListShuttle.Source('#{clientId}',
'#{clientId}internal_tab', '#{clientId}internal_header_tab',
'#{clientId}focusKeeper', undefined, Richfaces.ListShuttle.Source.SelectItem),
+ var listShuttle = new Richfaces.ListShuttle(new
Richfaces.ListShuttle.Target('#{clientId}', '#{clientId}tlInternal_tab',
'#{clientId}tlInternal_header_tab', '#{clientId}tlFocusKeeper',
cotrolsIdPrefix, '#{clientId}sortLabel', #{this:getAsEventHandler(context,
component, "onorderchanged")}, Richfaces.ListShuttle.Target.SelectItem,
#{this:getColumnClassesAsJSArray(context, component)},
#{this:getRowClassesAsJSArray(context, component)}),
+ new Richfaces.ListShuttle.Source('#{clientId}',
'#{clientId}internal_tab', '#{clientId}internal_header_tab',
'#{clientId}focusKeeper', undefined, Richfaces.ListShuttle.Source.SelectItem,
#{this:getColumnClassesAsJSArray(context, component)},
#{this:getRowClassesAsJSArray(context, component)}),
"#{clientId}", listShuttleCotrolsIdPrefix,
"#{switchByClick}", sourceLayoutManager, targetLayoutManager,
#{this:getAsEventHandler(context, component, "onlistchanged")});
var sourceLayoutManager = new
LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
var targetLayoutManager = new
LayoutManager('#{clientId}tlInternal_header_tab',
'#{clientId}tlInternal_tab');
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-01-21
20:14:22 UTC (rev 5514)
@@ -4,7 +4,9 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
@@ -16,6 +18,7 @@
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
+import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptString;
@@ -529,4 +532,21 @@
return ScriptUtils.toScript(result);
}
+
+ public String getColumnClassesAsJSArray(FacesContext context, UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component,
"columnClasses"));
+ }
+
+ public String getRowClassesAsJSArray(FacesContext context, UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component,
"rowClasses"));
+ }
+
+ protected List getClassesAsList(FacesContext context, UIComponent component, String
attr) {
+
+ String value = (String) ((UIDataAdaptor) component).getAttributes().get(attr);
+ if (value != null && (value.length() != 0)) {
+ return Arrays.asList(value.split(","));
+ }
+ return null;
+ }
}
Modified:
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2008-01-21
20:14:22 UTC (rev 5514)
@@ -1,9 +1,12 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -14,6 +17,7 @@
import javax.faces.convert.Converter;
import org.ajax4jsf.component.UIDataAdaptor;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/ListBase.js 2008-01-21
20:14:22 UTC (rev 5514)
@@ -32,7 +32,7 @@
Richfaces.ListBase.prototype = {
initialize : function(containerId, contentTableId, headerTableId, focusKeeperId,
- onclickControlId, controlClass) {
+ onclickControlId, controlClass, columnsClasses, rowClasses) {
this["rich:destructor"] = "destroy";
this.selectedItems = new Array();
@@ -52,6 +52,10 @@
this.activeItem = null;
this.pseudoActiveItem = null; //it services for items selection by Shift+click
this.items = null;
+
+ //FIX
+ this.rowClasses = rowClasses;
+ this.columnsClasses = columnsClasses;
this.retrieveShuttleItems(containerId, controlClass);
@@ -144,7 +148,7 @@
}
if (this.activeItem) {
- this.activeItem.item.doActive();
+ this.activeItem.item.doActive(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
}
},
@@ -187,7 +191,7 @@
this.selectAll();
Event.stop(event);
}
- this.activeItem.item.doActive();
+ this.activeItem.item.doActive(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
//this.saveState();
break;
}
@@ -209,10 +213,11 @@
},
changeActiveItems : function(newItem, item) {
+ item.item.doNormal();
this.resetMarked();
- newItem.item.doSelect();
- newItem.item.doActive();
+ newItem.item.doSelect(this.getExtRowClass(newItem.rowIndex), this.columnsClasses);
+ newItem.item.doActive(this.getExtRowClass(newItem.rowIndex), this.columnsClasses);
this.setActiveItem(newItem);
this.selectedItems.push(newItem);
},
@@ -240,9 +245,9 @@
this.selectedItems[0] = markedShuttleItem;
}*/
if (activeItem.item.isSelected()) {
- activeItem.item.doNormal();
+ activeItem.item.doNormal(this.getExtRowClass(activeItem.rowIndex),
this.columnsClasses);
} else {
- activeItem.item.doSelect();
+ activeItem.item.doSelect(this.getExtRowClass(activeItem.rowIndex),
this.columnsClasses);
this.selectedItems[0] = markedShuttleItem; //TODO: delete
}
//}
@@ -256,18 +261,18 @@
if (activeItem.item.isSelected()) {
this.selectedItems.remove(markedShuttleItem);
- activeItem.item.doNormal();
+ activeItem.item.doNormal(this.getExtRowClass(activeItem.rowIndex),
this.columnsClasses);
} else {
- activeItem.item.doSelect();
+ activeItem.item.doSelect(this.getExtRowClass(activeItem.rowIndex),
this.columnsClasses);
this.selectedItems.push(markedShuttleItem);
}
if ((this.activeItem != null) && (this.activeItem.rowIndex !=
activeItem.rowIndex)) {
//reset activity of an element
if (this.activeItem.item.isSelected()) {
- this.activeItem.item.doSelect();
+ this.activeItem.item.doSelect(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
} else {
- this.activeItem.item.doNormal();
+ this.activeItem.item.doNormal(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
}
}
},
@@ -297,7 +302,7 @@
selectItemRange : function(startIndex, endIndex) {
var rows = this.shuttleTbody.rows;
for (var i = startIndex; i <= endIndex; i++) {
- rows[i].item.doSelect();
+ rows[i].item.doSelect(this.getExtRowClass(rows[i].rowIndex), this.columnsClasses);
this.selectedItems.push(rows[i]);
}
//this.saveState();
@@ -308,7 +313,7 @@
var length = rows.length;
for (var i = 0; i < length; i++) {
var shuttleItem = rows[i];
- shuttleItem.item.doNormal();
+ shuttleItem.item.doNormal(this.getExtRowClass(shuttleItem.rowIndex),
this.columnsClasses);
}
this.selectedItems.length = 0;
@@ -364,9 +369,9 @@
if (this.activeItem) {
if (this.activeItem.item.isSelected()) {
- this.activeItem.item.doSelect();
+ this.activeItem.item.doSelect(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
} else {
- this.activeItem.item.doNormal();
+ this.activeItem.item.doNormal(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
}
}
},
@@ -388,16 +393,9 @@
return true;
}
return false;
- }//,
+ },
- /*saveState : function() {
- for (var i = 0; i < this.shuttleItems.length; i++) {
- var item = this.shuttleItems[i];
-
- item.saveState();
- }
- }*/
-
-}
-
-
+ getExtRowClass : function(index) {
+ return Richfaces.getExternalClass(this.rowClasses, index);
+ }
+}
\ No newline at end of file
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2008-01-21
20:14:22 UTC (rev 5514)
@@ -20,8 +20,8 @@
Richfaces.OrderingList = Class.create(Richfaces.ListBase, {
- initialize: function($super, containerId, contentTableId, headerTableId, focusKeeperId,
ids, onclickControlId, onorderchanged, controlClass) {
- $super(containerId, contentTableId, headerTableId, focusKeeperId, onclickControlId,
controlClass);
+ initialize: function($super, containerId, contentTableId, headerTableId, focusKeeperId,
ids, onclickControlId, onorderchanged, controlClass, columnsClasses, rowClasses) {
+ $super(containerId, contentTableId, headerTableId, focusKeeperId, onclickControlId,
controlClass, columnsClasses, rowClasses);
this.container.component = this;
@@ -167,7 +167,7 @@
this.selectAll();
Event.stop(event);
}
- this.activeItem.item.doActive();
+ this.activeItem.item.doActive(this.getExtRowClass(this.activeItem.rowIndex),
this.columnsClasses);
//this.saveState();
this.controlListManager();
break;
Modified:
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectItem.js 2008-01-21
20:14:22 UTC (rev 5514)
@@ -1,5 +1,16 @@
if (!window.Richfaces) { window.Richfaces = {}; }
+Richfaces.getExternalClass = function(classes, index) {
+ if (classes) {
+ var len = classes.length;
+ while (index >= len) {
+ index -= len;
+ }
+ return (classes[index]) ? classes[index] : "";
+ }
+ return "";
+}
+
Richfaces.SelectItem = Class.create();
Richfaces.SelectItem.prototype = {
@@ -21,41 +32,38 @@
this._node.item = null;
},
- doActive : function() {
+ doActive : function(rowStoredClass, cellStoredClasses) {
var classes = this.CLASSES;
var row = this._node;
+ var rowClass = classes.ROW.ACTIVE;
+ var cellClass = classes.CELL.ACTIVE;
+ if (this.isSelected()) {
+ rowClass = classes.ROW.SELECTED + " " + classes.ROW.ACTIVE;
+ cellClass = classes.CELL.SELECTED + " " + classes.CELL.ACTIVE;
+ }
+ this.changeClass(row, rowClass, cellClass, rowStoredClass, cellStoredClasses);
- this.addClass(row, classes.ROW.ACTIVE, classes.CELL.ACTIVE);
-
this.active = true;
this.saveState();
},
- doSelect : function() {
+ doSelect : function(rowStoredClass, cellStoredClasses) {
var row = this._node;
var classes = this.CLASSES;
- this.addClass(row, classes.ROW.SELECTED, classes.CELL.SELECTED);
- if (this.active) {
- this.removeClass(row, classes.ROW.ACTIVE, classes.CELL.ACTIVE);
- }
+ this.changeClass(row, classes.ROW.SELECTED, classes.CELL.SELECTED, rowStoredClass,
cellStoredClasses);
this.selected = true;
this.saveState();
},
- doNormal : function() {
+ doNormal : function(rowStoredClass, cellStoredClasses) {
var row = this._node;
var classes = this.CLASSES;
- if (this.active) {
- this.removeClass(row, classes.ROW.ACTIVE, classes.CELL.ACTIVE);
- }
- if (this.selected) {
- this.removeClass(row, classes.ROW.SELECTED, classes.CELL.SELECTED);
- }
+ this.changeClass(row, classes.ROW.NORMAL, classes.CELL.NORMAL, rowStoredClass,
cellStoredClasses);
this.active = false;
this.selected = false;
@@ -71,7 +79,16 @@
return this.active;
},
- addClass : function(row, classNameRow, classNameCell) {
+ changeClass : function(row, rowClassName, cellClassName, rowStoredClass,
cellStoredClasses) {
+ row.className = rowStoredClass + " " + rowClassName;
+ var cells = row.cells;
+ for (var i = 0; i < cells.length; i++) {
+ var cell = cells[i];
+ cell.className = Richfaces.getExternalClass(cellStoredClasses, cell.cellIndex) +
" " + cellClassName;
+ }
+ },
+
+ /*addClass : function(row, classNameRow, classNameCell) {
if (row.addClassName) {
row.addClassName(classNameRow);
} else {
@@ -81,7 +98,6 @@
var cells = row.cells;
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
-
if (cell.addClassName) {
cell.addClassName(classNameCell);
} else {
@@ -96,7 +112,6 @@
} else {
Element.removeClassName(row, classNameRow);
}
-
var cells = row.cells;
for (var i = 0; i < cells.length; i++) {
var cell = cells[i];
@@ -107,7 +122,7 @@
Element.removeClassName(cell, classNameCell);
}
}
- },
+ },*/
saveState: function() {
var regex = /^s?a?/;
Modified:
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
---
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2008-01-21
19:49:12 UTC (rev 5513)
+++
branches/3.1.x/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2008-01-21
20:14:22 UTC (rev 5514)
@@ -89,7 +89,13 @@
var clientId = '#{cId}';
Event.onReady(function() {
var cotrolsIdPrefix = [['up', 'disup'], ['down',
'disdown'], ['last', 'dislast'],
['first','disfirst']];
- var shuttle = new Richfaces.OrderingList('#{cId}',
'#{cId}internal_tab', '#{cId}internal_header_tab',
'#{cId}focusKeeper', cotrolsIdPrefix, '#{cId}sortLabel',
#{this:getAsEventHandler(context, component, "onorderchanged")},
Richfaces.OrderingListSelectItem);
+ var shuttle = new Richfaces.OrderingList('#{cId}',
'#{cId}internal_tab',
+ '#{cId}internal_header_tab', '#{cId}focusKeeper',
+ cotrolsIdPrefix, '#{cId}sortLabel',
+ #{this:getAsEventHandler(context, component, "onorderchanged")},
+ Richfaces.OrderingListSelectItem,
+ #{this:getColumnClassesAsJSArray(context, component)},
+ #{this:getRowClassesAsJSArray(context, component)});
var layoutManager = new LayoutManager('#{clientId}internal_header_tab',
'#{clientId}internal_tab');
layoutManager.widthSynchronization();
});