Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-20-2009, 02:02 AM
Member
 
Join Date: Mar 2008
Posts: 6
Rep Power: 0
Rodrigo Braz is on a distinguished road
Question Adding/removing nodes to tree under TreeViewer
Hi,

I am learning how to use JFace and wondering what is the best way to work with modifying a model under TreeViewer (the model could be, for example, a data structure representing a biological taxonomy).

A direct way of doing it would be to have the viewer capture events (say, the key '+'), and to add a node to the tree using the Viewer's 'insert' method, as well as updating the model below.

However, the would require the viewer to know how to manipulate the model. Note that this is not true on getting information from the model, which is managed by the content provider.

Am I missing something, or there isn't in JFace an equivalent to content providers when it comes to modifying the underlying model?

Update: I added the following code to my TreeViewer event listener:
insert(((TreeSelection)getSelection()).getFirstEle ment(), newElement, 0);
refresh();
System.out.println("Added new element");

I know this is being executed because of the println. However, it has no effect on my tree. What am I doing wrong?

Thanks,

Rodrigo

Last edited by Rodrigo Braz; 04-20-2009 at 02:26 AM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Images problem in treeviewer Gandolf SWT / JFace 0 04-03-2009 03:18 PM
SWT treeviewer sushistix SWT / JFace 4 10-28-2008 10:25 PM
TreeViewer Demonstration Java Tip SWT 0 07-07-2008 05:54 PM
Adding and removing panels dynamically kbyrne AWT / Swing 1 04-12-2008 09:28 PM


All times are GMT +2. The time now is 12:39 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org