You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by he...@apache.org on 2006/11/13 23:55:14 UTC

svn commit: r474551 [11/49] - in /struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo: ./ src/ src/alg/ src/animation/ src/cal/ src/charting/ src/charting/svg/ src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/cs...

Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/deep.html
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/deep.html?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/deep.html (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/deep.html Mon Nov 13 14:54:45 2006
@@ -0,0 +1,362 @@
+<html>
+<head>
+<title>Deep Debugger</title>
+<script>
+
+var tableRows = {};
+var tableCels = {};
+var tableObjs = {};
+var tablesBuilt = {};
+var tableShows = {};
+var tableHides = {};
+
+// IE: nodes w/id need to be redeclared or getElementById is b0rked
+var frame = null;
+
+window.onload = function(){
+	// if IE loads this page too quickly (instantly) then 
+	// window.debugVar might not have been set
+	window.setTimeout(startMeUp, 100);
+}
+
+function startMeUp(){
+	frame = document.getElementById('frame');
+	// GET string 
+	var index = location.search.split("=").pop();
+	var debugObj = window.opener.dojo.debugDeep;
+	var debugVar = debugObj.debugVars[index] || window.debugVar;
+	buildTable('root', frame, debugVar);
+}
+
+function buildTable(path, parent, obj){
+	var keys = [];
+	var vals = [];
+	for(var prop in obj){
+		keys.push(prop);
+		try {
+			vals[prop] = obj[prop];
+		} catch(E) {
+			vals[prop] = 'ERROR: ' + E.message;
+		}
+	}
+	keys.sort(keySorter);
+
+	if (!keys.length){
+
+		var div = document.createElement('div');
+		div.appendChild(document.createTextNode('Object has no properties.'));
+
+		parent.appendChild(div);
+		return;
+	}
+
+
+	var t = document.createElement('table');
+	t.border = "1";
+
+	var tb = document.createElement('tbody');
+	t.appendChild(tb);
+
+
+	for(var i = 0; i < keys.length; i++) {
+		buildTableRow(path+'-'+keys[i], tb, keys[i], vals[keys[i]]);
+	}
+
+	if (path == 'root'){
+		//t.style.width = '90%';
+	}
+	t.style.width = '100%';
+
+	parent.appendChild(t);
+
+	tablesBuilt[path] = true;
+}
+
+function buildTableRow(path, tb, name, value) {
+
+	var simpleType = typeof(value);
+	var createSubrow = (simpleType == 'object');
+	var complexType = simpleType;
+
+	if (simpleType == 'object'){
+		var cls = getConstructorClass(value);
+		if (cls){
+			if (cls == 'Object'){
+			}else if (cls == 'Array'){
+				complexType = 'array';
+			}else{
+				complexType += ' ('+cls+')';
+			}
+		}
+	}
+
+/*var tr1 = document.createElement('tr');
+	var td1 = document.createElement('td');
+	var td2 = document.createElement('td');
+	var td3 = document.createElement('td');
+	var td4 = document.createElement('td');*/
+
+	var row = tb.rows.length;
+	var tr1 = tb.insertRow(row++);
+	var td1 = tr1.insertCell(0);
+	var td2 = tr1.insertCell(1);
+	var td3 = tr1.insertCell(2);
+	var td4 = tr1.insertCell(3);
+	
+	tr1.style.verticalAlign = 'top';
+	td1.style.verticalAlign = 'middle';
+
+	td1.className = 'propPlus';
+	td2.className = 'propName';
+	td3.className = 'propType';
+	td4.className = 'propVal';
+
+	//tr1.appendChild(td1);
+	//tr1.appendChild(td2);
+	//tr1.appendChild(td3);
+	//tr1.appendChild(td4);
+
+	if (createSubrow){
+		var img1 = document.createElement('img');
+		img1.width = 9;
+		img1.height = 9;
+		img1.src = 'arrow_show.gif';
+		var a1 = document.createElement('a');
+		a1.appendChild(img1);
+		a1.href = '#';
+		a1.onclick = function(){ showTableRow(path); return false; };
+
+		var img2 = document.createElement('img');
+		img2.width = 9;
+		img2.height = 9;
+		img2.src = 'arrow_hide.gif';
+		var a2 = document.createElement('a');
+		a2.appendChild(img2);
+		a2.href = '#';
+		a2.onclick = function(){ hideTableRow(path); return false; };
+		a2.style.display = 'none';
+
+		tableShows[path] = a1;
+		tableHides[path] = a2;
+
+		td1.appendChild(a1);
+		td1.appendChild(a2);
+	}else{
+		var img = document.createElement('img');
+		img.width = 9;
+		img.height = 9;
+		img.src = 'spacer.gif';
+
+		td1.appendChild(img);
+	}
+
+	td2.appendChild(document.createTextNode(name));
+	td3.appendChild(document.createTextNode(complexType));
+	td4.appendChild(buildPreBlock(value));
+
+	//tb.appendChild(tr1);
+
+	if (createSubrow){
+		var tr2 = tb.insertRow(row++);
+		var td5 = tr2.insertCell(0);
+		var td6 = tr2.insertCell(1);
+		
+		//var tr2 = document.createElement('tr');
+		//var td5 = document.createElement('td');
+		//var td6 = document.createElement('td');
+
+		td5.innerHTML = '&nbsp;';
+		//td6.innerHTML = '&nbsp;';
+
+		td6.colSpan = '3';
+
+		tr2.appendChild(td5);
+		tr2.appendChild(td6);
+
+		tr2.style.display = 'none';
+
+		tb.appendChild(tr2);
+
+		tableRows[path] = tr2;
+		tableCels[path] = td6;
+		tableObjs[path] = value;
+	}
+}
+
+function showTableRow(path){
+
+	var tr = tableRows[path];
+	var td = tableCels[path];
+	var a1 = tableShows[path];
+	var a2 = tableHides[path];
+
+	if (!tablesBuilt[path]){
+
+		//alert('building table for '+path);
+		buildTable(path, td, tableObjs[path]);
+	}
+
+	tr.style.display = 'table-row';
+
+	a1.style.display = 'none';
+	a2.style.display = 'inline';
+}
+
+function hideTableRow(path){
+
+	var tr = tableRows[path];
+	var a1 = tableShows[path];
+	var a2 = tableHides[path];
+
+	tr.style.display = 'none';
+
+	a1.style.display = 'inline';
+	a2.style.display = 'none';
+}
+
+function buildPreBlock(value){
+
+	//
+	// how many lines ?
+	//
+
+	var s = ''+value;
+	s = s.replace("\r\n", "\n");
+	s = s.replace("\r", "");
+	var lines = s.split("\n");
+
+
+	if (lines.length < 2){
+
+		if (lines[0].length < 60){
+
+			var pre = document.createElement('pre');
+			pre.appendChild(document.createTextNode(s));
+			return pre;
+		}
+	}
+
+
+	//
+	// multiple lines :(
+	//
+
+	var preview = lines[0].substr(0, 60) + ' ...';
+
+	var pre1 = document.createElement('pre');
+	pre1.appendChild(document.createTextNode(preview));
+	pre1.className = 'clicky';
+
+	var pre2 = document.createElement('pre');
+	pre2.appendChild(document.createTextNode(s));
+	pre2.style.display = 'none';
+	pre2.className = 'clicky';
+
+	pre1.onclick = function(){
+		pre1.style.display = 'none';
+		pre2.style.display = 'block';
+	}
+
+	pre2.onclick = function(){
+		pre1.style.display = 'block';
+		pre2.style.display = 'none';
+	}
+
+	var pre = document.createElement('div');
+
+	pre.appendChild(pre1);
+	pre.appendChild(pre2);
+
+	return pre;
+}
+
+function getConstructorClass(obj){
+
+	if (!obj.constructor || !obj.constructor.toString) return;
+
+	var m = obj.constructor.toString().match(/function\s*(\w+)/);
+
+	if (m && m.length == 2) return m[1];
+
+	return null;
+}
+
+function keySorter(a, b){
+
+	if (a == parseInt(a) && b == parseInt(b)){
+
+		return (parseInt(a) > parseInt(b)) ? 1 : ((parseInt(a) < parseInt(b)) ? -1 : 0);
+	}
+
+	// sort by lowercase string
+
+	var a2 = String(a).toLowerCase();
+	var b2 = String(b).toLowerCase();
+
+	return (a2 > b2) ? 1 : ((a2 < b2) ? -1 : 0);
+}
+
+</script>
+<style>
+
+body {
+	font-family: arial, helvetica, sans-serif;
+}
+
+table {
+	border-width: 0px;
+	border-spacing: 1px;
+	border-collapse: separate;
+}
+
+td {
+	border-width: 0px;
+	padding: 2px;
+}
+
+img {
+	border: 0;
+}
+
+pre {
+	margin: 0;
+	padding: 0;
+	white-space: -moz-pre-wrap;  /* Mozilla, supported since 1999 */
+	white-space: -pre-wrap;      /* Opera 4 - 6 */
+	white-space: -o-pre-wrap;    /* Opera 7 */
+	white-space: pre-wrap;       /* CSS3 - Text module (Candidate Recommendation) http://www.w3.org/TR/css3-text/#white-space */
+	word-wrap: break-word;       /* IE 5.5+ */
+}
+
+pre.clicky {
+	cursor: hand;
+	cursor: pointer;
+}
+
+td.propPlus {
+	width: 9px;
+	background-color: #ddd;
+}
+
+td.propName {
+	background-color: #ddd;
+}
+
+td.propType {
+	background-color: #ddd;
+}
+
+td.propVal {
+	background-color: #ddd;
+}
+
+</style>
+</head>
+<body>
+
+<h2>Javascript Object Browser</h2>
+
+<div id="frame"></div>
+
+</body>
+</html>
\ No newline at end of file

Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/deep.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/spacer.gif
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/spacer.gif?view=auto&rev=474551
==============================================================================
Binary file - no diff available.

Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/debug/spacer.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/DragAndDrop.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the
@@ -8,26 +8,26 @@
 		http://dojotoolkit.org/community/licensing.shtml
 */
 
-dojo.require("dojo.lang");
-dojo.provide("dojo.dnd.DragSource");
-dojo.provide("dojo.dnd.DropTarget");
-dojo.provide("dojo.dnd.DragObject");
-dojo.provide("dojo.dnd.DragManager");
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.declare");
 dojo.provide("dojo.dnd.DragAndDrop");
 
-dojo.dnd.DragSource = function(){
-	dojo.dnd.dragManager.registerDragSource(this);
-}
-
-dojo.lang.extend(dojo.dnd.DragSource, {
+dojo.declare("dojo.dnd.DragSource", null, {
 	type: "",
-	
+
 	onDragEnd: function(){
 	},
-	
+
 	onDragStart: function(){
 	},
 
+	/*
+	 * This function gets called when the DOM element was 
+	 * selected for dragging by the HtmlDragAndDropManager.
+	 */
+	onSelected: function(){
+	},
+
 	unregister: function(){
 		dojo.dnd.dragManager.unregisterDragSource(this);
 	},
@@ -35,20 +35,27 @@
 	reregister: function(){
 		dojo.dnd.dragManager.registerDragSource(this);
 	}
-});
+}, function(){
 
-dojo.dnd.DragObject = function(){
-	dojo.dnd.dragManager.registerDragObject(this);
-}
+	//dojo.profile.start("DragSource");
+
+	var dm = dojo.dnd.dragManager;
+	if(dm["registerDragSource"]){ // side-effect prevention
+		dm.registerDragSource(this);
+	}
 
-dojo.lang.extend(dojo.dnd.DragObject, {
+	//dojo.profile.end("DragSource");
+
+});
+
+dojo.declare("dojo.dnd.DragObject", null, {
 	type: "",
-	
+
 	onDragStart: function(){
 		// gets called directly after being created by the DragSource
 		// default action is to clone self as icon
 	},
-	
+
 	onDragMove: function(){
 		// this changes the UI for the drag icon
 		//	"it moves itself"
@@ -56,10 +63,10 @@
 
 	onDragOver: function(){
 	},
-	
+
 	onDragOut: function(){
 	},
-	
+
 	onDragEnd: function(){
 	},
 
@@ -70,16 +77,14 @@
 	// non-camel aliases
 	ondragout: this.onDragOut,
 	ondragover: this.onDragOver
+}, function(){
+	var dm = dojo.dnd.dragManager;
+	if(dm["registerDragObject"]){ // side-effect prevention
+		dm.registerDragObject(this);
+	}
 });
 
-dojo.dnd.DropTarget = function(){
-	if (this.constructor == dojo.dnd.DropTarget) { return; } // need to be subclassed
-	this.acceptedTypes = [];
-	dojo.dnd.dragManager.registerDropTarget(this);
-}
-
-dojo.lang.extend(dojo.dnd.DropTarget, {
-	acceptedTypes: [],
+dojo.declare("dojo.dnd.DropTarget", null, {
 
 	acceptsType: function(type){
 		if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
@@ -98,17 +103,31 @@
 		return true;
 	},
 
+	unregister: function(){
+		dojo.dnd.dragManager.unregisterDropTarget(this);
+	},
+
 	onDragOver: function(){
 	},
-	
+
 	onDragOut: function(){
 	},
-	
+
 	onDragMove: function(){
 	},
-	
+
+	onDropStart: function(){
+	},
+
 	onDrop: function(){
+	},
+
+	onDropEnd: function(){
 	}
+}, function(){
+	if (this.constructor == dojo.dnd.DropTarget) { return; } // need to be subclassed
+	this.acceptedTypes = [];
+	dojo.dnd.dragManager.registerDropTarget(this);
 });
 
 // NOTE: this interface is defined here for the convenience of the DragManager
@@ -118,23 +137,19 @@
 	this.dragSource = null;
 	this.dragObject = null;
 	this.target = null;
-	this.eventStatus = "success"; 
+	this.eventStatus = "success";
 	//
 	// can be one of:
-	//	[	"dropSuccess", "dropFailure", "dragMove", 
+	//	[	"dropSuccess", "dropFailure", "dragMove",
 	//		"dragStart", "dragEnter", "dragLeave"]
 	//
 }
-
-dojo.dnd.DragManager = function(){
-	/* 
-	 *	The DragManager handles listening for low-level events and dispatching
-	 *	them to higher-level primitives like drag sources and drop targets. In
-	 *	order to do this, it must keep a list of the items.
-	 */
-}
-
-dojo.lang.extend(dojo.dnd.DragManager, {
+/*
+ *	The DragManager handles listening for low-level events and dispatching
+ *	them to higher-level primitives like drag sources and drop targets. In
+ *	order to do this, it must keep a list of the items.
+ */
+dojo.declare("dojo.dnd.DragManager", null, {
 	selectedSources: [],
 	dragObjects: [],
 	dragSources: [],

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragAndDrop.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the
@@ -9,113 +9,157 @@
 */
 
 dojo.provide("dojo.dnd.HtmlDragAndDrop");
-dojo.provide("dojo.dnd.HtmlDragSource");
-dojo.provide("dojo.dnd.HtmlDropTarget");
-dojo.provide("dojo.dnd.HtmlDragObject");
 
 dojo.require("dojo.dnd.HtmlDragManager");
-dojo.require("dojo.animation.*");
-dojo.require("dojo.dom");
-dojo.require("dojo.style");
-dojo.require("dojo.html");
-dojo.require("dojo.lang");
+dojo.require("dojo.dnd.DragAndDrop");
 
-dojo.dnd.HtmlDragSource = function(node, type){
-	node = dojo.byId(node);
-	this.constrainToContainer = false;
-	if(node){
-		this.domNode = node;
-		this.dragObject = node;
-
-		// register us
-		dojo.dnd.DragSource.call(this);
+dojo.require("dojo.html.*");
+dojo.require("dojo.html.display");
+dojo.require("dojo.html.util");
+dojo.require("dojo.html.selection");
+dojo.require("dojo.html.iframe");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.lfx.*");
+dojo.require("dojo.event.*");
 
-		// set properties that might have been clobbered by the mixin
-		this.type = type||this.domNode.nodeName.toLowerCase();
-	}
-
-}
-
-dojo.lang.extend(dojo.dnd.HtmlDragSource, {
+dojo.declare("dojo.dnd.HtmlDragSource", dojo.dnd.DragSource, {
 	dragClass: "", // CSS classname(s) applied to node when it is being dragged
 
 	onDragStart: function(){
-		var dragObj = new dojo.dnd.HtmlDragObject(this.dragObject, this.type, this.dragClass);
+		var dragObj = new dojo.dnd.HtmlDragObject(this.dragObject, this.type);
+		if(this.dragClass) { dragObj.dragClass = this.dragClass; }
 
 		if (this.constrainToContainer) {
-			dragObj.constrainTo(this.constrainingContainer);
+			dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
 		}
 
 		return dragObj;
 	},
+
 	setDragHandle: function(node){
 		node = dojo.byId(node);
 		dojo.dnd.dragManager.unregisterDragSource(this);
 		this.domNode = node;
 		dojo.dnd.dragManager.registerDragSource(this);
 	},
+
 	setDragTarget: function(node){
 		this.dragObject = node;
 	},
 
 	constrainTo: function(container) {
 		this.constrainToContainer = true;
-
 		if (container) {
 			this.constrainingContainer = container;
-		} else {
-			this.constrainingContainer = this.domNode.parentNode;
 		}
-	}
-});
+	},
+	
+	/*
+	*
+	* see dojo.dnd.DragSource.onSelected
+	*/
+	onSelected: function() {
+		for (var i=0; i<this.dragObjects.length; i++) {
+			dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragSource(this.dragObjects[i]));
+		}
+	},
 
-dojo.dnd.HtmlDragObject = function(node, type, dragClass){
-	this.domNode = dojo.byId(node);
-	this.type = type;
-	if(dragClass) { this.dragClass = dragClass; }
+	/**
+	* Register elements that should be dragged along with
+	* the actual DragSource.
+	*
+	* Example usage:
+	* 	var dragSource = new dojo.dnd.HtmlDragSource(...);
+	*	// add a single element
+	*	dragSource.addDragObjects(dojo.byId('id1'));
+	*	// add multiple elements to drag along
+	*	dragSource.addDragObjects(dojo.byId('id2'), dojo.byId('id3'));
+	*
+	* el A dom node to add to the drag list.
+	*/
+	addDragObjects: function(/*DOMNode*/ el) {
+		for (var i=0; i<arguments.length; i++) {
+			this.dragObjects.push(arguments[i]);
+		}
+	}
+}, function(node, type){
+	node = dojo.byId(node);
+	this.dragObjects = [];
 	this.constrainToContainer = false;
-}
+	if(node){
+		this.domNode = node;
+		this.dragObject = node;
+		// register us
+		dojo.dnd.DragSource.call(this);
+		// set properties that might have been clobbered by the mixin
+		this.type = (type)||(this.domNode.nodeName.toLowerCase());
+	}
 
-dojo.lang.extend(dojo.dnd.HtmlDragObject, {  
+});
+
+dojo.declare("dojo.dnd.HtmlDragObject", dojo.dnd.DragObject, {
 	dragClass: "",
 	opacity: 0.5,
+	createIframe: true,		// workaround IE6 bug
 
 	// if true, node will not move in X and/or Y direction
 	disableX: false,
 	disableY: false,
 
-	/**
-	 * Creates a clone of this node and replaces this node with the clone in the
-	 * DOM tree. This is done to prevent the browser from selecting the textual
-	 * content of the node. This node is then set to opaque and drags around as
-	 * the intermediate representation.
-	 */
+	createDragNode: function() {
+		var node = this.domNode.cloneNode(true);
+		if(this.dragClass) { dojo.html.addClass(node, this.dragClass); }
+		if(this.opacity < 1) { dojo.html.setOpacity(node, this.opacity); }
+		if(node.tagName.toLowerCase() == "tr"){
+			// dojo.debug("Dragging table row")
+			// Create a table for the cloned row
+			var doc = this.domNode.ownerDocument;
+			var table = doc.createElement("table");
+			var tbody = doc.createElement("tbody");
+			table.appendChild(tbody);
+			tbody.appendChild(node);
+
+			// Set a fixed width to the cloned TDs
+			var domTds = this.domNode.childNodes;
+			var cloneTds = node.childNodes;
+			for(var i = 0; i < domTds.length; i++){
+			    if((cloneTds[i])&&(cloneTds[i].style)){
+				    cloneTds[i].style.width = dojo.html.getContentBox(domTds[i]).width + "px";
+			    }
+			}
+			node = table;
+		}
+
+		if((dojo.render.html.ie55||dojo.render.html.ie60) && this.createIframe){
+			with(node.style) {
+				top="0px";
+				left="0px";
+			}
+			var outer = document.createElement("div");
+			outer.appendChild(node);
+			this.bgIframe = new dojo.html.BackgroundIframe(outer);
+			outer.appendChild(this.bgIframe.iframe);
+			node = outer;
+		}
+		node.style.zIndex = 999;
+
+		return node;
+	},
+
 	onDragStart: function(e){
 		dojo.html.clearSelection();
-		
-		this.scrollOffset = {
-			top: dojo.html.getScrollTop(), // document.documentElement.scrollTop,
-			left: dojo.html.getScrollLeft() // document.documentElement.scrollLeft
-		};
-	
-		this.dragStartPosition = {top: dojo.style.getAbsoluteY(this.domNode, true) + this.scrollOffset.top,
-			left: dojo.style.getAbsoluteX(this.domNode, true) + this.scrollOffset.left};
-		
 
-		this.dragOffset = {top: this.dragStartPosition.top - e.clientY,
-			left: this.dragStartPosition.left - e.clientX};
+		this.scrollOffset = dojo.html.getScroll().offset;
+		this.dragStartPosition = dojo.html.getAbsolutePosition(this.domNode, true);
 
-		this.dragClone = this.domNode.cloneNode(true);
-		//this.domNode.parentNode.replaceChild(this.dragClone, this.domNode);
+		this.dragOffset = {y: this.dragStartPosition.y - e.pageY,
+			x: this.dragStartPosition.x - e.pageX};
 
+		this.dragClone = this.createDragNode();
+
+		this.containingBlockPosition = this.domNode.offsetParent ? 
+			dojo.html.getAbsolutePosition(this.domNode.offsetParent, true) : {x:0, y:0};
 
- 		if ((this.domNode.parentNode.nodeName.toLowerCase() == 'body') || (dojo.style.getComputedStyle(this.domNode.parentNode,"position") == "static")) {
-			this.parentPosition = {top: 0, left: 0};
-		} else {
-			this.parentPosition = {top: dojo.style.getAbsoluteY(this.domNode.parentNode, true),
-				left: dojo.style.getAbsoluteX(this.domNode.parentNode,true)};
-		}
-	
 		if (this.constrainToContainer) {
 			this.constraints = this.getConstraints();
 		}
@@ -123,52 +167,69 @@
 		// set up for dragging
 		with(this.dragClone.style){
 			position = "absolute";
-			top = this.dragOffset.top + e.clientY + "px";
-			left = this.dragOffset.left + e.clientX + "px";
+			top = this.dragOffset.y + e.pageY + "px";
+			left = this.dragOffset.x + e.pageX + "px";
 		}
 
-		if(this.dragClass) { dojo.html.addClass(this.dragClone, this.dragClass); }
-		dojo.style.setOpacity(this.dragClone, this.opacity);
-		dojo.html.body().appendChild(this.dragClone);
+		dojo.body().appendChild(this.dragClone);
+
+		// shortly the browser will fire an onClick() event,
+		// but since this was really a drag, just squelch it
+		dojo.event.connect(this.domNode, "onclick", this, "squelchOnClick");
+
+		dojo.event.topic.publish('dragStart', { source: this } );
 	},
 
+	/** Return min/max x/y (relative to document.body) for this object) **/
 	getConstraints: function() {
-
 		if (this.constrainingContainer.nodeName.toLowerCase() == 'body') {
-			width = dojo.html.getViewportWidth();
-			height = dojo.html.getViewportHeight();
-			padLeft = 0;
-			padTop = 0;
+			var viewport = dojo.html.getViewport();
+			var width = viewport.width;
+			var height = viewport.height;
+			var x = 0;
+			var y = 0;
 		} else {
-			width = dojo.style.getContentWidth(this.constrainingContainer);
-			height = dojo.style.getContentHeight(this.constrainingContainer);	
-			padLeft = dojo.style.getPixelValue(this.constrainingContainer, "padding-left", true);
-			padTop = dojo.style.getPixelValue(this.constrainingContainer, "padding-top", true);
+			var content = dojo.html.getContentBox(this.constrainingContainer);
+			width = content.width;
+			height = content.height;
+			x =
+				this.containingBlockPosition.x +
+				dojo.html.getPixelValue(this.constrainingContainer, "padding-left", true) +
+				dojo.html.getBorderExtent(this.constrainingContainer, "left");
+			y =
+				this.containingBlockPosition.y +
+				dojo.html.getPixelValue(this.constrainingContainer, "padding-top", true) +
+				dojo.html.getBorderExtent(this.constrainingContainer, "top");
 		}
-
+		
+		var mb = dojo.html.getMarginBox(this.domNode);
 		return {
-			minX: padLeft,
-			minY: padTop,
-			maxX: padLeft+width - dojo.style.getOuterWidth(this.domNode),
-			maxY: padTop+height - dojo.style.getOuterHeight(this.domNode) 
+			minX: x,
+			minY: y,
+			maxX: x + width - mb.width,
+			maxY: y + height - mb.height
 		}
 	},
 
 	updateDragOffset: function() {
-		var sTop = dojo.html.getScrollTop(); // document.documentElement.scrollTop;
-		var sLeft = dojo.html.getScrollLeft(); // document.documentElement.scrollLeft;
-		if(sTop != this.scrollOffset.top) {
-			var diff = sTop - this.scrollOffset.top;
-			this.dragOffset.top += diff;
-			this.scrollOffset.top = sTop;
+		var scroll = dojo.html.getScroll().offset;
+		if(scroll.y != this.scrollOffset.y) {
+			var diff = scroll.y - this.scrollOffset.y;
+			this.dragOffset.y += diff;
+			this.scrollOffset.y = scroll.y;
+		}
+		if(scroll.x != this.scrollOffset.x) {
+			var diff = scroll.x - this.scrollOffset.x;
+			this.dragOffset.x += diff;
+			this.scrollOffset.x = scroll.x;
 		}
 	},
-	
+
 	/** Moves the node to follow the mouse */
 	onDragMove: function(e){
 		this.updateDragOffset();
-		var x = this.dragOffset.left + e.clientX - this.parentPosition.left;
-		var y = this.dragOffset.top + e.clientY - this.parentPosition.top;
+		var x = this.dragOffset.x + e.pageX;
+		var y = this.dragOffset.y + e.pageY;
 
 		if (this.constrainToContainer) {
 			if (x < this.constraints.minX) { x = this.constraints.minX; }
@@ -177,10 +238,21 @@
 			if (y > this.constraints.maxY) { y = this.constraints.maxY; }
 		}
 
+		this.setAbsolutePosition(x, y);
+
+		dojo.event.topic.publish('dragMove', { source: this } );
+	},
+
+	/**
+	 * Set the position of the drag clone.  (x,y) is relative to <body>.
+	 */
+	setAbsolutePosition: function(x, y){
+		// The drag clone is attached to document.body so this is trivial
 		if(!this.disableY) { this.dragClone.style.top = y + "px"; }
 		if(!this.disableX) { this.dragClone.style.left = x + "px"; }
 	},
 
+
 	/**
 	 * If the drag operation returned a success we reomve the clone of
 	 * ourself from the original position. If the drag operation returned
@@ -191,33 +263,43 @@
 		switch(e.dragStatus){
 
 			case "dropSuccess":
-				dojo.dom.removeNode(this.dragClone);
+				dojo.html.removeNode(this.dragClone);
 				this.dragClone = null;
 				break;
-		
+
 			case "dropFailure": // slide back to the start
-				var startCoords = [dojo.style.getAbsoluteX(this.dragClone), 
-							dojo.style.getAbsoluteY(this.dragClone)];
+				var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
 				// offset the end so the effect can be seen
-				var endCoords = [this.dragStartPosition.left + 1,
-					this.dragStartPosition.top + 1];
-	
+				var endCoords = { left: this.dragStartPosition.x + 1,
+					top: this.dragStartPosition.y + 1};
+
 				// animate
-				var line = new dojo.math.curves.Line(startCoords, endCoords);
-				var anim = new dojo.animation.Animation(line, 300, 0, 0);
+				var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 500, dojo.lfx.easeOut);
 				var dragObject = this;
-				dojo.event.connect(anim, "onAnimate", function(e) {
-					dragObject.dragClone.style.left = e.x + "px";
-					dragObject.dragClone.style.top = e.y + "px";
-				});
 				dojo.event.connect(anim, "onEnd", function (e) {
 					// pause for a second (not literally) and disappear
-					dojo.lang.setTimeout(dojo.dom.removeNode, 200,
-						dragObject.dragClone);
+					dojo.lang.setTimeout(function() {
+							dojo.html.removeNode(dragObject.dragClone);
+							// Allow drag clone to be gc'ed
+							dragObject.dragClone = null;
+						},
+						200);
 				});
 				anim.play();
 				break;
 		}
+
+		dojo.event.topic.publish('dragEnd', { source: this } );
+	},
+
+	squelchOnClick: function(e){
+		// squelch this onClick() event because it's the result of a drag (it's not a real click)
+		dojo.event.browser.stopEvent(e);
+
+		// disconnect after a short delay to prevent "Null argument to unrollAdvice()" warning
+		dojo.lang.setTimeout(function() {
+				dojo.event.disconnect(this.domNode, "onclick", this, "squelchOnClick");
+			},50);
 	},
 
 	constrainTo: function(container) {
@@ -228,51 +310,44 @@
 			this.constrainingContainer = this.domNode.parentNode;
 		}
 	}
+}, function(node, type){
+	this.domNode = dojo.byId(node);
+	this.type = type;
+	this.constrainToContainer = false;
+	this.dragSource = null;
 });
 
-dojo.dnd.HtmlDropTarget = function(node, types){
-	if (arguments.length == 0) { return; }
-	node = dojo.byId(node);
-	this.domNode = node;
-	dojo.dnd.DropTarget.call(this);
-	this.acceptedTypes = types || [];
-}
-dojo.inherits(dojo.dnd.HtmlDropTarget, dojo.dnd.DropTarget);
-
-dojo.lang.extend(dojo.dnd.HtmlDropTarget, {  
+dojo.declare("dojo.dnd.HtmlDropTarget", dojo.dnd.DropTarget, {
+	vertical: false,
 	onDragOver: function(e){
 		if(!this.accepts(e.dragObjects)){ return false; }
-		
+
 		// cache the positions of the child nodes
 		this.childBoxes = [];
 		for (var i = 0, child; i < this.domNode.childNodes.length; i++) {
 			child = this.domNode.childNodes[i];
-			if (child.nodeType != dojo.dom.ELEMENT_NODE) { continue; }
-			var top = dojo.style.getAbsoluteY(child);
-			var bottom = top + dojo.style.getInnerHeight(child);
-			var left = dojo.style.getAbsoluteX(child);
-			var right = left + dojo.style.getInnerWidth(child);
-			this.childBoxes.push({top: top, bottom: bottom,
-				left: left, right: right, node: child});
+			if (child.nodeType != dojo.html.ELEMENT_NODE) { continue; }
+			var pos = dojo.html.getAbsolutePosition(child, true);
+			var inner = dojo.html.getBorderBox(child);
+			this.childBoxes.push({top: pos.y, bottom: pos.y+inner.height,
+				left: pos.x, right: pos.x+inner.width, height: inner.height, 
+				width: inner.width, node: child});
 		}
-		
+
 		// TODO: use dummy node
-		
+
 		return true;
 	},
-	
-	_getNodeUnderMouse: function(e){
-		var mousex = e.pageX || e.clientX + dojo.html.body().scrollLeft;
-		var mousey = e.pageY || e.clientY + dojo.html.body().scrollTop;
 
+	_getNodeUnderMouse: function(e){
 		// find the child
 		for (var i = 0, child; i < this.childBoxes.length; i++) {
 			with (this.childBoxes[i]) {
-				if (mousex >= left && mousex <= right &&
-					mousey >= top && mousey <= bottom) { return i; }
+				if (e.pageX >= left && e.pageX <= right &&
+					e.pageY >= top && e.pageY <= bottom) { return i; }
 			}
 		}
-		
+
 		return -1;
 	},
 
@@ -280,60 +355,103 @@
 		this.dropIndicator = document.createElement("div");
 		with (this.dropIndicator.style) {
 			position = "absolute";
-			zIndex = 1;
-			borderTopWidth = "1px";
-			borderTopColor = "black";
-			borderTopStyle = "solid";
-			width = dojo.style.getInnerWidth(this.domNode) + "px";
-			left = dojo.style.getAbsoluteX(this.domNode) + "px";
+			zIndex = 999;
+			if(this.vertical){
+				borderLeftWidth = "1px";
+				borderLeftColor = "black";
+				borderLeftStyle = "solid";
+				height = dojo.html.getBorderBox(this.domNode).height + "px";
+				top = dojo.html.getAbsolutePosition(this.domNode, true).y + "px";
+			}else{
+				borderTopWidth = "1px";
+				borderTopColor = "black";
+				borderTopStyle = "solid";
+				width = dojo.html.getBorderBox(this.domNode).width + "px";
+				left = dojo.html.getAbsolutePosition(this.domNode, true).x + "px";
+			}
 		}
 	},
-	
+
 	onDragMove: function(e, dragObjects){
 		var i = this._getNodeUnderMouse(e);
-		
+
 		if(!this.dropIndicator){
 			this.createDropIndicator();
 		}
 
+		var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
+		var hide = false;
 		if(i < 0) {
 			if(this.childBoxes.length) {
-				var before = (dojo.html.gravity(this.childBoxes[0].node, e) & dojo.html.gravity.NORTH);
+				var before = (dojo.html.gravity(this.childBoxes[0].node, e) & gravity);
+				if(before){ hide = true; }
 			} else {
 				var before = true;
 			}
 		} else {
 			var child = this.childBoxes[i];
-			var before = (dojo.html.gravity(child.node, e) & dojo.html.gravity.NORTH);
+			var before = (dojo.html.gravity(child.node, e) & gravity);
+			if(child.node === dragObjects[0].dragSource.domNode){
+				hide = true;
+			}else{
+				var currentPosChild = before ? 
+						(i>0?this.childBoxes[i-1]:child) : 
+						(i<this.childBoxes.length-1?this.childBoxes[i+1]:child);
+				if(currentPosChild.node === dragObjects[0].dragSource.domNode){
+					hide = true;
+				}
+			}
 		}
+
+		if(hide){
+			this.dropIndicator.style.display="none";
+			return;
+		}else{
+			this.dropIndicator.style.display="";
+		}
+
 		this.placeIndicator(e, dragObjects, i, before);
 
 		if(!dojo.html.hasParent(this.dropIndicator)) {
-			dojo.html.body().appendChild(this.dropIndicator);
+			dojo.body().appendChild(this.dropIndicator);
 		}
 	},
 
+	/**
+	 * Position the horizontal line that indicates "insert between these two items"
+	 */
 	placeIndicator: function(e, dragObjects, boxIndex, before) {
-		with(this.dropIndicator.style){
-			if (boxIndex < 0) {
-				if (this.childBoxes.length) {
-					top = (before ? this.childBoxes[0].top
-						: this.childBoxes[this.childBoxes.length - 1].bottom) + "px";
-				} else {
-					top = dojo.style.getAbsoluteY(this.domNode) + "px";
-				}
+		var targetProperty = this.vertical ? "left" : "top";
+		var child;
+		if (boxIndex < 0) {
+			if (this.childBoxes.length) {
+				child = before ? this.childBoxes[0]
+					: this.childBoxes[this.childBoxes.length - 1];
 			} else {
-				var child = this.childBoxes[boxIndex];
-				top = (before ? child.top : child.bottom) + "px";
+				this.dropIndicator.style[targetProperty] = dojo.html.getAbsolutePosition(this.domNode, true)[this.vertical?"x":"y"] + "px";
+			}
+		} else {
+			child = this.childBoxes[boxIndex];
+		}
+		if(child){
+			this.dropIndicator.style[targetProperty] = (before ? child[targetProperty] : child[this.vertical?"right":"bottom"]) + "px";
+			if(this.vertical){
+				this.dropIndicator.style.height = child.height + "px";
+				this.dropIndicator.style.top = child.top + "px";
+			}else{
+				this.dropIndicator.style.width = child.width + "px";
+				this.dropIndicator.style.left = child.left + "px";
 			}
 		}
 	},
 
 	onDragOut: function(e) {
-		dojo.dom.removeNode(this.dropIndicator);
-		delete this.dropIndicator;
+		if(this.dropIndicator) {
+			dojo.html.removeNode(this.dropIndicator);
+			delete this.dropIndicator;
+		}
 	},
-	
+
 	/**
 	 * Inserts the DragObject as a child of this node relative to the
 	 * position of the mouse.
@@ -342,12 +460,13 @@
 	 */
 	onDrop: function(e){
 		this.onDragOut(e);
-		
+
 		var i = this._getNodeUnderMouse(e);
 
+		var gravity = this.vertical ? dojo.html.gravity.WEST : dojo.html.gravity.NORTH;
 		if (i < 0) {
 			if (this.childBoxes.length) {
-				if (dojo.html.gravity(this.childBoxes[0].node, e) & dojo.html.gravity.NORTH) {
+				if (dojo.html.gravity(this.childBoxes[0].node, e) & gravity) {
 					return this.insert(e, this.childBoxes[0].node, "before");
 				} else {
 					return this.insert(e, this.childBoxes[this.childBoxes.length-1].node, "after");
@@ -355,9 +474,9 @@
 			}
 			return this.insert(e, this.domNode, "append");
 		}
-		
+
 		var child = this.childBoxes[i];
-		if (dojo.html.gravity(child.node, e) & dojo.html.gravity.NORTH) {
+		if (dojo.html.gravity(child.node, e) & gravity) {
 			return this.insert(e, child.node, "before");
 		} else {
 			return this.insert(e, child.node, "after");
@@ -378,4 +497,12 @@
 
 		return false;
 	}
+}, function(node, types){
+	if (arguments.length == 0) { return; }
+	this.domNode = dojo.byId(node);
+	dojo.dnd.DropTarget.call(this);
+	if(types && dojo.lang.isString(types)) {
+		types = [types];
+	}
+	this.acceptedTypes = types || [];
 });

Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,85 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.dnd.HtmlDragCopy");
+dojo.require("dojo.dnd.*");
+
+dojo.declare("dojo.dnd.HtmlDragCopySource", dojo.dnd.HtmlDragSource,
+function(node, type, copyOnce){
+		this.copyOnce = copyOnce;
+		this.makeCopy = true;
+},
+{
+	onDragStart: function(){
+		var dragObj = new dojo.dnd.HtmlDragCopyObject(this.dragObject, this.type, this);
+		if(this.dragClass) { dragObj.dragClass = this.dragClass; }
+
+		if (this.constrainToContainer) {
+			dragObj.constrainTo(this.constrainingContainer || this.domNode.parentNode);
+		}
+
+		return dragObj;
+	},
+	onSelected: function() {
+		for (var i=0; i<this.dragObjects.length; i++) {
+			dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragCopySource(this.dragObjects[i]));
+		}
+	}
+});
+
+dojo.declare("dojo.dnd.HtmlDragCopyObject", dojo.dnd.HtmlDragObject,
+function(dragObject, type, source){
+		this.copySource = source;
+},
+{
+	onDragStart: function(e) {
+		dojo.dnd.HtmlDragCopyObject.superclass.onDragStart.apply(this, arguments);
+		if(this.copySource.makeCopy) {
+			this.sourceNode = this.domNode;
+			this.domNode    = this.domNode.cloneNode(true);
+		}
+	},
+	onDragEnd: function(e){
+		switch(e.dragStatus){
+			case "dropFailure": // slide back to the start
+				var startCoords = dojo.html.getAbsolutePosition(this.dragClone, true);
+				// offset the end so the effect can be seen
+				var endCoords = { left: this.dragStartPosition.x + 1,
+					top: this.dragStartPosition.y + 1};
+
+				// animate
+				var anim = dojo.lfx.slideTo(this.dragClone, endCoords, 500, dojo.lfx.easeOut);
+				var dragObject = this;
+				dojo.event.connect(anim, "onEnd", function (e) {
+					// pause for a second (not literally) and disappear
+					dojo.lang.setTimeout(function() {
+							dojo.html.removeNode(dragObject.dragClone);
+							dragObject.dragClone = null;
+							if(dragObject.copySource.makeCopy) {
+								dojo.html.removeNode(dragObject.domNode);
+								dragObject.domNode = dragObject.sourceNode;
+								dragObject.sourceNode = null;
+							}
+						},
+						200);
+				});
+				anim.play();
+				dojo.event.topic.publish('dragEnd', { source: this } );
+				return;
+		}
+		dojo.dnd.HtmlDragCopyObject.superclass.onDragEnd.apply(this, arguments);
+		this.copySource.dragObject = this.domNode;
+		if(this.copySource.copyOnce){
+			this.copySource.makeCopy = false;
+		}
+		new dojo.dnd.HtmlDragCopySource(this.sourceNode, this.type, this.copySource.copyOnce);
+		this.sourceNode = null;
+	}
+});

Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragCopy.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragManager.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragManager.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragManager.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragManager.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the
@@ -9,19 +9,15 @@
 */
 
 dojo.provide("dojo.dnd.HtmlDragManager");
+dojo.require("dojo.dnd.DragAndDrop");
 dojo.require("dojo.event.*");
-dojo.require("dojo.lang");
-dojo.require("dojo.html");
-dojo.require("dojo.style");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.html.common");
+dojo.require("dojo.html.layout");
 
 // NOTE: there will only ever be a single instance of HTMLDragManager, so it's
 // safe to use prototype properties for book-keeping.
-dojo.dnd.HtmlDragManager = function(){
-}
-
-dojo.inherits(dojo.dnd.HtmlDragManager, dojo.dnd.DragManager);
-
-dojo.lang.extend(dojo.dnd.HtmlDragManager, {
+dojo.declare("dojo.dnd.HtmlDragManager", dojo.dnd.DragManager, {
 	/**
 	 * There are several sets of actions that the DnD code cares about in the
 	 * HTML context:
@@ -66,7 +62,7 @@
 	dropTargetDimensions: [],
 
 	currentDropTarget: null,
-	currentDropTargetPoints: null,
+	// currentDropTargetPoints: null,
 	previousDropTarget: null,
 	_dragTriggered: false,
 
@@ -84,28 +80,52 @@
 
 	dropAcceptable: false,
 
+	cancelEvent: function(e){ e.stopPropagation(); e.preventDefault();},
+
 	// method over-rides
 	registerDragSource: function(ds){
+		//dojo.profile.start("register DragSource");
+
 		if(ds["domNode"]){
 			// FIXME: dragSource objects SHOULD have some sort of property that
 			// references their DOM node, we shouldn't just be passing nodes and
 			// expecting it to work.
+			//dojo.profile.start("register DragSource 1");
 			var dp = this.dsPrefix;
 			var dpIdx = dp+"Idx_"+(this.dsCounter++);
 			ds.dragSourceId = dpIdx;
 			this.dragSources[dpIdx] = ds;
 			ds.domNode.setAttribute(dp, dpIdx);
+			//dojo.profile.end("register DragSource 1");
+
+			//dojo.profile.start("register DragSource 2");
+
+			// so we can drag links
+			if(dojo.render.html.ie){
+				//dojo.profile.start("register DragSource IE");
+				
+				dojo.event.browser.addListener(ds.domNode, "ondragstart", this.cancelEvent);
+				// terribly slow
+				//dojo.event.connect(ds.domNode, "ondragstart", this.cancelEvent);
+				//dojo.profile.end("register DragSource IE");
+
+			}
+			//dojo.profile.end("register DragSource 2");
+
 		}
+		//dojo.profile.end("register DragSource");
 	},
 
 	unregisterDragSource: function(ds){
 		if (ds["domNode"]){
-
 			var dp = this.dsPrefix;
 			var dpIdx = ds.dragSourceId;
 			delete ds.dragSourceId;
 			delete this.dragSources[dpIdx];
 			ds.domNode.setAttribute(dp, null);
+			if(dojo.render.html.ie){
+				dojo.event.browser.removeListener(ds.domNode, "ondragstart", this.cancelEvent);			
+			}
 		}
 	},
 
@@ -113,13 +133,28 @@
 		this.dropTargets.push(dt);
 	},
 
+	unregisterDropTarget: function(dt){
+		var index = dojo.lang.find(this.dropTargets, dt, true);
+		if (index>=0) {
+			this.dropTargets.splice(index, 1);
+		}
+	},
+
+	/**
+	* Get the DOM element that is meant to drag.
+	* Loop through the parent nodes of the event target until
+	* the element is found that was created as a DragSource and 
+	* return it.
+	*
+	* @param event object The event for which to get the drag source.
+	*/
 	getDragSource: function(e){
 		var tn = e.target;
-		if(tn === dojo.html.body()){ return; }
+		if(tn === dojo.body()){ return; }
 		var ta = dojo.html.getAttribute(tn, this.dsPrefix);
 		while((!ta)&&(tn)){
 			tn = tn.parentNode;
-			if((!tn)||(tn === dojo.html.body())){ return; }
+			if((!tn)||(tn === dojo.body())){ return; }
 			ta = dojo.html.getAttribute(tn, this.dsPrefix);
 		}
 		return this.dragSources[ta];
@@ -131,85 +166,148 @@
 	onMouseDown: function(e){
 		if(this.disabled) { return; }
 
-		this.mouseDownX = e.clientX;
-		this.mouseDownY = e.clientY;
+		// only begin on left click
+		if(dojo.render.html.ie) {
+			if(e.button != 1) { return; }
+		} else if(e.which != 1) {
+			return;
+		}
 
-		var target = e.target.nodeType == dojo.dom.TEXT_NODE ?
+		var target = e.target.nodeType == dojo.html.TEXT_NODE ?
 			e.target.parentNode : e.target;
 
 		// do not start drag involvement if the user is interacting with
 		// a form element.
-		switch(target.tagName.toLowerCase()) {
-			case "a": case "button": case "textarea":
-			case "input":
-				return;
+		if(dojo.html.isTag(target, "button", "textarea", "input", "select", "option")) {
+			return;
 		}
-		
+
 		// find a selection object, if one is a parent of the source node
 		var ds = this.getDragSource(e);
+		
+		// this line is important.  if we aren't selecting anything then
+		// we need to return now, so preventDefault() isn't called, and thus
+		// the event is propogated to other handling code
 		if(!ds){ return; }
+
 		if(!dojo.lang.inArray(this.selectedSources, ds)){
 			this.selectedSources.push(ds);
+			ds.onSelected();
 		}
-		
+
+ 		this.mouseDownX = e.pageX;
+ 		this.mouseDownY = e.pageY;
+
+		// Must stop the mouse down from being propogated, or otherwise can't
+		// drag links in firefox.
 		// WARNING: preventing the default action on all mousedown events
 		// prevents user interaction with the contents.
 		e.preventDefault();
-		
+
 		dojo.event.connect(document, "onmousemove", this, "onMouseMove");
 	},
 
-	onMouseUp: function(e){
+	onMouseUp: function(e, cancel){
+		// if we aren't dragging then ignore the mouse-up
+		// (in particular, don't call preventDefault(), because other
+		// code may need to process this event)
+		if(this.selectedSources.length==0){
+			return;
+		}
+
 		this.mouseDownX = null;
 		this.mouseDownY = null;
 		this._dragTriggered = false;
-		var _this = this;
+ 		// e.preventDefault();
 		e.dragSource = this.dragSource;
-		if((!e.shiftKey)&&(!e.ctrlKey)){
+		// let ctrl be used for multiselect or another action
+		// if I use same key to trigger treeV3 node selection and here,
+		// I have bugs with drag'n'drop. why ?? no idea..
+		if((!e.shiftKey)&&(!e.ctrlKey)){ 
+		//if(!e.shiftKey){
+			if(this.currentDropTarget) {
+				this.currentDropTarget.onDropStart();
+			}
 			dojo.lang.forEach(this.dragObjects, function(tempDragObj){
 				var ret = null;
 				if(!tempDragObj){ return; }
-				if(_this.currentDropTarget) {
+				if(this.currentDropTarget) {
 					e.dragObject = tempDragObj;
-	
+
 					// NOTE: we can't get anything but the current drop target
 					// here since the drag shadow blocks mouse-over events.
 					// This is probelematic for dropping "in" something
-					var ce = _this.currentDropTarget.domNode.childNodes;
+					var ce = this.currentDropTarget.domNode.childNodes;
 					if(ce.length > 0){
 						e.dropTarget = ce[0];
 						while(e.dropTarget == tempDragObj.domNode){
 							e.dropTarget = e.dropTarget.nextSibling;
 						}
 					}else{
-						e.dropTarget = _this.currentDropTarget.domNode;
+						e.dropTarget = this.currentDropTarget.domNode;
 					}
-					if (_this.dropAcceptable){
-						ret = _this.currentDropTarget.onDrop(e);
-					} else {
-						 _this.currentDropTarget.onDragOut(e);
+					if(this.dropAcceptable){
+						ret = this.currentDropTarget.onDrop(e);
+					}else{
+						 this.currentDropTarget.onDragOut(e);
 					}
 				}
-				
-				e.dragStatus = _this.dropAcceptable && ret ? "dropSuccess" : "dropFailure";
-				tempDragObj.onDragEnd(e);
-			});
-						
+
+				e.dragStatus = this.dropAcceptable && ret ? "dropSuccess" : "dropFailure";
+				// decouple the calls for onDragEnd, so they don't block the execution here
+				// ie. if the onDragEnd would call an alert, the execution here is blocked until the
+				// user has confirmed the alert box and then the rest of the dnd code is executed
+				// while the mouse doesnt "hold" the dragged object anymore ... and so on
+				dojo.lang.delayThese([
+					function() {
+						// in FF1.5 this throws an exception, see 
+						// http://dojotoolkit.org/pipermail/dojo-interest/2006-April/006751.html
+						try{
+							tempDragObj.dragSource.onDragEnd(e)
+						} catch(err) {
+							// since the problem seems passing e, we just copy all 
+							// properties and try the copy ...
+							var ecopy = {};
+							for (var i in e) {
+								if (i=="type") { // the type property contains the exception, no idea why...
+									ecopy.type = "mouseup";
+									continue;
+								}
+								ecopy[i] = e[i];
+							}
+							tempDragObj.dragSource.onDragEnd(ecopy);
+						}
+					}
+					, function() {tempDragObj.onDragEnd(e)}]);
+			}, this);
+
 			this.selectedSources = [];
 			this.dragObjects = [];
 			this.dragSource = null;
+			if(this.currentDropTarget) {
+				this.currentDropTarget.onDropEnd();
+			}
+		} else {
+			//dojo.debug("special click");
 		}
+
 		dojo.event.disconnect(document, "onmousemove", this, "onMouseMove");
 		this.currentDropTarget = null;
-		this.currentDropTargetPoints = null;
 	},
 
-	scrollBy: function(x, y) {
+	onScroll: function(){
+		//dojo.profile.start("DNDManager updateoffset");
 		for(var i = 0; i < this.dragObjects.length; i++) {
 			if(this.dragObjects[i].updateDragOffset) {
 				this.dragObjects[i].updateDragOffset();
 			}
 		}
+		//dojo.profile.end("DNDManager updateoffset");
+
+		// TODO: do not recalculate, only adjust coordinates
+		if (this.dragObjects.length) {
+			this.cacheTargetLocations();
+		}
 	},
 
 	_dragStartDistance: function(x, y){
@@ -223,26 +321,60 @@
 		return parseInt(Math.sqrt(dx2+dy2), 10);
 	},
 
+	cacheTargetLocations: function(){
+		dojo.profile.start("cacheTargetLocations");
+
+		this.dropTargetDimensions = [];
+		dojo.lang.forEach(this.dropTargets, function(tempTarget){
+			var tn = tempTarget.domNode;
+			//only cache dropTarget which can accept current dragSource
+			if(!tn || dojo.lang.find(tempTarget.acceptedTypes, this.dragSource.type) < 0){ return; }
+			var abs = dojo.html.getAbsolutePosition(tn, true);
+			var bb = dojo.html.getBorderBox(tn);
+			this.dropTargetDimensions.push([
+				[abs.x, abs.y],	// upper-left
+				// lower-right
+				[ abs.x+bb.width, abs.y+bb.height ],
+				tempTarget
+			]);
+			//dojo.debug("Cached for "+tempTarget)
+		}, this);
+
+		dojo.profile.end("cacheTargetLocations");
+
+		//dojo.debug("Cache locations")
+	},
+
 	onMouseMove: function(e){
-		var _this = this;
+		if((dojo.render.html.ie)&&(e.button != 1)){
+			// Oooops - mouse up occurred - e.g. when mouse was not over the
+			// window. I don't think we can detect this for FF - but at least
+			// we can be nice in IE.
+			this.currentDropTarget = null;
+			this.onMouseUp(e, true);
+			return;
+		}
+
 		// if we've got some sources, but no drag objects, we need to send
 		// onDragStart to all the right parties and get things lined up for
 		// drop target detection
+
 		if(	(this.selectedSources.length)&&
 			(!this.dragObjects.length) ){
 			var dx;
 			var dy;
 			if(!this._dragTriggered){
-				this._dragTriggered = (this._dragStartDistance(e.clientX, e.clientY) > this.threshold);
+				this._dragTriggered = (this._dragStartDistance(e.pageX, e.pageY) > this.threshold);
 				if(!this._dragTriggered){ return; }
-				dx = e.clientX-this.mouseDownX;
-				dy = e.clientY-this.mouseDownY;
-			}
-		
-			if (this.selectedSources.length == 1) {
-				this.dragSource = this.selectedSources[0];
+				dx = e.pageX - this.mouseDownX;
+				dy = e.pageY - this.mouseDownY;
 			}
 
+			// the first element is always our dragSource, if there are multiple
+			// selectedSources (elements that move along) then the first one is the master
+			// and for it the events will be fired etc.
+			this.dragSource = this.selectedSources[0];
+			
 			dojo.lang.forEach(this.selectedSources, function(tempSource){
 				if(!tempSource){ return; }
 				var tdo = tempSource.onDragStart(e);
@@ -250,35 +382,36 @@
 					tdo.onDragStart(e);
 
 					// "bump" the drag object to account for the drag threshold
-					tdo.dragOffset.top += dy;
-					tdo.dragOffset.left += dx;
+					tdo.dragOffset.y += dy;
+					tdo.dragOffset.x += dx;
+					tdo.dragSource = tempSource;
 
-					_this.dragObjects.push(tdo);
+					this.dragObjects.push(tdo);
 				}
-			});
+			}, this);
 
-			this.dropTargetDimensions = [];
-			dojo.lang.forEach(this.dropTargets, function(tempTarget){
-				var tn = tempTarget.domNode;
-				if(!tn){ return; }
-				var ttx = dojo.style.getAbsoluteX(tn, true);
-				var tty = dojo.style.getAbsoluteY(tn, true);
-				_this.dropTargetDimensions.push([
-					[ttx, tty],	// upper-left
-					// lower-right
-					[ ttx+dojo.style.getInnerWidth(tn), tty+dojo.style.getInnerHeight(tn) ],
-					tempTarget
-				]);
-			});
+			/* clean previous drop target in dragStart */
+			this.previousDropTarget = null;
+
+			this.cacheTargetLocations();
 		}
+
 		// FIXME: we need to add dragSources and dragObjects to e
-		for (var i = 0; i < this.dragObjects.length; i++){
-			if(this.dragObjects[i]){ this.dragObjects[i].onDragMove(e); }
-		}
+		dojo.lang.forEach(this.dragObjects, function(dragObj){
+			if(dragObj){ dragObj.onDragMove(e); }
+		});
 
 		// if we have a current drop target, check to see if we're outside of
 		// it. If so, do all the actions that need doing.
-		var dtp = this.currentDropTargetPoints;
+		if(this.currentDropTarget){
+			//dojo.debug(dojo.html.hasParent(this.currentDropTarget.domNode))
+			var c = dojo.html.toCoordinateObject(this.currentDropTarget.domNode, true);
+			//		var dtp = this.currentDropTargetPoints;
+			var dtp = [
+				[c.x,c.y], [c.x+c.width, c.y+c.height]
+			];
+		}
+
 		if((!this.nestedTargets)&&(dtp)&&(this.isInsideBox(e, dtp))){
 			if(this.dropAcceptable){
 				this.currentDropTarget.onDragMove(e, this.dragObjects);
@@ -288,22 +421,24 @@
 			// see if we can find a better drop target
 			var bestBox = this.findBestTarget(e);
 
-			if(bestBox.target == null){
+			if(bestBox.target === null){
 				if(this.currentDropTarget){
 					this.currentDropTarget.onDragOut(e);
+					this.previousDropTarget = this.currentDropTarget;
 					this.currentDropTarget = null;
-					this.currentDropTargetPoints = null;
+					// this.currentDropTargetPoints = null;
 				}
 				this.dropAcceptable = false;
 				return;
 			}
 
-			if(this.currentDropTarget != bestBox.target){
+			if(this.currentDropTarget !== bestBox.target){
 				if(this.currentDropTarget){
+					this.previousDropTarget = this.currentDropTarget;
 					this.currentDropTarget.onDragOut(e);
 				}
 				this.currentDropTarget = bestBox.target;
-				this.currentDropTargetPoints = bestBox.points;
+				// this.currentDropTargetPoints = bestBox.points;
 				e.dragObjects = this.dragObjects;
 				this.dropAcceptable = this.currentDropTarget.onDragOver(e);
 
@@ -312,31 +447,33 @@
 					this.currentDropTarget.onDragMove(e, this.dragObjects);
 				}
 			}
-
 		}
 	},
-    
+
 	findBestTarget: function(e) {
 		var _this = this;
 		var bestBox = new Object();
 		bestBox.target = null;
 		bestBox.points = null;
-		dojo.lang.forEach(this.dropTargetDimensions, function(tmpDA) {
-			if(_this.isInsideBox(e, tmpDA)){
-				bestBox.target = tmpDA[2];
-				bestBox.points = tmpDA;
-				if(!_this.nestedTargets){ return "break"; }
+		dojo.lang.every(this.dropTargetDimensions, function(tmpDA) {
+			if(!_this.isInsideBox(e, tmpDA)){
+				return true;
 			}
+
+			bestBox.target = tmpDA[2];
+			bestBox.points = tmpDA;
+			// continue iterating only if _this.nestedTargets == true
+			return Boolean(_this.nestedTargets);
 		});
 
 		return bestBox;
 	},
 
 	isInsideBox: function(e, coords){
-		if(	(e.clientX > coords[0][0])&&
-			(e.clientX < coords[1][0])&&
-			(e.clientY > coords[0][1])&&
-			(e.clientY < coords[1][1]) ){
+		if(	(e.pageX > coords[0][0])&&
+			(e.pageX < coords[1][0])&&
+			(e.pageY > coords[0][1])&&
+			(e.pageY < coords[1][1]) ){
 			return true;
 		}
 		return false;
@@ -344,7 +481,7 @@
 
 	onMouseOver: function(e){
 	},
-	
+
 	onMouseOut: function(e){
 	}
 });
@@ -355,11 +492,14 @@
 (function(){
 	var d = document;
 	var dm = dojo.dnd.dragManager;
-	// set up event handlers on the document
-	dojo.event.connect(d, "onkeydown", 		dm, "onKeyDown");
-	dojo.event.connect(d, "onmouseover",	dm, "onMouseOver");
-	dojo.event.connect(d, "onmouseout", 	dm, "onMouseOut");
-	dojo.event.connect(d, "onmousedown",	dm, "onMouseDown");
-	dojo.event.connect(d, "onmouseup",		dm, "onMouseUp");
-	dojo.event.connect(window, "scrollBy",	dm, "scrollBy");
+	//TODO: when focus manager is ready, dragManager should be rewritten to use it
+	// set up event handlers on the document (or no?)
+	dojo.event.connect(d, "onkeydown", dm, "onKeyDown");
+	dojo.event.connect(d, "onmouseover", dm, "onMouseOver");
+	dojo.event.connect(d, "onmouseout", dm, "onMouseOut");
+	dojo.event.connect(d, "onmousedown", dm, "onMouseDown");
+	dojo.event.connect(d, "onmouseup", dm, "onMouseUp");
+	// TODO: process scrolling of elements, not only window (focus manager would 
+	// probably come to rescue here as well)
+	dojo.event.connect(window, "onscroll", dm, "onScroll");
 })();

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/HtmlDragMove.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the
@@ -9,66 +9,58 @@
 */
 
 dojo.provide("dojo.dnd.HtmlDragMove");
-dojo.provide("dojo.dnd.HtmlDragMoveSource");
-dojo.provide("dojo.dnd.HtmlDragMoveObject");
 dojo.require("dojo.dnd.*");
 
-dojo.dnd.HtmlDragMoveSource = function(node, type){
-	dojo.dnd.HtmlDragSource.call(this, node, type);
-}
-
-dojo.inherits(dojo.dnd.HtmlDragMoveSource, dojo.dnd.HtmlDragSource);
-
-dojo.lang.extend(dojo.dnd.HtmlDragMoveSource, {
+dojo.declare("dojo.dnd.HtmlDragMoveSource", dojo.dnd.HtmlDragSource, {
 	onDragStart: function(){
 		var dragObj =  new dojo.dnd.HtmlDragMoveObject(this.dragObject, this.type);
-
 		if (this.constrainToContainer) {
 			dragObj.constrainTo(this.constrainingContainer);
 		}
 		return dragObj;
+	},
+	/*
+	 * see dojo.dnd.HtmlDragSource.onSelected
+	 */
+	onSelected: function() {
+		for (var i=0; i<this.dragObjects.length; i++) {
+			dojo.dnd.dragManager.selectedSources.push(new dojo.dnd.HtmlDragMoveSource(this.dragObjects[i]));
+		}
 	}
 });
 
-dojo.dnd.HtmlDragMoveObject = function(node, type){
-	dojo.dnd.HtmlDragObject.call(this, node, type);
-}
-
-dojo.inherits(dojo.dnd.HtmlDragMoveObject, dojo.dnd.HtmlDragObject);
-
-dojo.lang.extend(dojo.dnd.HtmlDragMoveObject, {
+dojo.declare("dojo.dnd.HtmlDragMoveObject", dojo.dnd.HtmlDragObject, {
 	onDragEnd: function(e){
-		delete this.dragClone;
+		// shortly the browser will fire an onClick() event,
+		// but since this was really a drag, just squelch it
+		dojo.event.connect(this.domNode, "onclick", this, "squelchOnClick");
 	},
-	
 	onDragStart: function(e){
 		dojo.html.clearSelection();
-		
-		this.dragClone = this.domNode;
 
-		this.scrollOffset = {
-			top: dojo.html.getScrollTop(), // document.documentElement.scrollTop,
-			left: dojo.html.getScrollLeft() // document.documentElement.scrollLeft
-		};
+		this.dragClone = this.domNode;
 
-		this.dragStartPosition = {top: dojo.style.getAbsoluteY(this.domNode) ,
-			left: dojo.style.getAbsoluteX(this.domNode) };
+		this.scrollOffset = dojo.html.getScroll().offset;
+		this.dragStartPosition = dojo.html.abs(this.domNode, true);
 		
-		this.dragOffset = {top: this.dragStartPosition.top - e.clientY,
-			left: this.dragStartPosition.left - e.clientX};
+		this.dragOffset = {y: this.dragStartPosition.y - e.pageY,
+			x: this.dragStartPosition.x - e.pageX};
 
-		if (this.domNode.parentNode.nodeName.toLowerCase() == 'body') {
-			this.parentPosition = {top: 0, left: 0};
-		} else {
-			this.parentPosition = {top: dojo.style.getAbsoluteY(this.domNode.parentNode, true),
-				left: dojo.style.getAbsoluteX(this.domNode.parentNode,true)};
-		}
+		this.containingBlockPosition = this.domNode.offsetParent ? 
+			dojo.html.abs(this.domNode.offsetParent, true) : {x:0, y:0};
 
 		this.dragClone.style.position = "absolute";
 
 		if (this.constrainToContainer) {
 			this.constraints = this.getConstraints();
 		}
+	},
+	/**
+	 * Set the position of the drag node.  (x,y) is relative to <body>.
+	 */
+	setAbsolutePosition: function(x, y){
+		// The drag clone is attached to it's constraining container so offset for that
+		if(!this.disableY) { this.domNode.style.top = (y-this.containingBlockPosition.y) + "px"; }
+		if(!this.disableX) { this.domNode.style.left = (x-this.containingBlockPosition.x) + "px"; }
 	}
-
 });

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/Sortable.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDrop.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the
@@ -17,10 +17,12 @@
 */
 
 dojo.provide("dojo.dnd.TreeDragAndDrop");
-dojo.provide("dojo.dnd.TreeDragSource");
-dojo.provide("dojo.dnd.TreeDropTarget");
 
 dojo.require("dojo.dnd.HtmlDragAndDrop");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.html.layout");
 
 dojo.dnd.TreeDragSource = function(node, syncController, type, treeNode){
 	this.controller = syncController;
@@ -49,11 +51,12 @@
 
 			var result = dojo.dnd.HtmlDragObject.prototype.onDragStart.apply(this, arguments);
 
+
 			/* remove background grid from cloned object */
-			dojo.lang.forEach(
-				this.dragClone.getElementsByTagName('img'),
-				function(elem) { elem.style.backgroundImage='' }
-			);
+			var cloneGrid = this.dragClone.getElementsByTagName('img');
+			for(var i=0; i<cloneGrid.length; i++) {
+				cloneGrid.item(i).style.backgroundImage='url()';
+			}
 
 			return result;
 
@@ -88,93 +91,385 @@
 
 // .......................................
 
-dojo.dnd.TreeDropTarget = function(node, syncController, type, treeNode){
+dojo.dnd.TreeDropTarget = function(domNode, controller, type, treeNode){
 
 	this.treeNode = treeNode;
-	this.controller = syncController; // I will sync-ly process drops
-
-	dojo.dnd.HtmlDropTarget.apply(this, [node, type]);
-
+	this.controller = controller; // I will sync-ly process drops
+	
+	dojo.dnd.HtmlDropTarget.apply(this, [domNode, type]);
 }
 
 dojo.inherits(dojo.dnd.TreeDropTarget, dojo.dnd.HtmlDropTarget);
 
 dojo.lang.extend(dojo.dnd.TreeDropTarget, {
 
+	autoExpandDelay: 1500,
+	autoExpandTimer: null,
+
+
+	position: null,
+
+	indicatorStyle: "2px black solid",
+
+	showIndicator: function(position) {
+
+		// do not change style too often, cause of blinking possible
+		if (this.position == position) {
+			return;
+		}
+
+		//dojo.debug(position)
+
+		this.hideIndicator();
+
+		this.position = position;
+
+		if (position == "before") {
+			this.treeNode.labelNode.style.borderTop = this.indicatorStyle;
+		} else if (position == "after") {
+			this.treeNode.labelNode.style.borderBottom = this.indicatorStyle;
+		} else if (position == "onto") {
+			this.treeNode.markSelected();
+		}
+
+
+	},
+
+	hideIndicator: function() {
+		this.treeNode.labelNode.style.borderBottom="";
+		this.treeNode.labelNode.style.borderTop="";
+		this.treeNode.unMarkSelected();
+		this.position = null;
+	},
+
+
+
+	// is the target possibly ok ?
+	// This function is run on dragOver, but drop possibility is also determined by position over node
+	// that's why acceptsWithPosition is called
+	// doesnt take index into account ( can change while moving mouse w/o changing target )
+
+
 	/**
-	 * Check if I can drop sourceTreeNode here
-	 * only tree node targets are implemented ATM
+	 * Coarse (tree-level) access check.
+	 * We can't determine real accepts status w/o position
 	*/
 	onDragOver: function(e){
+//dojo.debug("onDragOver for "+e);
 
-		var sourceTreeNode = e.dragObjects[0].treeNode;
 
+		var accepts = dojo.dnd.HtmlDropTarget.prototype.onDragOver.apply(this, arguments);
 
-		if (dojo.lang.isUndefined(sourceTreeNode) || !sourceTreeNode || sourceTreeNode.widgetType != 'EditorTreeNode') {
-			dojo.raise("Source is not of EditorTreeNode widgetType or not found");
+		//dojo.debug("TreeDropTarget.onDragOver accepts:"+accepts)
+
+		if (accepts && this.treeNode.isFolder && !this.treeNode.isExpanded) {
+			this.setAutoExpandTimer();
 		}
-		//dojo.debug("This " + this.treeNode.title)
-		//dojo.debug("Source " + sourceTreeNode);
 
-		// check types compat
-		var acceptable = dojo.dnd.HtmlDropTarget.prototype.onDragOver.apply(this, arguments);
+		return accepts;
+	},
 
-		//dojo.debug("Check1 "+acceptable)
+	/* Parent.onDragOver calls this function to get accepts status */
+	accepts: function(dragObjects) {
 
+		var accepts = dojo.dnd.HtmlDropTarget.prototype.accepts.apply(this, arguments);
 
-		if (!acceptable) return false;
+		if (!accepts) return false;
 
-		// can't drop parent to child etc
-		acceptable = this.controller.canChangeParent(sourceTreeNode, this.treeNode);
+		var sourceTreeNode = dragObjects[0].treeNode;
 
+		if (dojo.lang.isUndefined(sourceTreeNode) || !sourceTreeNode || !sourceTreeNode.isTreeNode) {
+			dojo.raise("Source is not TreeNode or not found");
+		}
 
-		//dojo.debug("Check2 "+acceptable)
+		if (sourceTreeNode === this.treeNode) return false;
 
-		if (!acceptable) return false;
+		return true;
+	},
 
 
-		// mark current node being dragged into
-		if (sourceTreeNode !== this.treeNode) {
-			this.treeNode.markSelected();
+
+	setAutoExpandTimer: function() {
+		// set up autoexpand timer
+		var _this = this;
+
+		var autoExpand = function () {
+			if (dojo.dnd.dragManager.currentDropTarget === _this) {
+				_this.controller.expand(_this.treeNode);
+			}
 		}
 
-		return true;
+		this.autoExpandTimer = dojo.lang.setTimeout(autoExpand, _this.autoExpandDelay);
+	},
+
 
+	getDNDMode: function() {
+		return this.treeNode.tree.DNDMode;
 	},
+		
+
+	getAcceptPosition: function(e, sourceTreeNode) {
+
+		var DNDMode = this.getDNDMode();
+
+		if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO &&
+			// check if ONTO is allowed localy
+			!(
+			  !this.treeNode.actionIsDisabled(dojo.widget.TreeNode.prototype.actions.ADDCHILD) // check dynamically cause may change w/o regeneration of dropTarget
+			  && sourceTreeNode.parent !== this.treeNode
+			  && this.controller.canMove(sourceTreeNode, this.treeNode)
+			 )
+		) {
+			// disable ONTO if can't move
+			DNDMode &= ~dojo.widget.Tree.prototype.DNDModes.ONTO;
+		}
+
+
+		var position = this.getPosition(e, DNDMode);
+
+		//dojo.debug(DNDMode & +" : "+position);
+
+
+		// if onto is here => it was allowed before, no accept check is needed
+		if (position=="onto" ||
+			(!this.isAdjacentNode(sourceTreeNode, position)
+			 && this.controller.canMove(sourceTreeNode, this.treeNode.parent)
+			)
+		) {
+			return position;
+		} else {
+			return false;
+		}
 
-	onDragMove: function(e){
 	},
 
 	onDragOut: function(e) {
+		this.clearAutoExpandTimer();
+
+		this.hideIndicator();
+	},
 
-		this.treeNode.unMarkSelected();
 
-		//return dojo.dnd.HtmlDropTarget.prototype.onDragOut.call(this, e);
+	clearAutoExpandTimer: function() {
+		if (this.autoExpandTimer) {
+			clearTimeout(this.autoExpandTimer);
+			this.autoExpandTimer = null;
+		}
 	},
 
-	onDrop: function(e){
-		this.onDragOut(e);
 
-		//dojo.debug('drop');
 
-		var child = this.domNode;
-		var targetTreeNode = this.treeNode;
+	onDragMove: function(e, dragObjects){
+
+		var sourceTreeNode = dragObjects[0].treeNode;
+
+		var position = this.getAcceptPosition(e, sourceTreeNode);
+
+		if (position) {
+			this.showIndicator(position);
+		}
+
+	},
+
+	isAdjacentNode: function(sourceNode, position) {
+
+		if (sourceNode === this.treeNode) return true;
+		if (sourceNode.getNextSibling() === this.treeNode && position=="before") return true;
+		if (sourceNode.getPreviousSibling() === this.treeNode && position=="after") return true;
+
+		return false;
+	},
+
+
+	/* get DNDMode and see which position e fits */
+	getPosition: function(e, DNDMode) {
+		var node = dojo.byId(this.treeNode.labelNode);
+		var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
+		var nodey = dojo.html.getAbsolutePosition(node).y;
+		var height = dojo.html.getBorderBox(node).height;
+
+		var relY = mousey - nodey;
+		var p = relY / height;
+
+		var position = ""; // "" <=> forbidden
+		if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO
+		  && DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
+			if (p<=0.3) {
+				position = "before";
+			} else if (p<=0.7) {
+				position = "onto";
+			} else {
+				position = "after";
+			}
+		} else if (DNDMode & dojo.widget.Tree.prototype.DNDModes.BETWEEN) {
+			if (p<=0.5) {
+				position = "before";
+			} else {
+				position = "after";
+			}
+		}
+		else if (DNDMode & dojo.widget.Tree.prototype.DNDModes.ONTO) {
+			position = "onto";
+		}
+
+
+		return position;
+	},
+
+
 
+	getTargetParentIndex: function(sourceTreeNode, position) {
 
-		if (!dojo.lang.isObject(targetTreeNode)) {
-			dojo.raise("Wrong DropTarget engaged");
+		var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex()+1;
+		if (this.treeNode.parent === sourceTreeNode.parent
+		  && this.treeNode.getParentIndex() > sourceTreeNode.getParentIndex()) {
+		  	index--;  // dragging a node is different for simple move bacause of before-after issues
 		}
 
+		return index;
+	},
+
+
+	onDrop: function(e){
+		// onDragOut will clean position
+
+
+		var position = this.position;
+
+//dojo.debug(position);
+
+		this.onDragOut(e);
+
 		var sourceTreeNode = e.dragObject.treeNode;
 
 		if (!dojo.lang.isObject(sourceTreeNode)) {
-			return false;
+			dojo.raise("TreeNode not found in dragObject")
+		}
+
+		if (position == "onto") {
+			return this.controller.move(sourceTreeNode, this.treeNode, 0);
+		} else {
+			var index = this.getTargetParentIndex(sourceTreeNode, position);
+			return this.controller.move(sourceTreeNode, this.treeNode.parent, index);
 		}
 
-		// I don't check that trees are same! Target/source system deals with it
+		//dojo.debug('drop2');
+
 
-		//tree.changeParentRemote(sourceTreeNode, targetTreeNode);
-		return this.controller.processDrop(sourceTreeNode, targetTreeNode);
 
 	}
+
+
+});
+
+
+
+dojo.dnd.TreeDNDController = function(treeController) {
+
+	// I use this controller to perform actions
+	this.treeController = treeController;
+
+	this.dragSources = {};
+
+	this.dropTargets = {};
+
+}
+
+dojo.lang.extend(dojo.dnd.TreeDNDController, {
+
+
+	listenTree: function(tree) {
+		//dojo.debug("Listen tree "+tree);
+		dojo.event.topic.subscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+		dojo.event.topic.subscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
+		dojo.event.topic.subscribe(tree.eventNames.moveTo, this, "onMoveTo");
+		dojo.event.topic.subscribe(tree.eventNames.addChild, this, "onAddChild");
+		dojo.event.topic.subscribe(tree.eventNames.removeNode, this, "onRemoveNode");
+		dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+	},
+
+
+	unlistenTree: function(tree) {
+		//dojo.debug("Listen tree "+tree);
+		dojo.event.topic.unsubscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+		dojo.event.topic.unsubscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
+		dojo.event.topic.unsubscribe(tree.eventNames.moveTo, this, "onMoveTo");
+		dojo.event.topic.unsubscribe(tree.eventNames.addChild, this, "onAddChild");
+		dojo.event.topic.unsubscribe(tree.eventNames.removeNode, this, "onRemoveNode");
+		dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+	},
+
+	onTreeDestroy: function(message) {
+		this.unlistenTree(message.source);
+		// I'm not widget so don't use destroy() call and dieWithTree
+	},
+
+	onCreateDOMNode: function(message) {
+		this.registerDNDNode(message.source);
+	},
+
+	onAddChild: function(message) {
+		this.registerDNDNode(message.child);
+	},
+
+	onMoveFrom: function(message) {
+		var _this = this;
+		dojo.lang.forEach(
+			message.child.getDescendants(),
+			function(node) { _this.unregisterDNDNode(node); }
+		);
+	},
+
+	onMoveTo: function(message) {
+		var _this = this;
+		dojo.lang.forEach(
+			message.child.getDescendants(),
+			function(node) { _this.registerDNDNode(node); }
+		);
+	},
+
+	/**
+	 * Controller(node model) creates DNDNodes because it passes itself to node for synchroneous drops processing
+	 * I can't process DnD with events cause an event can't return result success/false
+	*/
+	registerDNDNode: function(node) {
+		if (!node.tree.DNDMode) return;
+
+//dojo.debug("registerDNDNode "+node);
+
+		/* I drag label, not domNode, because large domNodes are very slow to copy and large to drag */
+
+		var source = null;
+		var target = null;
+
+		if (!node.actionIsDisabled(node.actions.MOVE)) {
+			//dojo.debug("reg source")
+			var source = new dojo.dnd.TreeDragSource(node.labelNode, this, node.tree.widgetId, node);
+			this.dragSources[node.widgetId] = source;
+		}
+
+		var target = new dojo.dnd.TreeDropTarget(node.labelNode, this.treeController, node.tree.DNDAcceptTypes, node);
+
+		this.dropTargets[node.widgetId] = target;
+
+	},
+
+
+	unregisterDNDNode: function(node) {
+
+		if (this.dragSources[node.widgetId]) {
+			dojo.dnd.dragManager.unregisterDragSource(this.dragSources[node.widgetId]);
+			delete this.dragSources[node.widgetId];
+		}
+
+		if (this.dropTargets[node.widgetId]) {
+			dojo.dnd.dragManager.unregisterDropTarget(this.dropTargets[node.widgetId]);
+			delete this.dropTargets[node.widgetId];
+		}
+	}
+
+
+
+
+
 });

Added: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js?view=auto&rev=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js (added)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js Mon Nov 13 14:54:45 2006
@@ -0,0 +1,404 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/**
+ * TreeDrag* specialized on managing subtree drags
+ * It selects nodes and visualises what's going on,
+ * but delegates real actions upon tree to the controller
+ *
+ * This code is considered a part of controller
+*/
+
+dojo.provide("dojo.dnd.TreeDragAndDropV3");
+
+dojo.require("dojo.dnd.HtmlDragAndDrop");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.lang.extras");
+dojo.require("dojo.Deferred");
+dojo.require("dojo.html.layout");
+
+// FIXME: if controller can't move then skip node on move start
+dojo.dnd.TreeDragSourceV3 = function(node, syncController, type, treeNode){
+	//dojo.profile.start("TreeDragSourceV3 "+treeNode);
+	this.controller = syncController;
+	this.treeNode = treeNode;
+
+	dojo.dnd.HtmlDragSource.call(this, node, type);
+	//dojo.profile.end("TreeDragSourceV3 "+treeNode);
+
+}
+
+dojo.inherits(dojo.dnd.TreeDragSourceV3, dojo.dnd.HtmlDragSource);
+
+
+// .......................................
+
+dojo.dnd.TreeDropTargetV3 = function(domNode, controller, type, treeNode){
+
+	this.treeNode = treeNode;
+	this.controller = controller; // I will sync-ly process drops
+	
+	dojo.dnd.HtmlDropTarget.call(this, domNode, type);
+}
+
+dojo.inherits(dojo.dnd.TreeDropTargetV3, dojo.dnd.HtmlDropTarget);
+
+dojo.lang.extend(dojo.dnd.TreeDropTargetV3, {
+
+	autoExpandDelay: 1500,
+	autoExpandTimer: null,
+
+
+	position: null,
+
+	indicatorStyle: "2px black groove",
+
+	showIndicator: function(position) {
+
+		// do not change style too often, cause of blinking possible
+		if (this.position == position) {
+			return;
+		}
+
+		//dojo.debug("set position for "+this.treeNode)
+
+		this.hideIndicator();
+
+		this.position = position;
+		
+		var node = this.treeNode;
+			
+		
+		node.contentNode.style.width = dojo.html.getBorderBox(node.labelNode).width + "px";
+
+		if (position == "onto") {					
+			node.contentNode.style.border = this.indicatorStyle;
+		} else {
+			// FIXME: bottom-top or highlight should cover ONLY top/bottom or div itself,
+			// not span whole line (try Dnd)
+			// FAILURE: Can't put span inside div: multiline bottom-top will span multiple lines
+			if (position == "before") {
+				node.contentNode.style.borderTop = this.indicatorStyle;
+			} else if (position == "after") {
+				node.contentNode.style.borderBottom = this.indicatorStyle;
+			}									
+		}  
+	},
+
+	hideIndicator: function() {
+		this.treeNode.contentNode.style.borderBottom = "";
+		this.treeNode.contentNode.style.borderTop = "";
+		this.treeNode.contentNode.style.border = "";
+		this.treeNode.contentNode.style.width=""
+		this.position = null;
+	},
+
+
+
+	// is the target possibly ok ?
+	// This function is run on dragOver, but drop possibility is also determined by position over node
+	// that's why acceptsWithPosition is called
+	// doesnt take index into account ( can change while moving mouse w/o changing target )
+	/**
+	 * Coarse (tree-level) access check.
+	 * We can't determine real accepts status w/o position
+	*/
+	onDragOver: function(e){
+		//dojo.debug("onDragOver for "+e);
+
+		var accepts = dojo.dnd.HtmlDropTarget.prototype.onDragOver.apply(this, arguments);
+
+		//dojo.debug("TreeDropTarget.onDragOver accepts:"+accepts)
+
+		if (accepts && this.treeNode.isFolder && !this.treeNode.isExpanded) {
+			this.setAutoExpandTimer();
+		}
+		
+		if (accepts) {
+			this.cacheNodeCoords();
+		}
+
+
+		return accepts;
+	},
+
+	/* Parent.onDragOver calls this function to get accepts status */
+	accepts: function(dragObjects) {
+
+		var accepts = dojo.dnd.HtmlDropTarget.prototype.accepts.apply(this, arguments);
+
+		//dojo.debug("accepts "+accepts);
+
+		if (!accepts) return false;
+
+		for(var i=0; i<dragObjects.length; i++) {
+			// there may be NO treeNode
+			var sourceTreeNode = dragObjects[i].dragSource.treeNode;
+			
+			if (sourceTreeNode === this.treeNode) return false;
+		}
+
+		return true;
+	},
+
+
+
+	setAutoExpandTimer: function() {
+		// set up autoexpand timer
+		var _this = this;
+
+		var autoExpand = function () {
+			if (dojo.dnd.dragManager.currentDropTarget === _this) {
+				_this.controller.expand(_this.treeNode);
+				// SLOW. Coordinates will not be recalculated if collapse occurs, or
+				// other (generic) resize. So that's a kind of hack.
+				dojo.dnd.dragManager.cacheTargetLocations();
+			}
+		}
+
+		this.autoExpandTimer = dojo.lang.setTimeout(autoExpand, _this.autoExpandDelay);
+	},
+
+		
+
+	getAcceptPosition: function(e, dragObjects) {
+
+
+		var DndMode = this.treeNode.tree.DndMode;
+
+		// disable ONTO mode possibility if impossible 
+		if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO &&
+			// check if ONTO is allowed localy
+			// check dynamically cause may change w/o regeneration of dropTarget
+			this.treeNode.actionIsDisabledNow(this.treeNode.actions.ADDCHILD) 
+		) {
+			// disable ONTO if can't move
+			DndMode &= ~dojo.widget.TreeV3.prototype.DndModes.ONTO;
+		}
+		
+
+		var position = this.getPosition(e, DndMode);
+
+		//dojo.debug(DndMode & +" : "+position);
+
+
+		// if onto is here => it was allowed before, no accept check is needed
+		if (position=="onto") {
+			return position;
+		}
+		
+		for(var i=0; i<dragObjects.length; i++) {
+			var source = dragObjects[i].dragSource;
+			if (source.treeNode && this.isAdjacentNode(source.treeNode, position)) { // skip check if same parent
+				continue;
+			}		
+						
+			if (!this.controller.canMove(source.treeNode ? source.treeNode : source, this.treeNode.parent)) {
+				return false;
+			}
+		}
+		
+		return position;
+	
+	},
+
+	
+
+	onDropEnd: function(e) {
+		this.clearAutoExpandTimer();
+
+		this.hideIndicator();
+	},
+
+
+	onDragOut: function(e) {
+		this.clearAutoExpandTimer();
+
+		this.hideIndicator();
+	},
+
+	clearAutoExpandTimer: function() {
+		if (this.autoExpandTimer) {
+			clearTimeout(this.autoExpandTimer);
+			this.autoExpandTimer = null;
+		}
+	},
+
+
+
+	onDragMove: function(e, dragObjects){
+		
+		var position = this.getAcceptPosition(e, dragObjects);
+
+		if (position) {
+			this.showIndicator(position);
+		}
+
+	},
+
+	isAdjacentNode: function(sourceNode, position) {
+
+		if (sourceNode === this.treeNode) return true;
+		if (sourceNode.getNextSibling() === this.treeNode && position=="before") return true;
+		if (sourceNode.getPreviousSibling() === this.treeNode && position=="after") return true;
+
+		return false;
+	},
+
+
+	/**
+	 * cache node coordinates to speed up onDragMove
+	 */
+	cacheNodeCoords: function() {
+		var node = this.treeNode.contentNode;
+		
+		this.cachedNodeY = dojo.html.getAbsolutePosition(node).y;
+		this.cachedNodeHeight = dojo.html.getBorderBox(node).height;
+	},
+	
+	
+
+	/* get DndMode and see which position e fits */
+	getPosition: function(e, DndMode) {
+		var mousey = e.pageY || e.clientY + dojo.body().scrollTop;
+		
+		var relY = mousey - this.cachedNodeY;
+		var p = relY / this.cachedNodeHeight;
+
+		var position = ""; // "" <=> forbidden
+		if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO
+		  && DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
+			//dojo.debug("BOTH");
+			if (p<=0.33) {
+				position = "before";
+				// if children are expanded then I ignore understrike, cause it is confusing with firstChild
+				// but for last nodes I put understrike there
+			} else if (p<=0.66 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
+				position = "onto";
+			} else {
+				position = "after";
+			}
+		} else if (DndMode & dojo.widget.TreeV3.prototype.DndModes.BETWEEN) {
+			//dojo.debug("BETWEEN");
+			if (p<=0.5 || this.treeNode.isExpanded && this.treeNode.children.length && !this.treeNode.isLastChild()) {
+				position = "before";
+			} else {
+				position = "after";
+			}
+		}
+		else if (DndMode & dojo.widget.TreeV3.prototype.DndModes.ONTO) {
+			//dojo.debug("ONTO");
+			position = "onto";
+		}
+
+		//dojo.debug(position);
+
+		return position;
+	},
+
+
+
+	getTargetParentIndex: function(source, position) {
+
+		var index = position == "before" ? this.treeNode.getParentIndex() : this.treeNode.getParentIndex()+1;
+		if (source.treeNode
+		  && this.treeNode.parent === source.treeNode.parent
+		  && this.treeNode.getParentIndex() > source.treeNode.getParentIndex()) {
+		  	index--;  // dragging a node is different for simple move bacause of before-after issues
+		}
+
+		return index;
+	},
+
+
+	onDrop: function(e) {
+		// onDropEnd will clean position
+
+		
+		var position = this.position;
+
+//dojo.debug(position);
+		var source = e.dragObject.dragSource;
+		
+		//dojo.debug("onDrop "+source.treeNode+" " + position + " "+this.treeNode);
+
+
+		var targetParent, targetIndex;
+		if (position == "onto") {
+			targetParent = this.treeNode;
+			targetIndex = 0;
+		} else {
+			targetIndex = this.getTargetParentIndex(source, position);
+			targetParent = this.treeNode.parent;
+		}
+		
+		//dojo.profile.start("onDrop "+sourceTreeNode);
+		var r = this.getDropHandler(e, source, targetParent, targetIndex)();
+		
+		//dojo.profile.end("onDrop "+sourceTreeNode);
+			
+		return r;
+
+	},
+	
+	/**
+	 * determine, which action I should perform with nodes
+	 * e.g move, clone..
+	 */
+	getDropHandler: function(e, source, targetParent, targetIndex) {
+		var handler;
+		var _this = this;
+		handler = function () {
+			var result;
+			
+			//dojo.debug("Move "+source.treeNode+" to parent "+targetParent+":"+targetIndex);
+			if (source.treeNode) {
+				result = _this.controller.move(source.treeNode, targetParent, targetIndex, true);
+				//dojo.debug("moved "+result);
+			} else {
+				if (dojo.lang.isFunction(source.onDrop)) {
+					source.onDrop(targetParent, targetIndex);
+				}
+				
+				var treeNode = source.getTreeNode();
+				if (treeNode) {
+					result = _this.controller.createChild(targetParent, targetIndex, treeNode, true);
+				} else {
+					result = true;
+				}
+			}
+			
+			if (result instanceof dojo.Deferred) {
+				// this Deferred is always sync
+				var isSuccess = result.fired == 0;
+				if (!isSuccess) {
+					_this.handleDropError(source, targetParent, targetIndex, result);
+				}
+				
+				return isSuccess;				
+				
+			} else {
+				return result;
+			}
+		}
+		
+		return handler;
+	},
+	
+	
+	handleDropError: function(source, parent, index, result) {
+		dojo.debug("TreeDropTargetV3.handleDropError: DND error occured");
+		dojo.debugShallow(result);
+	}
+
+
+});
+

Propchange: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/TreeDragAndDropV3.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js?view=diff&rev=474551&r1=474550&r2=474551
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/src/dnd/__package__.js Mon Nov 13 14:54:45 2006
@@ -1,5 +1,5 @@
 /*
-	Copyright (c) 2004-2005, The Dojo Foundation
+	Copyright (c) 2004-2006, The Dojo Foundation
 	All Rights Reserved.
 
 	Licensed under the Academic Free License version 2.1 or above OR the
@@ -8,8 +8,9 @@
 		http://dojotoolkit.org/community/licensing.shtml
 */
 
-dojo.hostenv.conditionalLoadModule({
+dojo.kwCompoundRequire({
 	common: ["dojo.dnd.DragAndDrop"],
-	browser: ["dojo.dnd.HtmlDragAndDrop"]
+	browser: ["dojo.dnd.HtmlDragAndDrop"],
+	dashboard: ["dojo.dnd.HtmlDragAndDrop"]
 });
-dojo.hostenv.moduleLoaded("dojo.dnd.*");
+dojo.provide("dojo.dnd.*");