Пример #1
0
 /**
  * helper to create element format settings for all children paths of a given element path. Tree
  * paths at the same level will use the same format. Tree paths at different levels will use
  * different formats.
  *
  * @param _viewer tree viewer
  * @param path given element path
  * @param formats formats to rotate for different levels of children tree paths
  * @param levelStop depth to stop recursively walk down the children.
  * @param levelIndex index to a format for a level of children
  * @param result store the created element format settings
  */
 void makeElementFormatSetting(
     ITreeModelViewer _viewer,
     TreePath path,
     String[] formats,
     int levelStop,
     int levelIndex,
     HashMap<String, ElementFormatSetting> result) {
   if (levelStop >= 0 && levelIndex >= levelStop) return;
   IInternalTreeModelViewer viewer = (IInternalTreeModelViewer) _viewer;
   int childCount = viewer.getChildCount(path);
   if (childCount == 0) return;
   String fmt = formats[levelIndex % formats.length];
   ElementFormatSetting setting = result.get(fmt);
   if (setting == null) {
     setting = new ElementFormatSetting();
     setting.nodes = new ArrayList<IVMNode>(childCount);
     setting.elementPaths = new ArrayList<TreePath>(childCount);
     setting.formatId = fmt;
     result.put(fmt, setting);
   }
   for (int i = 0; i < childCount; i++) {
     Object viewerObject = viewer.getChildElement(path, i);
     if (viewerObject instanceof TestElementVMContext) {
       TreePath childPath = path.createChildPath(viewerObject);
       setting.nodes.add(((TestElementVMContext) viewerObject).getVMNode());
       setting.elementPaths.add(childPath);
       makeElementFormatSetting(viewer, childPath, formats, levelStop, levelIndex + 1, result);
     }
   }
 }
 private Object[] internalGetChildren(
     ISynchronizationContext context, Object parent, Object[] children) {
   List result = new ArrayList(children.length);
   for (int i = 0; i < children.length; i++) {
     Object object = children[i];
     // If the parent is a TreePath then the subclass is
     // TreePath aware and we can send a TrePath to the
     // isVisible method
     if (parent instanceof TreePath) {
       TreePath tp = (TreePath) parent;
       object = tp.createChildPath(object);
     }
     if (isVisible(context, object)) result.add(internalGetElement(object));
   }
   return result.toArray(new Object[result.size()]);
 }
Пример #3
0
  private void doDoubleClick() {
    MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    MassifTreeViewer treeViewer = view.getTreeViewer();

    MassifSnapshot[] snapshots = view.getSnapshots();
    node = snapshots[1].getRoot(); // first detailed
    TreePath path = new TreePath(new Object[] {node});
    while (node.getChildren().length > 0 && !node.hasSourceFile()) {
      node = node.getChildren()[0];
      path = path.createChildPath(node);
    }
    if (node.hasSourceFile()) {
      treeViewer.getViewer().expandToLevel(node, TreeViewer.ALL_LEVELS);
      TreeSelection selection = new TreeSelection(path);

      // do double click
      IDoubleClickListener listener = treeViewer.getDoubleClickListener();
      listener.doubleClick(new DoubleClickEvent(treeViewer.getViewer(), selection));
    } else {
      fail();
    }
  }