Exemplo n.º 1
0
 private void expandSelect() {
   if (fPathToSelect == null) return;
   if (fPathToSelect.isEmpty()) {
     fPathToSelect = null;
     fFileToSelect = null;
     return;
   }
   do {
     String name = fPathToSelect.getFirst();
     if (name.length() == 0) {
       fPathToSelect.removeFirst();
       continue;
     }
     FileInfo info = findFileInfo(fLastSelectedFileInfo, name);
     if (info == null) break;
     TreeItem item = findItem(info);
     if (item == null) break;
     fPathToSelect.removeFirst();
     if (fPathToSelect.isEmpty()) {
       fileTree.setSelection(item);
       fileTree.showItem(item);
     } else {
       item.setExpanded(true);
       fileTree.showItem(item);
     }
     fLastSelectedFileInfo = info;
   } while (!fPathToSelect.isEmpty());
 }
Exemplo n.º 2
0
 static void Scroll(Tree tree, int x, int y) {
   TreeItem item = tree.getItem(new Point(x, y));
   if (item == null) return;
   Rectangle area = tree.getClientArea();
   int headerHeight = tree.getHeaderHeight();
   int itemHeight = tree.getItemHeight();
   TreeItem nextItem = null;
   if (y < area.y + headerHeight + 2 * itemHeight) {
     nextItem = PreviousItem(tree, item);
   }
   if (y > area.y + area.height - 2 * itemHeight) {
     nextItem = NextItem(tree, item);
   }
   if (nextItem != null) tree.showItem(nextItem);
 }