Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to find a TreeItem when using a TreeViewer
How to find a TreeItem when using a TreeViewer [message #462970] Mon, 24 October 2005 10:44 Go to next message
Eclipse UserFriend
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;
}
}
}
}
Re: How to find a TreeItem when using a TreeViewer [message #462972 is a reply to message #462970] Mon, 24 October 2005 12:43 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

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;
> }
> }
> }
> }
>
>
Re: How to find a TreeItem when using a TreeViewer [message #462976 is a reply to message #462972] Mon, 24 October 2005 12:57 Go to previous message
Eclipse UserFriend
Originally posted by: glenn.dmello.barclaysglobal.com

How did I miss that?
Thanks a lot!

Glenn.
Previous Topic:EXCEPTION_ACCESS_VIOLATION
Next Topic:FieldEditor does not write default-value
Goto Forum:
  


Current Time: Fri Dec 19 04:43:53 GMT 2014

Powered by FUDForum. Page generated in 0.06386 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software