Results 1 to 1 of 1
- 04-20-2009, 01:02 AM #1Member
- Join Date
- Mar 2008
- Rep Power
Adding/removing nodes to tree under TreeViewer
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);
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?
Last edited by Rodrigo Braz; 04-20-2009 at 01:26 AM.
- By Gandolf in forum SWT / JFaceReplies: 0Last Post: 04-03-2009, 02:18 PM
- By sushistix in forum SWT / JFaceReplies: 4Last Post: 10-28-2008, 09:25 PM
- By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:54 PM
- By kbyrne in forum AWT / SwingReplies: 1Last Post: 04-12-2008, 08:28 PM