I think I answered my own question for 1. below. It is
Sequence.Tree.get(...).
And one possibility that occurred to me for 2. below is this patch to
TreeNode.java to add a "userData" member. This obviates the need for a
user-defined subclass for 3. below:
Index: wtk/src/org/apache/pivot/wtk/content/TreeNode.java
===================================================================
--- wtk/src/org/apache/pivot/wtk/content/TreeNode.java (revision
992054)
+++ wtk/src/org/apache/pivot/wtk/content/TreeNode.java (working copy)
@@ -30,6 +30,7 @@
public class TreeNode {
private Image icon = null;
private String text = null;
+ private Object userData = null;
public TreeNode() {
this(null, null);
@@ -46,6 +47,7 @@
public TreeNode(Image icon, String text) {
this.icon = icon;
this.text = text;
+ this.userData = null;
}
public Image getIcon() {
@@ -113,4 +115,12 @@
public void setText(String text) {
this.text = text;
}
+
+ public Object getUserData() {
+ return userData;
+ }
+
+ public void setUserData(Object userData) {
+ this.userData = userData;
+ }
}
Roger Whitcomb | Architect, Engineering | [email protected]|
Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
USA
<http://www.google.com/maps?f=q&hl=en&geocode=&q=500+Arguello+Street+%7C
+Suite+200+%7C+Redwood+City+%7C+CA+%7C+94063+%7C+USA+&sll=37.0625,-95.67
7068&sspn=50.557552,73.037109&ie=UTF8&t=h&z=16&iwloc=addr> | +1
650-587-5596 | fax: +1 650-587-5550
From: Roger L. Whitcomb [mailto:[email protected]]
Sent: Thursday, September 02, 2010 3:35 PM
To: [email protected]
Subject: Getting a TreeView node from mouse click
So, I've got a TreeView and I've configured a right-click context menu
for the component, and I can get the clicked node position inside
"configureContextMenu()" with:
Sequence.Tree.Path nodePath = tree.getNodeAt(y);
But, now, in order to actually correctly configure the menu I have to
get at the user data in that node, so I have three questions that are
not obvious to me:
1. Is there a generic method that takes the "Sequence.Tree.Path"
value and traverses the TreeView data model to come up with the correct
tree node that corresponds to that path? Or do I have to write my own,
depending on the type of tree node used? It's obviously not hard, but I
was trying to save having to write it myself.
2. I don't see any place for "userData" in the TreeNode object, so
if I want to add stuff (for instance, that is language-independent so I
can do string compares on it in any language), do I have to subclass
TreeNode and/or TreeBranch to create a compatible object to populate the
TreeView data model with?
3. If I create my own classes, can I use them in a .wtkx (now
.bxml) file (with the appropriate namespace definitions)? Is there any
special setup required for the XML parsing to make my own namespaces
accessible there?
Sorry if these are stupid questions...... Thanks.
Roger Whitcomb
Architect, Engineering
Ingres Corporation
[email protected]
PHONE +1 650.587.5596
FAX +1 650.587.5550
www.ingres.com <http://www.ingres.com/>
This transmission is confidential and intended solely for the use of the
recipient named above. It may contain confidential, proprietary, or
legally privileged information. If you are not the intended recipient,
you are hereby notified that any unauthorized review, use, disclosure or
distribution is strictly prohibited. If you have received this
transmission in error, please contact the sender by reply e-mail and
delete the original transmission and all copies from your system.