Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.62 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)