Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Tree DD
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pavel  
View profile  
 More options Oct 4 2007, 7:10 pm
From: Pavel <pave...@gmail.com>
Date: Thu, 04 Oct 2007 17:10:22 -0600
Local: Thurs, Oct 4 2007 7:10 pm
Subject: Tree DD

Hi,

I'm trying to implement a sophisticated tree DD listener. When I was
using ExtJS I could do something like this:

   myTree.addListener("nodedragover", function(dropEvent) {
      if (someSophisticatedCondition == true) {
         dropEvent.cancel = true;
      }
   });

What would be the equivalent in gwt-ext?

Attached is a patch that implements this behavior.

Pavel

[ gwt-ext-treedd.patch 7K ]
Index: main/src/com/gwtext/client/data/Node.java
===================================================================
--- main/src/com/gwtext/client/data/Node.java   (revision 764)
+++ main/src/com/gwtext/client/data/Node.java   (working copy)
@@ -20,14 +20,13 @@

 package com.gwtext.client.data;

+import java.util.Comparator;
+
 import com.google.gwt.core.client.JavaScriptObject;
 import com.gwtext.client.core.JsObject;
 import com.gwtext.client.data.event.NodeListener;
 import com.gwtext.client.util.JavaScriptObjectHelper;
-import com.gwtext.client.widgets.UserObject;

