[richfaces-svn-commits] JBoss Rich Faces SVN: r473 - in trunk/richfaces: common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd and 7 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Apr 20 16:01:57 EDT 2007
Author: nbelaevski
Date: 2007-04-20 16:01:56 -0400 (Fri, 20 Apr 2007)
New Revision: 473
Modified:
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js
trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js
trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
Log:
Initial fixes for http://jira.jboss.com/jira/browse/RF-88
Modified: trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js
===================================================================
--- trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -1,8 +1,8 @@
DnD.getDnDDefaultParams = function(elt) {
- var attr = elt.attributes["rich:defaultdndparams"];
+ var attr = Richfaces.getNSAttribute("defaultdndparams", elt);
if (attr) {
- var params = attr.value.parseJSON();
+ var params = attr.parseJSON();
if (params) {
return params;
}
@@ -14,10 +14,10 @@
DnD.getDnDMergedParams = function(elt, name) {
var params = DnD.getDnDDefaultParams(elt);
- var attr = elt.attributes[name];
+ var attr = Richfaces.getNSAttribute(name, elt);
if (attr) {
- var dndParams = attr.value.parseJSON();
+ var dndParams = attr.parseJSON();
if (params) {
if (dndParams) {
Object.extend(params, dndParams);
@@ -31,11 +31,11 @@
};
DnD.getDnDDragParams = function(elt) {
- return DnD.getDnDMergedParams(elt, "rich:dragdndparams");
+ return DnD.getDnDMergedParams(elt, "dragdndparams");
};
DnD.getDnDDropParams = function(elt) {
- return DnD.getDnDMergedParams(elt, "rich:dropdndparams");
+ return DnD.getDnDMergedParams(elt, "dropdndparams");
};
DnD.setDefaultDnDParams = function(params) {
Modified: trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js
===================================================================
--- trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -81,7 +81,7 @@
startDrag : function(event) {
var type = this.getContentType();
-
+
if (type) {
var indicator = this.getIndicator();
Modified: trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js
===================================================================
--- trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/utils.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -71,4 +71,30 @@
for (var i = 0; i < children.length; i++ ) {
Richfaces.visitTree(children[i], callback);
}
+};
+
+Richfaces.getNSAttribute = function (name, element) {
+ if (element.getAttributeNS) {
+ var attr = element.getAttributeNS('http://richfaces.ajax4jsf.org/rich', name);
+ if (attr) {
+ return attr.nodeValue;
+ }
+ }
+
+ var attrName = "rich:" + name;
+
+ var attr = element.attributes[attrName];
+ if (attr) {
+ return attr.nodeValue;
+ }
+
+ var attributes = element.attributes;
+ for (var i = 0; i < attributes.length; i++) {
+ attr = attributes[i];
+ if (attr && attrName == attr.nodeName) {
+ return attr.nodeValue;
+ }
+ }
+
+ return null;
};
\ No newline at end of file
Modified: trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
--- trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-04-20 20:01:56 UTC (rev 473)
@@ -114,6 +114,7 @@
PrototypeScript.class.getName(),
"/org/richfaces/renderkit/html/scripts/json/json.js",
DnDScript.class.getName(),
+ "/org/richfaces/renderkit/html/scripts/utils.js",
"/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js",
"/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js"
};
Modified: trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
--- trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-04-20 20:01:56 UTC (rev 473)
@@ -190,6 +190,7 @@
PrototypeScript.class.getName(),
"/org/richfaces/renderkit/html/scripts/json/json.js",
DnDScript.class.getName(),
+ "/org/richfaces/renderkit/html/scripts/utils.js",
"/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js",
"/org/richfaces/renderkit/html/scripts/dnd/dnd-dropzone.js"
};
Modified: trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js
===================================================================
--- trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/drag-drop/src/main/resources/org/richfaces/renderkit/html/scripts/simple-draggable.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -43,11 +43,6 @@
drag.params = this.options.parameters;
drag.params[this.id] = this.id;
- /*var attr = this.id.attributes["rich_f:draggableoptions"];
- if (attr) {
- Object.extend(drag.params, attr.value.parseJSON().parameters);
- }*/
-
this.setIndicator(event);
//this.dragEnter(event);
Modified: trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
===================================================================
--- trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-04-20 20:01:56 UTC (rev 473)
@@ -15,6 +15,7 @@
new org.ajax4jsf.framework.resource.PrototypeScript(),
new org.ajax4jsf.framework.ajax.AjaxScript(),
new org.ajax4jsf.dnd.DnDScript(),
+ /org/richfaces/renderkit/html/scripts/utils.js,
/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js,
scripts/drag-indicator.js
</h:scripts>
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-04-20 20:01:56 UTC (rev 473)
@@ -8,6 +8,7 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -31,6 +32,9 @@
public abstract class UITreeNode extends UIComponentBase implements
TreeListenerEventsProducer, Draggable, Dropzone {
+ private String dragType;
+ private Object acceptedTypes;
+
public static final String COMPONENT_TYPE = "org.richfaces.TreeNode";
public static final String COMPONENT_FAMILY = "org.richfaces.TreeNode";
@@ -105,7 +109,7 @@
tree.broadcast(event);
}
}
-
+
if (event instanceof AjaxEvent) {
AjaxRendererUtils.addRegionsFromComponent(this, getFacesContext());
}
@@ -134,8 +138,8 @@
public NodeSelectedListener[] getNodeSelectListeners() {
return (NodeSelectedListener[]) getFacesListeners(NodeSelectedListener.class);
}
-
-
+
+
/**
* Finds direct parent {@link UITree} component or throws
* {@link ClassCastException} if parent is not {@link UITree}
@@ -148,7 +152,7 @@
if (parent == null) {
return null;
}
-
+
if (parent instanceof UITree) {
return (UITree) parent;
@@ -198,7 +202,7 @@
public void setDragValue(Object value) {
// TODO Auto-generated method stub
-
+
}
public Object getDropValue() {
@@ -207,6 +211,76 @@
public void setDropValue(Object o) {
// TODO Auto-generated method stub
-
+
}
+
+ public void setAcceptedTypes(Object types) {
+ this.acceptedTypes = types;
+ }
+
+ /*
+ * List of drag types to be processd by the current drop zone.
+ * Getter for acceptedTypes
+ * @return acceptedTypes value from local variable or value bindings
+ */
+ public Object getAcceptedTypes( ){
+ if (null != this.acceptedTypes)
+ {
+ return this.acceptedTypes;
+ }
+ ValueBinding vb = getValueBinding("acceptedTypes");
+ if (null != vb){
+ return (Object)vb.getValue(getFacesContext());
+ } else {
+ UITree tree = getUITree();
+ if (tree != null) {
+ return tree.getAcceptedTypes();
+ }
+
+ return null;
+ }
+ }
+
+ public void setDragType(String dragType) {
+ this.dragType = dragType;
+ }
+
+ /*
+ * Key of a drag object. It's used to define a necessity of processing the current dragged element on the drop zone side
+ * Getter for dragType
+ * @return dragType value from local variable or value bindings
+ */
+ public String getDragType( ){
+ if (null != this.dragType)
+ {
+ return this.dragType;
+ }
+ ValueBinding vb = getValueBinding("dragType");
+ if (null != vb){
+ return (String)vb.getValue(getFacesContext());
+ } else {
+ UITree tree = getUITree();
+ if (tree != null) {
+ return tree.getDragType();
+ }
+
+ return null;
+ }
+ }
+
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[3];
+ state[0] = super.saveState(context);
+ state[1] = this.dragType;
+ state[2] = this.acceptedTypes;
+
+ return state;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object[] _state = (Object[]) state;
+ super.restoreState(context, _state[0]);
+ this.dragType = (String) _state[1];
+ this.acceptedTypes = _state[2];
+ }
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-04-20 20:01:56 UTC (rev 473)
@@ -167,7 +167,7 @@
}
}
- ajaxKeys.clear();
+ tree.setAjaxKeys(null);
}
} catch (Exception e) {
throw new FacesException(e);
Modified: trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js
===================================================================
--- trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item-dnd.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -54,9 +54,9 @@
},
getDropzoneOptions: function() {
- var attr = this.elements.icon.attributes["rich:dropzoneoptions"];
+ var attr = Richfaces.getNSAttribute("dropzoneoptions", this.elements.icon);
if (attr) {
- return attr.value.parseJSON();
+ return attr.parseJSON();
}
return null;
@@ -105,9 +105,9 @@
},
getDraggableOptions: function() {
- var attr = this.elements.icon.attributes["rich:draggableoptions"];
+ var attr = Richfaces.getNSAttribute("draggableoptions", this.elements.icon);
if (attr) {
- return attr.value.parseJSON();
+ return attr.parseJSON();
}
return null;
Modified: trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js
===================================================================
--- trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree-item.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -56,9 +56,9 @@
this.elements.icon = $(this.id + Tree.ID_DEVIDER + Tree.ID_ICON);
this.elements.text = $(this.id + Tree.ID_DEVIDER + Tree.ID_TEXT);
- var contextMenu = this.elements.icon.attributes['rich:oncontextmenu'];
- if (contextMenu && contextMenu.value.length > 0) {
- this.onContextMenu = new Function(contextMenu.value + "; return true;");
+ var contextMenu = Richfaces.getNSAttribute("oncontextmenu", this.elements.icon);
+ if (contextMenu && contextMenu.length > 0) {
+ this.onContextMenu = new Function(contextMenu + "; return true;");
}
var childsTd = $(childsRowId + Tree.ID_DEVIDER + Tree.ID_CHILDS_TD);
@@ -164,59 +164,79 @@
processMouseOut: function(e) {
if (this.isMouseIn) {
this.isMouseIn = false;
- var classNames = this.elements.text.attributes['rich:highlightedclass'].nodeValue.split(' ')
- for (var i = 0; i < classNames.length; i++) {
- Element.removeClassName(this.elements.text, classNames[i]);
+ var hClass = Richfaces.getNSAttribute("highlightedclass", this.elements.text);
+ if (hClass) {
+ var classNames = hClass.split(' ')
+ for (var i = 0; i < classNames.length; i++) {
+ Element.removeClassName(this.elements.text, classNames[i]);
+ }
+ if (window.drag){
+ this.dragLeave(e);
+ }
}
- if (window.drag){
- this.dragLeave(e);
- }
}
},
processMouseOver: function(e) {
if(!this.isMouseIn) {
this.isMouseIn = true;
- var classNames = this.elements.text.attributes['rich:highlightedclass'].nodeValue.split(' ')
- for (var i = 0; i < classNames.length; i++) {
- Element.addClassName(this.elements.text, classNames[i]);
+ var hClass = Richfaces.getNSAttribute("highlightedclass", this.elements.text);
+ if (hClass) {
+ var classNames = hClass.split(' ')
+ for (var i = 0; i < classNames.length; i++) {
+ Element.addClassName(this.elements.text, classNames[i]);
+ }
+ if (window.drag) {
+ this.dragEnter(e);
+ }
}
- if (window.drag) {
- this.dragEnter(e);
- }
}
},
toggleSelection: function(e) {
this.tree.deselectAll();
- var classNames = this.elements.text.attributes['rich:selectedclass'].nodeValue.split(' ')
- for (var i = 0; i < classNames.length; i++) {
- Element.addClassName(this.elements.text, classNames[i]);
+ var attr = this.elements.text.attributes;
+ var s = "";
+ for (var i = 0; i < attr.length; i++) {
+ s += attr[i].nodeName + ": " + attr[i].nodeValue + "; ";
}
- this.tree.input.value = this.id;
- this.tree.selectionManager.activeItem = this;
-
- if (this.tree.options.onSelection) this.tree.options.onSelection(this.id);
- this.tree.showNode(this.elements.text.parentNode);
+
+ alert(s);
+
+ var sClass = Richfaces.getNSAttribute("selectedclass", this.elements.text);
+ alert(sClass);
- if (e && e.type == "mousedown" /* can be keydown */) {
- if(Event.isLeftClick(e)) {
- var src = Event.element(e);
- if(src.tagName && (
- src.tagName=='INPUT' ||
- src.tagName=='SELECT' ||
- src.tagName=='OPTION' ||
- src.tagName=='BUTTON' ||
- src.tagName=='TEXTAREA')) return;
+ if (sClass) {
- Event.stop(e);
-
- Event.observe(this.elements.icon, "mousemove", this.listenDragBound);
- Event.observe(this.elements.text, "mousemove", this.listenDragBound);
+ var classNames = sClass.split(' ')
+ for (var i = 0; i < classNames.length; i++) {
+ Element.addClassName(this.elements.text, classNames[i]);
+ }
+ this.tree.input.value = this.id;
+ this.tree.selectionManager.activeItem = this;
+
+ if (this.tree.options.onSelection) this.tree.options.onSelection(this.id);
+ this.tree.showNode(this.elements.text.parentNode);
- Event.observe(this.elements.icon, "mouseup", this.stopListenDragBound);
- Event.observe(this.elements.text, "mouseup", this.stopListenDragBound);
+ if (e && e.type == "mousedown" /* can be keydown */) {
+ if(Event.isLeftClick(e)) {
+ var src = Event.element(e);
+ if(src.tagName && (
+ src.tagName=='INPUT' ||
+ src.tagName=='SELECT' ||
+ src.tagName=='OPTION' ||
+ src.tagName=='BUTTON' ||
+ src.tagName=='TEXTAREA')) return;
+
+ Event.stop(e);
+
+ Event.observe(this.elements.icon, "mousemove", this.listenDragBound);
+ Event.observe(this.elements.text, "mousemove", this.listenDragBound);
+
+ Event.observe(this.elements.icon, "mouseup", this.stopListenDragBound);
+ Event.observe(this.elements.text, "mouseup", this.stopListenDragBound);
+ }
}
}
},
@@ -233,9 +253,12 @@
},
deselect: function() {
- var classNames = this.elements.text.attributes['rich:selectedclass'].nodeValue.split(' ')
- for (var i = 0; i < classNames.length; i++) {
- Element.removeClassName(this.elements.text, classNames[i]);
+ var sClass = Richfaces.getNSAttribute("selectedclass", this.elements.text);
+ if (sClass) {
+ var classNames = sClass.split(' ')
+ for (var i = 0; i < classNames.length; i++) {
+ Element.removeClassName(this.elements.text, classNames[i]);
+ }
}
},
Modified: trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js
===================================================================
--- trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2007-04-20 20:01:56 UTC (rev 473)
@@ -53,8 +53,8 @@
Event.stop(event);
this.onselect(event);
- var attr = $(event.selectedNode + Tree.ID_DEVIDER + Tree.ID_ICON).attributes['rich:ajaxselectedlistener'];
- if (attr && attr.nodeValue) {
+ var attr = Richfaces.getNSAttribute("ajaxselectedlistener", $(event.selectedNode + Tree.ID_DEVIDER + Tree.ID_ICON));
+ if (attr) {
this.onAjaxSelect(event);
}
} else if (event[Richfaces.TreeExpandEvent]){
Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-04-20 16:26:34 UTC (rev 472)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-04-20 20:01:56 UTC (rev 473)
@@ -74,6 +74,7 @@
javaScripts.add("/org/richfaces/renderkit/html/scripts/json/json.js");
javaScripts.add("prototype.js");
javaScripts.add("dnd.js");
+ javaScripts.add("/org/richfaces/renderkit/html/scripts/utils.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js");
javaScripts.add("/org/richfaces/renderkit/html/scripts/dnd/dnd-dropzone.js");
More information about the richfaces-svn-commits
mailing list