Guest User

Untitled

a guest
May 5th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Vertical align 2 jface TreeViewers to specific element.
  2. treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
  3. @Override
  4. public void selectionChanged(SelectionChangedEvent arg0) {
  5. TreeViewer mirrorTree = (treeViewer == treeVwrSource ? treeVwrTarget : treeVwrSource);
  6. // find position of selected element (element x) in treeViewer
  7. // set position of element x in mirrorTree, it is already selected.
  8. }
  9. });
  10.  
  11. Tree tree1 = ...;
  12. Tree tree2 = ...;
  13.  
  14. int topIndex = tree1.indexOf(tree1.getTopItem());
  15. tree2.setTopItem(tree2.getItem(topIndex));
  16.  
  17. viewer.setSelection(otherViewer.getSelection)
Advertisement
Add Comment
Please, Sign In to add comment