Results 1 to 1 of 1
  1. #1
    Rodrigo Braz is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    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 01:26 AM.

Similar Threads

  1. Images problem in treeviewer
    By Gandolf in forum SWT / JFace
    Replies: 0
    Last Post: 04-03-2009, 02:18 PM
  2. SWT treeviewer
    By sushistix in forum SWT / JFace
    Replies: 4
    Last Post: 10-28-2008, 09:25 PM
  3. TreeViewer Demonstration
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-07-2008, 04:54 PM
  4. Adding and removing panels dynamically
    By kbyrne in forum AWT / Swing
    Replies: 1
    Last Post: 04-12-2008, 08:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •