TreeViews, Nodes and Paths

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TreeViews, Nodes and Paths

David McNelis

I have just changed a single select TreeView to a Multi, and am having some issues.

 

Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.

 

The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.

 

I’m I missing something obvious?  Or is this really not as straightforward as it would seem.

 

Thanks in advance for any suggestions.

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TreeViews, Nodes and Paths

Greg Brown
Administrator
<base href="x-msg://274/">Hi David, 

You can use the get() method of org.apache.pivot.collections.Sequence.Tree to access your tree nodes by path.

Greg

On Feb 23, 2010, at 3:33 PM, David McNelis wrote:

I have just changed a single select TreeView to a Multi, and am having some issues.
 
Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.
 
The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.
 
I’m I missing something obvious?  Or is this really not as straightforward as it would seem.
 
Thanks in advance for any suggestions.
 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TreeViews, Nodes and Paths

Robert Piotrowski-2
I have to admit, it's a little awkward at first.  For instance "going up the tree", I was getting the selected path, then removing the last node from the path, then taking that new path and grabbing the node.


Bob


On Tue, Feb 23, 2010 at 2:43 PM, Greg Brown <[hidden email]> wrote:
Hi David, 

You can use the get() method of org.apache.pivot.collections.Sequence.Tree to access your tree nodes by path.

Greg

On Feb 23, 2010, at 3:33 PM, David McNelis wrote:

I have just changed a single select TreeView to a Multi, and am having some issues.
 
Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.
 
The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.
 
I’m I missing something obvious?  Or is this really not as straightforward as it would seem.
 
Thanks in advance for any suggestions.
 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: TreeViews, Nodes and Paths

David McNelis
In reply to this post by Greg Brown
<base href="x-msg://274/">

Thanks Greg.

 

I think I’m on the right track, but I’m missing something clear I think.  Here is my snippet:

 

