Author: nbelaevski
Date: 2007-10-28 23:11:27 -0400 (Sun, 28 Oct 2007)
New Revision: 3583
Added:
trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Removed:
trunk/sandbox/ui/orderingList/src/main/config/component/selectordershuttle.xml
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UISelectOrderShuttle.java
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/selectOrderShuttle.xcss
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectOrderShuttle.js
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlSelectOrderShuttle.jspx
Modified:
trunk/sandbox/ui/orderingList/pom.xml
Log:
orderingList & listShuttle components updated:
- pom.xml
- sandbox added to group
- required dependencies added & excess removed
- listShuttle renamed to orderingList
- orderingListDemo: beans & demo page added
- orderinList: added rendering of table using AbstractRowsRenderer from dataTable
Modified: trunk/sandbox/ui/orderingList/pom.xml
===================================================================
--- trunk/sandbox/ui/orderingList/pom.xml 2007-10-29 03:11:15 UTC (rev 3582)
+++ trunk/sandbox/ui/orderingList/pom.xml 2007-10-29 03:11:27 UTC (rev 3583)
@@ -1,14 +1,14 @@
-<?xml version="1.0"?><project>
+<?xml version="1.0"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>ui</artifactId>
<groupId>org.richfaces.sandbox</groupId>
<version>3.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces</groupId>
+ <groupId>org.richfaces.sandbox.ui</groupId>
<artifactId>orderingList</artifactId>
<name>orderingList</name>
- <version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
@@ -33,18 +33,12 @@
</configuration>
</plugin>
</plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.richfaces.framework</groupId>
- <artifactId>richfaces-impl</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- </dependency>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>dataTable</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Copied: trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml (from rev
3579, trunk/sandbox/ui/orderingList/src/main/config/component/selectordershuttle.xml)
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml
(rev 0)
+++ trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml 2007-10-29
03:11:27 UTC (rev 3583)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
+<components>
+ <component>
+ <name>org.richfaces.OrderingList</name>
+ <family>org.richfaces.OrderingList</family>
+ <classname>org.richfaces.component.html.HtmlOrderingList</classname>
+ <superclass>org.richfaces.component.UIOrderingList</superclass>
+ <description>
+ </description>
+
+ <renderer generate="true" override="true">
+ <name>org.richfaces.OrderingListRenderer</name>
+ <template>org/richfaces/htmlOrderingList.jspx</template>
+ </renderer>
+
+ <tag>
+ <name>orderingList</name>
+ <classname>org.richfaces.taglib.OrderingListTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ <test/>
+ </tag>
+
+ <taghandler generate="true">
+
<classname>org.richfaces.taglib.OrderingListTagHandler</classname>
+
<superclass>com.sun.facelets.tag.jsf.ComponentHandler</superclass>
+ </taghandler>
+
+ &ui_component_attributes;
+
+ <property>
+ <name>onmousemove</name>
+ <classname>java.lang.String</classname>
+ <description>
+ HTML: script expression; a pointer was moved within.
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
+ </component>
+</components>
Deleted: trunk/sandbox/ui/orderingList/src/main/config/component/selectordershuttle.xml
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/config/component/selectordershuttle.xml 2007-10-29
03:11:15 UTC (rev 3582)
+++
trunk/sandbox/ui/orderingList/src/main/config/component/selectordershuttle.xml 2007-10-29
03:11:27 UTC (rev 3583)
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
-<components>
- <component>
- <name>org.richfaces.SelectOrderShuttle</name>
- <family>org.richfaces.SelectOrderShuttle</family>
-
<classname>org.richfaces.component.html.HtmlSelectOrderShuttle</classname>
-
<superclass>org.richfaces.component.UISelectOrderShuttle</superclass>
- <description>
- </description>
-
- <renderer generate="true" override="true">
- <name>org.richfaces.SelectOrderShuttleRenderer</name>
- <template>org/richfaces/htmlSelectOrderShuttle.jspx</template>
- </renderer>
-
- <tag>
- <name>selectOrderShuttle</name>
-
<classname>org.richfaces.taglib.SelectOrderShuttleTag</classname>
- <superclass>
- org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
- </superclass>
- <test/>
- </tag>
-
- <taghandler generate="true">
-
<classname>org.richfaces.taglib.SelectOrderShuttleTagHandler</classname>
-
<superclass>com.sun.facelets.tag.jsf.ComponentHandler</superclass>
- </taghandler>
-
- &ui_component_attributes;
-
- <property>
- <name>onmousemove</name>
- <classname>java.lang.String</classname>
- <description>
- HTML: script expression; a pointer was moved within.
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
-
- </component>
-</components>
Copied:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
(from rev 3579,
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UISelectOrderShuttle.java)
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2007-10-29
03:11:27 UTC (rev 3583)
@@ -0,0 +1,42 @@
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import org.ajax4jsf.component.UIDataAdaptor;
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.RepeatState;
+import org.ajax4jsf.model.SequenceDataModel;
+import org.apache.commons.collections.iterators.EmptyIterator;
+
+public abstract class UIOrderingList extends UIDataAdaptor {
+
+ @Override
+ protected DataComponentState createComponentState() {
+ return new RepeatState();
+ }
+
+ @Override
+ protected ExtendedDataModel createDataModel() {
+ return new SequenceDataModel(super.getDataModel());
+ }
+
+ @Override
+ protected Iterator dataChildren() {
+ if (getChildCount() != 0) {
+ return getChildren().iterator();
+ } else {
+ return EmptyIterator.INSTANCE;
+ }
+ }
+
+ @Override
+ protected Iterator fixedChildren() {
+ if (getFacetCount() != 0) {
+ return getFacets().values().iterator();
+ } else {
+ return EmptyIterator.INSTANCE;
+ }
+ }
+
+}
Deleted:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UISelectOrderShuttle.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UISelectOrderShuttle.java 2007-10-29
03:11:15 UTC (rev 3582)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/component/UISelectOrderShuttle.java 2007-10-29
03:11:27 UTC (rev 3583)
@@ -1,8 +0,0 @@
-package org.richfaces.component;
-
-import javax.faces.component.UIComponentBase;
-
-public abstract class UISelectOrderShuttle extends UIComponentBase {
-
-
-}
Added:
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-10-29
03:11:27 UTC (rev 3583)
@@ -0,0 +1,65 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.component.UIColumn;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.UIDataAdaptor;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIOrderingList;
+
+public abstract class OrderingListRendererBase extends AbstractRowsRenderer {
+
+ protected Class getComponentClass() {
+ return UIOrderingList.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ @Override
+ public void encodeOneRow(FacesContext context, TableHolder holder)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ UIDataAdaptor table = holder.getTable();
+
+ writer.startElement(HTML.TR_ELEMENT, table);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, table.getClientId(context), null);
+
+ List<UIComponent> children = table.getChildren();
+ for (UIComponent component : children) {
+ if (component instanceof UIColumn && component.isRendered()) {
+ UIColumn column = (UIColumn) component;
+
+ writer.startElement(HTML.td_ELEM, table);
+
+ renderChildren(context, column);
+
+ writer.endElement(HTML.td_ELEM);
+ }
+ }
+
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ encodeRows(context, component);
+ }
+
+ public String initJSShuttleObject(FacesContext context, UIOrderingList component) {
+ StringBuffer script = new StringBuffer();
+ script.append("var shuttleItems = new Array();");
+ script.append("for (var i = 9; i > 0; i--) {");
+ script.append("shuttleItems[9-i] = new SelectItem('Item ' + i, i,
'description' + i, null, false);");
+ script.append("}");
+ script.append("var shuttle = new
Shuttle('").append(component.getClientId(context)).append("',
shuttleItems);");
+ //script.append(" shuttle.init();");
+ return script.toString();
+ }
+}
Copied:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
(from rev 3579,
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/selectOrderShuttle.xcss)
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-10-29
03:11:27 UTC (rev 3583)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml" >
+
+<f:verbatim><![CDATA[
+.selectedItem {
+ color: white;
+ background-color: blue;
+}
+.normalItem {
+ background-color: white;
+ color: black;
+}
+.activeItem {
+ color: white;
+ background-color: brown;
+ border: 1px black dotted;
+}
+
+.body {
+ -moz-user-select: none;
+}
+]]>
+
+</f:verbatim>
+</f:template>
\ No newline at end of file
Deleted:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/selectOrderShuttle.xcss
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/selectOrderShuttle.xcss 2007-10-29
03:11:15 UTC (rev 3582)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/selectOrderShuttle.xcss 2007-10-29
03:11:27 UTC (rev 3583)
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<f:template
xmlns:f='http:/jsf.exadel.com/template'
-
xmlns:u='http:/jsf.exadel.com/template/util'
-
xmlns="http://www.w3.org/1999/xhtml" >
-
-<f:verbatim><![CDATA[
-.selectedItem {
- color: white;
- background-color: blue;
-}
-.normalItem {
- background-color: white;
- color: black;
-}
-.activeItem {
- color: white;
- background-color: brown;
- border: 1px black dotted;
-}
-
-.body {
- -moz-user-select: none;
-}
-]]>
-
-</f:verbatim>
-</f:template>
\ No newline at end of file
Copied:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
(from rev 3579,
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectOrderShuttle.js)
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/OrderingList.js 2007-10-29
03:11:27 UTC (rev 3583)
@@ -0,0 +1,317 @@
+Array.prototype.remove = function(object) {
+
+ var index = this.indexOf(object, 0, this.length);
+ if (index == 0) {
+ this.shift();
+ } else {
+ this.splice(index, 1);
+ }
+}
+
+Shuttle = function(containerId, shuttleItems) {
+ this.container = document.getElementById(containerId);
+ this.shuttleTable = document.getElementById(this.container.id + "table");
+ this.shuttleTbody = document.getElementById(this.container.id + "tbody");
+ this.shuttle = this.shuttleTbody;
+
+ this.items = null;
+ this.selectedItems = new Array();
+
+
+ this.shuttleItems = new Array();
+
+ var rows = this.shuttleTable.rows;
+ var shuttle = this;
+
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i];
+ this.shuttleItems.push(new SelectItem("", i, "", row.id, false,
row));
+ row.onclick = function(e) {
+ e = (window.event || e);
+ shuttle.onclickHandler(e);
+ }
+ }
+
+ //this.shuttleItems = shuttleItems;
+
+ //this.shuttle = null;
+ this.sortOrder = Shuttle.ASC;
+
+ //this.shuttleTable = null;
+ //this.shuttleTbody = null;
+
+ this.activeItem = null;
+}
+
+Shuttle.ASC = "acs";
+Shuttle.DESC = "desc";
+Shuttle.SELECTED_ITEM_CLASS = "selectedItem";
+Shuttle.NORMAL_ITEM_CLASS = "normalItem";
+Shuttle.ACTIVE_ITEM_CLASS = "activeItem";
+
+Shuttle.prototype.add = function(selectItem) {
+ this.createShuttleItem(selectItem, this.shuttle);
+}
+
+Shuttle.prototype.addList = function(shuttleItems) {
+ for (var i = 0; i < shuttleItems.length; i++) {
+ this.add(shuttleItems[i]);
+ }
+}
+
+Shuttle.prototype.remove = function() {
+
+}
+
+Shuttle.prototype.removeList = function() {
+
+}
+
+Shuttle.prototype.sort = function() {
+ if (this.sortOrder == Shuttle.ASC) {
+ this.shuttleItems.sort(this.compare);
+ this.sortOrder = Shuttle.DESC;
+ } else {
+ this.shuttleItems.reverse();
+ this.sortOrder = Shuttle.ASC;
+ }
+ this.rebuild();
+}
+
+Shuttle.prototype.moveSelectedItems = function(action) {
+ var rows = this.shuttleTbody.rows;
+ var item;
+ this.selectedItems.sort(this.compareByRowIndex);
+ if ((action == 'up') &&
this.getExtremeItem("first").previousSibling) {
+ for (var i = 0; i < this.selectedItems.length; i++) {
+ item = this.selectedItems[i];
+ item.parentNode.insertBefore(item, item.previousSibling);
+ }
+ } else if ((action == 'down') &&
this.getExtremeItem("last").nextSibling) {
+ for (var i = this.selectedItems.length - 1; i > -1; i--) {
+ item = this.selectedItems[i];
+ item.parentNode.insertBefore(item.nextSibling, item);
+ }
+ } else if (action == 'first') {
+ var incr = this.selectedItems[0].rowIndex;
+ for (var i = 0; i < this.selectedItems.length; i++) {
+ item = this.selectedItems[i];
+ item.parentNode.insertBefore(item, rows[item.rowIndex - incr]);
+ }
+ } else if (action == 'last') {
+ var length = this.shuttleItems.length;
+ var incr = length - this.selectedItems[this.selectedItems.length - 1].rowIndex;
+ for (var i = this.selectedItems.length - 1; i > -1; i--) {
+ item = this.selectedItems[i];
+ if (item.rowIndex + incr > length - 1) {
+ item.parentNode.insertBefore(item, null);
+ } else {
+ item.parentNode.insertBefore(item, rows[item.rowIndex + incr]);
+ }
+ }
+ }
+}
+
+Shuttle.prototype.getExtremeItem = function(position) {
+ var extremeItem = this.selectedItems[0];
+ var currentItem;
+
+ for (var i = 1; i < this.selectedItems.length; i++) {
+ currentItem = this.selectedItems[i];
+ if (position == "first") {
+ if (currentItem.rowIndex < extremeItem.rowIndex) {
+ extremeItem = currentItem;
+ }
+ } else {
+ if (currentItem.rowIndex > extremeItem.rowIndex) {
+ extremeItem = currentItem;
+ }
+ }
+ }
+ return extremeItem;
+}
+
+Shuttle.prototype.getLastSelectedItem = function() {
+
+}
+
+Shuttle.prototype.onclickHandler = function(event) {
+ //this.selectItem(event.srcElement);
+ var activeElem = event.target || event.srcElement;
+ if (activeElem == null) {
+ return;
+ }
+
+ while (activeElem.tagName.toLowerCase() != "tr") {
+ activeElem = activeElem.parentNode;
+ }
+
+ if (event.ctrlKey) {
+ this.addSelectedItem(activeElem);
+ //FIX
+ } else if (event.shiftKey) {
+ this.selectItemGroup(activeElem);
+ } else {
+ this.selectItem(activeElem);
+ }
+ activeElem.className = Shuttle.ACTIVE_ITEM_CLASS;
+ this.activeItem = activeElem;
+}
+
+/**
+ * Click handler
+ */
+Shuttle.prototype.selectItem = function(activeItem) {
+ var markedItem = this.getSelectItemById(activeItem.id);
+ var markedShuttleItem = activeItem;
+
+ if (markedItem != null) {
+ if (markedItem._selected) {
+ this.resetMarked();
+ markedItem._selected = false;
+ } else {
+ this.resetMarked();
+
+ markedItem._selected = true;
+ //markedShuttleItem.className = Shuttle.ACTIVE_ITEM_CLASS;
+ this.selectedItems[0] = markedShuttleItem;
+ }
+ }
+}
+
+/**
+ * CTRL+Click handler
+ */
+Shuttle.prototype.addSelectedItem = function(activeItem) {
+ var markedItem = this.getSelectItemById(activeItem.id);
+ var markedShuttleItem = activeItem;
+
+ if (markedItem._selected) {
+ //this.activeItem.className = Shuttle.NORMAL_ITEM_CLASS;
+ this.selectedItems.remove(markedShuttleItem);
+ markedItem._selected = false;
+ } else {
+ markedItem._selected = true;
+ //markedShuttleItem.className = Shuttle.SELECTED_ITEM_CLASS;
+ this.selectedItems.push(markedShuttleItem);
+ }
+ this.activeItem.className = Shuttle.SELECTED_ITEM_CLASS;
+
+ if (this.activeItem && !this.getSelectItemById(this.activeItem.id)._selected) {
+ this.activeItem.className = Shuttle.NORMAL_ITEM_CLASS;
+ }
+}
+
+/**
+ * Shift+Click handler
+ */
+Shuttle.prototype.selectItemGroup = function(activeItem) {
+ var lastItemIndex = this.activeItem.rowIndex;
+ var startIndex;
+ var endIndex;
+ this.resetMarked();
+ if (activeItem.rowIndex > lastItemIndex) {
+ startIndex = lastItemIndex;
+ endIndex = activeItem.rowIndex;
+ } else {
+ startIndex = activeItem.rowIndex;
+ endIndex = lastItemIndex;
+ }
+ var rows = this.shuttleTbody.rows;
+ for (var i = startIndex; i <= endIndex; i++) {
+ rows[i].className = Shuttle.SELECTED_ITEM_CLASS;
+ this.selectedItems.push(rows[i]);
+ this.getSelectItemById(rows[i].id)._selected = true;
+ }
+}
+
+Shuttle.prototype.resetMarked = function() {
+ var rows = this.shuttleTbody.rows;
+ for (var i = 0; i < rows.length; i++) {
+ var shuttleItem = rows[i];
+ shuttleItem.className = Shuttle.NORMAL_ITEM_CLASS;
+ this.getSelectItemById(shuttleItem.id)._selected = false; //FIXME
+ }
+ this.selectedItems.length = 0;
+}
+
+Shuttle.prototype.getSelectItemById = function(selectItemId) {
+ for (var i = 0; i < this.shuttleItems.length; i++) {
+ var item = this.shuttleItems[i];
+ if (selectItemId == item._id) {
+ return item;
+ }
+ }
+ return null
+}
+
+Shuttle.prototype.init = function() {
+ this.addList(this.shuttleItems);
+ //this.shuttleTable.appendChild(this.shuttle)
+ //this.container.appendChild(this.shuttleTable);
+
+}
+
+Shuttle.prototype.rebuild = function() {
+ this.shuttle = document.createElement("tbody");
+
+ for (var i = 0; i < this.shuttleItems.length; i++) {
+ this.shuttle.appendChild(this.shuttleItems[i]._node);
+ }
+ this.shuttleTbody.parentNode.removeChild(this.shuttleTbody);
+ this.shuttleTable.appendChild(this.shuttle);
+ this.shuttleTbody = this.shuttleTable.tBodies[0];
+}
+//--------------------------------
+Shuttle.prototype.createShuttleItem = function(selectItem, elemContainer) {
+ var tr = document.createElement("tr");
+ elemContainer.appendChild(tr);
+ tr.id = selectItem._id
+ //elemContainer.append('<tr
id="').append(selectItem._id).append('" ');
+ var className = null;
+ if (selectItem._selected) {
+ className = Shuttle.SELECTED_ITEM_CLASS;
+ } else if (this.activeItem && (this.activeItem == selectItem)) {
+ className = Shuttle.ACTIVE_ITEM_CLASS;
+ } else {
+ className = Shuttle.NORMAL_ITEM_CLASS;
+ }
+ //elemContainer.append('class="').append(className);
+ tr.className = className;
+ var obj = this;
+ tr.onclick = function(e) {
+ e = (window.event || e);
+ obj.onclickHandler(e);
+ }
+ //elemContainer.append('"
onclick="shuttle.onclickHandler(window.event||event);"');
+ //elemContainer.append('>').append('<td>');
+ var td = document.createElement("td");
+ tr.appendChild(td);
+ if (td.textContent == undefined) {
+ td.innerText = selectItem._label;
+ } else {
+ td.textContent = selectItem._label;
+ }
+ selectItem._node = tr;
+ //elemContainer.append(selectItem._label);
+ //elemContainer.append('</td><td width="0">');
+ //this.createValueKeeper(selectItem, elemContainer);
+ //elemContainer.append('</td></tr>');
+}
+
+Shuttle.prototype.compare = function(obj1, obj2) {
+ obj1 = obj1._label;
+ obj2 = obj2._label;
+ return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
+}
+
+Shuttle.prototype.compareByRowIndex = function(obj1, obj2) {
+ obj1 = obj1.rowIndex;
+ obj2 = obj2.rowIndex;
+ return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
+}
+
+Shuttle.prototype.createValueKeeper = function(selectItem, elemContainer) {
+ elemContainer.append('<input type="hidden" value="')
+ .append(selectItem._value).append('"/>');
+}
Deleted:
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectOrderShuttle.js
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectOrderShuttle.js 2007-10-29
03:11:15 UTC (rev 3582)
+++
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/scripts/SelectOrderShuttle.js 2007-10-29
03:11:27 UTC (rev 3583)
@@ -1,300 +0,0 @@
-Array.prototype.remove = function(object) {
-
- var index = this.indexOf(object, 0, this.length);
- if (index == 0) {
- this.shift();
- } else {
- this.splice(index, 1);
- }
-}
-
-Shuttle = function(containerId, shuttleItems) {
- this.container = document.getElementById(containerId);
- this.items = null;
- this.selectedItems = new Array();
- this.shuttleItems = shuttleItems;
-
- this.shuttle = null;
- this.sortOrder = Shuttle.ASC;
-
- this.shuttleTable = null;
- this.shuttleTbody = null;
-
- this.activeItem = null;
-}
-
-Shuttle.ASC = "acs";
-Shuttle.DESC = "desc";
-Shuttle.SELECTED_ITEM_CLASS = "selectedItem";
-Shuttle.NORMAL_ITEM_CLASS = "normalItem";
-Shuttle.ACTIVE_ITEM_CLASS = "activeItem";
-
-Shuttle.prototype.add = function(selectItem) {
- this.createShuttleItem(selectItem, this.shuttle);
-}
-
-Shuttle.prototype.addList = function(shuttleItems) {
- for (var i = 0; i < shuttleItems.length; i++) {
- this.add(shuttleItems[i]);
- }
-}
-
-Shuttle.prototype.remove = function() {
-
-}
-
-Shuttle.prototype.removeList = function() {
-
-}
-
-Shuttle.prototype.sort = function() {
- if (this.sortOrder == Shuttle.ASC) {
- this.shuttleItems.sort(this.compare);
- this.sortOrder = Shuttle.DESC;
- } else {
- this.shuttleItems.reverse();
- this.sortOrder = Shuttle.ASC;
- }
- this.rebuild();
-}
-
-Shuttle.prototype.moveSelectedItems = function(action) {
- var rows = this.shuttleTbody.rows;
- var item;
- this.selectedItems.sort(this.compareByRowIndex);
- if ((action == 'up') &&
this.getExtremeItem("first").previousSibling) {
- for (var i = 0; i < this.selectedItems.length; i++) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item, item.previousSibling);
- }
- } else if ((action == 'down') &&
this.getExtremeItem("last").nextSibling) {
- for (var i = this.selectedItems.length - 1; i > -1; i--) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item.nextSibling, item);
- }
- } else if (action == 'first') {
- var incr = this.selectedItems[0].rowIndex;
- for (var i = 0; i < this.selectedItems.length; i++) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item, rows[item.rowIndex - incr]);
- }
- } else if (action == 'last') {
- var length = this.shuttleItems.length;
- var incr = length - this.selectedItems[this.selectedItems.length - 1].rowIndex;
- for (var i = this.selectedItems.length - 1; i > -1; i--) {
- item = this.selectedItems[i];
- if (item.rowIndex + incr > length - 1) {
- item.parentNode.insertBefore(item, null);
- } else {
- item.parentNode.insertBefore(item, rows[item.rowIndex + incr]);
- }
- }
- }
-}
-
-Shuttle.prototype.getExtremeItem = function(position) {
- var extremeItem = this.selectedItems[0];
- var currentItem;
-
- for (var i = 1; i < this.selectedItems.length; i++) {
- currentItem = this.selectedItems[i];
- if (position == "first") {
- if (currentItem.rowIndex < extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
- } else {
- if (currentItem.rowIndex > extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
- }
- }
- return extremeItem;
-}
-
-Shuttle.prototype.getLastSelectedItem = function() {
-
-}
-
-Shuttle.prototype.onclickHandler = function(event) {
- //this.selectItem(event.srcElement);
- var activeElem = event.target || event.srcElement;
- if (activeElem == null) {
- return;
- }
-
- while (activeElem.tagName.toLowerCase() != "tr") {
- activeElem = activeElem.parentNode;
- }
-
- if (event.ctrlKey) {
- this.addSelectedItem(activeElem);
- //FIX
- } else if (event.shiftKey) {
- this.selectItemGroup(activeElem);
- } else {
- this.selectItem(activeElem);
- }
- activeElem.className = Shuttle.ACTIVE_ITEM_CLASS;
- this.activeItem = activeElem;
-}
-
-/**
- * Click handler
- */
-Shuttle.prototype.selectItem = function(activeItem) {
- var markedItem = this.getSelectItemById(activeItem.id);
- var markedShuttleItem = activeItem;
-
- if (markedItem != null) {
- if (markedItem._selected) {
- this.resetMarked();
- markedItem._selected = false;
- } else {
- this.resetMarked();
-
- markedItem._selected = true;
- //markedShuttleItem.className = Shuttle.ACTIVE_ITEM_CLASS;
- this.selectedItems[0] = markedShuttleItem;
- }
- }
-}
-
-/**
- * CTRL+Click handler
- */
-Shuttle.prototype.addSelectedItem = function(activeItem) {
- var markedItem = this.getSelectItemById(activeItem.id);
- var markedShuttleItem = activeItem;
-
- if (markedItem._selected) {
- //this.activeItem.className = Shuttle.NORMAL_ITEM_CLASS;
- this.selectedItems.remove(markedShuttleItem);
- markedItem._selected = false;
- } else {
- markedItem._selected = true;
- //markedShuttleItem.className = Shuttle.SELECTED_ITEM_CLASS;
- this.selectedItems.push(markedShuttleItem);
- }
- this.activeItem.className = Shuttle.SELECTED_ITEM_CLASS;
-
- if (this.activeItem && !this.getSelectItemById(this.activeItem.id)._selected) {
- this.activeItem.className = Shuttle.NORMAL_ITEM_CLASS;
- }
-}
-
-/**
- * Shift+Click handler
- */
-Shuttle.prototype.selectItemGroup = function(activeItem) {
- var lastItemIndex = this.activeItem.rowIndex;
- var startIndex;
- var endIndex;
- this.resetMarked();
- if (activeItem.rowIndex > lastItemIndex) {
- startIndex = lastItemIndex;
- endIndex = activeItem.rowIndex;
- } else {
- startIndex = activeItem.rowIndex;
- endIndex = lastItemIndex;
- }
- var rows = this.shuttleTbody.rows;
- for (var i = startIndex; i <= endIndex; i++) {
- rows[i].className = Shuttle.SELECTED_ITEM_CLASS;
- this.selectedItems.push(rows[i]);
- this.getSelectItemById(rows[i].id)._selected = true;
- }
-}
-
-Shuttle.prototype.resetMarked = function() {
- var rows = this.shuttleTbody.rows;
- for (var i = 0; i < rows.length; i++) {
- var shuttleItem = rows[i];
- shuttleItem.className = Shuttle.NORMAL_ITEM_CLASS;
- this.getSelectItemById(shuttleItem.id)._selected = false; //FIXME
- }
- this.selectedItems.length = 0;
-}
-
-Shuttle.prototype.getSelectItemById = function(selectItemId) {
- for (var i = 0; i < this.shuttleItems.length; i++) {
- var item = this.shuttleItems[i];
- if (selectItemId == item._id) {
- return item;
- }
- }
- return null
-}
-
-Shuttle.prototype.init = function() {
- this.shuttleTable = document.createElement("table");
- this.shuttleTbody = document.createElement("tbody");
- this.shuttle = this.shuttleTbody;
- this.addList(this.shuttleItems);
- this.shuttleTable.appendChild(this.shuttle)
- this.container.appendChild(this.shuttleTable);
-
-}
-
-Shuttle.prototype.rebuild = function() {
- this.shuttle = document.createElement("tbody");
-
- for (var i = 0; i < this.shuttleItems.length; i++) {
- this.shuttle.appendChild(this.shuttleItems[i]._node);
- }
- this.shuttleTbody.parentNode.removeChild(this.shuttleTbody);
- this.shuttleTable.appendChild(this.shuttle);
- this.shuttleTbody = this.shuttleTable.tBodies[0];
-}
-//--------------------------------
-Shuttle.prototype.createShuttleItem = function(selectItem, elemContainer) {
- var tr = document.createElement("tr");
- elemContainer.appendChild(tr);
- tr.id = selectItem._id
- //elemContainer.append('<tr
id="').append(selectItem._id).append('" ');
- var className = null;
- if (selectItem._selected) {
- className = Shuttle.SELECTED_ITEM_CLASS;
- } else if (this.activeItem && (this.activeItem == selectItem)) {
- className = Shuttle.ACTIVE_ITEM_CLASS;
- } else {
- className = Shuttle.NORMAL_ITEM_CLASS;
- }
- //elemContainer.append('class="').append(className);
- tr.className = className;
- var obj = this;
- tr.onclick = function(e) {
- e = (window.event || e);
- obj.onclickHandler(e);
- }
- //elemContainer.append('"
onclick="shuttle.onclickHandler(window.event||event);"');
- //elemContainer.append('>').append('<td>');
- var td = document.createElement("td");
- tr.appendChild(td);
- if (td.textContent == undefined) {
- td.innerText = selectItem._label;
- } else {
- td.textContent = selectItem._label;
- }
- selectItem._node = tr;
- //elemContainer.append(selectItem._label);
- //elemContainer.append('</td><td width="0">');
- //this.createValueKeeper(selectItem, elemContainer);
- //elemContainer.append('</td></tr>');
-}
-
-Shuttle.prototype.compare = function(obj1, obj2) {
- obj1 = obj1._label;
- obj2 = obj2._label;
- return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
-}
-
-Shuttle.prototype.compareByRowIndex = function(obj1, obj2) {
- obj1 = obj1.rowIndex;
- obj2 = obj2.rowIndex;
- return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
-}
-
-Shuttle.prototype.createValueKeeper = function(selectItem, elemContainer) {
- elemContainer.append('<input type="hidden" value="')
- .append(selectItem._value).append('"/>');
-}
Copied:
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx (from
rev 3579,
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlSelectOrderShuttle.jspx)
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
(rev 0)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-10-29
03:11:27 UTC (rev 3583)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:root
+
xmlns:f="http://ajax4jsf.org/cdk/template"
+ xmlns:c="
http://java.sun.com/jsf/core"
+ xmlns:ui="
http://ajax4jsf.org/cdk/ui"
+ xmlns:u="
http://ajax4jsf.org/cdk/u"
+ xmlns:x="
http://ajax4jsf.org/cdk/x"
+ baseclass="org.richfaces.renderkit.OrderingListRendererBase"
+ class="org.richfaces.renderkit.html.OrderingListRenderer"
+ component="org.richfaces.component.UIOrderingList"
+ >
+ <h:styles>css/orderingList.xcss</h:styles>
+
+ <h:scripts>
+ scripts/StringBuilder.js,scripts/SelectItem.js,scripts/OrderingList.js
+ </h:scripts>
+
+ <f:clientid var="clientId"/>
+ <div id="#{clientId}">
+ <table id="#{clientId}table">
+ <tbody id="#{clientId}tbody">
+ <vcp:body>
+ <input type="text" value="dsfdsf"
name="asdasdas"/>
+ <f:call name="renderChildren" />
+ </vcp:body>
+ </tbody>
+ </table>
+ </div>
+ <a href="#"
onclick="shuttle.sort();">Header</a><br/>
+ <a href="#"
onclick="shuttle.moveSelectedItems('up');">up</a><br/>
+ <a href="#"
onclick="shuttle.moveSelectedItems('down');">down</a><br/>
+ <a href="#"
onclick="shuttle.moveSelectedItems('first');">first</a><br/>
+ <a href="#"
onclick="shuttle.moveSelectedItems('last');">last</a>
+ <script type="text/javascript">
+ #{this:initJSShuttleObject(context, component)}
+ document.body.onselectstart = function() {return false;};
+ document.body.className = "body";
+
+ </script>
+</f:root>
\ No newline at end of file
Deleted:
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlSelectOrderShuttle.jspx
===================================================================
---
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlSelectOrderShuttle.jspx 2007-10-29
03:11:15 UTC (rev 3582)
+++
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlSelectOrderShuttle.jspx 2007-10-29
03:11:27 UTC (rev 3583)
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<f:root
-
xmlns:f="http://ajax4jsf.org/cdk/template"
- xmlns:c="
http://java.sun.com/jsf/core"
- xmlns:ui="
http://ajax4jsf.org/cdk/ui"
- xmlns:u="
http://ajax4jsf.org/cdk/u"
- xmlns:x="
http://ajax4jsf.org/cdk/x"
- baseclass="org.richfaces.renderkit.html.SelectOrderShuttleRendererBase"
- class="org.richfaces.renderkit.html.SelectOrderShuttleRenderer"
- component="org.richfaces.component.UISelectOrderShuttle"
- >
- <h:styles>css/selectOrderShuttle.xcss</h:styles>
-
- <h:scripts>
- scripts/StringBuilder.js,scripts/SelectItem.js,scripts/SelectOrderShuttle.js
- </h:scripts>
-
- <f:clientid var="clientId"/>
- <div id="#{clientId}">
- <vcp:body>
- <input type="text" value="dsfdsf"
name="asdasdas"/>
- <f:call name="renderChildren" />
- </vcp:body>
- </div>
- <a href="#"
onclick="shuttle.sort();">Header</a><br/>
- <a href="#"
onclick="shuttle.moveSelectedItems('up');">up</a><br/>
- <a href="#"
onclick="shuttle.moveSelectedItems('down');">down</a><br/>
- <a href="#"
onclick="shuttle.moveSelectedItems('first');">first</a><br/>
- <a href="#"
onclick="shuttle.moveSelectedItems('last');">last</a>
- <script type="text/javascript">
- #{this:initJSShuttleObject(context, component)}
- document.body.onselectstart = function() {return false;};
- document.body.className = "body";
-
- </script>
-</f:root>
\ No newline at end of file