コード例 #1
0
  public SlicePanel(
      @NotNull final Project project,
      boolean dataFlowToThis,
      @NotNull SliceNode rootNode,
      boolean splitByLeafExpressions,
      @NotNull final ToolWindow toolWindow) {
    super(new BorderLayout());
    myToolWindow = toolWindow;
    final ToolWindowManagerListener listener =
        new ToolWindowManagerListener() {
          ToolWindowAnchor myAnchor = toolWindow.getAnchor();

          @Override
          public void toolWindowRegistered(@NotNull String id) {}

          @Override
          public void stateChanged() {
            if (!project.isOpen()) return;
            if (toolWindow.getAnchor() != myAnchor) {
              myAnchor = myToolWindow.getAnchor();
              layoutPanel();
            }
          }
        };
    ToolWindowManagerEx.getInstanceEx(project).addToolWindowManagerListener(listener, this);

    ApplicationManager.getApplication().assertIsDispatchThread();
    myProject = project;
    myTree = createTree();

    myBuilder =
        new SliceTreeBuilder(myTree, project, dataFlowToThis, rootNode, splitByLeafExpressions);
    myBuilder.setCanYieldUpdate(!ApplicationManager.getApplication().isUnitTestMode());

    Disposer.register(this, myBuilder);

    myBuilder.addSubtreeToUpdate(
        (DefaultMutableTreeNode) myTree.getModel().getRoot(),
        new Runnable() {
          @Override
          public void run() {
            if (isDisposed || myBuilder.isDisposed() || myProject.isDisposed()) return;
            final SliceNode rootNode = myBuilder.getRootSliceNode();
            myBuilder.expand(
                rootNode,
                new Runnable() {
                  @Override
                  public void run() {
                    if (isDisposed || myBuilder.isDisposed() || myProject.isDisposed()) return;
                    myBuilder.select(
                        rootNode.myCachedChildren.get(0)); // first there is ony one child
                  }
                });
            treeSelectionChanged();
          }
        });

    layoutPanel();
  }
コード例 #2
0
 protected void close() {
   final ProgressIndicator progress = myBuilder.getUi().getProgress();
   if (progress != null) {
     progress.cancel();
   }
 }