public void selectedPathsChanged(TreeView arg0, Sequence<Path> paths) {

Sequence.Tree<TreeNode> tree = new Sequence.Tree<TreeNode>();          

                       

for(int i, n=paths.getLength(); i < n; i++){

                       

TreeNode node = tree.get(paths, paths.get(i));

                             

}

 

I tried casting the tree.get() to a TreeNode, but that didn’t work, as the get is still bringing back a path.

 

David

 

From: Greg Brown [mailto:[hidden email]]
Sent: Tuesday, February 23, 2010 2:44 PM
To: [hidden email]
Subject: Re: TreeViews, Nodes and Paths

 

Hi David, 

 

You can use the get() method of org.apache.pivot.collections.Sequence.Tree to access your tree nodes by path.

 

Greg

 

On Feb 23, 2010, at 3:33 PM, David McNelis wrote:



I have just changed a single select TreeView to a Multi, and am having some issues.

 

Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.

 

The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.

 

I’m I missing something obvious?  Or is this really not as straightforward as it would seem.

 

Thanks in advance for any suggestions.

 

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TreeViews, Nodes and Paths

Robert Piotrowski-2
http://pivot.apache.org/1.3/docs/api/org/apache/pivot/collections/Sequence.Tree.html#get%28org.apache.pivot.collections.Sequence,%20org.apache.pivot.collections.Sequence.Tree.Path%29




On Tue, Feb 23, 2010 at 3:08 PM, David McNelis <[hidden email]> wrote:

Thanks Greg.

 

I think I’m on the right track, but I’m missing something clear I think.  Here is my snippet:

 

public void selectedPathsChanged(TreeView arg0, Sequence<Path> paths) {

Sequence.Tree<TreeNode> tree = new Sequence.Tree<TreeNode>();          

                       

for(int i, n=paths.getLength(); i < n; i++){

                       

TreeNode node = tree.get(paths, paths.get(i));

                             

}

 

I tried casting the tree.get() to a TreeNode, but that didn’t work, as the get is still bringing back a path.

 

David

 

From: Greg Brown [mailto:[hidden email]]
Sent: Tuesday, February 23, 2010 2:44 PM
To: [hidden email]
Subject: Re: TreeViews, Nodes and Paths

 

Hi David, 

 

You can use the get() method of org.apache.pivot.collections.Sequence.Tree to access your tree nodes by path.

 

Greg

 

On Feb 23, 2010, at 3:33 PM, David McNelis wrote:



I have just changed a single select TreeView to a Multi, and am having some issues.

 

Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.

 

The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.

 

I’m I missing something obvious?  Or is this really not as straightforward as it would seem.

 

Thanks in advance for any suggestions.

 

 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TreeViews, Nodes and Paths

Todd Volkert
Yup.  More specifically, you'll call Sequence.Tree.get(treeView.getTreeData(), paths.get(i)) (assuming you didn't choose to cache such intermediate calls in local variables).

-T

On Tue, Feb 23, 2010 at 4:11 PM, Robert Piotrowski <[hidden email]> wrote:
http://pivot.apache.org/1.3/docs/api/org/apache/pivot/collections/Sequence.Tree.html#get%28org.apache.pivot.collections.Sequence,%20org.apache.pivot.collections.Sequence.Tree.Path%29





On Tue, Feb 23, 2010 at 3:08 PM, David McNelis <[hidden email]> wrote:

Thanks Greg.

 

I think I’m on the right track, but I’m missing something clear I think.  Here is my snippet:

 

public void selectedPathsChanged(TreeView arg0, Sequence<Path> paths) {

Sequence.Tree<TreeNode> tree = new Sequence.Tree<TreeNode>();          

                       

for(int i, n=paths.getLength(); i < n; i++){

                       

TreeNode node = tree.get(paths, paths.get(i));

                             

}

 

I tried casting the tree.get() to a TreeNode, but that didn’t work, as the get is still bringing back a path.

 

David

 

From: Greg Brown [mailto:[hidden email]]
Sent: Tuesday, February 23, 2010 2:44 PM
To: [hidden email]
Subject: Re: TreeViews, Nodes and Paths

 

Hi David, 

 

You can use the get() method of org.apache.pivot.collections.Sequence.Tree to access your tree nodes by path.

 

Greg

 

On Feb 23, 2010, at 3:33 PM, David McNelis wrote:



I have just changed a single select TreeView to a Multi, and am having some issues.

 

Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.

 

The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.

 

I’m I missing something obvious?  Or is this really not as straightforward as it would seem.

 

Thanks in advance for any suggestions.

 

 



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: TreeViews, Nodes and Paths

David McNelis

Thanks, gentlemen.  I’d been staring at that JavaDoc for an hour, and 2 minutes after Rob’s email, and 2 before Todd’s had that elusive “A ha” moment.

 

From: Todd Volkert [mailto:[hidden email]]
Sent: Tuesday, February 23, 2010 3:14 PM
To: [hidden email]
Subject: Re: TreeViews, Nodes and Paths

 

Yup.  More specifically, you'll call Sequence.Tree.get(treeView.getTreeData(), paths.get(i)) (assuming you didn't choose to cache such intermediate calls in local variables).

 

-T

On Tue, Feb 23, 2010 at 4:11 PM, Robert Piotrowski <[hidden email]> wrote:

http://pivot.apache.org/1.3/docs/api/org/apache/pivot/collections/Sequence.Tree.html#get%28org.apache.pivot.collections.Sequence,%20org.apache.pivot.collections.Sequence.Tree.Path%29





On Tue, Feb 23, 2010 at 3:08 PM, David McNelis <[hidden email]> wrote:

Thanks Greg.

 

I think I’m on the right track, but I’m missing something clear I think.  Here is my snippet:

 

public void selectedPathsChanged(TreeView arg0, Sequence<Path> paths) {

Sequence.Tree<TreeNode> tree = new Sequence.Tree<TreeNode>();          

                       

for(int i, n=paths.getLength(); i < n; i++){

                       

TreeNode node = tree.get(paths, paths.get(i));

                             

}

 

I tried casting the tree.get() to a TreeNode, but that didn’t work, as the get is still bringing back a path.

 

David

 

From: Greg Brown [mailto:[hidden email]]
Sent: Tuesday, February 23, 2010 2:44 PM
To: [hidden email]
Subject: Re: TreeViews, Nodes and Paths

 

Hi David, 

 

You can use the get() method of org.apache.pivot.collections.Sequence.Tree to access your tree nodes by path.

 

Greg

 

On Feb 23, 2010, at 3:33 PM, David McNelis wrote:

 

I have just changed a single select TreeView to a Multi, and am having some issues.

 

Before I was able to use TreeView and the getSelectedNode() method, but clearly that doesn’t apply to this situation.

 

The getSelectedPaths() seems to be the logical direction to go, but how to I retrieve the selected node(s) itself from there?  There is not a getNode(Path) method and the getNodeAt(int) returns another path.

 

I’m I missing something obvious?  Or is this really not as straightforward as it would seem.

 

Thanks in advance for any suggestions.

 

 

 

 

Loading...