[richfaces-svn-commits] JBoss Rich Faces SVN: r5218 - in trunk/ui/tree/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Jan 9 09:06:21 EST 2008


Author: nbelaevski
Date: 2008-01-09 09:06:21 -0500 (Wed, 09 Jan 2008)
New Revision: 5218

Modified:
   trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
   trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
   trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
   trunk/ui/tree/src/main/templates/htmlTreeNode.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1850

Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java	2008-01-09 14:05:00 UTC (rev 5217)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java	2008-01-09 14:06:21 UTC (rev 5218)
@@ -296,19 +296,50 @@
 		}
 	}
 
-	public String getDraggableScriptOptions(FacesContext context,
-			UITreeNode component) {
+	private ScriptOptions createOptions(FacesContext context, UITreeNode component, Class clazz) {
 		ScriptOptions options = new TreeNodeOptions(component);
-		mergeScriptOptions(options, context, component, Draggable.class);
+		mergeScriptOptions(options, context, component, clazz);
 		convertOptions(options.getMap());
-		return ScriptUtils.toScript(options);
+		return options;
 	}
+	
+	protected static final class DnDOptionsHolder {
+		private String dragOptions;
+		private String dropOptions;
 
-	public String getDropzoneScriptOptions(FacesContext context,
+		private String dragCursorOptions;
+		private String dropCursorOptions;
+		
+		public DnDOptionsHolder(String dragOptions, String dragCursorOptions,
+				String dropOptions, String dropCursorOptions) {
+			super();
+			this.dragOptions = dragOptions;
+			this.dragCursorOptions = dragCursorOptions;
+			this.dropOptions = dropOptions;
+			this.dropCursorOptions = dropCursorOptions;
+		}
+		
+		public String getDragOptions() {
+			return dragOptions;
+		}
+		public String getDropOptions() {
+			return dropOptions;
+		}
+		public String getDragCursorOptions() {
+			return dragCursorOptions;
+		}
+		public String getDropCursorOptions() {
+			return dropCursorOptions;
+		}
+	};
+	
+	protected DnDOptionsHolder getScriptOptions(FacesContext context,
 			UITreeNode component) {
-		ScriptOptions options = new TreeNodeOptions(component);
-		mergeScriptOptions(options, context, component, Dropzone.class);
-		convertOptions(options.getMap());
-		return ScriptUtils.toScript(options);
+		
+		ScriptOptions dragOptions = createOptions(context, component, Draggable.class);
+		ScriptOptions dropOptions = createOptions(context, component, Dropzone.class);
+
+		return new DnDOptionsHolder(ScriptUtils.toScript(dragOptions), null,
+				ScriptUtils.toScript(dropOptions), null);
 	}
 }

Modified: trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
===================================================================
--- trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js	2008-01-09 14:05:00 UTC (rev 5217)
+++ trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js	2008-01-09 14:06:21 UTC (rev 5218)
@@ -54,7 +54,7 @@
 	},
 
 	getDropzoneOptions: function() {
-		var attr = Richfaces.getNSAttribute("dropzoneoptions", $(this.elementID.icon));
+		var attr = Richfaces.getNSAttribute("dropzoneoptions", this.iconElement);
 		if (attr) {
 			return attr.parseJSON(EventHandlersWalk);
 		}
@@ -108,7 +108,7 @@
 			return window.drag.treeDraggableOptions;		
 		}
 
-		var attr = Richfaces.getNSAttribute("draggableoptions", $(this.elementID.icon));
+		var attr = Richfaces.getNSAttribute("draggableoptions", this.iconElement);
 		if (attr) {
 			var opts = attr.parseJSON(EventHandlersWalk);
 			if (window.drag) {
@@ -131,6 +131,6 @@
 
 	getElement: function() {
 		//returns <tr> holding node without children
-		return $(this.elementID.text).parentNode;
+		return this.textElement.parentNode;
 	}
 });
\ No newline at end of file

Modified: trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
===================================================================
--- trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js	2008-01-09 14:05:00 UTC (rev 5217)
+++ trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js	2008-01-09 14:06:21 UTC (rev 5218)
@@ -28,6 +28,30 @@
 		
 		this.getElements(element, ajaxUpdate);
 
