예제 #1
0
 /**
  * Hook to compute the menu location if the focus widget is a tree widget.
  *
  * @param tree the tree widget that has the focus
  * @return a widget relative position of the menu to pop up or <code>null</code> if now position
  *     inside the widget can be computed
  */
 protected Point computeMenuLocation(Tree tree) {
   TreeItem[] items = tree.getSelection();
   Rectangle clientArea = tree.getClientArea();
   switch (items.length) {
     case 0:
       return null;
     case 1:
       Rectangle bounds = items[0].getBounds();
       Rectangle intersect = clientArea.intersection(bounds);
       if (intersect != null && intersect.height == bounds.height) {
         return new Point(
             Math.max(0, bounds.x + getAvarageCharWith(tree) * CHAR_INDENT),
             bounds.y + bounds.height);
       } else {
         return null;
       }
     default:
       Rectangle[] rectangles = new Rectangle[items.length];
       for (int i = 0; i < rectangles.length; i++) {
         rectangles[i] = items[i].getBounds();
       }
       Point cursorLocation = tree.getDisplay().getCursorLocation();
       Point result =
           findBestLocation(
               getIncludedPositions(rectangles, clientArea), tree.toControl(cursorLocation));
       if (result != null) result.x = result.x + getAvarageCharWith(tree) * CHAR_INDENT;
       return result;
   }
 }
예제 #2
0
 public static SWTBotTreeColumn getColumn(final Tree tree, final int index) {
   TreeColumn treeColumn =
       UIThreadRunnable.syncExec(
           tree.getDisplay(),
           new WidgetResult<TreeColumn>() {
             public TreeColumn run() {
               return tree.getColumn(index);
             }
           });
   return new SWTBotTreeColumn(treeColumn);
 }
 public void gotValue(
     LiveExpression<Filter<BootDashElement>> exp, Filter<BootDashElement> value) {
   tv.refresh();
   final Tree t = tv.getTree();
   t.getDisplay()
       .asyncExec(
           new Runnable() {
             public void run() {
               Composite parent = t.getParent();
               parent.layout();
             }
           });
 }