You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2006/04/14 01:47:17 UTC

svn commit: r393978 [17/25] - in /incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo: ./ demos/ demos/widget/ demos/widget/EditorTree/ demos/widget/EditorTree/static/ demos/widget/Mail/ demos/widget/images/ src/ src/alg/...

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ComboBox.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ComboBox.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ComboBox.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ComboBox.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,197 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.ComboBox");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+
+dojo.widget.incrementalComboBoxDataProvider = function(url, limit, timeout){
+	this.searchUrl = url;
+	this.inFlight = false;
+	this.activeRequest = null;
+	this.allowCache = false;
+
+	this.cache = {};
+	this.addToCache = function(keyword, data){
+		if(this.allowCache){
+			this.cache[keyword] = data;
+		}
+	}
+
+	this.startSearch = function(searchStr, type, ignoreLimit){
+		if(this.inFlight){
+			// FIXME: implement backoff!
+		}
+		var tss = encodeURIComponent(searchStr);
+		var realUrl = dojo.string.paramString(this.searchUrl, {"searchString": tss});
+		var _this = this;
+		var request = dojo.io.bind({
+			url: realUrl,
+			method: "get",
+			mimetype: "text/javascript",
+			load: function(type, data, evt){
+				_this.inFlight = false;
+				_this.addToCache(searchStr, data);
+				_this.provideSearchResults(data);
+			}
+		});
+		this.inFlight = true;
+	}
+}
+
+dojo.widget.ComboBoxDataProvider = function(dataPairs, limit, timeout){
+	// NOTE: this data provider is designed as a naive reference
+	// implementation, and as such it is written more for readability than
+	// speed. A deployable data provider would implement lookups, search
+	// caching (and invalidation), and a significantly less naive data
+	// structure for storage of items.
+
+	this.data = [];
+	this.searchTimeout = 500;
+	this.searchLimit = 30;
+	this.searchType = "STARTSTRING"; // may also be "STARTWORD" or "SUBSTRING"
+	this.caseSensitive = false;
+	// for caching optimizations
+	this._lastSearch = "";
+	this._lastSearchResults = null;
+
+	this.startSearch = function(searchStr, type, ignoreLimit){
+		// FIXME: need to add timeout handling here!!
+		this._preformSearch(searchStr, type, ignoreLimit);
+	}
+
+	this._preformSearch = function(searchStr, type, ignoreLimit){
+		//
+		//	NOTE: this search is LINEAR, which means that it exhibits perhaps
+		//	the worst possible speed charachteristics of any search type. It's
+		//	written this way to outline the responsibilities and interfaces for
+		//	a search.
+		//
+		var st = type||this.searchType;
+		// FIXME: this is just an example search, which means that we implement
+		// only a linear search without any of the attendant (useful!) optimizations
+		var ret = [];
+		if(!this.caseSensitive){
+			searchStr = searchStr.toLowerCase();
+		}
+		for(var x=0; x<this.data.length; x++){
+			if((!ignoreLimit)&&(ret.length >= this.searchLimit)){
+				break;
+			}
+			// FIXME: we should avoid copies if possible!
+			var dataLabel = new String((!this.caseSensitive) ? this.data[x][0].toLowerCase() : this.data[x][0]);
+			if(dataLabel.length < searchStr.length){
+				// this won't ever be a good search, will it? What if we start
+				// to support regex search?
+				continue;
+			}
+
+			if(st == "STARTSTRING"){
+				// jum.debug(dataLabel.substr(0, searchStr.length))
+				// jum.debug(searchStr);
+				if(searchStr == dataLabel.substr(0, searchStr.length)){
+					ret.push(this.data[x]);
+				}
+			}else if(st == "SUBSTRING"){
+				// this one is a gimmie
+				if(dataLabel.indexOf(searchStr) >= 0){
+					ret.push(this.data[x]);
+				}
+			}else if(st == "STARTWORD"){
+				// do a substring search and then attempt to determine if the
+				// preceeding char was the beginning of the string or a
+				// whitespace char.
+				var idx = dataLabel.indexOf(searchStr);
+				if(idx == 0){
+					// implicit match
+					ret.push(this.data[x]);
+				}
+				if(idx <= 0){
+					// if we didn't match or implicily matched, march onward
+					continue;
+				}
+				// otherwise, we have to go figure out if the match was at the
+				// start of a word...
+				// this code is taken almost directy from nWidgets
+				var matches = false;
+				while(idx!=-1){
+					// make sure the match either starts whole string, or
+					// follows a space, or follows some punctuation
+					if(" ,/(".indexOf(dataLabel.charAt(idx-1)) != -1){
+						// FIXME: what about tab chars?
+						matches = true; break;
+					}
+					idx = dataLabel.indexOf(searchStr, tti+1);
+				}
+				if(!matches){
+					continue;
+				}else{
+					ret.push(this.data[x]);
+				}
+			}
+		}
+		this.provideSearchResults(ret);
+	}
+
+	this.provideSearchResults = function(resultsDataPairs){
+	}
+
+	this.addData = function(pairs){
+		// FIXME: incredibly naive and slow!
+		this.data = this.data.concat(pairs);
+	}
+
+	this.setData = function(pdata){
+		// populate this.data and initialize lookup structures
+		this.data = pdata;
+	}
+	
+	if(dataPairs){
+		this.setData(dataPairs);
+	}
+}
+
+dojo.widget.ComboBox = function(){
+	dojo.widget.Widget.call(this);
+}
+
+dojo.inherits(dojo.widget.ComboBox, dojo.widget.Widget);
+
+dojo.widget.ComboBox.defaults = {
+	widgetType: "ComboBox",
+	isContainer: false,
+
+	forceValidOption: false,
+	searchType: "stringstart",
+	dataProvider: null,
+
+	startSearch: function(searchString){},
+	openResultList: function(results){},
+	clearResultList: function(){},
+	hideResultList: function(){},
+	selectNextResult: function(){},
+	selectPrevResult: function(){},
+	setSelectedResult: function(){}
+};
+
+dojo.lang.extend(dojo.widget.ComboBox, dojo.widget.ComboBox.defaults);
+
+dojo.widget.DomComboBox = function(){
+	dojo.widget.ComboBox.call(this);
+	dojo.widget.DomWidget.call(this, true);
+}
+
+dojo.inherits(dojo.widget.DomComboBox, dojo.widget.DomWidget);
+dojo.widget.tags.addParseTreeHandler("dojo:combobox");
+
+// render-specific includes
+dojo.requireAfterIf("html", "dojo.widget.html.ComboBox");
+

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Container.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Container.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Container.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Container.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,12 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.Container");
+dojo.requireAfterIf("html", "dojo.widget.html.Container");

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContentPane.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContentPane.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContentPane.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContentPane.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,16 @@
+/*
+	Copyright (c) 2004-2005, 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
+*/
+
+// This widget doesn't do anything; is basically the same as <div>.
+// It's useful as a child of LayoutPane, SplitPane, or TabPane.
+// But note that those classes can contain any widget as a child.
+
+dojo.provide("dojo.widget.ContentPane");
+dojo.requireAfterIf("html", "dojo.widget.html.ContentPane");

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContextMenu.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContextMenu.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContextMenu.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/ContextMenu.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,33 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.ContextMenu");
+
+dojo.deprecated("dojo.widget.ContextMenu",  "use dojo.widget.Menu2", "0.4");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.DomWidget");
+
+dojo.widget.ContextMenu = function(){
+	dojo.widget.Widget.call(this);
+	this.widgetType = "ContextMenu";
+	this.isContainer = true;
+	this.isOpened = false;
+	
+	// copy children widgets output directly to parent (this node), to avoid
+	// errors trying to insert an <li> under a <div>
+	this.snarfChildDomOutput = true;
+
+}
+
+dojo.inherits(dojo.widget.ContextMenu, dojo.widget.Widget);
+dojo.widget.tags.addParseTreeHandler("dojo:contextmenu");
+
+dojo.requireAfterIf("html", "dojo.widget.html.ContextMenu");

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DatePicker.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DatePicker.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DatePicker.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DatePicker.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,74 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.DatePicker");
+dojo.provide("dojo.widget.DatePicker.util");
+dojo.require("dojo.widget.DomWidget");
+dojo.require("dojo.date");
+
+dojo.widget.DatePicker = function(){
+	dojo.widget.Widget.call(this);
+	this.widgetType = "DatePicker";
+	this.isContainer = false;
+	// the following aliases prevent breaking people using 0.2.x
+	this.months = dojo.date.months;
+	this.weekdays = dojo.date.days;
+	this.toRfcDate = dojo.widget.DatePicker.util.toRfcDate;
+	this.fromRfcDate = dojo.widget.DatePicker.util.fromRfcDate;
+	this.initFirstSaturday = dojo.widget.DatePicker.util.initFirstSaturday;
+}
+
+dojo.inherits(dojo.widget.DatePicker, dojo.widget.Widget);
+dojo.widget.tags.addParseTreeHandler("dojo:datepicker");
+
+dojo.requireAfterIf("html", "dojo.widget.html.DatePicker");
+
+dojo.widget.DatePicker.util = new function() {
+	this.months = dojo.date.months;
+	this.weekdays = dojo.date.days;
+	
+	this.toRfcDate = function(jsDate) {
+		if(!jsDate) {
+			jsDate = this.today;
+		}
+		var year = jsDate.getFullYear();
+		var month = jsDate.getMonth() + 1;
+		if (month < 10) {
+			month = "0" + month.toString();
+		}
+		var date = jsDate.getDate();
+		if (date < 10) {
+			date = "0" + date.toString();
+		}
+		// because this is a date picker and not a time picker, we treat time 
+		// as zero
+		return year + "-" + month + "-" + date + "T00:00:00+00:00";
+	}
+	
+	this.fromRfcDate = function(rfcDate) {
+		var tempDate = rfcDate.split("-");
+		if(tempDate.length < 3) {
+			return new Date();
+		}
+		// fullYear, month, date
+		return new Date(parseInt(tempDate[0]), (parseInt(tempDate[1], 10) - 1), parseInt(tempDate[2].substr(0,2), 10));
+	}
+	
+	this.initFirstSaturday = function(month, year) {
+		if(!month) {
+			month = this.date.getMonth();
+		}
+		if(!year) {
+			year = this.date.getFullYear();
+		}
+		var firstOfMonth = new Date(year, month, 1);
+		return {year: year, month: month, date: 7 - firstOfMonth.getDay()};
+	}
+}

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DebugConsole.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DebugConsole.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DebugConsole.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DebugConsole.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,22 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.DebugConsole");
+dojo.require("dojo.widget.Widget");
+
+dojo.widget.DebugConsole= function(){
+	dojo.widget.Widget.call(this);
+
+	this.widgetType = "DebugConsole";
+	this.isContainer = true;
+}
+dojo.inherits(dojo.widget.DebugConsole, dojo.widget.Widget);
+dojo.widget.tags.addParseTreeHandler("dojo:debugconsole");
+dojo.requireAfterIf("html", "dojo.widget.html.DebugConsole");

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Dialog.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Dialog.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Dialog.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Dialog.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,297 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.Dialog");
+dojo.provide("dojo.widget.HtmlDialog");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.graphics.color");
+dojo.require("dojo.fx.*");
+dojo.require("dojo.html");
+
+dojo.widget.tags.addParseTreeHandler("dojo:dialog");
+
+dojo.widget.HtmlDialog = function(){
+	dojo.widget.HtmlWidget.call(this);
+
+	this.resizeConnectArgs = {
+		srcObj: window,
+		srcFunc: "onresize",
+		adviceObj: this,
+		adviceFunc: "onResize",
+		rate: 500
+	}
+}
+
+dojo.inherits(dojo.widget.HtmlDialog, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.HtmlDialog, {
+	templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlDialog.html"),
+	widgetType: "Dialog",
+	isContainer: true,
+
+	_scrollConnected: false,
+	_resizeConnected: false,
+	
+	// provide a focusable element or element id if you need to
+	// work around FF's tendency to send focus into outer space on hide
+	focusElement: "",
+
+	// Only supports fade right now
+	effect: "fade",
+	effectDuration: 250,
+
+	bg: null,
+	bgIframe: null,
+	bgColor: "black",
+	bgOpacity: 0.4,
+	followScroll: 1,
+	_fromTrap: false,
+	anim: null,
+
+	trapTabs: function(e){
+		if(e.target == this.tabStart) {
+			if(this._fromTrap) {
+				this._fromTrap = false;
+			} else {
+				this._fromTrap = true;
+				this.tabEnd.focus();
+			}
+		} else if(e.target == this.tabEnd) {
+			if(this._fromTrap) {
+				this._fromTrap = false;
+			} else {
+				this._fromTrap = true;
+				this.tabStart.focus();
+			}
+		}
+	},
+
+	clearTrap: function(e) {
+		var _this = this;
+		setTimeout(function() {
+			_this._fromTrap = false;
+		}, 100);
+	},
+
+	postCreate: function(args, frag, parentComp) {
+		with(this.domNode.style) {
+			position = "absolute";
+			zIndex = 999;
+			display = "none";
+		}
+		var b = dojo.html.body();
+		b.appendChild(this.domNode);
+		this.nodeRef = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+		if(this.nodeRef) {
+			this.setContent(this.nodeRef);
+		}
+
+		this.bgIframe = new dojo.html.BackgroundIframe();
+
+		this.bg = document.createElement("div");
+		this.bg.className = "dialogUnderlay";
+		with(this.bg.style) {
+			position = "absolute";
+			left = top = "0px";
+			zIndex = 998;
+			display = "none";
+		}
+		this.setBackgroundColor(this.bgColor);
+		b.appendChild(this.bg);
+		this.bgIframe.setZIndex(this.bg);
+	},
+
+	setContent: function(content) {
+		if(typeof content == "string") {
+			this.containerNode.innerHTML = content;
+		} else if(content.nodeType != undefined) {
+			// dojo.dom.removeChildren(this.containerNode);
+			this.containerNode.appendChild(content);
+		} else {
+			dojo.raise("Tried to setContent with unknown content (" + content + ")");
+		}
+	},
+
+	setBackgroundColor: function(color) {
+		if(arguments.length >= 3) {
+			color = new dojo.graphics.color.Color(arguments[0], arguments[1], arguments[2]);
+		} else {
+			color = new dojo.graphics.color.Color(color);
+		}
+		this.bg.style.backgroundColor = color.toString();
+		return this.bgColor = color;
+	},
+	
+	setBackgroundOpacity: function(op) {
+		if(arguments.length == 0) { op = this.bgOpacity; }
+		dojo.style.setOpacity(this.bg, op);
+		try {
+			this.bgOpacity = dojo.style.getOpacity(this.bg);
+		} catch (e) {
+			this.bgOpacity = op;
+		}
+		return this.bgOpacity;
+	},
+
+	sizeBackground: function() {
+		if(this.bgOpacity > 0) {
+			var h = document.documentElement.scrollHeight || dojo.html.body().scrollHeight;
+			var w = dojo.html.getViewportWidth();
+			this.bg.style.width = w + "px";
+			this.bg.style.height = h + "px";
+			this.bgIframe.size([0, 0, w, h]);
+		} else {
+			this.bgIframe.size(this.domNode);
+		}
+	},
+
+	showBackground: function() {
+		this.sizeBackground();
+		this.bgIframe.show();
+		if(this.bgOpacity > 0) {
+			this.bg.style.display = "block";
+		}
+	},
+
+	placeDialog: function() {
+		var scroll_offset = dojo.html.getScrollOffset();
+		var viewport_size = dojo.html.getViewportSize();
+
+		// find the size of the dialog
+		// we should really be using dojo.style but i'm not sure
+		// which (inner, outer, box, content, client) --cal
+		this.domNode.style.display = "block";
+		var w = this.domNode.offsetWidth;
+		var h = this.domNode.offsetHeight;
+		this.domNode.style.display = "none";
+
+		var x = scroll_offset[0] + (viewport_size[0] - w)/2;
+		var y = scroll_offset[1] + (viewport_size[1] - h)/2;
+
+		with(this.domNode.style) {
+			left = x + "px";
+			top = y + "px";
+		}
+
+		// tied to domNode, so we need to update the position
+		if(this.bgOpacity == 0) {
+			this.bgIframe.size([x, y, w, h]);
+		}
+	},
+
+	show: function() {
+		this.setBackgroundOpacity();
+		this.placeDialog();
+		this.showBackground();
+		switch((this.effect||"").toLowerCase()){
+			case "fade":
+				this.domNode.style.display = "block";
+				var _this = this;
+				if(this.anim){ this.anim.stop(); }
+				// FIXME: we should be supporting other effect types here!
+				this.anim = dojo.fx.fade(this.domNode, 
+					this.effectDuration, 
+					0, 
+					1,
+					dojo.lang.hitch(this, 
+						function(node){
+							if(dojo.lang.isFunction(_this.onShow)) {
+								_this.onShow(node);
+							}
+						}
+					)
+				);
+				break;
+			default:
+				this.domNode.style.display = "block";
+				if(dojo.lang.isFunction(this.onShow)){
+					this.onShow(this.domNode);
+				}
+				break;
+		}
+
+		// FIXME: moz doesn't generate onscroll events for mouse or key scrolling (wtf)
+		// we should create a fake event by polling the scrolltop/scrollleft every X ms.
+		// this smells like it should be a dojo feature rather than just for this widget.
+
+		if (this.followScroll && !this._scrollConnected){
+			this._scrollConnected = true;
+			dojo.event.connect(window, "onscroll", this, "onScroll");
+		}
+
+		if(!this._resizeConnected) {
+			this._resizeConnected = true;
+			dojo.event.kwConnect(this.resizeConnectArgs);
+		}
+	},
+
+	hide: function(){
+		// workaround for FF focus going into outer space
+		if (this.focusElement) { 
+			dojo.byId(this.focusElement).focus(); 
+			dojo.byId(this.focusElement).blur();
+		}
+		switch((this.effect||"").toLowerCase()) {
+			case "fade":
+				this.bg.style.display = "none";
+				this.bgIframe.hide();
+				var _this = this;
+				if(this.anim){ this.anim.stop(); }
+				this.anim = dojo.fx.fadeOut(this.domNode, this.effectDuration, function(node) {
+					node.style.display = "none";
+					if(dojo.lang.isFunction(_this.onHide)) {
+						_this.onHide(node);
+					}
+					_this.anim = null;
+				});
+				break;
+			default:
+				this.bg.style.display = "none";
+				this.bgIframe.hide();
+				this.domNode.style.display = "none";
+				if(dojo.lang.isFunction(this.onHide)) {
+					this.onHide(node);
+				}
+				break;
+		}
+
+		this.bg.style.width = this.bg.style.height = "1px";
+
+		if (this._scrollConnected){
+			this._scrollConnected = false;
+			dojo.event.disconnect(window, "onscroll", this, "onScroll");
+		}
+
+		if(this._resizeConnected) {
+			this._resizeConnected = false;
+			dojo.event.kwDisconnect(this.resizeConnectArgs);
+		}
+	},
+
+	setCloseControl: function(node) {
+		dojo.event.connect(node, "onclick", this, "hide");
+	},
+
+	setShowControl: function(node) {
+		dojo.event.connect(node, "onclick", this, "show");
+	},
+
+	onScroll: function(){
+		this.placeDialog();
+		this.domNode.style.display = "block";
+	},
+
+	onResize: function(e) {
+		this.sizeBackground();
+	}
+});
+

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DomWidget.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DomWidget.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DomWidget.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DomWidget.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,534 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.DomWidget");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.string");
+dojo.require("dojo.widget.Widget");
+dojo.require("dojo.dom");
+dojo.require("dojo.xml.Parse");
+dojo.require("dojo.uri.*");
+
+dojo.widget._cssFiles = {};
+
+dojo.widget.defaultStrings = {
+	dojoRoot: dojo.hostenv.getBaseScriptUri(),
+	baseScriptUri: dojo.hostenv.getBaseScriptUri()
+};
+
+
+// static method to build from a template w/ or w/o a real widget in place
+dojo.widget.buildFromTemplate = function(obj, templatePath, templateCssPath, templateString) {
+	var tpath = templatePath || obj.templatePath;
+	var cpath = templateCssPath || obj.templateCssPath;
+
+	if (!cpath && obj.templateCSSPath) {
+		obj.templateCssPath = cpath = obj.templateCSSPath;
+		obj.templateCSSPath = null;
+		dj_deprecated("templateCSSPath is deprecated, use templateCssPath");
+	}
+
+	// DEPRECATED: use Uri objects, not strings
+	if (tpath && !(tpath instanceof dojo.uri.Uri)) {
+		tpath = dojo.uri.dojoUri(tpath);
+		dj_deprecated("templatePath should be of type dojo.uri.Uri");
+	}
+	if (cpath && !(cpath instanceof dojo.uri.Uri)) {
+		cpath = dojo.uri.dojoUri(cpath);
+		dj_deprecated("templateCssPath should be of type dojo.uri.Uri");
+	}
+	
+	var tmplts = dojo.widget.DomWidget.templates;
+	if(!obj["widgetType"]) { // don't have a real template here
+		do {
+			var dummyName = "__dummyTemplate__" + dojo.widget.buildFromTemplate.dummyCount++;
+		} while(tmplts[dummyName]);
+		obj.widgetType = dummyName;
+	}
+
+	if((cpath)&&(!dojo.widget._cssFiles[cpath])){
+		dojo.html.insertCssFile(cpath);
+		obj.templateCssPath = null;
+		dojo.widget._cssFiles[cpath] = true;
+	}
+
+	var ts = tmplts[obj.widgetType];
+	if(!ts){
+		tmplts[obj.widgetType] = {};
+		ts = tmplts[obj.widgetType];
+	}
+	if(!obj.templateString){
+		obj.templateString = templateString || ts["string"];
+	}
+	if(!obj.templateNode){
+		obj.templateNode = ts["node"];
+	}
+	if((!obj.templateNode)&&(!obj.templateString)&&(tpath)){
+		// fetch a text fragment and assign it to templateString
+		// NOTE: we rely on blocking IO here!
+		var tstring = dojo.hostenv.getText(tpath);
+		if(tstring){
+			var matches = tstring.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+			if(matches){
+				tstring = matches[1];
+			}
+		}else{
+			tstring = "";
+		}
+		obj.templateString = tstring;
+		ts.string = tstring;
+	}
+	if(!ts["string"]) {
+		ts.string = obj.templateString;
+	}
+}
+dojo.widget.buildFromTemplate.dummyCount = 0;
+
+dojo.widget.attachProperties = ["dojoAttachPoint", "id"];
+dojo.widget.eventAttachProperty = "dojoAttachEvent";
+dojo.widget.onBuildProperty = "dojoOnBuild";
+
+dojo.widget.attachTemplateNodes = function(rootNode, targetObj, events){
+	// FIXME: this method is still taking WAAAY too long. We need ways of optimizing:
+	//	a.) what we are looking for on each node
+	//	b.) the nodes that are subject to interrogation (use xpath instead?)
+	//	c.) how expensive event assignment is (less eval(), more connect())
+	// var start = new Date();
+	var elementNodeType = dojo.dom.ELEMENT_NODE;
+
+	if(!rootNode){ 
+		rootNode = targetObj.domNode;
+	}
+
+	if(rootNode.nodeType != elementNodeType){
+		return;
+	}
+	// alert(events.length);
+
+	var nodes = rootNode.getElementsByTagName("*");
+	var _this = targetObj;
+	for(var x=-1; x<nodes.length; x++){
+		var baseNode = (x == -1) ? rootNode : nodes[x];
+		// FIXME: is this going to have capitalization problems?
+		var attachPoint = [];
+		for(var y=0; y<this.attachProperties.length; y++){
+			var tmpAttachPoint = baseNode.getAttribute(this.attachProperties[y]);
+			if(tmpAttachPoint){
+				attachPoint = tmpAttachPoint.split(";");
+				for(var z=0; z<this.attachProperties.length; z++){
+					if((targetObj[attachPoint[z]])&&(dojo.lang.isArray(targetObj[attachPoint[z]]))){
+						targetObj[attachPoint[z]].push(baseNode);
+					}else{
+						targetObj[attachPoint[z]]=baseNode;
+					}
+				}
+				break;
+			}
+		}
+		// continue;
+
+		// FIXME: we need to put this into some kind of lookup structure
+		// instead of direct assignment
+		var tmpltPoint = baseNode.getAttribute(this.templateProperty);
+		if(tmpltPoint){
+			targetObj[tmpltPoint]=baseNode;
+		}
+
+		var attachEvent = baseNode.getAttribute(this.eventAttachProperty);
+		if(attachEvent){
+			// NOTE: we want to support attributes that have the form
+			// "domEvent: nativeEvent; ..."
+			var evts = attachEvent.split(";");
+			for(var y=0; y<evts.length; y++){
+				if((!evts[y])||(!evts[y].length)){ continue; }
+				var thisFunc = null;
+				// var tevt = dojo.string.trim(evts[y]);
+				var tevt = dojo.string.trim(evts[y]);
+				if(evts[y].indexOf(":") >= 0){
+					// oh, if only JS had tuple assignment
+					var funcNameArr = tevt.split(":");
+					tevt = dojo.string.trim(funcNameArr[0]);
+					thisFunc = dojo.string.trim(funcNameArr[1]);
+				}
+				if(!thisFunc){
+					thisFunc = tevt;
+				}
+
+				var tf = function(){ 
+					var ntf = new String(thisFunc);
+					return function(evt){
+						if(_this[ntf]){
+							_this[ntf](dojo.event.browser.fixEvent(evt));
+						}
+					};
+				}();
+				dojo.event.browser.addListener(baseNode, tevt, tf, false, true);
+			}
+		}
+
+		for(var y=0; y<events.length; y++){
+			//alert(events[x]);
+			var evtVal = baseNode.getAttribute(events[y]);
+			if((evtVal)&&(evtVal.length)){
+				var thisFunc = null;
+				var domEvt = events[y].substr(4); // clober the "dojo" prefix
+				thisFunc = dojo.string.trim(evtVal);
+				var tf = function(){ 
+					var ntf = new String(thisFunc);
+					return function(evt){
+						if(_this[ntf]){
+							_this[ntf](dojo.event.browser.fixEvent(evt));
+						}
+					}
+				}();
+				dojo.event.browser.addListener(baseNode, domEvt, tf, false, true);
+			}
+		}
+
+		var onBuild = baseNode.getAttribute(this.onBuildProperty);
+		if(onBuild){
+			eval("var node = baseNode; var widget = targetObj; "+onBuild);
+		}
+
+		// strip IDs to prevent dupes
+		baseNode.id = "";
+	}
+
+}
+
+dojo.widget.getDojoEventsFromStr = function(str){
+	// var lstr = str.toLowerCase();
+	var re = /(dojoOn([a-z]+)(\s?))=/gi;
+	var evts = str ? str.match(re)||[] : [];
+	var ret = [];
+	var lem = {};
+	for(var x=0; x<evts.length; x++){
+		if(evts[x].legth < 1){ continue; }
+		var cm = evts[x].replace(/\s/, "");
+		cm = (cm.slice(0, cm.length-1));
+		if(!lem[cm]){
+			lem[cm] = true;
+			ret.push(cm);
+		}
+	}
+	return ret;
+}
+
+
+dojo.widget.buildAndAttachTemplate = function(obj, templatePath, templateCssPath, templateString, targetObj) {
+	this.buildFromTemplate(obj, templatePath, templateCssPath, templateString);
+	var node = dojo.dom.createNodesFromText(obj.templateString, true)[0];
+	this.attachTemplateNodes(node, targetObj||obj, dojo.widget.getDojoEventsFromStr(templateString));
+	return node;
+}
+
+dojo.widget.DomWidget = function(){
+	dojo.widget.Widget.call(this);
+	if((arguments.length>0)&&(typeof arguments[0] == "object")){
+		this.create(arguments[0]);
+	}
+}
+dojo.inherits(dojo.widget.DomWidget, dojo.widget.Widget);
+
+dojo.lang.extend(dojo.widget.DomWidget, {
+	templateNode: null,
+	templateString: null,
+	preventClobber: false,
+	domNode: null, // this is our visible representation of the widget!
+	containerNode: null, // holds child elements
+
+	// Process the given child widget, inserting it's dom node as a child of our dom node
+	// FIXME: should we support addition at an index in the children arr and
+	// order the display accordingly? Right now we always append.
+	addChild: function(widget, overrideContainerNode, pos, ref, insertIndex){
+		if(!this.isContainer){ // we aren't allowed to contain other widgets, it seems
+			dojo.debug("dojo.widget.DomWidget.addChild() attempted on non-container widget");
+			return null;
+		}else{
+			this.addWidgetAsDirectChild(widget, overrideContainerNode, pos, ref, insertIndex);
+			this.registerChild(widget, insertIndex);
+		}
+		return widget;
+	},
+	
+	addWidgetAsDirectChild: function(widget, overrideContainerNode, pos, ref, insertIndex){
+		if((!this.containerNode)&&(!overrideContainerNode)){
+			this.containerNode = this.domNode;
+		}
+		var cn = (overrideContainerNode) ? overrideContainerNode : this.containerNode;
+		if(!pos){ pos = "after"; }
+		if(!ref){ ref = cn.lastChild; }
+		if(!insertIndex) { insertIndex = 0; }
+		widget.domNode.setAttribute("dojoinsertionindex", insertIndex);
+
+		// insert the child widget domNode directly underneath my domNode, in the
+		// specified position (by default, append to end)
+		if(!ref){
+			cn.appendChild(widget.domNode);
+		}else{
+			// FIXME: was this meant to be the (ugly hack) way to support insert @ index?
+			//dojo.dom[pos](widget.domNode, ref, insertIndex);
+
+			// CAL: this appears to be the intended way to insert a node at a given position...
+			if (pos == 'insertAtIndex'){
+				// dojo.debug("idx:", insertIndex, "isLast:", ref === cn.lastChild);
+				dojo.dom.insertAtIndex(widget.domNode, ref.parentNode, insertIndex);
+			}else{
+				// dojo.debug("pos:", pos, "isLast:", ref === cn.lastChild);
+				if((pos == "after")&&(ref === cn.lastChild)){
+					cn.appendChild(widget.domNode);
+				}else{
+					dojo.dom.insertAtPosition(widget.domNode, cn, pos);
+				}
+			}
+		}
+	},
+
+	// Record that given widget descends from me
+	registerChild: function(widget, insertionIndex){
+
+		// we need to insert the child at the right point in the parent's 
+		// 'children' array, based on the insertionIndex
+
+		widget.dojoInsertionIndex = insertionIndex;
+
+		var idx = -1;
+		for(var i=0; i<this.children.length; i++){
+			if (this.children[i].dojoInsertionIndex < insertionIndex){
+				idx = i;
+			}
+		}
+
+		this.children.splice(idx+1, 0, widget);
+
+		widget.parent = this;
+		widget.addedTo(this);
+		
+		// If this widget was created programatically, then it was erroneously added
+		// to dojo.widget.manager.topWidgets.  Fix that here.
+		delete dojo.widget.manager.topWidgets[widget.widgetId];
+	},
+
+	// FIXME: we really need to normalize how we do things WRT "destroy" vs. "remove"
+	removeChild: function(widget){
+		for(var x=0; x<this.children.length; x++){
+			if(this.children[x] === widget){
+				this.children.splice(x, 1);
+				break;
+			}
+		}
+		return widget;
+	},
+
+	getFragNodeRef: function(frag){
+		if( !frag["dojo:"+this.widgetType.toLowerCase()] ){
+			dojo.raise("Error: no frag for widget type " + this.widgetType +
+				", id " + this.widgetId + " (maybe a widget has set it's type incorrectly)");
+		}
+		return (frag ? frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"] : null);
+	},
+	
+	// Replace source domNode with generated dom structure, and register
+	// widget with parent.
+	postInitialize: function(args, frag, parentComp){
+		var sourceNodeRef = this.getFragNodeRef(frag);
+		// Stick my generated dom into the output tree
+		//alert(this.widgetId + ": replacing " + sourceNodeRef + " with " + this.domNode.innerHTML);
+		if (parentComp && (parentComp.snarfChildDomOutput || !sourceNodeRef)){
+			// Add my generated dom as a direct child of my parent widget
+			// This is important for generated widgets, and also cases where I am generating an
+			// <li> node that can't be inserted back into the original DOM tree
+			parentComp.addWidgetAsDirectChild(this, "", "insertAtIndex", "",  args["dojoinsertionindex"], sourceNodeRef);
+		} else if (sourceNodeRef){
+			// Do in-place replacement of the my source node with my generated dom
+			if(this.domNode && (this.domNode !== sourceNodeRef)){
+				var oldNode = sourceNodeRef.parentNode.replaceChild(this.domNode, sourceNodeRef);
+			}
+		}
+
+		// Register myself with my parent, or with the widget manager if
+		// I have no parent
+		// TODO: the code below erroneously adds all programatically generated widgets
+		// to topWidgets (since we don't know who the parent is until after creation finishes)
+		if ( parentComp ) {
+			parentComp.registerChild(this, args.dojoinsertionindex);
+		} else {
+			dojo.widget.manager.topWidgets[this.widgetId]=this;
+		}
+
+		// Expand my children widgets
+		if(this.isContainer){
+			//alert("recurse from " + this.widgetId);
+			// build any sub-components with us as the parent
+			var fragParser = dojo.widget.getParser();
+			fragParser.createComponents(frag, this);
+		}
+	},
+
+	startResize: function(coords){
+		dj_unimplemented("dojo.widget.DomWidget.startResize");
+	},
+
+	updateResize: function(coords){
+		dj_unimplemented("dojo.widget.DomWidget.updateResize");
+	},
+
+	endResize: function(coords){
+		dj_unimplemented("dojo.widget.DomWidget.endResize");
+	},
+
+	// method over-ride
+	buildRendering: function(args, frag){
+		// DOM widgets construct themselves from a template
+		var ts = dojo.widget.DomWidget.templates[this.widgetType];
+		if(	
+			(!this.preventClobber)&&(
+				(this.templatePath)||
+				(this.templateNode)||
+				(
+					(this["templateString"])&&(this.templateString.length) 
+				)||
+				(
+					(typeof ts != "undefined")&&( (ts["string"])||(ts["node"]) )
+				)
+			)
+		){
+			// if it looks like we can build the thing from a template, do it!
+			this.buildFromTemplate(args, frag);
+		}else{
+			// otherwise, assign the DOM node that was the source of the widget
+			// parsing to be the root node
+			this.domNode = this.getFragNodeRef(frag);
+		}
+		this.fillInTemplate(args, frag); 	// this is where individual widgets
+											// will handle population of data
+											// from properties, remote data
+											// sets, etc.
+	},
+
+	buildFromTemplate: function(args, frag){
+		// var start = new Date();
+		// copy template properties if they're already set in the templates object
+		var ts = dojo.widget.DomWidget.templates[this.widgetType];
+		if(ts){
+			if(!this.templateString.length){
+				this.templateString = ts["string"];
+			}
+			if(!this.templateNode){
+				this.templateNode = ts["node"];
+			}
+		}
+		var matches = false;
+		var node = null;
+		var tstr = new String(this.templateString); 
+		// attempt to clone a template node, if there is one
+		if((!this.templateNode)&&(this.templateString)){
+			matches = this.templateString.match(/\$\{([^\}]+)\}/g);
+			if(matches) {
+				// if we do property replacement, don't create a templateNode
+				// to clone from.
+				var hash = this.strings || {};
+				// FIXME: should this hash of default replacements be cached in
+				// templateString?
+				for(var key in dojo.widget.defaultStrings) {
+					if(dojo.lang.isUndefined(hash[key])) {
+						hash[key] = dojo.widget.defaultStrings[key];
+					}
+				}
+				// FIXME: this is a lot of string munging. Can we make it faster?
+				for(var i = 0; i < matches.length; i++) {
+					var key = matches[i];
+					key = key.substring(2, key.length-1);
+					var kval = (key.substring(0, 5) == "this.") ? this[key.substring(5)] : hash[key];
+					var value;
+					if((kval)||(dojo.lang.isString(kval))){
+						value = (dojo.lang.isFunction(kval)) ? kval.call(this, key, this.templateString) : kval;
+						tstr = tstr.replace(matches[i], value);
+					}
+				}
+			}else{
+				// otherwise, we are required to instantiate a copy of the template
+				// string if one is provided.
+				
+				// FIXME: need to be able to distinguish here what should be done
+				// or provide a generic interface across all DOM implementations
+				// FIMXE: this breaks if the template has whitespace as its first 
+				// characters
+				// node = this.createNodesFromText(this.templateString, true);
+				// this.templateNode = node[0].cloneNode(true); // we're optimistic here
+				this.templateNode = this.createNodesFromText(this.templateString, true)[0];
+				ts.node = this.templateNode;
+			}
+		}
+		if((!this.templateNode)&&(!matches)){ 
+			dojo.debug("weren't able to create template!");
+			return false;
+		}else if(!matches){
+			node = this.templateNode.cloneNode(true);
+			if(!node){ return false; }
+		}else{
+			node = this.createNodesFromText(tstr, true)[0];
+		}
+
+		// recurse through the node, looking for, and attaching to, our
+		// attachment points which should be defined on the template node.
+
+		this.domNode = node;
+		// dojo.profile.start("attachTemplateNodes");
+		this.attachTemplateNodes(this.domNode, this);
+		// dojo.profile.end("attachTemplateNodes");
+		
+		// relocate source contents to templated container node
+		// this.containerNode must be able to receive children, or exceptions will be thrown
+		if (this.isContainer && this.containerNode){
+			var src = this.getFragNodeRef(frag);
+			if (src){
+				dojo.dom.moveChildren(src, this.containerNode);
+			}
+		}
+	},
+
+	attachTemplateNodes: function(baseNode, targetObj){
+		if(!targetObj){ targetObj = this; }
+		return dojo.widget.attachTemplateNodes(baseNode, targetObj, 
+					dojo.widget.getDojoEventsFromStr(this.templateString));
+	},
+
+	fillInTemplate: function(){
+		// dj_unimplemented("dojo.widget.DomWidget.fillInTemplate");
+	},
+	
+	// method over-ride
+	destroyRendering: function(){
+		try{
+			var tempNode = this.domNode.parentNode.removeChild(this.domNode);
+			delete tempNode;
+		}catch(e){ /* squelch! */ }
+	},
+
+	// FIXME: method over-ride
+	cleanUp: function(){},
+	
+	getContainerHeight: function(){
+		// FIXME: the generic DOM widget shouldn't be using HTML utils!
+		return dojo.html.getInnerHeight(this.domNode.parentNode);
+	},
+
+	getContainerWidth: function(){
+		// FIXME: the generic DOM widget shouldn't be using HTML utils!
+		return dojo.html.getInnerWidth(this.domNode.parentNode);
+	},
+
+	createNodesFromText: function(){
+		dj_unimplemented("dojo.widget.DomWidget.createNodesFromText");
+	}
+});
+dojo.widget.DomWidget.templates = {};

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DropdownButton.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DropdownButton.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DropdownButton.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/DropdownButton.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,29 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.DropdownButton");
+
+dojo.deprecated("dojo.widget.DropdownButton",  "use dojo.widget.ComboButton2", "0.4");
+
+// Draws a button with a down arrow;
+// when you press the down arrow something appears (usually a menu)
+
+dojo.require("dojo.widget.*");
+
+dojo.widget.tags.addParseTreeHandler("dojo:dropdownbutton");
+
+dojo.widget.DropdownButton = function(){
+	dojo.widget.Widget.call(this);
+
+	this.widgetType = "DropdownButton";
+}
+dojo.inherits(dojo.widget.DropdownButton, dojo.widget.Widget);
+
+dojo.requireAfterIf("html", "dojo.widget.html.DropdownButton");

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Editor.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Editor.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Editor.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/Editor.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,619 @@
+/*
+	Copyright (c) 2004-2005, 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
+*/
+
+/* TODO:
+ * - font selector
+ * - test, bug fix, more features :)
+*/
+dojo.provide("dojo.widget.Editor");
+dojo.provide("dojo.widget.html.Editor");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.Toolbar");
+dojo.require("dojo.widget.RichText");
+dojo.require("dojo.widget.ColorPalette");
+
+dojo.widget.tags.addParseTreeHandler("dojo:Editor");
+
+dojo.widget.html.Editor = function() {
+	dojo.widget.HtmlWidget.call(this);
+	this.contentFilters = [];
+}
+dojo.inherits(dojo.widget.html.Editor, dojo.widget.HtmlWidget);
+
+dojo.widget.html.Editor.itemGroups = {
+	textGroup: ["bold", "italic", "underline", "strikethrough"],
+	blockGroup: ["formatBlock", "fontName"],
+	justifyGroup: ["justifyleft", "justifycenter", "justifyright"],
+	commandGroup: ["save", "cancel"],
+	colorGroup: ["forecolor", "hilitecolor"],
+	listGroup: ["insertorderedlist", "insertunorderedlist"],
+	indentGroup: ["outdent", "indent"],
+	linkGroup: ["createlink", "insertimage"]
+};
+
+dojo.widget.html.Editor.formatBlockValues = {
+	"Normal": "p",
+	"Main heading": "h2",
+	"Sub heading": "h3",
+	"Sub sub headering": "h4",
+	"Preformatted": "pre"
+};
+
+dojo.widget.html.Editor.fontNameValues = {
+	"Arial": "Arial, Helvetica, sans-serif",
+	"Verdana": "Verdana, sans-serif",
+	"Times New Roman": "Times New Roman, serif",
+	"Courier": "Courier New, monospace"
+};
+
+dojo.widget.html.Editor.defaultItems = [
+	"commandGroup", "|", "linkGroup", "|", "textGroup", "|", "justifyGroup", "|", "listGroup", "indentGroup", "|", "colorGroup"
+];
+
+// ones we support by default without asking the RichText component
+// NOTE: you shouldn't put buttons like bold, italic, etc in here
+dojo.widget.html.Editor.supportedCommands = ["save", "cancel", "|", "-", "/", " "];
+
+dojo.lang.extend(dojo.widget.html.Editor, {
+	widgetType: "Editor",
+
+	items: dojo.widget.html.Editor.defaultItems,
+	formatBlockItems: dojo.lang.shallowCopy(dojo.widget.html.Editor.formatBlockValues),
+	fontNameItems: dojo.lang.shallowCopy(dojo.widget.html.Editor.fontNameValues),
+
+	// used to get the properties of an item if it is given as a string
+	getItemProperties: function(name) {
+		var props = {};
+		switch(name.toLowerCase()) {
+			case "bold":
+			case "italic":
+			case "underline":
+			case "strikethrough":
+				props.toggleItem = true;
+				break;
+
+			case "justifygroup":
+				props.defaultButton = "justifyleft";
+				props.preventDeselect = true;
+				props.buttonGroup = true;
+				break;
+
+			case "listgroup":
+				props.buttonGroup = true;
+				break;
+
+			case "save":
+			case "cancel":
+				props.label = dojo.string.capitalize(name);
+				break;
+
+			case "forecolor":
+			case "hilitecolor":
+				props.name = name;
+				props.toggleItem = true; // FIXME: they aren't exactly toggle items
+				props.icon = this.getCommandImage(name);
+				break;
+
+			case "formatblock":
+				props.name = "formatBlock";
+				props.values = this.formatBlockItems;
+				break;
+
+			case "fontname":
+				props.name = "fontName";
+				props.values = this.fontNameItems;
+		}
+		return props;
+	},
+
+	validateItems: true, // set to false to add items, regardless of support
+	focusOnLoad: true,
+	minHeight: "1em",
+
+	_richText: null, // RichText widget
+	_richTextType: "RichText",
+
+	_toolbarContainer: null, // ToolbarContainer widget
+	_toolbarContainerType: "ToolbarContainer",
+
+	_toolbars: [],
+	_toolbarType: "Toolbar",
+
+	_toolbarItemType: "ToolbarItem",
+
+	buildRendering: function(args, frag) {
+		// get the node from args/frag
+		var node = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+		var trt = dojo.widget.createWidget(this._richTextType, {
+			focusOnLoad: this.focusOnLoad,
+			minHeight: this.minHeight
+		}, node)
+		var _this = this;
+		// this appears to fix a weird timing bug on Safari
+		setTimeout(function(){
+			_this.setRichText(trt);
+
+			_this.initToolbar();
+
+			_this.fillInTemplate(args, frag);
+		}, 0);
+	},
+
+	setRichText: function(richText) {
+		if(this._richText && this._richText == richText) {
+			dojo.debug("Already set the richText to this richText!");
+			return;
+		}
+
+		if(this._richText && !this._richText.isClosed) {
+			dojo.debug("You are switching richTexts yet you haven't closed the current one. Losing reference!");
+		}
+		this._richText = richText;
+		dojo.event.connect(this._richText, "close", this, "onClose");
+		dojo.event.connect(this._richText, "onLoad", this, "onLoad");
+		dojo.event.connect(this._richText, "onDisplayChanged", this, "updateToolbar");
+		if(this._toolbarContainer) {
+			this._toolbarContainer.enable();
+			this.updateToolbar(true);
+		}
+	},
+
+	initToolbar: function() {
+		// var tic = new Date();
+		if(this._toolbarContainer) { return; } // only create it once
+		this._toolbarContainer = dojo.widget.createWidget(this._toolbarContainerType);
+		var tb = this.addToolbar();
+		var last = true;
+		for(var i = 0; i < this.items.length; i++) {
+			if(this.items[i] == "\n") { // new row
+				tb = this.addToolbar();
+			} else {
+				if((this.items[i] == "|")&&(!last)){
+					last = true;
+				}else{
+					last = this.addItem(this.items[i], tb);
+				}
+			}
+		}
+		this.insertToolbar(this._toolbarContainer.domNode, this._richText.domNode);
+		// alert(new Date - tic);
+	},
+
+	// allow people to override this so they can make their own placement logic
+	insertToolbar: function(tbNode, richTextNode) {
+		dojo.html.insertBefore(tbNode, richTextNode);
+		//dojo.html.insertBefore(this._toolbarContainer.domNode, this._richText.domNode);
+	},
+
+	addToolbar: function(toolbar) {
+		this.initToolbar();
+		if(!(toolbar instanceof dojo.widget.html.Toolbar)) {
+			toolbar = dojo.widget.createWidget(this._toolbarType);
+		}
+		this._toolbarContainer.addChild(toolbar);
+		this._toolbars.push(toolbar);
+		return toolbar;
+	},
+
+	addItem: function(item, tb, dontValidate) {
+		if(!tb) { tb = this._toolbars[0]; }
+		var cmd = ((item)&&(!dojo.lang.isUndefined(item["getValue"]))) ?  cmd = item["getValue"](): item;
+
+		var groups = dojo.widget.html.Editor.itemGroups;
+		if(item instanceof dojo.widget.ToolbarItem) {
+			tb.addChild(item);
+		} else if(groups[cmd]) {
+			var group = groups[cmd];
+			var worked = true;
+			if(cmd == "justifyGroup" || cmd == "listGroup") {
+				var btnGroup = [cmd];
+				for(var i = 0 ; i < group.length; i++) {
+					if(dontValidate || this.isSupportedCommand(group[i])) {
+						btnGroup.push(this.getCommandImage(group[i]));
+					}else{
+						worked = false;
+					}
+				}
+				if(btnGroup.length) {
+					var btn = tb.addChild(btnGroup, null, this.getItemProperties(cmd));
+					dojo.event.connect(btn, "onClick", this, "_action");
+					dojo.event.connect(btn, "onChangeSelect", this, "_action");
+				}
+				return worked;
+			} else {
+				for(var i = 0; i < group.length; i++) {
+					if(!this.addItem(group[i], tb)){
+						worked = false;
+					}
+				}
+				return worked;
+			}
+		} else {
+			if((!dontValidate)&&(!this.isSupportedCommand(cmd))){
+				return false;
+			}
+			if(dontValidate || this.isSupportedCommand(cmd)) {
+				cmd = cmd.toLowerCase();
+				if(cmd == "formatblock") {
+					var select = dojo.widget.createWidget("ToolbarSelect", {
+						name: "formatBlock",
+						values: this.formatBlockItems
+					});
+					tb.addChild(select);
+					var _this = this;
+					dojo.event.connect(select, "onSetValue", function(item, value) {
+						_this.onAction("formatBlock", value);
+					});
+				} else if(cmd == "fontname") {
+					var select = dojo.widget.createWidget("ToolbarSelect", {
+						name: "fontName",
+						values: this.fontNameItems
+					});
+					tb.addChild(select);
+					dojo.event.connect(select, "onSetValue", dojo.lang.hitch(this, function(item, value) {
+						this.onAction("fontName", value);
+					}));
+				} else if(dojo.lang.inArray(cmd, ["forecolor", "hilitecolor"])) {
+					var btn = tb.addChild(dojo.widget.createWidget("ToolbarColorDialog", this.getItemProperties(cmd)));
+					dojo.event.connect(btn, "onSetValue", this, "_setValue");
+				} else {
+					var btn = tb.addChild(this.getCommandImage(cmd), null, this.getItemProperties(cmd));
+					if(dojo.lang.inArray(cmd, ["save", "cancel"])) {
+						dojo.event.connect(btn, "onClick", this, "_close");
+					} else {
+						dojo.event.connect(btn, "onClick", this, "_action");
+						dojo.event.connect(btn, "onChangeSelect", this, "_action");
+					}
+				}
+			}
+		}
+		return true;
+	},
+
+	enableToolbar: function() {
+		if(this._toolbarContainer) {
+			this._toolbarContainer.domNode.style.display = "";
+			this._toolbarContainer.enable();
+		}
+	},
+
+	disableToolbar: function(hide){
+		if(hide){
+			if(this._toolbarContainer){
+				this._toolbarContainer.domNode.style.display = "none";
+			}
+		}else{
+			if(this._toolbarContainer){
+				this._toolbarContainer.disable();
+			}
+		}
+	},
+
+	_updateToolbarLastRan: null,
+	_updateToolbarTimer: null,
+	_updateToolbarFrequency: 500,
+
+	updateToolbar: function(force) {
+		if(!this._toolbarContainer) { return; }
+
+		// keeps the toolbar from updating too frequently
+		// TODO: generalize this functionality?
+		var diff = new Date() - this._updateToolbarLastRan;
+		if(!force && this._updateToolbarLastRan && (diff < this._updateToolbarFrequency)) {
+			clearTimeout(this._updateToolbarTimer);
+			var _this = this;
+			this._updateToolbarTimer = setTimeout(function() {
+				_this.updateToolbar();
+			}, this._updateToolbarFrequency/2);
+			return;
+		} else {
+			this._updateToolbarLastRan = new Date();
+		}
+		// end frequency checker
+
+		var items = this._toolbarContainer.getItems();
+		for(var i = 0; i < items.length; i++) {
+			var item = items[i];
+			if(item instanceof dojo.widget.html.ToolbarSeparator) { continue; }
+			var cmd = item._name;
+			if (cmd == "save" || cmd == "cancel") { continue; }
+			else if(cmd == "justifyGroup") {
+				try {
+					if(!this._richText.queryCommandEnabled("justifyleft")) {
+						item.disable(false, true);
+					} else {
+						item.enable(false, true);
+						var jitems = item.getItems();
+						for(var j = 0; j < jitems.length; j++) {
+							var name = jitems[j]._name;
+							var value = this._richText.queryCommandValue(name);
+							if(typeof value == "boolean" && value) {
+								value = name;
+								break;
+							} else if(typeof value == "string") {
+								value = "justify"+value;
+							} else {
+								value = null;
+							}
+						}
+						if(!value) { value = "justifyleft"; } // TODO: query actual style
+						item.setValue(value, false, true);
+					}
+				} catch(err) {}
+			} else if(cmd == "listGroup") {
+				var litems = item.getItems();
+				for(var j = 0; j < litems.length; j++) {
+					this.updateItem(litems[j]);
+				}
+			} else {
+				this.updateItem(item);
+			}
+		}
+	},
+
+	updateItem: function(item) {
+		try {
+			var cmd = item._name;
+			var enabled = this._richText.queryCommandEnabled(cmd);
+			item.setEnabled(enabled, false, true);
+
+			var active = this._richText.queryCommandState(cmd);
+			if(active && cmd == "underline") {
+				// don't activate underlining if we are on a link
+				active = !this._richText.queryCommandEnabled("unlink");
+			}
+			item.setSelected(active, false, true);
+			return true;
+		} catch(err) {
+			return false;
+		}
+	},
+
+	supportedCommands: dojo.widget.html.Editor.supportedCommands.concat(),
+
+	isSupportedCommand: function(cmd) {
+		// FIXME: how do we check for ActiveX?
+		var yes = dojo.lang.inArray(cmd, this.supportedCommands);
+		if(!yes) {
+			try {
+				var richText = this._richText || dojo.widget.html.RichText.prototype;
+				yes = richText.queryCommandAvailable(cmd);
+			} catch(E) {}
+		}
+		return yes;
+	},
+
+	getCommandImage: function(cmd) {
+		if(cmd == "|") {
+			return cmd;
+		} else {
+			return dojo.uri.dojoUri("src/widget/templates/buttons/" + cmd + ".gif");
+		}
+	},
+
+	_action: function(e) {
+		// djConfig.isDebug = true;
+		// dojo.debug(e);
+		// dojo.debug(e.getValue());
+		this._fire("onAction", e.getValue());
+	},
+
+	_setValue: function(a, b) {
+		this._fire("onAction", a.getValue(), b);
+	},
+
+	_close: function(e) {
+		if(!this._richText.isClosed) {
+			this._richText.close(e.getName().toLowerCase() == "save");
+		}
+	},
+
+	onAction: function(cmd, value) {
+		switch(cmd) {
+			case "createlink":
+				if(!(value = prompt("Please enter the URL of the link:", "http://"))) {
+					return;
+				}
+				break;
+			case "insertimage":
+				if(!(value = prompt("Please enter the URL of the image:", "http://"))) {
+					return;
+				}
+				break;
+		}
+		this._richText.execCommand(cmd, value);
+	},
+
+	fillInTemplate: function(args, frag) {
+		// dojo.event.connect(this, "onResized", this._richText, "onResized");
+	},
+
+	_fire: function(eventName) {
+		if(dojo.lang.isFunction(this[eventName])) {
+			var args = [];
+			if(arguments.length == 1) {
+				args.push(this);
+			} else {
+				for(var i = 1; i < arguments.length; i++) {
+					args.push(arguments[i]);
+				}
+			}
+			this[eventName].apply(this, args);
+		}
+	},
+
+	getHtml: function(){
+		this._richText.contentFilters = this.contentFilters;
+		return this._richText.getEditorContent();
+	},
+
+	getEditorContent: function(){
+		return this.getHtml();
+	},
+
+	onClose: function(save, hide){
+		this.disableToolbar(hide);
+		if(save) {
+			this._fire("onSave");
+		} else {
+			this._fire("onCancel");
+		}
+	},
+
+	// events baby!
+	onLoad: function(){},
+	onSave: function(){},
+	onCancel: function(){}
+});
+
+/*
+function dontRunMe() {
+function createToolbar() {
+	tick("createToolbar");
+	tick("ct-init");
+	tbCont = dojo.widget.createWidget("toolbarContainer");
+	tb = dojo.widget.createWidget("toolbar");
+	tbCont.addChild(tb);
+
+	var saveBtn = tb.addChild("Save");
+	dojo.event.connect(saveBtn, "onClick", function() { editor.close(true); });
+	var cancelBtn = tb.addChild("Cancel");
+	dojo.event.connect(cancelBtn, "onClick", function() { editor.close(false); });
+	tb.addChild("|");
+
+	var headings = dojo.widget.createWidget("ToolbarSelect", {
+		name: "formatBlock",
+		values: {
+			"Normal": "p",
+			"Main heading": "h2",
+			"Sub heading": "h3",
+			"Sub sub heading": "h4",
+			"Preformatted": "pre"
+		}
+	});
+	dojo.event.connect(headings, "onSetValue", function(item, val) {
+		editor.execCommand("formatBlock", val);
+	});
+	tb.addChild(headings);
+	tb.addChild("|");
+	tock("ct-init");
+
+	// toolbar layout (2 rows):
+	// Save Cancel | WikiWord | Link Img | Table
+	// Heading FontFace | B I U | Alignment | OL UL < > | FG BG
+	var rows = [
+		["save", "cancel", "|", "wikiword", "|", "createlink", "insertimage", "|", "table"],
+		["formatBlock", "font", "|", "bold", "italic", "underline", "|", "justification", "|", "ol", "ul", "forecolor", "hilitecolor"]
+	];
+
+	tick("command array");
+	var commands = [
+		{ values: ["bold", "italic", "underline", "strikethrough"], toggleItem: true },
+		{ values: [
+				dojo.widget.createWidget("ToolbarColorDialog", {toggleItem: true, name: "forecolor", icon: cmdImg("forecolor")}),
+				dojo.widget.createWidget("ToolbarColorDialog", {toggleItem: true, name: "hilitecolor", icon: cmdImg("hilitecolor")})
+		]},
+		{ values: ["justifyleft", "justifycenter", "justifyright"], name: "justify", defaultButton: "justifyleft", buttonGroup: true, preventDeselect: true },
+		{ values: ["createlink", "insertimage"] },
+		{ values: ["outdent", "indent"] },
+		{ values: ["insertorderedlist", "insertunorderedlist"], name: "list", buttonGroup: true },
+		{ values: ["undo", "redo"] },
+		{ values: ["wikiword"], title: "WikiWord" }
+	];
+	tock("command array");
+
+	tick("processCommands");
+	for(var i = 0; i < commands.length; i++) {
+		var set = commands[i];
+		var values = set.values;
+		var btnGroup = [set.name];
+		for(var j = 0; j < values.length; j++) {
+			if(typeof values[j] == "string") {
+				var cmd = values[j];
+				if(cmd == "wikiword") {
+					var btn = tb.addChild(cmdImg(cmd), null, {name:cmd, label:"WikiWord"});
+					//dojo.event.connect(bt, "onClick", listenWikiWord);
+					//dojo.event.connect(bt, "onChangeSelect", listenWikiWord);
+				} else if(dojo.widget.html.RichText.prototype.queryCommandAvailable(cmd)) {
+					if(set.buttonGroup) {
+						btnGroup.push(cmdImg(cmd));
+					} else {
+						var btn = tb.addChild(cmdImg(cmd), null, {name:cmd, toggleItem:set.toggleItem});
+						dojo.event.connect(btn, "onClick", listen);
+						dojo.event.connect(btn, "onChangeSelect", listen);
+					}
+				}
+			} else {
+				if(dojo.widget.html.RichText.prototype.queryCommandAvailable(values[j].getName())) {
+					var btn = tb.addChild(values[j]);
+					dojo.event.connect(btn, "onSetValue", colorListen, values[j].getName());
+				}
+			}
+		}
+		if(set.buttonGroup && btnGroup.length > 1) {
+			var btn = tb.addChild(btnGroup, null, {defaultButton:set.defaultButton});
+			dojo.event.connect(btn, "onClick", listen);
+			dojo.event.connect(btn, "onChangeSelect", listen);
+		}
+
+		if(i + 1 != commands.length
+			&& !(tb.children[tb.children.length-1] instanceof dojo.widget.html.ToolbarSeparator)) {
+			tb.addChild("|");
+		}
+	}
+	tock("processCommands");
+	tock("createToolbar");
+	return tbCont;
+}
+function cmdImg(cmd) {
+	return dojo.uri.dojoUri("src/widget/templates/buttons/" + cmd + ".gif");
+}
+function createWysiwyg(node) {
+	tick("createWysiwyg");
+	tick("editor");
+	editor = dojo.widget.createWidget("RichText", {}, node);
+	tock("editor");
+	dojo.event.connect(editor, "close", function(changed) {
+		if(changed) { setTimeout(save, 5); }
+		setTimeout(function() {
+			dojo.io.bind({
+				url: location,
+				content: {
+					edit: "0",
+					cancel: "Cancel"
+				},
+				handler: function() {
+					hideLoad();
+				}
+			});
+		}, 15);
+		finishEdit();
+	});
+	autolinkWikiWords(editor);
+	cleanupWord(editor);
+	//createToolbar();
+	dojo.event.connect(editor, "onDisplayChanged", updateToolbar);
+
+	if(editor && tbCont && tb) {
+		var top = document.getElementById("jot-topbar");
+		dojo.html.addClass(top, "hidden");
+		//placeToolbar(tbCont.domNode);
+		//top.appendChild(tbCont.domNode);
+		//document.getElementById("jot-bottombar").innerHTML = "&nbsp;";
+	} else {
+		alert("Something went wrong trying to create the toolbar + editor.");
+	}
+	tock("createWysiwyg");
+	
+	return editor;
+}
+
+}
+*/

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTree.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTree.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTree.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTree.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,499 @@
+/*
+	Copyright (c) 2004-2005, 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
+*/
+
+/**
+ * Tree model does all the drawing, visual node management etc.
+ * Throws events about clicks on it, so someone may catch them and process
+ * Tree knows nothing about DnD stuff, covered in TreeDragAndDrop and (if enabled) attached by controller
+*/
+dojo.provide("dojo.widget.EditorTree");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.dnd.*");
+dojo.require("dojo.fx.html");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Container");
+dojo.require("dojo.widget.Tree");
+dojo.require("dojo.widget.EditorTreeNode");
+
+// make it a tag
+dojo.widget.tags.addParseTreeHandler("dojo:EditorTree");
+
+
+dojo.widget.EditorTree = function() {
+	dojo.widget.html.Container.call(this);
+	this.acceptDropSources = [];
+
+	this.eventNames = {
+		// new node built.. Well, just built
+		nodeCreate: "",
+		// expand icon clicked
+		treeClick: "",
+		// node icon clicked
+		iconClick: "",
+		// node title clicked
+		titleClick: ""
+	};
+}
+dojo.inherits(dojo.widget.EditorTree, dojo.widget.html.Container);
+
+/* extend DOES NOT copy recursively */
+dojo.lang.extend(dojo.widget.EditorTree, {
+	widgetType: "EditorTree",
+
+	domNode: null,
+
+	templateCssPath: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/EditorTree.css"),
+
+	templateString: '<div class="dojoTree"></div>',
+
+	/* Model events */
+	eventNames: null,
+
+	toggler: null,
+
+	//
+	// these icons control the grid and expando buttons for the whole tree
+	//
+
+	blankIconSrc: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_blank.gif").toString(),
+
+	gridIconSrcT: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_t.gif").toString(), // for non-last child grid
+	gridIconSrcL: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_l.gif").toString(), // for last child grid
+	gridIconSrcV: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_v.gif").toString(), // vertical line
+	gridIconSrcP: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_p.gif").toString(), // for under parent item child icons
+	gridIconSrcC: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_c.gif").toString(), // for under child item child icons
+	gridIconSrcX: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_x.gif").toString(), // grid for sole root item
+	gridIconSrcY: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_y.gif").toString(), // grid for last rrot item
+	gridIconSrcZ: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_grid_z.gif").toString(), // for under root parent item child icon
+
+	expandIconSrcPlus: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_expand_plus.gif").toString(),
+	expandIconSrcMinus: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_expand_minus.gif").toString(),
+	expandIconSrcLoading: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/treenode_loading.gif").toString(),
+
+
+	iconWidth: 18,
+	iconHeight: 18,
+
+
+	//
+	// tree options
+	//
+
+	showGrid: true,
+	showRootGrid: true,
+
+	toggle: "default",
+	toggleDuration: 150,
+	title: "My Tree", // used for debug only
+	selector: null,
+
+	initialize: function(args, frag){
+
+		var sources;
+		if ( (sources = args['acceptDropSources']) || (sources = args['acceptDropSources']) ) {
+			this.acceptDropSources = sources.split(',');
+		}
+
+		switch (this.toggle) {
+
+			case "fade": this.toggler = new dojo.widget.Tree.FadeToggle(); break;
+			// buggy - try to open many nodes in FF (IE is ok)
+			case "wipe": this.toggler = new dojo.widget.Tree.WipeToggle(); break;
+			default    : this.toggler = new dojo.widget.Tree.DefaultToggle();
+		}
+
+
+		if (args['eventNaming'] == "default" || args['eventnaming'] == "default" ) { // IE || FF
+
+			for (eventName in this.eventNames) {
+				this.eventNames[eventName] = this.widgetId+"/"+eventName;
+			}
+			/*
+			this.eventNames.watch("nodeCreate",
+   				function (id,oldval,newval) {
+      				alert("o." + id + " changed from " + oldval + " to " + newval);
+      				return newval;
+			   }
+			  );
+			 */
+
+		//	alert(dojo.widget.manager.getWidgetById('firstTree').widgetId)
+		//	alert(dojo.widget.manager.getWidgetById('firstTree').eventNames.nodeCreate);
+
+		}
+
+
+		if (args['controller']) {
+			var controller = dojo.widget.manager.getWidgetById(args['controller']);
+
+			controller.subscribeTree(this); // controller listens to my events
+		}
+
+		if (args['selector']) {
+			this.selector = dojo.widget.manager.getWidgetById(args['selector']);
+		}
+		else {
+			this.selector = new dojo.widget.createWidget("dojo.widget.EditorTreeSelector");
+		}
+
+	},
+
+
+
+	postCreate: function() {
+		this.buildTree();
+	},
+
+	buildTree: function() {
+
+		dojo.html.disableSelection(this.domNode);
+
+		for(var i=0; i<this.children.length; i++){
+
+			this.children[i].isFirstNode = (i == 0) ? true : false;
+			this.children[i].isLastNode = (i == this.children.length-1) ? true : false;
+			this.children[i].parentNode = this; // root nodes have tree as parent
+
+			var node = this.children[i].buildNode(this, 0);
+
+
+			this.domNode.appendChild(node);
+		}
+
+
+		//
+		// when we don't show root toggles, we need to auto-expand root nodes
+		//
+
+		if (!this.showRootGrid){
+			for(var i=0; i<this.children.length; i++){
+				this.children[i].expand();
+			}
+		}
+
+
+		for(var i=0; i<this.children.length; i++){
+			this.children[i].startMe();
+		}
+	},
+
+
+
+	/**
+	 * Move child to newParent as last child
+	 * redraw tree and update icons
+	*/
+	changeParent: function(child, newParent) {
+		//dojo.debug("Move "+child.title+" to "+newParent.title)
+
+		/* do actual parent change here. Write remove child first */
+		child.parentNode.removeChild(child);
+
+		newParent.addChild(child, 0);
+
+	},
+
+	removeChild: function(child) {
+
+		var parentNode = child.parentNode;
+
+		var children = parentNode.children;
+
+		for(var i=0; i<children.length; i++){
+			if(children[i] === child){
+				if (children.length>1) {
+					if (i==0) {
+						children[i+1].isFirstNode = true;
+					}
+					if (i==children.length-1) {
+						children[i-1].isLastNode = true;
+					}
+				}
+				children.splice(i, 1);
+				break;
+			}
+		}
+
+		child.domNode.parentNode.removeChild(child.domNode);
+
+
+		//dojo.debug("removeChild: "+child.title+" from "+parentNode.title);
+
+		if (children.length == 0) {
+			// toggle empty container off
+			if (parentNode.widgetType == 'EditorTreeNode') { // if has container
+				parentNode.containerNode.style.display = 'none';
+			}
+
+		}
+
+		parentNode.updateIconTree();
+
+		return child;
+
+	},
+
+
+
+	// not called for initial tree building. See buildNode instead.
+	// builds child html node if needed
+	// index is "last node" by default
+	addChild: function(child, index){
+		//dojo.debug("This "+this.title+" Child "+child.title+" index "+index);
+
+		if (dojo.lang.isUndefined(index)) {
+			index = this.children.length;
+		}
+
+		//
+		// this function gets called to add nodes to both trees and nodes, so it's a little confusing :)
+		//
+
+		if (child.widgetType != 'EditorTreeNode'){
+			dojo.raise("You can only add EditorTreeNode widgets to a "+this.widgetType+" widget!");
+			return;
+		}
+
+		// set/clean isFirstNode and isLastNode
+		if (this.children.length){
+			if (index == 0) {
+				this.children[0].isFirstNode = false;
+				child.isFirstNode = true;
+			}
+			else {
+				child.isFirstNode = false;
+			}
+			if (index == this.children.length) {
+				this.children[index-1].isLastNode = false;
+				child.isLastNode = true;
+			}
+			else {
+				child.isLastNode = false;
+			}
+		}
+		else {
+			child.isLastNode = true;
+			child.isFirstNode = true;
+		}
+
+
+
+		// usually it is impossible to change "isFolder" state, but if anyone wants to add a child to leaf,
+		// it is possible program-way.
+		if (this.widgetType == 'EditorTreeNode'){
+			this.isFolder = true;
+			//this.isExpanded = false;
+		}
+
+		// adjust tree
+		var tree = this.widgetType == 'EditorTreeNode' ? this.tree : this;
+		dojo.lang.forEach(child.getDescendants(), function(elem) { elem.tree = tree; });
+
+		/*
+		var stack = [child];
+		var elem;
+		// change tree for all subnodes
+		while (elem = stack.pop()) {
+			//dojo.debug("Tree for "+elem.title);
+			elem.tree = tree;
+			dojo.lang.forEach(elem.children, function(elem) { stack.push(elem); });
+		}
+		*/
+
+		// fix parent
+		child.parentNode = this;
+
+
+		// no dynamic loading for those who are parents already
+		if (this.widgetType == 'EditorTreeNode') {
+			this.loaded = this.loadStates.LOADED;
+		}
+
+		// if node exists - adjust its depth, otherwise build it
+		if (child.domNodeInitialized) {
+			//dojo.debug(this.widgetType)
+			var d = (this.widgetType == 'EditorTreeNode') ? this.depth : 0;
+			//dojo.debug('Depth is '+this.depth);
+			child.adjustDepth(d-child.depth+1);
+		}
+		else {
+			child.depth = this.widgetType == 'EditorTreeNode' ? this.depth+1 : 0;
+			child.buildNode(child.tree, child.depth);
+		}
+
+
+
+		//dojo.debug(child.domNode.outerHTML)
+
+		if (index < this.children.length) {
+
+			//dojo.debug('insert '+index)
+			//dojo.debugShallow(child);
+
+			// insert
+			this.children[index].domNode.parentNode.insertBefore(child.domNode, this.children[index].domNode);
+		}
+		else {
+			if (this.widgetType == 'EditorTree') {
+				this.domNode.appendChild(node);
+			}
+			else {
+
+				//dojo.debug('append '+index)
+
+			// enable container, cause I add first child into it
+				this.containerNode.style.display = 'block';
+
+				//this.domNode.insertBefore(child.domNode, this.containerNode);
+
+				//dojo.debugShallow(this.containerNode);
+				this.containerNode.appendChild(child.domNode);
+				//dojo.debugShallow(this.containerNode);
+			}
+		}
+
+		this.children.splice(index, 0, child);
+
+		//dojo.lang.forEach(this.children, function(child) { dojo.debug("Child "+child.title); } );
+
+		//dojo.debugShallow(child);
+
+		this.updateIconTree();
+
+		child.startMe();
+
+
+	},
+
+	makeBlankImg: function() {
+		var img = document.createElement('img');
+
+		img.style.width = this.iconWidth + 'px';
+		img.style.height = this.iconHeight + 'px';
+		img.src = this.blankIconSrc;
+		img.style.verticalAlign = 'middle';
+
+		return img;
+	},
+
+
+	/* Swap nodes with SAME parent */
+	swapNodes: function(node1, node2) {
+		if (node1 === node2) return;
+
+		if (node1.parentNode !== node2.parentNode) {
+			dojo.raise("You may only swap nodes with same parent")
+		}
+
+		var parentNode = node1.parentNode;
+
+		var nodeIndex1 = node1.getParentIndex();
+		var nodeIndex2 = node2.getParentIndex();
+
+		/* Fix children order */
+		parentNode.children[nodeIndex1] = node2;
+		parentNode.children[nodeIndex2] = node1;
+
+		/* swap isFirst/isLast flags */
+		var a = node1.isLastNode;
+		var b = node1.isFirstNode;
+		node1.isLastNode = node2.isLastNode;
+		node1.isFirstNode = node2.isFirstNode;
+		node2.isLastNode = a;
+		node2.isFirstNode = b;
+
+		//dojo.debug(node1.title+" : "+node2.title)
+
+		this.swapDomNodes(node1.domNode, node2.domNode);
+		//parentNode.containerNode.insertBefore(node2.domNode, node1.domNode);
+		//parentNode.containerNode.insertBefore(node1.domNode, node2.domNode);
+
+		//parentNode.containerNode.removeChild(this.domNode);
+
+		parentNode.updateIconTree();
+
+
+	},
+
+
+	/* Should go dojo.dom */
+	swapDomNodes: function(node1, node2) {
+		// replace node1 with node2
+		//dojo.debug(node1.parentNode)
+
+		// may have siblings only in n1 -> n2 order
+		if (node2.nextSibling === node1) return this.swapDomNodes(node2, node1);
+
+		var parentNode1 = node1.parentNode;
+		var parentNode2 = node2.parentNode;
+
+		var inserter1;
+		var inserter2;
+		var removed1;
+		var removed2;
+
+		if (node1.nextSibling === node2) {			// node1->node2
+			if (node2.nextSibling) {
+				var a2n = node2.nextSibling;
+				inserter1 = function(newNode) { parentNode1.insertBefore(newNode, a2n); }
+				inserter2 = function(newNode) { parentNode1.insertBefore(newNode, a2n); }
+			}
+			else {
+				inserter1 = function(newNode) { parentNode1.appendChild(newNode); }
+				inserter2 = function(newNode) { parentNode1.appendChild(newNode); }
+			}
+		}
+		else {
+			if (node1.nextSibling) {
+				inserter1 = function(newNode) { parentNode1.insertBefore(newNode, node1.nextSibling); }
+			}
+			else {
+				inserter1 = function(newNode) { parentNode1.appendChild(newNode); }
+			}
+
+			if (node2.nextSibling) {
+				inserter2 = function(newNode) { parentNode2.insertBefore(newNode, node2.nextSibling); }
+			}
+			else {
+				inserter2 = function(newNode) { parentNode2.appendChild(newNode); }
+			}
+		}
+
+
+		removed1 = parentNode1.removeChild(node1);
+		removed2 = parentNode2.removeChild(node2);
+
+		// order is important cause of n1->n2 case
+		inserter1.apply(this, [removed2]);
+		inserter2.apply(this, [removed1]);
+
+
+	},
+
+
+	updateIconTree: function(){
+
+		if (this.widgetType=='EditorTreeNode') {
+			this.updateIcons();
+		}
+
+		for(var i=0; i<this.children.length; i++){
+			this.children[i].updateIconTree();
+		}
+
+	}
+
+
+
+
+
+});
+

Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTreeContextMenu.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTreeContextMenu.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTreeContextMenu.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/EditorTreeContextMenu.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,136 @@
+/*
+	Copyright (c) 2004-2005, 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.widget.EditorTreeContextMenu");
+dojo.provide("dojo.widget.EditorTreeMenuItem");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.dnd.*");
+dojo.require("dojo.fx.html");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Container");
+dojo.require("dojo.widget.Menu2");
+
+
+dojo.widget.tags.addParseTreeHandler("dojo:EditorTreeContextMenu");
+dojo.widget.tags.addParseTreeHandler("dojo:EditorTreeMenuItem");
+
+
+
+dojo.widget.EditorTreeContextMenu = function() {
+	dojo.widget.PopupMenu2.call(this);
+	this.widgetType = "EditorTreeContextMenu";
+
+	this.eventNames =  {
+		open: ""
+	};
+
+
+}
+
+
+dojo.inherits(dojo.widget.EditorTreeContextMenu, dojo.widget.PopupMenu2);
+
+dojo.lang.extend(dojo.widget.EditorTreeContextMenu, {
+
+	initialize: function(args, frag) {
+
+		var result = dojo.widget.PopupMenu2.prototype.initialize.apply(this, arguments);
+
+		if (args['eventNaming'] == "default" || args['eventnaming'] == "default" ) { // IE || FF
+			for (eventName in this.eventNames) {
+				this.eventNames[eventName] = this.widgetId+"/"+eventName;
+			}
+		}
+
+		return result;
+
+	},
+
+	postCreate: function(){
+		var result = dojo.widget.PopupMenu2.prototype.postCreate.apply(this, arguments);
+
+		var subItems = this.getChildrenOfType('EditorTreeMenuItem')
+
+		for(var i=0; i<subItems.length; i++) {
+			dojo.event.topic.subscribe(this.eventNames.open, subItems[i], "menuOpen")
+		}
+
+
+		return result;
+	},
+
+	open: function(x, y, parentMenu, explodeSrc){
+
+		var result = dojo.widget.PopupMenu2.prototype.open.apply(this, arguments);
+
+		/* publish many events here about structural changes */
+		dojo.event.topic.publish(this.eventNames.open, { menu:this });
+
+		return result;
+	}
+
+
+
+});
+
+
+
+
+
+
+dojo.widget.EditorTreeMenuItem = function() {
+	dojo.widget.MenuItem2.call(this);
+	this.widgetType = "EditorTreeMenuItem";
+
+}
+
+
+dojo.inherits(dojo.widget.EditorTreeMenuItem, dojo.widget.MenuItem2);
+
+dojo.lang.extend(dojo.widget.EditorTreeMenuItem, {
+	for_folders: true,
+
+
+	getTreeNode: function() {
+		var menu = this;
+
+		while (menu.widgetType != 'EditorTreeContextMenu') {
+			menu = menu.parent;
+		}
+
+		var source = menu.getTopOpenEvent().target;
+
+		while (!source.treeNode && source.tagName != 'body') {
+			source = source.parentNode;
+		}
+		if (source.tagName == 'body') {
+			dojo.raise("treeNode not detected");
+		}
+		var treeNode = dojo.widget.manager.getWidgetById(source.treeNode);
+
+		return treeNode;
+	},
+
+	menuOpen: function(message) {
+		var treeNode = this.getTreeNode();
+
+		/* manage for folders status */
+		if (!treeNode.isFolder && this.for_folders==false) {
+			this.setDisabled(true);
+		}
+		else {
+			this.setDisabled(false);
+		}
+	}
+
+
+
+});
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org