jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edgarp...@apache.org
Subject svn commit: r473755 [36/43] - in /jackrabbit/trunk/contrib/jcr-browser: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/browser/ src/main/resources/ ...
Date Sat, 11 Nov 2006 16:44:48 GMT
Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tooltip.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tooltip.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tooltip.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tooltip.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,155 @@
+dojo.provide("dojo.widget.Tooltip");
+dojo.require("dojo.widget.ContentPane");
+dojo.require("dojo.widget.PopupContainer");
+dojo.require("dojo.uri.Uri");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html.style");
+dojo.require("dojo.html.util");
+dojo.require("dojo.html.iframe");
+
+dojo.widget.defineWidget(
+	"dojo.widget.Tooltip",
+	[dojo.widget.ContentPane, dojo.widget.PopupContainerBase],
+	{
+		isContainer: true,
+
+		// Constructor arguments
+		caption: "",
+		showDelay: 500,
+		hideDelay: 100,
+		connectId: "",
+
+		templateCssPath: dojo.uri.dojoUri("src/widget/templates/TooltipTemplate.css"),
+
+		fillInTemplate: function(args, frag){
+			if(this.caption != ""){
+				this.domNode.appendChild(document.createTextNode(this.caption));
+			}
+			this._connectNode = dojo.byId(this.connectId);
+			dojo.widget.Tooltip.superclass.fillInTemplate.call(this, args, frag);
+
+			this.addOnLoad(this, "_loadedContent");
+			dojo.html.addClass(this.domNode, "dojoTooltip");
+
+			//copy style from input node to output node
+			var source = this.getFragNodeRef(frag);
+			dojo.html.copyStyle(this.domNode, source);
+
+			//apply the necessary css rules to the node so that it can popup
+			this.applyPopupBasicStyle();
+		},
+
+		postCreate: function(args, frag){
+			dojo.event.connect(this._connectNode, "onmouseover", this, "onMouseOver");
+			dojo.widget.Tooltip.superclass.postCreate.call(this, args, frag);
+		},
+
+		onMouseOver: function(e){
+			this._mouse = {x: e.pageX, y: e.pageY};
+
+			// Start tracking mouse movements, so we know when to cancel timers or erase the tooltip
+			if(!this._tracking){
+				dojo.event.connect(document.documentElement, "onmousemove", this, "onMouseMove");
+				this.tracking=true;
+			}
+
+			this._onHover(e);			
+		},
+
+		onMouseMove: function(e) {
+			this._mouse = {x: e.pageX, y: e.pageY};
+
+			if(dojo.html.overElement(this._connectNode, e) || dojo.html.overElement(this.domNode, e)){
+				this._onHover(e);
+			} else {
+				// mouse has been moved off the element/tooltip
+				// note: can't use onMouseOut to detect this because the "explode" effect causes
+				// spurious onMouseOut events (due to interference from outline), w/out corresponding onMouseOver
+				this._onUnHover(e);
+			}
+		},
+
+		_onHover: function(e) {
+			if(this._hover){ return; }
+			this._hover=true;
+
+			// If the tooltip has been scheduled to be erased, cancel that timer
+			// since we are hovering over element/tooltip again
+			if(this._hideTimer) {
+				clearTimeout(this._hideTimer);
+				delete this._hideTimer;
+			}
+			
+			// If tooltip not showing yet then set a timer to show it shortly
+			if(!this.isShowingNow && !this._showTimer){
+				this._showTimer = setTimeout(dojo.lang.hitch(this, "open"), this.showDelay);
+			}
+		},
+
+		_onUnHover: function(e){
+			if(!this._hover){ return; }
+			this._hover=false;
+
+			if(this._showTimer){
+				clearTimeout(this._showTimer);
+				delete this._showTimer;
+			}
+			if(this.isShowingNow && !this._hideTimer){
+				this._hideTimer = setTimeout(dojo.lang.hitch(this, "close"), this.hideDelay);
+			}
+			
+			// If we aren't showing the tooltip, then we can stop tracking the mouse now;
+			// otherwise must track the mouse until tooltip disappears
+			if(!this.isShowingNow){
+				dojo.event.disconnect(document.documentElement, "onmousemove", this, "onMouseMove");
+				this._tracking=false;
+			}
+		},
+
+		open: function() {
+			if (this.isShowingNow) { return; }
+
+			dojo.widget.PopupContainerBase.prototype.open.call(this, this._mouse.x, this._mouse.y, null, [this._mouse.x, this._mouse.y], "TL,TR,BL,BR", [10,15]);
+		},
+
+		close: function() {
+			if (this.isShowingNow) {
+				if ( this._showTimer ) {
+					clearTimeout(this._showTimer);
+					delete this._showTimer;
+				}
+				if ( this._hideTimer ) {
+					clearTimeout(this._hideTimer);
+					delete this._hideTimer;
+				}
+				dojo.event.disconnect(document.documentElement, "onmousemove", this, "onMouseMove");
+				this._tracking=false;
+				dojo.widget.PopupContainerBase.prototype.close.call(this);
+			}
+		},
+
+		_position: function(){
+			this.move(this._mouse.x, this._mouse.y, [10,15], "TL,TR,BL,BR");
+		},
+
+		_loadedContent: function(){
+			if(this.isShowingNow){
+				// the tooltip has changed size due to downloaded contents, so reposition it
+				this._position();
+			}
+		},
+
+		checkSize: function(){
+			// checkSize() is called when the user has resized the browser window,
+			// but that doesn't affect this widget (or this widget's children)
+			// so it can be safely ignored
+		},
+
+		uninitialize: function(){
+			this.close();
+			dojo.event.disconnect(this._connectNode, "onmouseover", this, "onMouseOver");
+		}
+
+	}
+);

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tooltip.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tree.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tree.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tree.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tree.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,553 @@
+/**
+ * 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
+*/
+
+/**
+ * TODO: use domNode.cloneNode instead of createElement for grid
+ * Should be faster (lyxsus)
+ */
+dojo.provide("dojo.widget.Tree");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeNode");
+dojo.require("dojo.html.common");
+dojo.require("dojo.html.selection");
+
+
+dojo.widget.defineWidget("dojo.widget.Tree", dojo.widget.HtmlWidget, function() {
+	this.eventNames = {};
+
+	this.tree = this;
+	this.DNDAcceptTypes = [];
+	this.actionsDisabled = [];
+
+},
+{
+	widgetType: "Tree",
+
+	eventNamesDefault: {
+		// new child does not get domNode filled in (only template draft)
+		// until addChild->createDOMNode is called(program way) OR createDOMNode (html-way)
+		// hook events to operate on new DOMNode, create dropTargets etc
+		createDOMNode: "createDOMNode",
+		// tree created.. Perform tree-wide actions if needed
+		treeCreate: "treeCreate",
+		treeDestroy: "treeDestroy",
+		// expand icon clicked
+		treeClick: "treeClick",
+		// node icon clicked
+		iconClick: "iconClick",
+		// node title clicked
+		titleClick: "titleClick",
+
+		moveFrom: "moveFrom",
+		moveTo: "moveTo",
+		addChild: "addChild",
+		removeNode: "removeNode",
+		expand: "expand",
+		collapse: "collapse"
+	},
+
+	isContainer: true,
+
+	DNDMode: "off",
+
+	lockLevel: 0, // lock ++ unlock --, so nested locking works fine
+
+	strictFolders: true,
+
+	DNDModes: {
+		BETWEEN: 1,
+		ONTO: 2
+	},
+
+	DNDAcceptTypes: "",
+
+	templateCssPath: dojo.uri.dojoUri("src/widget/templates/images/Tree/Tree.css"),
+
+	templateString: '<div class="dojoTree"></div>',
+
+	isExpanded: true, // consider this "root node" to be always expanded
+
+	isTree: true,
+
+	objectId: "",
+
+	// autoCreate if not "off"
+	// used to get the autocreated controller ONLY.
+	// generally, tree DOES NOT KNOW about its CONTROLLER, it just doesn't care
+	// controller gets messages via dojo.event
+	controller: "",
+
+	// autoCreate if not "off"
+	// used to get the autocreated selector ONLY.
+	// generally, tree DOES NOT KNOW its SELECTOR
+	// binding is made with dojo.event
+	selector: "",
+
+	// used ONLY at initialization time
+	menu: "", // autobind menu if menu's widgetId is set here
+
+	expandLevel: "", // expand to level automatically
+
+	//
+	// these icons control the grid and expando buttons for the whole tree
+	//
+
+	blankIconSrc: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_blank.gif"),
+
+	gridIconSrcT: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_t.gif"), // for non-last child grid
+	gridIconSrcL: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_l.gif"), // for last child grid
+	gridIconSrcV: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_v.gif"), // vertical line
+	gridIconSrcP: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_p.gif"), // for under parent item child icons
+	gridIconSrcC: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_c.gif"), // for under child item child icons
+	gridIconSrcX: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_x.gif"), // grid for sole root item
+	gridIconSrcY: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_y.gif"), // grid for last rrot item
+	gridIconSrcZ: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_grid_z.gif"), // for under root parent item child icon
+
+	expandIconSrcPlus: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_expand_plus.gif"),
+	expandIconSrcMinus: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_expand_minus.gif"),
+	expandIconSrcLoading: dojo.uri.dojoUri("src/widget/templates/images/Tree/treenode_loading.gif"),
+
+
+	iconWidth: 18,
+	iconHeight: 18,
+
+
+	//
+	// tree options
+	//
+
+	showGrid: true,
+	showRootGrid: true,
+
+	actionIsDisabled: function(action) {
+		var _this = this;
+		return dojo.lang.inArray(_this.actionsDisabled, action)
+	},
+
+
+	actions: {
+    	ADDCHILD: "ADDCHILD"
+	},
+
+
+	getInfo: function() {
+		var info = {
+			widgetId: this.widgetId,
+			objectId: this.objectId
+		}
+
+		return info;
+	},
+
+	initializeController: function() {
+		if (this.controller != "off") {
+			if (this.controller) {
+				this.controller = dojo.widget.byId(this.controller);
+			}
+			else {
+				// create default controller here
+				dojo.require("dojo.widget.TreeBasicController");
+				this.controller = dojo.widget.createWidget("TreeBasicController",
+					{ DNDController: (this.DNDMode ? "create" : ""), dieWithTree: true }
+				 );
+
+			}
+			this.controller.listenTree(this); // controller listens to my events
+
+		} else {
+			this.controller = null;
+		}
+	},
+
+	initializeSelector: function() {
+
+		if (this.selector != "off") {
+			if (this.selector) {
+				this.selector = dojo.widget.byId(this.selector);
+			}
+			else {
+				// create default controller here
+				dojo.require("dojo.widget.TreeSelector");
+				this.selector = dojo.widget.createWidget("TreeSelector", {dieWithTree: true});
+			}
+
+			this.selector.listenTree(this);
+
+		} else {
+			this.selector = null;
+		}
+	},
+
+	initialize: function(args, frag){
+
+		var _this = this;
+
+		for(name in this.eventNamesDefault) {
+			if (dojo.lang.isUndefined(this.eventNames[name])) {
+				this.eventNames[name] = this.widgetId+"/"+this.eventNamesDefault[name];
+			}
+		}
+
+		for(var i=0; i<this.actionsDisabled.length; i++) {
+			this.actionsDisabled[i] = this.actionsDisabled[i].toUpperCase();
+		}
+
+		if (this.DNDMode == "off") {
+			this.DNDMode = 0;
+		} else if (this.DNDMode == "between") {
+			this.DNDMode = this.DNDModes.ONTO | this.DNDModes.BETWEEN;
+		} else if (this.DNDMode == "onto") {
+			this.DNDMode = this.DNDModes.ONTO;
+		}
+
+		this.expandLevel = parseInt(this.expandLevel);
+
+		this.initializeSelector();
+		this.initializeController();
+
+		if (this.menu) {
+			this.menu = dojo.widget.byId(this.menu);
+			this.menu.listenTree(this);
+		}
+
+
+		this.containerNode = this.domNode;
+
+	},
+
+
+	postCreate: function() {
+		this.createDOMNode();
+	},
+
+
+	createDOMNode: function() {
+
+		dojo.html.disableSelection(this.domNode);
+
+		for(var i=0; i<this.children.length; i++){
+			this.children[i].parent = this; // root nodes have tree as parent
+
+			var node = this.children[i].createDOMNode(this, 0);
+
+
+			this.domNode.appendChild(node);
+		}
+
+
+		if (!this.showRootGrid){
+			for(var i=0; i<this.children.length; i++){
+				this.children[i].expand();
+			}
+		}
+
+		dojo.event.topic.publish(this.eventNames.treeCreate, { source: this } );
+
+	},
+
+
+	destroy: function() {
+		dojo.event.topic.publish(this.tree.eventNames.treeDestroy, { source: this } );
+
+		return dojo.widget.HtmlWidget.prototype.destroy.apply(this, arguments);
+	},
+
+
+	addChild: function(child, index) {
+
+//		dojo.debug("doAddChild "+index+" called for "+child);
+
+		var message = {
+			child: child,
+			index: index,
+			parent: this,
+			// remember if dom was already initialized
+			// initialized => no createDOMNode => no createDOMNode event
+			domNodeInitialized: child.domNodeInitialized
+		}
+
+		this.doAddChild.apply(this, arguments);
+
+		dojo.event.topic.publish(this.tree.eventNames.addChild, message);
+	},
+
+
+	// not called for initial tree building. See createDOMNode instead.
+	// builds child html node if needed
+	// index is "last node" by default
+	/**
+	 * FIXME: Is it possible that removeNode from the tree will cause leaks cause of attached events ?
+	 * if yes, then only attach events in addChild and detach in remove.. Seems all ok yet.
+	*/
+	doAddChild: function(child, index){
+
+		if (dojo.lang.isUndefined(index)) {
+			index = this.children.length;
+		}
+
+		if (!child.isTreeNode){
+			dojo.raise("You can only add TreeNode widgets to a "+this.widgetType+" widget!");
+			return;
+		}
+
+		// 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.isTreeNode){
+			if (!this.isFolder) { // just became a folder.
+				//dojo.debug("becoming folder "+this);
+				this.setFolder();
+			}
+		}
+
+		// adjust tree
+		var _this = this;
+		dojo.lang.forEach(child.getDescendants(), function(elem) { elem.tree = _this.tree; });
+
+		// fix parent
+		child.parent = this;
+
+
+		// no dynamic loading for those who become parents
+		if (this.isTreeNode) {
+			this.state = this.loadStates.LOADED;
+		}
+
+		// add new child into DOM after it was added into children
+		if (index < this.children.length) { // children[] already has child
+			//dojo.debug("Inserting before "+this.children[index].title);
+			dojo.html.insertBefore(child.domNode, this.children[index].domNode);
+		} else {
+			this.containerNode.appendChild(child.domNode);
+			if (this.isExpanded && this.isTreeNode) {
+				/* When I add children to hidden containerNode => show container w/ them */
+				this.showChildren();
+			}
+		}
+
+
+		this.children.splice(index, 0, child);
+
+		//dojo.debugShallow(this.children);
+
+
+		// if node exists - adjust its depth, otherwise build it
+		if (child.domNodeInitialized) {
+			var d = this.isTreeNode ? this.depth : -1;
+			child.adjustDepth( d - child.depth + 1 );
+
+
+			// update icons to link generated dom with Tree => updateParentGrid
+			// if I moved child from LastNode inside the tree => need to link it up'n'down =>
+			// updateExpandGridColumn
+			// if I change depth => need to update all grid..
+			child.updateIconTree();
+		} else {
+			//dojo.debug("Create domnode ");
+			child.depth = this.isTreeNode ? this.depth+1 : 0;
+			child.createDOMNode(child.tree, child.depth);
+		}
+
+
+
+		// Use-case:
+		// When previous sibling was created => it was last, no children after it
+		// so it did not create link down => let's add it for all descendants
+		// Use-case:
+		// a child was moved down under the last node so last node should be updated
+		var prevSibling = child.getPreviousSibling();
+		if (child.isLastChild() && prevSibling) {
+			prevSibling.updateExpandGridColumn();
+		}
+
+
+		//dojo.debug("Added child "+child);
+
+
+
+	},
+
+
+
+
+	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;
+	},
+
+
+	updateIconTree: function(){
+
+		//dojo.debug("Update icons for "+this)
+		if (!this.isTree) {
+			this.updateIcons();
+		}
+
+		for(var i=0; i<this.children.length; i++){
+			this.children[i].updateIconTree();
+		}
+
+	},
+
+	toString: function() {
+		return "["+this.widgetType+" ID:"+this.widgetId+"]"
+	},
+
+
+
+
+	/**
+	 * Move child to newParent as last child
+	 * redraw tree and update icons.
+	 *
+	 * Called by target, saves source in event.
+	 * events are published for BOTH trees AFTER update.
+	*/
+	move: function(child, newParent, index) {
+
+		//dojo.debug(child+" "+newParent+" at "+index);
+
+		var oldParent = child.parent;
+		var oldTree = child.tree;
+
+		this.doMove.apply(this, arguments);
+
+		var newParent = child.parent;
+		var newTree = child.tree;
+
+		var message = {
+				oldParent: oldParent, oldTree: oldTree,
+				newParent: newParent, newTree: newTree,
+				child: child
+		};
+
+		/* publish events here about structural changes for both source and target trees */
+		dojo.event.topic.publish(oldTree.eventNames.moveFrom, message);
+		dojo.event.topic.publish(newTree.eventNames.moveTo, message);
+
+	},
+
+
+	/* do actual parent change here. Write remove child first */
+	doMove: function(child, newParent, index) {
+		//var parent = child.parent;
+		child.parent.doRemoveNode(child);
+
+		newParent.doAddChild(child, index);
+	},
+
+
+
+// ================================ removeNode ===================================
+
+	removeNode: function(child) {
+		if (!child.parent) return;
+
+		var oldTree = child.tree;
+		var oldParent = child.parent;
+
+		var removedChild = this.doRemoveNode.apply(this, arguments);
+
+
+		dojo.event.topic.publish(this.tree.eventNames.removeNode,
+			{ child: removedChild, tree: oldTree, parent: oldParent }
+		);
+
+		return removedChild;
+	},
+
+
+	doRemoveNode: function(child) {
+		if (!child.parent) return;
+
+		var parent = child.parent;
+
+		var children = parent.children;
+
+
+		var index = child.getParentIndex();
+		if (index < 0) {
+			dojo.raise("Couldn't find node "+child+" for removal");
+		}
+
+
+		children.splice(index,1);
+		dojo.html.removeNode(child.domNode);
+
+		if (parent.children.length == 0 && !parent.isTree) {
+			parent.containerNode.style.display = "none";
+		}
+
+		// if WAS last node (children.length decreased already) and has prevSibling
+		if (index == children.length && index>0) {
+			children[index-1].updateExpandGridColumn();
+		}
+		// if it WAS first node in WHOLE TREE -
+		// update link up of its former lower neighbour(if exists still)
+		if (parent instanceof dojo.widget.Tree && index == 0 && children.length>0) {
+			children[0].updateExpandGrid();
+		}
+
+		//parent.updateIconTree();
+
+
+		child.parent = child.tree = null;
+
+		return child;
+	},
+
+	markLoading: function() {
+		// no way to mark tree loading
+	},
+
+	unMarkLoading: function() {
+		// no way to show that tree finished loading
+	},
+
+
+	lock: function() {
+		!this.lockLevel && this.markLoading();
+		this.lockLevel++;
+	},
+	unlock: function() {
+		if (!this.lockLevel) {
+			dojo.raise("unlock: not locked");
+		}
+		this.lockLevel--;
+		!this.lockLevel && this.unMarkLoading();
+	},
+
+	isLocked: function() {
+		var node = this;
+		while (true) {
+			if (node.lockLevel) {
+				return true;
+			}
+			if (node instanceof dojo.widget.Tree) {
+				break;
+			}
+			node = node.parent;
+		}
+
+		return false;
+	},
+
+	flushLock: function() {
+		this.lockLevel = 0;
+		this.unMarkLoading();
+	}
+});
+
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/Tree.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicController.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicController.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicController.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicController.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,274 @@
+
+dojo.provide("dojo.widget.TreeBasicController");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.json")
+dojo.require("dojo.io.*");
+
+
+dojo.widget.defineWidget("dojo.widget.TreeBasicController", dojo.widget.HtmlWidget, {
+	widgetType: "TreeBasicController",
+
+	DNDController: "",
+
+	dieWithTree: false,
+
+	initialize: function(args, frag){
+
+		/* no DND by default for compatibility */
+		if (this.DNDController == "create") {
+			dojo.require("dojo.dnd.TreeDragAndDrop");
+			this.DNDController = new dojo.dnd.TreeDNDController(this);
+		}
+
+
+
+	},
+
+
+	/**
+	 * Binds controller to all tree events
+	*/
+	listenTree: function(tree) {
+		//dojo.debug("Event "+tree.eventNames.treeClick);
+		dojo.event.topic.subscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+		dojo.event.topic.subscribe(tree.eventNames.treeClick, this, "onTreeClick");
+		dojo.event.topic.subscribe(tree.eventNames.treeCreate, this, "onTreeCreate");
+		dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+
+		if (this.DNDController) {
+			this.DNDController.listenTree(tree);
+		}
+	},
+
+	unlistenTree: function(tree) {
+		dojo.event.topic.unsubscribe(tree.eventNames.createDOMNode, this, "onCreateDOMNode");
+		dojo.event.topic.unsubscribe(tree.eventNames.treeClick, this, "onTreeClick");
+		dojo.event.topic.unsubscribe(tree.eventNames.treeCreate, this, "onTreeCreate");
+		dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+	},
+
+	onTreeDestroy: function(message) {
+		var tree = message.source;
+
+		this.unlistenTree(tree);
+
+		if (this.dieWithTree) {
+			//alert("Killing myself "+this.widgetId);
+			this.destroy();
+			//dojo.debug("done");
+		}
+	},
+
+	onCreateDOMNode: function(message) {
+
+		var node = message.source;
+
+
+		if (node.expandLevel > 0) {
+			this.expandToLevel(node, node.expandLevel);
+		}
+	},
+
+	// perform actions-initializers for tree
+	onTreeCreate: function(message) {
+		var tree = message.source;
+		var _this = this;
+		if (tree.expandLevel) {
+			dojo.lang.forEach(tree.children,
+				function(child) {
+					_this.expandToLevel(child, tree.expandLevel-1)
+				}
+			);
+		}
+	},
+
+	expandToLevel: function(node, level) {
+		if (level == 0) return;
+
+		var children = node.children;
+		var _this = this;
+
+		var handler = function(node, expandLevel) {
+			this.node = node;
+			this.expandLevel = expandLevel;
+			// recursively expand opened node
+			this.process = function() {
+				//dojo.debug("Process "+node+" level "+level);
+				for(var i=0; i<this.node.children.length; i++) {
+					var child = node.children[i];
+
+					_this.expandToLevel(child, this.expandLevel);
+				}
+			};
+		}
+
+		var h = new handler(node, level-1);
+
+
+		this.expand(node, false, h, h.process);
+
+	},
+
+
+
+
+	onTreeClick: function(message){
+		var node = message.source;
+
+		if(node.isLocked()) {
+			return false;
+		}
+
+		if (node.isExpanded){
+			this.collapse(node);
+		} else {
+			this.expand(node);
+		}
+	},
+
+	expand: function(node, sync, callObj, callFunc) {
+		node.expand();
+		if (callFunc) callFunc.apply(callObj, [node]);
+	},
+
+	collapse: function(node) {
+
+		node.collapse();
+	},
+
+// =============================== move ============================
+
+	/**
+	 * Checks whether it is ok to change parent of child to newParent
+	 * May incur type checks etc
+	 *
+	 * It should check only hierarchical possibility w/o index, etc
+	 * because in onDragOver event for Between DND mode we can't calculate index at once on onDragOVer.
+	 * index changes as client moves mouse up-down over the node
+	 */
+	canMove: function(child, newParent){
+
+		if (child.actionIsDisabled(child.actions.MOVE)) {
+			return false;
+		}
+
+		// if we move under same parent then no matter if ADDCHILD disabled for him
+		// but if we move to NEW parent then check if action is disabled for him
+		// also covers case for newParent being a non-folder in strict mode etc
+		if (child.parent !== newParent && newParent.actionIsDisabled(newParent.actions.ADDCHILD)) {
+			return false;
+		}
+
+		// Can't move parent under child. check whether new parent is child of "child".
+		var node = newParent;
+		while(node.isTreeNode) {
+			//dojo.debugShallow(node.title)
+			if (node === child) {
+				// parent of newParent is child
+				return false;
+			}
+			node = node.parent;
+		}
+
+		return true;
+	},
+
+
+	move: function(child, newParent, index) {
+
+		/* move sourceTreeNode to new parent */
+		if (!this.canMove(child, newParent)) {
+			return false;
+		}
+
+		var result = this.doMove(child, newParent, index);
+
+		if (!result) return result;
+
+		if (newParent.isTreeNode) {
+			this.expand(newParent);
+		}
+
+		return result;
+	},
+
+	doMove: function(child, newParent, index) {
+		child.tree.move(child, newParent, index);
+
+		return true;
+	},
+
+// =============================== removeNode ============================
+
+
+	canRemoveNode: function(child) {
+		if (child.actionIsDisabled(child.actions.REMOVE)) {
+			return false;
+		}
+
+		return true;
+	},
+
+
+	removeNode: function(node, callObj, callFunc) {
+		if (!this.canRemoveNode(node)) {
+			return false;
+		}
+
+		return this.doRemoveNode(node, callObj, callFunc);
+	},
+
+
+	doRemoveNode: function(node, callObj, callFunc) {
+		node.tree.removeNode(node);
+
+		if (callFunc) {
+			callFunc.apply(dojo.lang.isUndefined(callObj) ? this : callObj, [node]);
+		}
+	},
+
+
+	// -----------------------------------------------------------------------------
+	//                             Create node stuff
+	// -----------------------------------------------------------------------------
+
+
+	canCreateChild: function(parent, index, data) {
+		if (parent.actionIsDisabled(parent.actions.ADDCHILD)) return false;
+
+		return true;
+	},
+
+
+	/* send data to server and add child from server */
+	/* data may contain an almost ready child, or anything else, suggested to server */
+	/*in RPC controllers server responds with child data to be inserted */
+	createChild: function(parent, index, data, callObj, callFunc) {
+		if (!this.canCreateChild(parent, index, data)) {
+			return false;
+		}
+
+		return this.doCreateChild.apply(this, arguments);
+	},
+
+	doCreateChild: function(parent, index, data, callObj, callFunc) {
+
+		var widgetType = data.widgetType ? data.widgetType : "TreeNode";
+
+		var newChild = dojo.widget.createWidget(widgetType, data);
+
+		parent.addChild(newChild, index);
+
+		this.expand(parent);
+
+		if (callFunc) {
+			callFunc.apply(callObj, [newChild]);
+		}
+
+		return newChild;
+	}
+
+
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicController.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicControllerV3.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicControllerV3.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicControllerV3.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicControllerV3.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,816 @@
+
+dojo.provide("dojo.widget.TreeBasicControllerV3");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.json")
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.TreeCommon");
+dojo.require("dojo.widget.TreeNodeV3");
+dojo.require("dojo.widget.TreeV3");
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeBasicControllerV3",
+	[dojo.widget.HtmlWidget, dojo.widget.TreeCommon],
+	function(){
+		this.listenedTrees = {};
+	},
+{
+	// TODO: do something with addChild / setChild, so that RpcController become able
+	// to hook on this and report to server
+	
+	// TODO: make sure keyboard control stuff works when node is moved between trees
+	// node should be unfocus()'ed when it its ancestor is moved and tree,lastFocus - cleared
+
+	/**
+	 * TreeCommon.listenTree will attach listeners to these events
+	 *
+	 * The logic behind the naming:
+	 * 1. (after|before)
+	 * 2. if an event refers to tree, then add "Tree"
+	 * 3. add action
+	 */
+	listenTreeEvents: ["afterSetFolder", "afterTreeCreate", "beforeTreeDestroy"],
+	listenNodeFilter: function(elem) { return elem instanceof dojo.widget.Widget},	
+		
+		
+	editor: null,
+
+	
+	initialize: function(args) {
+		if (args.editor) {
+			this.editor = dojo.widget.byId(args.editor);
+			this.editor.controller = this;
+		}
+		
+	},
+		
+	
+	getInfo: function(elem) {
+		return elem.getInfo();
+	},
+
+	onBeforeTreeDestroy: function(message) {
+                this.unlistenTree(message.source);
+	},
+
+	onAfterSetFolder: function(message) {
+		
+		//dojo.profile.start("onTreeChange");
+        
+		if (message.source.expandLevel > 0) {
+			this.expandToLevel(message.source, message.source.expandLevel);				
+		}
+		if (message.source.loadLevel > 0) {
+			this.loadToLevel(message.source, message.source.loadLevel);				
+		}
+			
+		
+		//dojo.profile.end("onTreeChange");
+	},
+	
+	
+
+
+	// down arrow
+	_focusNextVisible: function(nodeWidget) {
+		
+		// if this is an expanded folder, get the first child
+		if (nodeWidget.isFolder && nodeWidget.isExpanded && nodeWidget.children.length > 0) {
+			returnWidget = nodeWidget.children[0];			
+		} else {
+			// find a parent node with a sibling
+			while (nodeWidget.isTreeNode && nodeWidget.isLastChild()) {
+				nodeWidget = nodeWidget.parent;
+			}
+			
+			if (nodeWidget.isTreeNode) {
+				var returnWidget = nodeWidget.parent.children[nodeWidget.getParentIndex()+1];				
+			}
+			
+		}
+				
+		if (returnWidget && returnWidget.isTreeNode) {
+			this._focusLabel(returnWidget);
+			return returnWidget;
+		}
+		
+	},
+	
+	// up arrow
+	_focusPreviousVisible: function(nodeWidget) {
+		var returnWidget = nodeWidget;
+		
+		// if younger siblings		
+		if (!nodeWidget.isFirstChild()) {
+			var previousSibling = nodeWidget.parent.children[nodeWidget.getParentIndex()-1]
+
+			nodeWidget = previousSibling;
+			// if the previous nodeWidget is expanded, dive in deep
+			while (nodeWidget.isFolder && nodeWidget.isExpanded && nodeWidget.children.length > 0) {
+				returnWidget = nodeWidget;
+				// move to the last child
+				nodeWidget = nodeWidget.children[nodeWidget.children.length-1];
+			}
+		} else {
+			// if this is the first child, return the parent
+			nodeWidget = nodeWidget.parent;
+		}
+		
+		if (nodeWidget && nodeWidget.isTreeNode) {
+			returnWidget = nodeWidget;
+		}
+		
+		if (returnWidget && returnWidget.isTreeNode) {
+			this._focusLabel(returnWidget);
+			return returnWidget;
+		}
+		
+	},
+	
+	// right arrow
+	_focusZoomIn: function(nodeWidget) {
+		var returnWidget = nodeWidget;
+		
+		// if not expanded, expand, else move to 1st child
+		if (nodeWidget.isFolder && !nodeWidget.isExpanded) {
+			this.expand(nodeWidget);
+		}else if (nodeWidget.children.length > 0) {
+			nodeWidget = nodeWidget.children[0];
+		}
+		
+		if (nodeWidget && nodeWidget.isTreeNode) {
+			returnWidget = nodeWidget;
+		}
+		
+		if (returnWidget && returnWidget.isTreeNode) {
+			this._focusLabel(returnWidget);
+			return returnWidget;
+		}
+		
+	},
+	
+	// left arrow
+	_focusZoomOut: function(node) {
+		
+		var returnWidget = node;
+		
+		// if not expanded, expand, else move to 1st child
+		if (node.isFolder && node.isExpanded) {
+			this.collapse(node);
+		} else {
+			node = node.parent;
+		}
+		if (node && node.isTreeNode) {
+			returnWidget = node;
+		}
+		
+		if (returnWidget && returnWidget.isTreeNode) {
+			this._focusLabel(returnWidget);
+			return returnWidget;
+		}
+		
+	},
+	
+	onFocusNode: function(e) {
+		var node = this.domElement2TreeNode(e.target);
+		
+		if (node) {
+			node.viewFocus();			
+			dojo.event.browser.stopEvent(e);
+		}
+	},
+	
+	onBlurNode: function(e) {
+		var node = this.domElement2TreeNode(e.target);
+		
+		if (!node) {
+			return;
+		}
+		
+		var labelNode = node.labelNode;
+		
+		labelNode.setAttribute("tabIndex", "-1");
+		node.viewUnfocus();		
+		dojo.event.browser.stopEvent(e);
+		
+		// this could have been set to -1 by the shift+TAB processing
+		node.tree.domNode.setAttribute("tabIndex", "0");
+		
+	},
+	
+	
+	_focusLabel: function(node) {
+		//dojo.debug((new Error()).stack)		
+		var lastFocused = node.tree.lastFocused;
+		var labelNode;
+		
+		if (lastFocused && lastFocused.labelNode) {
+			labelNode = lastFocused.labelNode;
+			// help Opera out with blur events
+			dojo.event.disconnect(labelNode, "onblur", this, "onBlurNode");
+			labelNode.setAttribute("tabIndex", "-1");
+			dojo.html.removeClass(labelNode, "TreeLabelFocused");
+		}
+		
+		// set tabIndex so that the tab key can find this node
+		labelNode = node.labelNode;
+		labelNode.setAttribute("tabIndex", "0");
+		node.tree.lastFocused = node;
+		
+		// add an outline - this helps opera a lot
+		dojo.html.addClass(labelNode, "TreeLabelFocused");
+		dojo.event.connectOnce(labelNode, "onblur", this, "onBlurNode");
+		// prevent the domNode from seeing the focus event
+		dojo.event.connectOnce(labelNode, "onfocus", this, "onFocusNode");
+		// set focus so that the label wil be voiced using screen readers
+		labelNode.focus();
+			
+	},
+	
+	onKey: function(e) {
+		if (!e.key || e.ctrkKey || e.altKey) { return; }
+		// pretend the key was directed toward the current focused node (helps opera out)
+		
+		var nodeWidget = this.domElement2TreeNode(e.target);
+		if (!nodeWidget) {
+			return;
+		}
+		
+		var treeWidget = nodeWidget.tree;
+		
+		if (treeWidget.lastFocused && treeWidget.lastFocused.labelNode) {
+			nodeWidget = treeWidget.lastFocused;
+		}
+		
+		switch(e.key) {
+			case e.KEY_TAB:
+				if (e.shiftKey) {
+					// we're moving backwards so don't tab to the domNode
+					// it'll be added back in onBlurNode
+					treeWidget.domNode.setAttribute("tabIndex", "-1");
+				}
+				break;
+			case e.KEY_RIGHT_ARROW:
+				this._focusZoomIn(nodeWidget);
+				dojo.event.browser.stopEvent(e);
+				break;
+			case e.KEY_LEFT_ARROW:
+				this._focusZoomOut(nodeWidget);
+				dojo.event.browser.stopEvent(e);
+				break;
+			case e.KEY_UP_ARROW:
+				this._focusPreviousVisible(nodeWidget);
+				dojo.event.browser.stopEvent(e);
+				break;
+			case e.KEY_DOWN_ARROW:
+				this._focusNextVisible(nodeWidget);
+				dojo.event.browser.stopEvent(e);
+				break;
+		}
+	},
+	
+	
+	onFocusTree: function(e) {
+		if (!e.currentTarget) { return; }
+		try {
+			var treeWidget = this.getWidgetByNode(e.currentTarget);
+			if (!treeWidget || !treeWidget.isTree) { return; }
+			// on first focus, choose the root node
+			var nodeWidget = this.getWidgetByNode(treeWidget.domNode.firstChild);
+			if (nodeWidget && nodeWidget.isTreeNode) {
+				if (treeWidget.lastFocused && treeWidget.lastFocused.isTreeNode) { // onClick could have chosen a non-root node
+					nodeWidget = treeWidget.lastFocused;
+				}
+				this._focusLabel(nodeWidget);
+			}
+		}
+		catch(e) {}
+	},
+
+	// perform actions-initializers for tree
+	onAfterTreeCreate: function(message) {
+		var tree = message.source;
+		dojo.event.browser.addListener(tree.domNode, "onKey", dojo.lang.hitch(this, this.onKey));
+		dojo.event.browser.addListener(tree.domNode, "onmousedown", dojo.lang.hitch(this, this.onTreeMouseDown));
+		dojo.event.browser.addListener(tree.domNode, "onclick", dojo.lang.hitch(this, this.onTreeClick));
+		dojo.event.browser.addListener(tree.domNode, "onfocus", dojo.lang.hitch(this, this.onFocusTree));
+		tree.domNode.setAttribute("tabIndex", "0");
+		
+		if (tree.expandLevel) {								
+			this.expandToLevel(tree, tree.expandLevel)
+		}
+		if (tree.loadLevel) {
+			this.loadToLevel(tree, tree.loadLevel);
+		}
+	},
+
+    onTreeMouseDown: function(e) {
+    },
+
+	onTreeClick: function(e){
+		//dojo.profile.start("onTreeClick");
+		
+		var domElement = e.target;
+		//dojo.debug('click')
+		// find node
+        var node = this.domElement2TreeNode(domElement);		
+		if (!node || !node.isTreeNode) {
+			return;
+		}
+		
+		// now check if expand was clicked
+		while (!domElement.widgetId) { // node found => there must be widgetId up here
+			if (domElement === node.expandNode) {
+				this.processExpandClick(node);
+				break;
+			}
+			domElement = domElement.parentNode;
+		}
+		
+		this._focusLabel(node);
+		
+		//dojo.profile.end("onTreeClick");
+		
+	},
+	
+	processExpandClick: function(node){
+		
+		//dojo.profile.start("processExpandClick");
+		
+		if (node.isExpanded){
+			this.collapse(node);
+		} else {
+			this.expand(node);
+		}
+		
+		//dojo.profile.end("processExpandClick");
+	},
+		
+	
+	
+	/**
+	 * time between expand calls for batch operations
+	 * @see expandToLevel
+	 */
+	batchExpandTimeout: 20,
+	
+	
+	expandAll: function(nodeOrTree) {		
+		return this.expandToLevel(nodeOrTree, Number.POSITIVE_INFINITY);
+		
+	},
+	
+	
+	collapseAll: function(nodeOrTree) {
+		var _this = this;
+		
+		var filter = function(elem) {
+			return (elem instanceof dojo.widget.Widget) && elem.isFolder && elem.isExpanded;
+		}
+		
+		if (nodeOrTree.isTreeNode) {		
+			this.processDescendants(nodeOrTree, filter, this.collapse);
+		} else if (nodeOrTree.isTree) {
+			dojo.lang.forEach(nodeOrTree.children,function(c) { _this.processDescendants(c, filter, _this.collapse) });
+		}
+	},
+	
+	/**
+	 * expand tree to specific node
+	 */
+	expandToNode: function(node) {
+		n = node.parent
+		s = []
+		while (!n.isExpanded) {
+			s.push(n)
+			n = n.parent
+		}
+				
+		dojo.lang.forEach(s, function(n) { n.expand() })
+	},
+		
+	/**
+	 * walk a node in time, forward order, with pauses between expansions
+	 */
+	expandToLevel: function(nodeOrTree, level) {
+		dojo.require("dojo.widget.TreeTimeoutIterator");
+		
+		var _this = this;
+		var filterFunc = function(elem) {
+			var res = elem.isFolder || elem.children && elem.children.length;
+			//dojo.debug("Filter "+elem+ " result:"+res);
+			return res;
+		};
+		var callFunc = function(node, iterator) {			
+			 _this.expand(node, true);
+			 iterator.forward();
+		}
+			
+		var iterator = new dojo.widget.TreeTimeoutIterator(nodeOrTree, callFunc, this);
+		iterator.setFilter(filterFunc);
+		
+		
+		iterator.timeout = this.batchExpandTimeout;
+		
+		//dojo.debug("here "+nodeOrTree+" level "+level);
+		
+		iterator.setMaxLevel(nodeOrTree.isTreeNode ? level-1 : level);
+		
+		
+		return iterator.start(nodeOrTree.isTreeNode);
+	},
+	
+
+	getWidgetByNode: function(node) {
+		var widgetId;
+		var newNode = node;
+		while (! (widgetId = newNode.widgetId) ) {
+			newNode = newNode.parentNode;
+			if (newNode == null) { break; }
+		}
+		if (widgetId) { return dojo.widget.byId(widgetId); }
+		else if (node == null) { return null; }
+		else{ return dojo.widget.manager.byNode(node); }
+	},
+
+
+
+	/**
+	 * callout activated even if node is expanded already
+	 */
+	expand: function(node) {
+		
+		//dojo.profile.start("expand");
+		
+		//dojo.debug("Expand "+node.isFolder);
+		
+		if (node.isFolder) {
+			
+			node.expand(); // skip trees or non-folders
+		}
+		
+		
+		//dojo.profile.end("expand");
+				
+	},
+
+	/**
+	 * safe to call on tree and non-folder
+	 */
+	collapse: function(node) {
+		if (node.isFolder) {
+			node.collapse();
+		}
+	},
+	
+	
+	// -------------------------- TODO: Inline edit node ---------------------
+	canEditLabel: function(node) {
+		if (node.actionIsDisabledNow(node.actions.EDIT)) return false;
+
+		return true;
+	},
+	
+		
+	editLabelStart: function(node) {		
+		if (!this.canEditLabel(node)) {
+			return false;
+		}
+		
+		if (!this.editor.isClosed()) {
+			//dojo.debug("editLabelStart editor open");
+			this.editLabelFinish(this.editor.saveOnBlur);			
+		}
+				
+		this.doEditLabelStart(node);
+		
+	
+	},
+	
+	
+	editLabelFinish: function(save) {
+		this.doEditLabelFinish(save);		
+	},
+	
+	
+	doEditLabelStart: function(node) {
+		if (!this.editor) {
+			dojo.raise(this.widgetType+": no editor specified");
+		}
+		
+		//dojo.debug("editLabelStart editor open "+node);
+		
+		this.editor.open(node);		
+	},
+	
+	doEditLabelFinish: function(save, server_data) {
+		//dojo.debug("Finish "+save);
+		//dojo.debug((new Error()).stack)
+		if (!this.editor) {
+			dojo.raise(this.widgetType+": no editor specified");
+		}
+
+		var node = this.editor.node;	
+		var editorTitle = this.editor.getContents();
+		
+		this.editor.close(save);
+
+		if (save) {
+			var data = {title:editorTitle};
+			dojo.lang.mixin(data, server_data);
+			
+			
+			if (node.isPhantom) {			
+				// I can't just set node phantom's title, because widgetId/objectId/widgetName...
+				// may be provided by server
+				var parent = node.parent;
+				var index = node.getParentIndex();				
+				node.destroy();
+				// new node was added!
+				dojo.widget.TreeBasicControllerV3.prototype.doCreateChild.call(this, parent, index, data);
+			} else {
+				var title = server_data && server_data.title ? server_data.title : editorTitle;
+				// use special method to make sure everything updated and event sent
+				node.setTitle(title); 
+			}
+		} else {
+			//dojo.debug("Kill phantom on cancel");
+			if (node.isPhantom) {
+				node.destroy();
+			}
+		}
+	},
+	
+	
+		
+	makeDefaultNode: function(parent, index) {
+		var data = {title:parent.tree.defaultChildTitle};
+		return dojo.widget.TreeBasicControllerV3.prototype.doCreateChild.call(this,parent,index,data);
+	},
+	
+	/**
+	 * check that something is possible
+	 * run maker to do it
+	 * run exposer to expose result to visitor immediatelly
+	 *   exposer does not affect result
+	 */
+	runStages: function(check, prepare, make, finalize, expose, args) {
+		
+		if (check && !check.apply(this, args)) {
+			return false;
+		}
+		
+		if (prepare && !prepare.apply(this, args)) {
+			return false;
+		}
+		
+		var result = make.apply(this, args);
+		
+		
+		if (finalize) {
+			finalize.apply(this,args);			
+		}
+			
+		if (!result) {
+			return result;
+		}
+		
+			
+		if (expose) {
+			expose.apply(this, args);
+		}
+		
+		return result;
+	}
+});
+
+
+// create and edit
+dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {
+		
+	createAndEdit: function(parent, index) {
+		var data = {title:parent.tree.defaultChildTitle};
+		
+		if (!this.canCreateChild(parent, index, data)) {
+			return false;
+		}
+		
+		var child = this.doCreateChild(parent, index, data);
+		if (!child) return false;
+		this.exposeCreateChild(parent, index, data);
+		
+		child.isPhantom = true;
+		
+		if (!this.editor.isClosed()) {
+			//dojo.debug("editLabelStart editor open");
+			this.editLabelFinish(this.editor.saveOnBlur);			
+		}
+		
+		
+				
+		this.doEditLabelStart(child);		
+	
+	}
+	
+});
+
+
+// =============================== clone ============================
+dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {
+	
+	canClone: function(child, newParent, index, deep){
+		return true;
+	},
+	
+	
+	clone: function(child, newParent, index, deep) {
+		return this.runStages(
+			this.canClone, this.prepareClone, this.doClone, this.finalizeClone, this.exposeClone, arguments
+		);			
+	},
+
+	exposeClone: function(child, newParent) {
+		if (newParent.isTreeNode) {
+			this.expand(newParent);
+		}
+	},
+
+	doClone: function(child, newParent, index, deep) {
+		//dojo.debug("Clone "+child);
+		var cloned = child.clone(deep);
+		newParent.addChild(cloned, index);
+				
+		return cloned;
+	}
+	
+
+});
+
+// =============================== detach ============================
+
+dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {
+	canDetach: function(child) {
+		if (child.actionIsDisabledNow(child.actions.DETACH)) {
+			return false;
+		}
+
+		return true;
+	},
+
+
+	detach: function(node) {
+		return this.runStages(
+			this.canDetach, this.prepareDetach, this.doDetach, this.finalizeDetach, this.exposeDetach, arguments
+		);			
+	},
+
+
+	doDetach: function(node, callObj, callFunc) {
+		node.detach();
+	}
+	
+});
+
+
+// =============================== destroy ============================
+dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {
+
+	canDestroyChild: function(child) {
+		
+		if (child.parent && !this.canDetach(child)) {
+			return false;
+		}
+		return true;
+	},
+
+
+	destroyChild: function(node) {
+		return this.runStages(
+			this.canDestroyChild, this.prepareDestroyChild, this.doDestroyChild, this.finalizeDestroyChild, this.exposeDestroyChild, arguments
+		);			
+	},
+
+
+	doDestroyChild: function(node) {
+		node.destroy();
+	}
+	
+});
+
+
+
+// =============================== move ============================
+
+dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {
+
+	/**
+	 * check for non-treenodes
+	 */
+	canMoveNotANode: function(child, parent) {
+		if (child.treeCanMove) {
+			return child.treeCanMove(parent);
+		}
+		
+		return true;
+	},
+
+	/**
+	 * Checks whether it is ok to change parent of child to newParent
+	 * May incur type checks etc
+	 *
+	 * It should check only hierarchical possibility w/o index, etc
+	 * because in onDragOver event for Between Dnd mode we can't calculate index at once on onDragOVer.
+	 * index changes as client moves mouse up-down over the node
+	 */
+	canMove: function(child, newParent){
+		if (!child.isTreeNode) {
+			return this.canMoveNotANode(child, newParent);
+		}
+						
+		if (child.actionIsDisabledNow(child.actions.MOVE)) {
+			return false;
+		}
+
+		// if we move under same parent then no matter if ADDCHILD disabled for him
+		// but if we move to NEW parent then check if action is disabled for him
+		// also covers case for newParent being a non-folder in strict mode etc
+		if (child.parent !== newParent && newParent.actionIsDisabledNow(newParent.actions.ADDCHILD)) {
+			return false;
+		}
+
+		// Can't move parent under child. check whether new parent is child of "child".
+		var node = newParent;
+		while(node.isTreeNode) {
+			//dojo.debugShallow(node.title)
+			if (node === child) {
+				// parent of newParent is child
+				return false;
+			}
+			node = node.parent;
+		}
+
+		return true;
+	},
+
+
+	move: function(child, newParent, index/*,...*/) {
+		return this.runStages(this.canMove, this.prepareMove, this.doMove, this.finalizeMove, this.exposeMove, arguments);			
+	},
+
+	doMove: function(child, newParent, index) {
+		//dojo.debug("MOVE "+child);
+		child.tree.move(child, newParent, index);
+
+		return true;
+	},
+	
+	exposeMove: function(child, newParent) {		
+		if (newParent.isTreeNode) {
+			this.expand(newParent);
+		}
+	}
+		
+
+});
+
+dojo.lang.extend(dojo.widget.TreeBasicControllerV3, {
+
+	// -----------------------------------------------------------------------------
+	//                             Create node stuff
+	// -----------------------------------------------------------------------------
+
+
+	canCreateChild: function(parent, index, data) {
+		if (parent.actionIsDisabledNow(parent.actions.ADDCHILD)) {
+			return false;
+		}
+
+		return true;
+	},
+
+
+	/* send data to server and add child from server */
+	/* data may contain an almost ready child, or anything else, suggested to server */
+	/*in Rpc controllers server responds with child data to be inserted */
+	createChild: function(parent, index, data) {
+		return this.runStages(this.canCreateChild, this.prepareCreateChild, this.doCreateChild, this.finalizeCreateChild, this.exposeCreateChild, arguments);		
+	},
+
+
+	doCreateChild: function(parent, index, data) {
+		//dojo.debug("doCreateChild parent "+parent+" index "+index+" data "+data);
+		
+		var newChild = parent.tree.createNode(data); 
+		//var newChild = dojo.widget.createWidget(widgetType, data);
+
+		parent.addChild(newChild, index);
+
+		return newChild;
+	},
+	
+	exposeCreateChild: function(parent) {
+		return this.expand(parent);
+	}
+
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeBasicControllerV3.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeCommon.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeCommon.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeCommon.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeCommon.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,118 @@
+
+dojo.provide("dojo.widget.TreeCommon");
+dojo.require("dojo.widget.*"); // for dojo.widget.manager
+
+dojo.declare(
+	"dojo.widget.TreeCommon",
+	null,
+{
+	listenTreeEvents: [],
+	listenedTrees: {},
+	
+	/**
+	 * evaluates to false => skip unlistening nodes
+	 * provided => use it
+	 */	
+	listenNodeFilter: null,
+	
+	listenTree: function(tree) {
+		
+		//dojo.debug("listenTree in "+this+" tree "+tree);
+		
+		var _this = this;
+		
+		if (this.listenedTrees[tree.widgetId]) {
+			return; // already listening
+		}
+		
+		dojo.lang.forEach(this.listenTreeEvents, function(event) {
+			var eventHandler =  "on" + event.charAt(0).toUpperCase() + event.substr(1);
+			//dojo.debug("subscribe: event "+tree.eventNames[event]+" widget "+_this+" handler "+eventHandler);
+			dojo.event.topic.subscribe(tree.eventNames[event], _this, eventHandler);
+		});
+		
+		
+		var filter;
+		
+		if (this.listenNodeFilter) {			
+			this.processDescendants(tree, this.listenNodeFilter, this.listenNode, true);
+		}
+		
+		/**
+		 * remember that I listen to this tree. No unbinding/binding/deselection
+		 * needed when transfer between listened trees
+		 */
+		this.listenedTrees[tree.widgetId] = true;
+		
+	},			
+	
+	// interface functions
+	listenNode: function() {},	
+	unlistenNode: function() {},
+			
+	unlistenTree: function(tree, nodeFilter) {
+		
+		var _this = this;
+	
+		if (!this.listenedTrees[tree.widgetId]) {
+			return; 
+		}
+		
+		dojo.lang.forEach(this.listenTreeEvents, function(event) {
+			var eventHandler =  "on" + event.charAt(0).toUpperCase() + event.substr(1);
+			dojo.event.topic.unsubscribe(tree.eventNames[event], _this, eventHandler);
+		});
+		
+		
+		if (this.listenNodeFilter) {
+			this.processDescendants(tree, this.listenNodeFilter, this.unlistenNode, true);
+		}
+		
+		delete this.listenedTrees[tree.widgetId];
+		
+	},
+	
+	
+	domElement2TreeNode: function(domElement) {
+		while (domElement && !domElement.widgetId) {
+			domElement = domElement.parentNode;
+		}
+		
+		if (!domElement) {
+			return null;
+		}
+		
+		var widget = dojo.widget.byId(domElement.widgetId);
+		if (!widget.isTreeNode) {
+			return null;
+		}
+		
+		return widget;
+	},
+	
+	/**
+	 * it is here, not in Widget, because mostly tree needs it
+	 */
+	processDescendants: function(elem, filter, func, skipFirst) {
+		
+		var _this = this;
+		
+		if (!skipFirst) {
+			if (!filter.call(_this,elem)) {
+				return;
+			}
+			func.call(_this,elem);	        
+		}
+		
+		
+		var stack = [elem];
+		while (elem = stack.pop()) {
+			dojo.lang.forEach(elem.children, function(elem) {
+				if (filter.call(_this, elem)) {		
+					func.call(_this, elem);
+					stack.push(elem);
+				}
+			});
+		}
+    }
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeCommon.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenu.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenu.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenu.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenu.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,171 @@
+
+
+dojo.provide("dojo.widget.TreeContextMenu");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Menu2");
+
+
+dojo.widget.defineWidget("dojo.widget.TreeContextMenu", dojo.widget.PopupMenu2, function() {
+	this.listenedTrees = [];
+},
+{
+	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;
+	},
+
+	listenTree: function(tree) {
+		/* add context menu to all nodes that exist already */
+		var nodes = tree.getDescendants();
+
+		for(var i=0; i<nodes.length; i++) {
+			if (!nodes[i].isTreeNode) continue;
+			this.bindDomNode(nodes[i].labelNode);
+		}
+
+
+		/* bind context menu to all nodes that will be created in the future (e.g loaded from server)*/
+		var _this = this;
+		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.removeNode, this, "onRemoveNode");
+		dojo.event.topic.subscribe(tree.eventNames.addChild, this, "onAddChild");
+		dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+
+		this.listenedTrees.push(tree);
+
+	},
+
+	unlistenTree: function(tree) {
+		/* clear event listeners */
+
+		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.removeNode, this, "onRemoveNode");
+		dojo.event.topic.unsubscribe(tree.eventNames.addChild, this, "onAddChild");
+		dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
+
+		for(var i=0; i<this.listenedTrees.length; i++){
+           if(this.listenedTrees[i] === tree){
+                   this.listenedTrees.splice(i, 1);
+                   break;
+           }
+		}
+	},
+
+	onTreeDestroy: function(message) {
+		this.unlistenTree(message.source);
+	},
+
+	bindTreeNode: function(node) {
+		var _this = this;
+		//dojo.debug("bind to "+node);
+		dojo.lang.forEach(node.getDescendants(),
+			function(e) {_this.bindDomNode(e.labelNode); }
+		);
+	},
+
+
+	unBindTreeNode: function(node) {
+		var _this = this;
+		//dojo.debug("Unbind from "+node);
+		dojo.lang.forEach(node.getDescendants(),
+			function(e) {_this.unBindDomNode(e.labelNode); }
+		);
+	},
+
+	onCreateDOMNode: function(message) {
+		this.bindTreeNode(message.source);
+	},
+
+
+	onMoveFrom: function(message) {
+		if (!dojo.lang.inArray(this.listenedTrees, message.newTree)) {
+			this.unBindTreeNode(message.child);
+		}
+	},
+
+	onMoveTo: function(message) {
+		if (dojo.lang.inArray(this.listenedTrees, message.newTree)) {
+			this.bindTreeNode(message.child);
+		}
+	},
+
+	onRemoveNode: function(message) {
+		this.unBindTreeNode(message.child);
+	},
+
+	onAddChild: function(message) {
+		if (message.domNodeInitialized) {
+			// dom node was there already => I did not process onNodeDomCreate
+			this.bindTreeNode(message.child);
+		}
+	}
+
+
+});
+
+dojo.widget.defineWidget("dojo.widget.TreeMenuItem", dojo.widget.MenuItem2, {
+	// treeActions menu item performs following actions (to be checked for permissions)
+	treeActions: "",
+
+	initialize: function(args, frag) {
+
+		this.treeActions = this.treeActions.split(",");
+		for(var i=0; i<this.treeActions.length; i++) {
+			this.treeActions[i] = this.treeActions[i].toUpperCase();
+		}
+
+	},
+
+	getTreeNode: function() {
+		var menu = this;
+
+		while (! (menu instanceof dojo.widget.TreeContextMenu) ) {
+			menu = menu.parent;
+		}
+
+		var source = menu.getTopOpenEvent().target;
+
+		while (!source.getAttribute('treeNode') && source.tagName != 'body') {
+			source = source.parentNode;
+		}
+		if (source.tagName == 'body') {
+			dojo.raise("treeNode not detected");
+		}
+		var treeNode = dojo.widget.manager.getWidgetById(source.getAttribute('treeNode'));
+
+		return treeNode;
+	},
+
+
+	menuOpen: function(message) {
+		var treeNode = this.getTreeNode();
+
+		this.setDisabled(false); // enable by default
+
+		var _this = this;
+		dojo.lang.forEach(_this.treeActions,
+			function(action) {
+				_this.setDisabled( treeNode.actionIsDisabled(action) );
+			}
+		);
+
+	},
+
+	toString: function() {
+		return "["+this.widgetType+" node "+this.getTreeNode()+"]";
+	}
+
+});
+
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenu.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenuV3.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenuV3.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenuV3.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenuV3.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,119 @@
+dojo.provide("dojo.widget.TreeContextMenuV3");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.Menu2");
+dojo.require("dojo.widget.TreeCommon");
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeContextMenuV3",
+	[dojo.widget.PopupMenu2, dojo.widget.TreeCommon],
+	function() {
+		this.listenedTrees = {};
+		
+	},
+{
+
+	listenTreeEvents: ["afterTreeCreate","beforeTreeDestroy"],
+	listenNodeFilter: function(elem) { return elem instanceof dojo.widget.Widget},
+	
+	onAfterTreeCreate: function(message) {
+		var tree = message.source;
+		this.bindDomNode(tree.domNode);
+	},
+	
+	onBeforeTreeDestroy: function(message) {
+		this.unBindDomNode(message.source.domNode);
+	},
+	
+	
+	getTreeNode: function() {
+		
+		var source = this.getTopOpenEvent().target;
+		var treeNode = this.domElement2TreeNode(source);
+		return treeNode
+	},
+		
+	open: function() {
+		var result = dojo.widget.PopupMenu2.prototype.open.apply(this, arguments);
+
+		for(var i=0; i< this.children.length; i++) {
+			if (this.children[i].menuOpen) {
+				this.children[i].menuOpen(this.getTreeNode());
+			}
+		}
+		return result
+	},
+	
+	close: function(){
+		
+		for(var i=0; i< this.children.length; i++) {
+			if (this.children[i].menuClose) {
+				this.children[i].menuClose(this.getTreeNode());
+			}
+		}
+		
+
+		var result = dojo.widget.PopupMenu2.prototype.close.apply(this, arguments);
+		
+		return result
+	}
+	
+});
+
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeMenuItemV3",
+	[dojo.widget.MenuItem2, dojo.widget.TreeCommon],
+	function() {
+		this.treeActions = [];
+	},
+{
+	// treeActions menu item performs following actions (to be checked for permissions)
+	treeActions: "",
+
+	initialize: function(args, frag) {
+		for(var i=0; i<this.treeActions.length; i++) {
+			this.treeActions[i] = this.treeActions[i].toUpperCase();
+		}
+	},
+
+		
+	getTreeNode: function() {
+		var menu = this;
+
+		// FIXME: change to dojo.widget[this.widgetType]
+		while (! (menu instanceof dojo.widget.TreeContextMenuV3) ) {
+				menu = menu.parent;
+		}
+
+		var treeNode = menu.getTreeNode()
+
+		return treeNode;
+	},
+
+
+	menuOpen: function(treeNode) {
+
+		treeNode.viewEmphase()
+		this.setDisabled(false); // enable by default
+
+		var _this = this;
+		dojo.lang.forEach(_this.treeActions,
+			function(action) {
+				_this.setDisabled( treeNode.actionIsDisabledNow(action) );
+			}
+		);
+
+	},
+	
+	menuClose: function(treeNode) {
+
+		treeNode.viewUnemphase()
+	},
+
+	toString: function() {
+		return "["+this.widgetType+" node "+this.getTreeNode()+"]";
+	}
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeContextMenuV3.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeControllerExtension.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeControllerExtension.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeControllerExtension.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeControllerExtension.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,84 @@
+/**
+ * Additional tree utils
+ *
+ */
+dojo.provide("dojo.widget.TreeControllerExtension");
+
+dojo.declare(
+	"dojo.widget.TreeControllerExtension",
+	null,
+{
+	saveExpandedIndices: function(node, field) {
+		var obj = {};
+
+		for(var i=0; i<node.children.length; i++) {
+			if (node.children[i].isExpanded) {
+				var key = dojo.lang.isUndefined(field) ? i : node.children[i][field];
+				obj[key] = this.saveExpandedIndices(node.children[i], field);
+			}
+		}
+
+		return obj;
+	},
+
+
+	restoreExpandedIndices: function(node, savedIndices, field) {
+		var _this = this;
+
+		var handler = function(node, savedIndices) {
+			this.node = node; //.children[i];
+			this.savedIndices = savedIndices; //[i];
+			// recursively read next savedIndices level and apply to opened node
+			this.process = function() {
+				//dojo.debug("Callback applied for "+this.node);
+				_this.restoreExpandedIndices(this.node, this.savedIndices, field);
+			};
+		}
+
+
+		for(var i=0; i<node.children.length; i++) {
+			var child = node.children[i];
+
+			var found = false;
+			var key = -1;
+
+			//dojo.debug("Check "+child)
+			// process field set case
+			if (dojo.lang.isUndefined(field) && savedIndices[i]) {
+				found = true;
+				key = i;
+			}
+
+			// process case when field is not set
+			if (field) {
+				for(var key in savedIndices) {
+					//dojo.debug("Compare "+key+" "+child[field])
+					if (key == child[field]) {
+						found = true;
+						break;
+					}
+				}
+			}
+
+			// if we found anything - expand it
+			if (found) {
+				//dojo.debug("Found at "+key)
+				var h = new handler(child, savedIndices[key]);
+				_this.expand(child, false, h, h.process);
+			} else if (child.isExpanded) { // not found, so collapse
+				//dojo.debug("Collapsing all descendants "+node.children[i])
+				dojo.lang.forEach(child.getDescendants(), function(elem) { _this.collapse(elem); });
+				//this.collapse(node.children[i]);
+			}
+
+		}
+
+
+	}
+
+});
+
+
+
+
+

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeControllerExtension.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDemo.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDemo.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDemo.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDemo.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,113 @@
+
+dojo.provide("dojo.widget.TreeDemo");
+dojo.require("dojo.Deferred");
+
+dojo.widget.TreeDemo = {
+	
+	reportIfDefered: function(res) {
+		if (res instanceof dojo.Deferred) {			
+			res.addCallbacks(
+				function(res) { /* dojo.debug("OK " + (res ? res: '')); */ return res },
+				function(err) { dojo.debug("Error"); dojo.debugShallow(err); }
+			);
+		}		
+	},
+	
+	resetRandomChildren: function(maxCount) {
+		this.randomChildrenMaxCount = maxCount;
+		this.randomChildrenCount = 0;
+		this.randomChildrenDepth = 0;
+	},
+	
+	
+	makeRandomChildren: function(title) {		
+
+		this.randomChildrenDepth++;
+			
+		var children = [];
+		for (var i=1; i<=5; i++) {				
+
+			var t = title+(this.randomChildrenDepth==1 ? '' : '.')+i;
+			var node = {title: t};
+				
+			children.push(node);		
+			this.randomChildrenCount++	
+			if (this.randomChildrenCount >= this.randomChildrenMaxCount) {
+				break;			
+			}
+		}
+
+		var i=1;
+		var _this = this;
+		dojo.lang.forEach(children, function(child) {
+			var t = title+(_this.randomChildrenDepth==1 ? '' : '.')+i;
+			i++;
+		
+			// first node is always folder for tests
+			if (_this.randomChildrenCount<_this.randomChildrenMaxCount && (
+				_this.randomChildrenDepth==1 && child === children[0] || _this.randomChildrenDepth<5 && Math.random()>0.3 )
+			  ) {
+				//dojo.debug("add child "+t);
+				child.children = _this.makeRandomChildren(t);	
+			}
+		});
+				
+
+			//dojo.debug("out "+nodeOrTree);
+			
+		this.randomChildrenDepth--;
+			
+		return children;			
+	},
+	
+	bindDemoMenu: function(controller) {
+		var _t = this;
+		
+		dojo.event.topic.subscribe('treeContextMenuDestroy/engage',
+			function (menuItem) { 
+				var node = menuItem.getTreeNode();
+				//if (confirm("Delete node with descendants: "+node.title.replace(/(<([^>]+)>)/ig," ") +" ?")) {
+				_t.reportIfDefered(controller.destroyChild(node)); 
+				
+			}
+		);
+
+
+		dojo.event.topic.subscribe('treeContextMenuCreate/engage',
+			function (menuItem) {
+				var node = menuItem.getTreeNode();
+				var d = controller.createAndEdit(node, 0);
+				_t.reportIfDefered(d);
+            }
+		);
+
+
+		dojo.event.topic.subscribe('treeContextMenuUp/engage',
+			function (menuItem) {
+                var node = menuItem.getTreeNode();
+                if (node.isFirstChild()) return;
+                _t.reportIfDefered(controller.move(node, node.parent, node.getParentIndex()-1));
+            }
+		);
+
+
+		dojo.event.topic.subscribe('treeContextMenuDown/engage',
+			function (menuItem) {
+                var node = menuItem.getTreeNode();
+                if (node.isLastChild()) return;
+                _t.reportIfDefered(controller.move(node, node.parent, node.getParentIndex()+1));
+            }
+		);
+
+		dojo.event.topic.subscribe('treeContextMenuEdit/engage',
+			function (menuItem) {
+                var node = menuItem.getTreeNode();
+                _t.reportIfDefered(controller.editLabelStart(node));
+			}
+		);
+
+	}
+	
+	
+	
+}

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDemo.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDeselectOnDblselect.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDeselectOnDblselect.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDeselectOnDblselect.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDeselectOnDblselect.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,26 @@
+
+dojo.provide("dojo.widget.TreeDeselectOnDblselect");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeSelectorV3");
+
+// selector extension to emphase node
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeDeselectOnDblselect",
+	[dojo.widget.HtmlWidget],
+{
+	selector: "",
+	
+	initialize: function() {
+		this.selector = dojo.widget.byId(this.selector);
+		//dojo.debug("OK "+this.selector);
+		dojo.event.topic.subscribe(this.selector.eventNames.dblselect, this, "onDblselect");		
+	},
+
+	onDblselect: function(message) {
+		//dojo.debug("happen "+this.selector);
+		//dojo.debug(message.node);
+		this.selector.deselect(message.node);
+	}
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDeselectOnDblselect.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDisableWrapExtension.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDisableWrapExtension.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDisableWrapExtension.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDisableWrapExtension.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,45 @@
+
+dojo.provide( "dojo.widget.TreeDisableWrapExtension" );
+
+dojo.require( "dojo.widget.HtmlWidget" );
+dojo.require( "dojo.widget.TreeExtension" );
+
+// selector extension to emphase node
+dojo.widget.defineWidget(
+	"dojo.widget.TreeDisableWrapExtension",
+	dojo.widget.TreeExtension,
+{
+	/**
+	 * can't unlisten
+	 */
+	templateCssPath: dojo.uri.dojoUri( "src/widget/templates/TreeDisableWrap.css" ),
+		
+	listenTree: function(tree) {
+		
+		var wrappingDiv = document.createElement( "div" );
+		var clazz = tree.classPrefix+"DisableWrap";
+		if (dojo.render.html.ie) {
+			clazz = clazz+' '+ tree.classPrefix+"IEDisableWrap";
+		}
+		dojo.html.setClass(wrappingDiv, clazz);
+		
+		var table = document.createElement( "table" );
+		wrappingDiv.appendChild( table );
+		
+		var tbody = document.createElement( "tbody" );
+		table.appendChild( tbody );
+		
+		var tr = document.createElement( "tr" );
+		tbody.appendChild( tr );
+		
+		var td = document.createElement( "td" );
+		tr.appendChild( td );
+		
+		if( tree.domNode.parentNode ) {
+			tree.domNode.parentNode.replaceChild( wrappingDiv, tree.domNode );
+		}
+		
+		td.appendChild( tree.domNode );
+		tree.domNode = wrappingDiv;
+	}
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDisableWrapExtension.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDndControllerV3.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDndControllerV3.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDndControllerV3.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDndControllerV3.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,127 @@
+
+dojo.provide("dojo.widget.TreeDndControllerV3");
+
+dojo.require("dojo.dnd.TreeDragAndDropV3");
+	
+dojo.widget.defineWidget(
+	"dojo.widget.TreeDndControllerV3",
+	[dojo.widget.HtmlWidget, dojo.widget.TreeCommon],
+	function() {
+		this.dragSources = {};
+		this.dropTargets = {};
+		this.listenedTrees = {};
+	},
+{
+	listenTreeEvents: ["afterChangeTree","beforeTreeDestroy", "afterAddChild"],
+	listenNodeFilter: function(elem) { return elem instanceof dojo.widget.Widget}, 
+	
+	initialize: function(args) {
+		this.treeController = dojo.lang.isString(args.controller) ? dojo.widget.byId(args.controller) : args.controller;
+		
+		if (!this.treeController) {
+			dojo.raise("treeController must be declared");
+		}
+		
+	},
+
+	onBeforeTreeDestroy: function(message) {
+		this.unlistenTree(message.source);
+	},
+	
+	// first Dnd registration happens in addChild
+	// because I have information about parent on this stage and can use it
+	// to check locking or other things
+	onAfterAddChild: function(message) {
+		//dojo.debug("Dnd addChild "+message.child);
+		this.listenNode(message.child);		
+	},
+
+
+	onAfterChangeTree: function(message) {
+		/* catch new nodes on afterAddChild, because I need parent */		
+		if (!message.oldTree) return;
+		
+		//dojo.debug("HERE");
+		
+		if (!message.newTree || !this.listenedTrees[message.newTree.widgetId]) {			
+			this.processDescendants(message.node, this.listenNodeFilter, this.unlistenNode);
+		}		
+		
+		if (!this.listenedTrees[message.oldTree.widgetId]) {
+			// we have new node
+			this.processDescendants(message.node, this.listenNodeFilter, this.listenNode);	
+		}
+		//dojo.profile.end("onTreeChange");
+	},
+	
+	
+	/**
+	 * 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
+	*/
+	listenNode: function(node) {
+
+		//dojo.debug("listen dnd "+node);
+		//dojo.debug((new Error()).stack)
+		//dojo.profile.start("Dnd listenNode "+node);		
+		if (!node.tree.DndMode) return;
+		if (this.dragSources[node.widgetId] || this.dropTargets[node.widgetId]) return;
+
+	
+		/* 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")
+			
+			//dojo.profile.start("Dnd source "+node);		
+			var source = this.makeDragSource(node);
+			//dojo.profile.end("Dnd source "+node);		
+
+			this.dragSources[node.widgetId] = source;
+		}
+
+		//dojo.profile.start("Dnd target "+node);		
+		//dojo.debug("reg target");
+		var target = this.makeDropTarget(node);
+		//dojo.profile.end("Dnd target "+node);		
+
+		this.dropTargets[node.widgetId] = target;
+
+		//dojo.profile.end("Dnd listenNode "+node);		
+
+
+	},
+	
+	/**
+	 * Factory method, override it to create special source
+	 */
+	makeDragSource: function(node) {
+		return new dojo.dnd.TreeDragSourceV3(node.contentNode, this, node.tree.widgetId, node);
+	},
+
+
+	/**
+	 * Factory method, override it to create special target
+	 */
+	makeDropTarget: function(node) {
+		 return new dojo.dnd.TreeDropTargetV3(node.contentNode, this.treeController, node.tree.DndAcceptTypes, node);
+	},
+
+	unlistenNode: 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];
+		}
+	}
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDndControllerV3.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDocIconExtension.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDocIconExtension.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDocIconExtension.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDocIconExtension.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,107 @@
+
+dojo.provide("dojo.widget.TreeDocIconExtension");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeExtension");
+
+// selector extension to emphase node
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeDocIconExtension",
+	[dojo.widget.TreeExtension],
+{
+	/**
+	 * can't unlisten
+	 */
+	
+	templateCssPath: dojo.uri.dojoUri("src/widget/templates/TreeDocIcon.css"),
+
+	
+	listenTreeEvents: ["afterChangeTree","afterSetFolder","afterUnsetFolder"],
+	
+	listenNodeFilter: function(elem) { return elem instanceof dojo.widget.Widget },
+	
+	getnodeDocType: function(node) {
+		var nodeDocType = node.getnodeDocType();
+		if (!nodeDocType) { // set default type
+			nodeDocType = node.isFolder ? "Folder" : "Document";
+		}
+		return nodeDocType;
+	},
+	
+	setnodeDocTypeClass: function(node) {
+		
+		var reg = new RegExp("(^|\\s)"+node.tree.classPrefix+"Icon\\w+",'g');			
+				
+		var clazz = dojo.html.getClass(node.iconNode).replace(reg,'') + ' ' + node.tree.classPrefix+'Icon'+this.getnodeDocType(node);
+		dojo.html.setClass(node.iconNode, clazz);		
+	},
+		
+		
+	onAfterSetFolder: function(message) {
+		//dojo.debug("FOLDER");
+		if (message.source.iconNode) {
+			// on node-initialize time when folder is set there is no iconNode
+			// this case will be processed in treeChange anyway			
+			this.setnodeDocTypeClass(message.source);
+		}
+	},
+	
+	
+	onAfterUnsetFolder: function(message) {
+		this.setnodeDocTypeClass(message.source);
+	},
+		
+	
+	listenNode: function(node) {
+		/**
+		 * add node with document type icon to node template and Tree.iconNodeTemplate
+		 * it will be set to TreeNode.iconNode on node creation
+		 * we do not assign document type yet, its node specific
+		 */
+		//dojo.debug("listenNode in "+node);
+			
+		node.contentIconNode = document.createElement("div");
+		var clazz = node.tree.classPrefix+"IconContent";
+		if (dojo.render.html.ie) {
+			clazz = clazz+' '+ node.tree.classPrefix+"IEIconContent";
+		}
+		dojo.html.setClass(node.contentIconNode, clazz);
+		
+		node.contentNode.parentNode.replaceChild(node.contentIconNode, node.expandNode);
+									  
+	  	node.iconNode = document.createElement("div");
+		dojo.html.setClass(node.iconNode, node.tree.classPrefix+"Icon"+' '+node.tree.classPrefix+'Icon'+this.getnodeDocType(node));
+		
+		node.contentIconNode.appendChild(node.expandNode);
+		node.contentIconNode.appendChild(node.iconNode);
+		
+		dojo.dom.removeNode(node.contentNode);
+		node.contentIconNode.appendChild(node.contentNode);
+		
+	
+		
+		//dojo.html.insertAfter(node.iconNode, node.expandNode);
+		
+		//dojo.debug("listenNode out "+node);
+		
+	},
+			
+	
+	onAfterChangeTree: function(message) {
+		var _this = this;
+		
+		//dojo.debug(message.node)
+		
+		if (!message.oldTree || !this.listenedTrees[message.oldTree.widgetId]) {			
+			// moving from old tree to our tree
+			this.processDescendants(message.node,
+				this.listenNodeFilter,
+				this.listenNode
+			);
+		}
+		
+	}
+	
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeDocIconExtension.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEditor.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEditor.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEditor.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEditor.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,105 @@
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.RichText");
+
+dojo.provide("dojo.widget.TreeEditor");
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeEditor",
+	dojo.widget.HtmlWidget,
+{
+		
+		
+	singleLineMode: false, // enter saves
+	saveOnBlur: true, // blur or new edit saves current
+	sync: false,  // finish editing in sync/async mode
+	selectOnOpen: true,
+	
+	controller: null,
+		
+	node: null,
+	
+	richTextParams: {},
+	
+	
+	
+	getContents: function() {
+		return this.richText.getEditorContent();
+	},
+	
+	open: function(node) {
+		
+		if (!this.richText) {
+			this.richText = dojo.widget.createWidget("RichText", this.richTextParams, node.labelNode);
+		
+			dojo.event.connect("around", this.richText, "onKeyDown", this, "richText_onKeyDown" );
+			dojo.event.connect(this.richText, "onBlur", this, "richText_onBlur" );
+			
+			var self = this;
+			dojo.event.connect(this.richText, "onLoad", function(){
+				if (self.selectOnOpen) {
+					self.richText.execCommand("selectall");
+				}
+			});
+		} else {
+			this.richText.open(node.labelNode);
+		}
+		
+		this.node = node;		
+	},
+	
+	close: function(save) {
+		
+		this.richText.close(save);
+		
+		
+		this.node = null;	
+	},
+	
+	isClosed: function() {
+		return !this.richText || this.richText.isClosed;
+	},
+	
+	execCommand: function() {
+		this.richText.execCommand.apply(this.richText, arguments);
+	},
+	
+	richText_onKeyDown: function(invocation) {
+		var e = invocation.args[0];
+		if((!e)&&(this.object)) {
+			e = dojo.event.browser.fixEvent(this.editor.window.event);
+		}
+		
+		switch (e.keyCode) {
+			case e.KEY_ESCAPE:
+				this.finish(false);
+				dojo.event.browser.stopEvent(e);		
+				break;
+			case e.KEY_ENTER:
+				if( e.ctrlKey && !this.singleLineMode ) {
+					this.execCommand( "inserthtml", "<br/>" );
+							
+				}
+				else {
+					this.finish(true);					
+					//dojo.debug("finish");
+				}
+				dojo.event.browser.stopEvent(e);
+				break;
+			default:
+				return invocation.proceed();
+		}
+	},
+	
+	richText_onBlur: function() {
+		this.finish(this.saveOnBlur);
+	},
+	
+	
+	finish: function(save) {
+		return this.controller.editLabelFinish(save, this.sync);
+	}
+		
+		
+	
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEditor.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEmphaseOnSelect.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEmphaseOnSelect.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEmphaseOnSelect.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEmphaseOnSelect.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,33 @@
+
+dojo.provide("dojo.widget.TreeEmphaseOnSelect");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeSelectorV3");
+dojo.require("dojo.html.selection");
+
+// selector extension to emphase node
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeEmphaseOnSelect",
+	dojo.widget.HtmlWidget,
+{
+	selector: "",
+	
+	initialize: function() {
+		this.selector = dojo.widget.byId(this.selector);
+		
+		dojo.event.topic.subscribe(this.selector.eventNames.select, this, "onSelect");
+		dojo.event.topic.subscribe(this.selector.eventNames.deselect, this, "onDeselect");	
+	},
+
+	
+	onSelect: function(message) {
+		message.node.viewEmphase()		
+	},
+	
+	onDeselect: function(message) {
+		message.node.viewUnemphase()
+	}
+	
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeEmphaseOnSelect.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExpandOnSelect.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExpandOnSelect.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExpandOnSelect.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExpandOnSelect.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,31 @@
+
+dojo.provide("dojo.widget.TreeExpandOnSelect");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeSelectorV3");
+dojo.require("dojo.html.selection");
+
+// selector extension to emphase node
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeExpandOnSelect",
+	dojo.widget.HtmlWidget,
+{
+	selector: "",
+	controller: "",
+	
+	initialize: function() {
+		this.selector = dojo.widget.byId(this.selector);
+		this.controller = dojo.widget.byId(this.controller);
+		
+		dojo.event.topic.subscribe(this.selector.eventNames.select, this, "onSelect");	
+	},
+
+	
+	onSelect: function(message) {
+		this.controller.expandToNode(message.node)
+	}
+	
+	
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExpandOnSelect.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExtension.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExtension.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExtension.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExtension.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,14 @@
+
+dojo.provide("dojo.widget.TreeExtension");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeCommon");
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeExtension",
+	[dojo.widget.HtmlWidget, dojo.widget.TreeCommon],
+	function() {
+		this.listenedTrees = {};
+	},
+	{}
+);

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeExtension.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeLinkExtension.js
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeLinkExtension.js?view=auto&rev=473755
==============================================================================
--- jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeLinkExtension.js (added)
+++ jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeLinkExtension.js Sat Nov 11 08:44:22 2006
@@ -0,0 +1,63 @@
+
+dojo.provide("dojo.widget.TreeLinkExtension");
+
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TreeExtension");
+
+dojo.widget.defineWidget(
+	"dojo.widget.TreeLinkExtension",
+	dojo.widget.TreeExtension,
+	function() {
+		this.params = {};
+	},
+{
+	/**
+	 * can only listen, no unlisten
+	 */
+
+	listenTreeEvents: ["afterChangeTree"],	
+
+	listenTree: function(tree) {
+		
+		dojo.widget.TreeCommon.prototype.listenTree.call(this,tree);
+		
+		var labelNode = tree.labelNodeTemplate;
+		var newLabel = this.makeALabel();
+		dojo.html.setClass(newLabel, dojo.html.getClass(labelNode));
+		labelNode.parentNode.replaceChild(newLabel, labelNode);		
+	},
+	
+		
+	
+	makeALabel: function() {		
+		var newLabel = document.createElement("a");
+		
+		for(var key in this.params) {
+			if (key in {}) continue;
+			newLabel.setAttribute(key, this.params[key]);
+		}
+		
+		return newLabel;
+	},
+		
+	
+	onAfterChangeTree: function(message) {
+		var _this = this;
+		
+		
+		// only for new nodes
+		if (!message.oldTree) {
+			this.listenNode(message.node);
+		}
+		
+	},
+	
+	listenNode: function(node) {
+		for(var key in node.object) {
+			if (key in {}) continue;
+			node.labelNode.setAttribute(key, node.object[key]);
+		}
+	}
+
+
+});

Propchange: jackrabbit/trunk/contrib/jcr-browser/src/main/webapp/dojo/src/widget/TreeLinkExtension.js
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message