Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Google Web Toolkit : Tree.addTreeListener is deprecated what should I use instead.

 
Laurence Turpin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm learning about the Google web toolkit from the book "Beginning Google Web Toolkit"
I have got to the part where it starts using a Tree widget.
It uses Tree.addTreeListener() which apparently is now deprecated.
I can't work out what to use instead.

There is a class called Category and I'm creating a tree of Category.

The method below is where the problem is:

 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Javadoc says all you need to know.
 
Laurence Turpin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Rob Spoor for replying to my problem.
Unfortunately I'm not clever enough or experienced enough to work out how to rewrite the method from the Javadoc
The full method is shown below can you show me how to rewrite it please:

 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check out the link Rob provided? It suggests the alternative to the tree listener.
All you need to do is replace your addXXXListener method by the method provided in the javadoc. In case you run into problems, post your modified code here and we will help you figure out what's wrong with it.
 
Laurence Turpin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply Maneesh Godbole.
I'm still having problems below is my latest attempt at resolving the problem.
I get an error on one line and a warning on the line next to it.
I have marked the error line and the warning line as a comment in the code shown below.
Below my latest coding attempt I have reproduced the error message and warning message from eclipse




--------------------------------------------------------------------------------------------------------------------

Inside Eclipse I get the following error message for the line I have marked as the error line:

Multiple markers at this line
- The type new SelectionHandler<TreeItem>(){} must implement the inherited abstract
method SelectionHandler<TreeItem>.onSelection(SelectionEvent<TreeItem>)
- The type new TreeListener(){} must implement the inherited abstract method
TreeListener.onTreeItemStateChanged(TreeItem)
-------------------------------------------------------------------------------------------------------------------------------------------------

Inside Eclipse I get the following warning message for the line I have marked as the warning line:

The method onTreeItemSelected(TreeItem) from the type new SelectionHandler<TreeItem>(){} is never used locally

----------------------------------------------------------------------------------------------------------------------------------------------------
I have also tried replacing the error line with the following which also does not work:

categoryTree.addSelectionHandler(new SelectionHandler() {
 
Laurence Turpin
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally managed to resolve my problem.
Thank you everyone for your help.
Below is the solution:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic