Insert item on TreeViewer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssaraceni
    New Member
    • Sep 2008
    • 18

    Insert item on TreeViewer

    I need to add an element on a tree object in an Eclipse plug-in into a specified position.

    I use org.eclipse.jfa ce.viewers.Tree Viewer for the viewer.
    I want to insert an item before the current selected one, for having the selected item I use the viewer.getTree( ).getSelection( )[0] instruction, but I can't find the right position. if I use the viewer.getTree( ).getItems() I only receive the root elements and not all items (also under the roots elements).
    so when I pass the selected item on viewer.getTree. indexOf( elem ) instruction, I receive -1

    Any suggestions?

    Thanks
  • ssaraceni
    New Member
    • Sep 2008
    • 18

    #2
    Now I've solved the problem: after getting selected item using the getTree().getSe lection()[0];
    I get the list of child items with selected.getIte ms(); and after that I scan the array finding the position of the previous item, so I can insert the new item on the position searched

    Comment

    Working...