+		var cells = element.rows[0].cells;
+		var eIcon = null;
+		var eText = null;
+		if ("NETSCAPE" == RichFaces.navigatorType()) {
+			for (var i = 0; i < cells.length; i++) {
+				if (cells[i].id == this.elementID.icon) {
+					eIcon = cells[i];
+				} else if (cells[i].id == this.elementID.text) {
+					eText = cells[i];
+				}
+				if (eIcon && eText) {
+					break;
+				}
+			}
+		} else {
+			var cells = element.rows[0].cells;
+			//seeking by id seems to be miserably slow in IE than by index
+			eIcon = cells[this.elementID.icon];
+			eText = cells[this.elementID.text];
+		}
+
+		this.iconElement = eIcon;
+		this.textElement = eText;
+		
 		this.eventSelectionClick = this.toggleSelection.bindAsEventListener(this);
 		this.eventMouseOut = this.processMouseOut.bindAsEventListener(this);
 		this.eventMouseOver = this.processMouseOver.bindAsEventListener(this);
@@ -42,9 +66,7 @@
 			this.enableDropzoneCursors(dropOpts.acceptCursor, dropOpts.rejectCursor);
 		}
 		 
-		
-
-		this.observeEvents(element);
+		this.observeEvents(eIcon, eText);
 	},
 
 	destroy: function() {
@@ -59,36 +81,13 @@
 		this.childs = null;
 	},
 
-	observeEvents: function(element) {
-		var cells = element.rows[0].cells;
-		var eIcon = null;
-		var eText = null;
-		if ("NETSCAPE" == RichFaces.navigatorType()) {
-			for (var i = 0; i < cells.length; i++) {
-				if (cells[i].id == this.elementID.icon) {
-					eIcon = cells[i];
-				} else if (cells[i].id == this.elementID.text) {
-					eText = cells[i];
-				}
-				if (eIcon && eText) {
-					break;
-				}
-			}
-		} else {
-			var cells = element.rows[0].cells;
-			//seeking by id seems to be miserably slow in IE than by index
-			eIcon = cells[this.elementID.icon];
-			eText = cells[this.elementID.text];
-		}
-
+	observeEvents: function(eIcon, eText) {
 		if (eIcon) {
 			var contextMenu = Richfaces.getNSAttribute("oncontextmenu", eIcon);
 			if (contextMenu && contextMenu.length > 0) {
 				this.onContextMenu = new Function("event", contextMenu + "; return true;").bindAsEventListener(this);
 			}
-		}
 
-		if (eIcon) {
 			Event.observe(eIcon, "mousedown", this.eventSelectionClick);
 			Event.observe(eIcon, "mouseout", this.eventMouseOut);
 			Event.observe(eIcon, "mouseover", this.eventMouseOver);
@@ -96,6 +95,7 @@
 				eIcon.oncontextmenu = this.onContextMenu;
 			}			
 		}
+
 		if (eText)
 		{
 			Event.observe(eText, "mousedown", this.eventSelectionClick);

Modified: trunk/ui/tree/src/main/templates/htmlTreeNode.jspx
===================================================================
--- trunk/ui/tree/src/main/templates/htmlTreeNode.jspx	2008-01-09 14:05:00 UTC (rev 5217)
+++ trunk/ui/tree/src/main/templates/htmlTreeNode.jspx	2008-01-09 14:06:21 UTC (rev 5218)
@@ -161,11 +161,16 @@
 				}
 				variables.setVariable("iconClass",iconClass);
 				]]>
-			</jsp:scriptlet>		
+			</jsp:scriptlet>
+		
+		<c:object value="#{this:getScriptOptions(context, component)}" type="org.richfaces.renderkit.NodeRendererBase$DnDOptionsHolder" var="scriptOptionsMap" />	
+				
 		<td
 			rich:ajaxselectedlistener="#{this:getAjaxSelectedListenerFlag(context, component)}"
-			rich:draggableoptions="#{this:getDraggableScriptOptions(context, component)}"
-			rich:dropzoneoptions="#{this:getDropzoneScriptOptions(context, component)}"
+			rich:draggableoptions="#{scriptOptionsMap.dragOptions}"
+			rich:dragcursoroptions="#{scriptOptionsMap.dragCursorOptions}"
+			rich:dropzoneoptions="#{scriptOptionsMap.dropOptions}"
+			rich:dropcursoroptions="#{scriptOptionsMap.dropCursorOptions}"
 			rich:oncontextmenu="#{component.attributes['oncontextmenu']}"
 			rich:onselected="#{component.attributes['onselected']}"
 			rich:onexpand="#{component.attributes['onexpand']}"




More information about the richfaces-svn-commits mailing list