-import java.util.Comparator;
-
 public class Node extends JsObject {

     public Node(NodeConfig config) {
@@ -49,15 +48,22 @@
     protected Node createNode(JavaScriptObject jsNode) {
         return new Node(jsNode);
     }
-
-    public UserObject getUserObject() {
-        Object o = getUserObject(getJsObj());
-        if (o == null) {
+    
+    public native Object getUserObject() /*-{
+        var node = th...@com.gwtext.client.core.JsObject::jsObj;
+        
+        //need to convert javascript undefined to null before passing to java layer
+        if(node.attributes.data === undefined) {
             return null;
         } else {
-            return new UserObject(o);
-        }
-    }
+            return node.attributes.data;
+       }
+    }-*/;
+    
+    public native void setUserObject(Object o) /*-{
+        var node = th...@com.gwtext.client.core.JsObject::jsObj;
+        node.attributes.data = o;
+    }-*/;

        public native void setAttribute(String name, String value) /*-{
                var node = th...@com.gwtext.client.core.JsObject::jsObj;
@@ -75,15 +81,6 @@
                return value === undefined ? null : value;
        }-*/;

-       private static native Object getUserObject(JavaScriptObject node) /*-{
-        //need to convert javascript undefined to null before passing to java layer
-        if(node.attributes.data === undefined) {
-            return null;
-        } else {
-            return node.attributes.data;
-       }
-    }-*/;
-
     public Node[] getChildNodes() {
         JavaScriptObject[] jsNodes = JavaScriptObjectHelper.getAttributeAsJavaScriptObjectArray(jsObj, "childNodes");
         if(jsNodes == null) return null;
@@ -109,7 +106,7 @@
         return node.id;
     }-*/;

-    public native void setId(String id) /*-{
+    public native String setId(String id) /*-{
         var node = th...@com.gwtext.client.core.JsObject::jsObj;
         node.id = id;
     }-*/;
Index: main/src/com/gwtext/client/widgets/tree/event/TreeDragOverEvent.java
===================================================================
--- main/src/com/gwtext/client/widgets/tree/event/TreeDragOverEvent.java        (revision 0)
+++ main/src/com/gwtext/client/widgets/tree/event/TreeDragOverEvent.java        (revision 0)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007 ???
+ */
+package com.gwtext.client.widgets.tree.event;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.gwtext.client.dd.DragDrop;
+import com.gwtext.client.widgets.tree.TreeNode;
+import com.gwtext.client.widgets.tree.TreePanel;
+
+public class TreeDragOverEvent {
+    
+    private TreePanel treePanel;
+    private TreeNode target;
+    private String point;
+    private DragDrop source;
+    private TreeNode dropNode;
+
+    private JavaScriptObject jsObj;
+    
+    public TreeDragOverEvent(JavaScriptObject dropEvent, TreePanel treePanel, TreeNode target, String point, DragDrop source, TreeNode dropNode) {
+        this.jsObj = dropEvent;
+        this.treePanel = treePanel;
+        this.target = target;
+        this.point = point;
+        this.source = source;
+        this.dropNode = dropNode;
+    }
+
+    public static TreeDragOverEvent instance(JavaScriptObject dropEvent, TreePanel treePanel, TreeNode target, String point, DragDrop source, TreeNode dropNode) {
+        return new TreeDragOverEvent(dropEvent, treePanel, target, point, source, dropNode);
+    }
+    
+    public TreePanel getTreePanel() {
+        return treePanel;
+    }
+
+    public TreeNode getTarget() {
+        return target;
+    }
+
+    public String getPoint() {
+        return point;
+    }
+
+    public DragDrop getSource() {
+        return source;
+    }
+
+    public TreeNode getDropNode() {
+        return dropNode;
+    }
+
+    public JavaScriptObject getJsObj() {
+        return jsObj;
+    }
+
+    public native void cancel() /*-{
+        th...@com.gwtext.client.widgets.tree.event.TreeDragOverEvent::jsObj.cancel = true;
+    }-*/;
+}
Index: main/src/com/gwtext/client/widgets/tree/event/TreePanelListener.java
===================================================================
--- main/src/com/gwtext/client/widgets/tree/event/TreePanelListener.java        (revision 764)
+++ main/src/com/gwtext/client/widgets/tree/event/TreePanelListener.java        (working copy)
@@ -20,7 +20,6 @@

 package com.gwtext.client.widgets.tree.event;

-import com.google.gwt.user.client.Event;
 import com.gwtext.client.core.EventObject;
 import com.gwtext.client.dd.DD;
 import com.gwtext.client.dd.DragDrop;
@@ -63,7 +62,7 @@

     void onLoad(TreeNode node);

-    void onNodeDragOver(TreePanel treePanel, TreeNode target, String point, DragDrop source, TreeNode dropNode);
+    void onNodeDragOver(TreeDragOverEvent dropEvent);

     void onNodeDrop(TreePanel treePanel, TreeNode target, String point, DragDrop source, TreeNode dropNode);

Index: main/src/com/gwtext/client/widgets/tree/event/TreePanelListenerAdapter.java
===================================================================
--- main/src/com/gwtext/client/widgets/tree/event/TreePanelListenerAdapter.java (revision 764)
+++ main/src/com/gwtext/client/widgets/tree/event/TreePanelListenerAdapter.java (working copy)
@@ -83,7 +83,7 @@
     public void onLoad(TreeNode node) {
     }

-    public void onNodeDragOver(TreePanel treePanel, TreeNode target, String point, DragDrop source, TreeNode dropNode) {
+    public void onNodeDragOver(TreeDragOverEvent dropEvent) {
     }

     public void onNodeDrop(TreePanel treePanel, TreeNode target, String point, DragDrop source, TreeNode dropNode) {
Index: main/src/com/gwtext/client/widgets/tree/TreePanel.java
===================================================================
--- main/src/com/gwtext/client/widgets/tree/TreePanel.java      (revision 764)
+++ main/src/com/gwtext/client/widgets/tree/TreePanel.java      (working copy)
@@ -345,7 +345,10 @@
                 var targetNodeJ = @com.gwtext.client.widgets.tree.TreeNode::instance(Lcom/google/gwt/core/cli ent/JavaScriptObject;)(targetNode);
                 var sourceJ = @com.gwtext.client.dd.DragDrop::instance(Lcom/google/gwt/core/client/JavaSc riptObject;)(source);
                 var dropNodeJ = @com.gwtext.client.widgets.tree.TreeNode::instance(Lcom/google/gwt/core/cli ent/JavaScriptObject;)(dropNode);
-                listen...@com.gwtext.client.widgets.tree.event.TreePanelListener::onNodeDragOver(Lco m/gwtext/client/widgets/tree/TreePanel;Lcom/gwtext/client/widgets/tree/Tree Node;Ljava/lang/String;Lcom/gwtext/client/dd/DragDrop;Lcom/gwtext/client/wi dgets/tree/TreeNode;)(treePanelJ, targetNodeJ, point, sourceJ, dropNodeJ);
+                    
+                var dropEvent = @com.gwtext.client.widgets.tree.event.TreeDragOverEvent::instance(Lcom/goog le/gwt/core/client/JavaScriptObject;Lcom/gwtext/client/widgets/tree/TreePan el;Lcom/gwtext/client/widgets/tree/TreeNode;Ljava/lang/String;Lcom/gwtext/c lient/dd/DragDrop;Lcom/gwtext/client/widgets/tree/TreeNode;)(e, treePanelJ, targetNodeJ, point, sourceJ, dropNodeJ);
+
+                listen...@com.gwtext.client.widgets.tree.event.TreePanelListener::onNodeDragOver(Lco m/gwtext/client/widgets/tree/event/TreeDragOverEvent;)(dropEvent);
             }
         );


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sanjiv Jivan  
View profile  
 More options Oct 4 2007, 7:52 pm
From: "Sanjiv Jivan" <sanjiv.ji...@gmail.com>
Date: Thu, 4 Oct 2007 19:52:23 -0400
Local: Thurs, Oct 4 2007 7:52 pm
Subject: Re: Tree DD

I think it might be simpler if TreePanenListener's onNodeDragOver signature
changed from

void onNodeDragOver(TreePanel treePanel, TreeNode target, String point,
DragDrop source, TreeNode dropNode);

to

boolean onNodeDragOver(TreePanel treePanel, TreeNode target, String point,
DragDrop source, TreeNode dropNode);

And a user returns false to to signal that drop not allowed. Adding a new
TreeDragOverEvent class that wraps these arguments seems unnecessary and I
feel that the current API of onNodeDragOver with the arguments listed out
adds clarity.

Does that make sense?

Sanjiv

On 10/4/07, Pavel <pave...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pavel J  
View profile  
 More options Oct 4 2007, 9:55 pm
From: "Pavel J" <pave...@gmail.com>
Date: Thu, 4 Oct 2007 19:55:18 -0600
Local: Thurs, Oct 4 2007 9:55 pm
Subject: Re: Tree DD

I agree, I'll just make sure we haven't missed anything else from that event
object. AFAIK, it's not very well documented.

Also, if you take a look at the Node class, I added setUserObject(Object)
and changed getUserObject methods. Would you agree with those changes?

Thanks,

Pavel

On 10/4/07, Sanjiv Jivan <sanjiv.ji...@gmail.com> wrote:

...

read more »


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sanjiv Jivan  
View profile  
 More options Oct 7 2007, 3:08 pm
From: "Sanjiv Jivan" <sanjiv.ji...@gmail.com>
Date: Sun, 7 Oct 2007 15:08:17 -0400
Local: Sun, Oct 7 2007 3:08 pm
Subject: Re: Tree DD

Pavel,
I've made the change so that the onNodeDragOver API returns boolean. Your
suggestions on get/setUserObject look good and I've incorporated them.

Thanks,
Sanjiv

On 10/4/07, Pavel J <pave...@gmail.com> wrote:

...

read more »


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pavel J  
View profile  
 More options Oct 7 2007, 10:10 pm
From: "Pavel J" <pave...@gmail.com>
Date: Sun, 7 Oct 2007 20:10:40 -0600
Local: Sun, Oct 7 2007 10:10 pm
Subject: Re: Tree DD

Thanks Sanjiv, the change works great.
I also noticed that "move" TreePanel event is missing from the
TreePanelListener. Attached is a patch adding "move" event handler.

(Sorry in advance if the patch doesn't work -- I'm not using my regular
TortoiseSVN.)

Pavel

On 10/7/07, Sanjiv Jivan <sanjiv.ji...@gmail.com> wrote:

...

read more »

  onmove.patch
3K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sanjiv Jivan  
View profile  
 More options Oct 8 2007, 7:41 pm
From: "Sanjiv Jivan" <sanjiv.ji...@gmail.com>
Date: Mon, 8 Oct 2007 19:41:15 -0400
Local: Mon, Oct 8 2007 7:41 pm
Subject: Re: Tree DD

I've added the onMove() event handler.

Sanjiv

On 10/7/07, Pavel J <pave...@gmail.com> wrote:

...

read more »


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pavel J  
View profile  
 More options Oct 8 2007, 10:16 pm
From: "Pavel J" <pave...@gmail.com>
Date: Mon, 8 Oct 2007 20:16:54 -0600
Local: Mon, Oct 8 2007 10:16 pm
Subject: Re: Tree DD

Thanks Sanjiv.

Pavel

On 10/8/07, Sanjiv Jivan <sanjiv.ji...@gmail.com> wrote:

...

read more »


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google