Ejemplo n.º 1
0
  /**
   * Gets the frame root nodes.
   *
   * @param thread The target thread for callers/callees
   * @return The frame root nodes
   */
  private List<CallTreeNode> getFrameRootNodes(String thread) {
    if (thread == null) {
      return new ArrayList<CallTreeNode>();
    }

    List<CallTreeNode> frameRootNodes = null;
    if (focusTarget == null) {
      for (ThreadNode<CallTreeNode> treeNode : callTreeThreads) {
        ThreadNode<CallTreeNode> threadNode = treeNode;
        if (threadNode.getName().equals(thread)) {
          frameRootNodes = threadNode.getChildren();
          break;
        }
      }
      if (frameRootNodes == null) {
        throw new IllegalArgumentException("unknown thread: " + thread); // $NON-NLS-1$
      }
    } else {
      String focusedThread = null;
      ITreeNode node = focusTarget;
      if (node != null) {
        while (node.getParent() != null) {
          node = node.getParent();
        }
        focusedThread = node.getName();
      }
      frameRootNodes = new ArrayList<CallTreeNode>();
      if (!thread.equals(focusedThread)) {
        return frameRootNodes;
      }
      frameRootNodes.add(focusTarget);
    }
    return frameRootNodes;
  }
Ejemplo n.º 2
0
 public void execute() {
   String s = domNodeCreationHandlerCV.getValue();
   trace("got TEXT: '" + s + "'");
   ITreeNode node = new TreeNode();
   Text text = new Text();
   text.setValue(s);
   node.setDomainObject(text);
   tb.addChild(treeNodeCV.getTreeNode(), node);
 }
Ejemplo n.º 3
0
 public String getValue(ITreeNode node, int column) {
   if (node.value() instanceof Profile) {
     switch (column) {
       case 0:
         return ((Profile) node.value()).getThreadName();
       default:
         return "";
     }
   }
   if (node.value() instanceof MethodStats) {
     switch (column) {
       case 0:
         final MethodIdentifier id = resolver.getRawMethodName(((MethodStats) node.value()));
         return id == null ? "<unknown method>" : id.toString();
       case 1:
         return "" + ((MethodStats) node.value()).getInvocationCount();
       case 2:
         return format(((MethodStats) node.value()).getTotalTimeMillis());
       case 3:
         final double percentageOfParentTime =
             100 * ((MethodStats) node.value()).getPercentageOfParentTime();
         return format(percentageOfParentTime);
       case 4:
         return format(((MethodStats) node.value()).getOwnTimeMillis());
       default:
     }
   }
   return "";
 }
Ejemplo n.º 4
0
 public TreeItem<ITreeNode> toTreeItems() {
   final TreeItem<ITreeNode> result = new TreeItem<>(null);
   for (ITreeNode child : root.children()) {
     result.getChildren().add(createTreeItem(child));
   }
   return result;
 }
Ejemplo n.º 5
0
 private TreeItem<ITreeNode> createTreeItem(ITreeNode node) {
   final TreeItem<ITreeNode> result = new TreeItem<>(node);
   for (ITreeNode child : node.children()) {
     result.getChildren().add(createTreeItem(child));
   }
   return result;
 }
Ejemplo n.º 6
0
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {
      ITreeNode node = (ITreeNode) event.getElement();
      IModelTransferNode model = node.getElement();

      // apply the check state to the model
      if (event.getChecked()) {
        config.addModelToTransfer(model.getPrimaryResourceURI());
      } else {
        config.removeModelToTransfer(model);
      }

      // propagate the check state to other occurrences of the same model
      for (ITreeNode next : nodes.get(model)) {
        event.getCheckable().setChecked(next, event.getChecked());
      }
    }
Ejemplo n.º 7
0
  private void initializeCheckedNodes() {
    final Collection<IModelTransferNode> initialSet = importConfig.getModelsToTransfer();
    final ITreeContentProvider contents = (ITreeContentProvider) modelsTree.getContentProvider();
    final ICheckable checkable = (ICheckable) modelsTree;

    final Set<IModelTransferNode> visited = Sets.newHashSet();
    final Queue<Object> queue =
        new java.util.ArrayDeque<Object>(Arrays.asList(contents.getElements(importConfig)));

    for (Object next = queue.poll(); next != null; next = queue.poll()) {
      ITreeNode parent = (ITreeNode) next;

      // we must check a parent if the user initially selected it on opening the wizard
      // or we are importing and it is a dependent of a checked node,
      // or we are exporting and it is a dependency of a checked node,
      // or it is a model sub-unit (required dependency) of a checked node
      boolean mustCheck = initialSet.contains(parent.getElement());
      if (mustCheck) {
        checkable.setChecked(next, true);
      }

      if (visited.add(parent.getElement())) {
        // recurse into the children
        for (Object child : contents.getChildren(next)) {
          ITreeNode treeNode = (ITreeNode) child;
          queue.add(treeNode);

          // we must check a node if either the user initially selected it on opening the wizard,
          // or we are importing and it is a dependent of a checked node,
          // or we are exporting and it is a dependency of a checked node,
          // or it is a model sub-unit (required dependency) of a checked node
          mustCheck =
              initialSet.contains(treeNode.getElement()) //
                  || (isImport ? treeNode.isDependent() : treeNode.isDependency()) //
                  || (checkable.getChecked(parent)
                      && parent.getElement().isModelSubUnit(treeNode.getElement()));

          if (mustCheck) {
            checkable.setChecked(child, true);
            importConfig.addModelToTransfer(treeNode.getElement().getPrimaryResourceURI());
          }
        }
      }
    }
  }
Ejemplo n.º 8
0
    @Override
    public Image getImage(Object element) {
      ITreeNode treeNode = (ITreeNode) element;
      Image result = super.getImage(element);

      if ((result != null) && treeNode.isDependent()) {
        // decorate it
        result =
            (Image)
                images.get(
                    new DecorationOverlayIcon(
                        result,
                        Activator.getIcon(Activator.ICON_DEPENDENT_OVERLAY16),
                        IDecoration.TOP_RIGHT));
      }

      return result;
    }