Skip to main content


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.refresh();
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:
reeViewer.refresh();
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,
diwe
Previous Topic:Programmatically Edit TableViewer
Next Topic:Expanding all nodes in a tree viewer
Goto Forum:
  


Current Time: Sat Apr 20 02:36:43 GMT 2024

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

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

Back to the top