Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow to find a TreeItem when using a TreeViewer
https://www.eclipse.org/forums/index.php/mv/msg/147043/462970/#msg_462970
Originally posted by: glenn.dmello.barclaysglobal.com
Hi,
I was wondering if there was an easy way to search for an item in a
TreeViewer?
Searching through the tree is very very slow....
Here's what I'm currently doing:
protected void findSubItem(String text) {
Tree t = viewer.getTree();
for(int k = 0; k < t.getItemCount(); k++){
if(t.getItem(k).getText().equalsIgnoreCase("SubItem")){
for(int l = 0; l < t.getItem(k).getItemCount(); l++)
if(t.getItem(k).getItem(l).getText().equalsIgnoreCase(text)) {
t.showItem(t.getItem(k).getItem(l));
return;
}
}
}
}]]>2005-10-24T10:44:49-00:00Re: How to find a TreeItem when using a TreeViewer
https://www.eclipse.org/forums/index.php/mv/msg/147043/462972/#msg_462972
I guess the best way would be to search for an element in your model (see
getContentProvider()) and if you find the element then you can call the
reveal() method for your treeviewer.
Best regards,
Boby
"Glenn D'mello" <glenn.dmello@barclaysglobal.com> wrote in message
news:1ac7ec2ba49403e079de27f2996acc86$1@www.eclipse.org...
> Hi,
>
> I was wondering if there was an easy way to search for an item in a
> TreeViewer?
>
> Searching through the tree is very very slow....
>
> Here's what I'm currently doing:
>
> protected void findSubItem(String text) {
> Tree t = viewer.getTree();
> for(int k = 0; k < t.getItemCount(); k++){
> if(t.getItem(k).getText().equalsIgnoreCase("SubItem")){
> for(int l = 0; l < t.getItem(k).getItemCount(); l++)
> if(t.getItem(k).getItem(l).getText().equalsIgnoreCase(text)) {
> t.showItem(t.getItem(k).getItem(l));
> return;
> }
> }
> }
> }
>
>]]>Robert Bacs2005-10-24T12:43:27-00:00Re: How to find a TreeItem when using a TreeViewer
https://www.eclipse.org/forums/index.php/mv/msg/147043/462976/#msg_462976
Originally posted by: glenn.dmello.barclaysglobal.com