Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TreeViewer setSelection does not work properly(Selection of ArrayLists (domain objects) does not work, if an ArrayList was added before at a lower index number in the list.)
TreeViewer setSelection does not work properly [message #652774] Sun, 06 February 2011 16:36
diwe  is currently offline diwe Friend
Messages: 1
Registered: February 2011
Junior Member
Hi all,
I have problems with treeViewer.setSelection method.
My domain model:

  • myListRoot

    • A
    • B
    • myListQ

      • A
      • C

    • myListX

When a new component, e.g. "B", is added, the selection of the new component works fine with the following code:
treeViewer.setSelection(newStructuredSelection(currentList.get(indexofA+1)), true);

Now I select A to add myList1 after A and execute the same code for the selection. Works fine.
The problem:
When a new myList2 is added after let's say myListX, the same code is executed:
treeViewer.setSelection(newStructuredSelection(currentList.get(indexofMyListX+1)), true);

The selection is not at the desired position of myList2 (indexofMyListX+1), but on myList1.
When I add myList3 after myList2, then myList1 is selected again.
When I add myList4 before myList1, then myList4 is selected (as desired).
When I add myList5 after myList2, then myList4 is selected instead of myList5.

Do you have any advice?

Best Regards,
Previous Topic:Programmatically Edit TableViewer
Next Topic:Expanding all nodes in a tree viewer
Goto Forum:

Current Time: Tue Apr 24 12:57:26 GMT 2018

Powered by FUDForum. Page generated in 0.02929 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software