public void actionPerformed(final AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNode = getSelectedNodes(e.getDataContext());
    final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();

    if (debugProcess == null) return;

    //noinspection ConstantConditions
    for (final DebuggerTreeNodeImpl debuggerTreeNode : selectedNode) {
      final ThreadDescriptorImpl threadDescriptor =
          ((ThreadDescriptorImpl) debuggerTreeNode.getDescriptor());

      if (threadDescriptor.isSuspended()) {
        final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
        debugProcess
            .getManagerThread()
            .schedule(
                new DebuggerCommandImpl() {
                  @Override
                  protected void action() throws Exception {
                    Set<SuspendContextImpl> contexts =
                        SuspendManagerUtil.getSuspendingContexts(
                            debugProcess.getSuspendManager(), thread);
                    if (!contexts.isEmpty()) {
                      debugProcess
                          .createResumeThreadCommand(contexts.iterator().next(), thread)
                          .run();
                    }
                    debuggerTreeNode.calcValue();
                  }
                });
      }
    }
  }
  @Override
  public void update(final AnActionEvent e) {
    if (!isFirstStart(e)) {
      return;
    }

    final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
      e.getPresentation().setVisible(false);
      return;
    }

    DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    if (selectedNode == null) {
      e.getPresentation().setVisible(false);
      return;
    }

    final NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
    if (descriptor instanceof ValueDescriptor) {
      debugProcess
          .getManagerThread()
          .schedule(
              new EnableCommand(debuggerContext, (ValueDescriptor) descriptor, debugProcess, e));
    } else {
      e.getPresentation().setVisible(false);
    }
  }
  public DebuggerTreeNodeImpl addWatch(TextWithImports text) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getModel().getRoot();
    DebuggerTreeNodeImpl node =
        DebuggerTreeNodeImpl.createNodeNoUpdate(this, new WatchItemDescriptor(getProject(), text));
    root.add(node);

    treeChanged();
    getSelectionModel().setSelectionPath(new TreePath(node.getPath()));

    return node;
  }
  public DebuggerTreeNodeImpl[] getWatches() {
    DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getModel().getRoot();
    DebuggerTreeNodeImpl[] watches = new DebuggerTreeNodeImpl[root.getChildCount()];

    final Enumeration e = root.children();
    int i = 0;
    while (e.hasMoreElements()) {
      watches[i++] = (DebuggerTreeNodeImpl) e.nextElement();
    }

    return watches;
  }
Example #5
0
 private void updateTree(final TreeModel model, final DebuggerTreeNodeImpl node) {
   if (node == null) {
     return;
   }
   if (node.getDescriptor().myIsExpanded) {
     final int count = model.getChildCount(node);
     for (int idx = 0; idx < count; idx++) {
       final DebuggerTreeNodeImpl child = (DebuggerTreeNodeImpl) model.getChild(node, idx);
       updateTree(model, child);
     }
   }
   node.labelChanged();
 }
  public DebuggerTreeNodeImpl addWatch(WatchItemDescriptor descriptor) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getModel().getRoot();
    WatchItemDescriptor watchDescriptor =
        new WatchItemDescriptor(getProject(), descriptor.getEvaluationText());
    watchDescriptor.displayAs(descriptor);

    final DebuggerTreeNodeImpl node =
        DebuggerTreeNodeImpl.createNodeNoUpdate(this, watchDescriptor);
    root.add(node);

    treeChanged();
    getSelectionModel().setSelectionPath(new TreePath(node.getPath()));

    // node.calcValue();

    return node;
  }
  @Override
  public void actionPerformed(AnActionEvent e) {
    DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    if (selectedNode == null) {
      return;
    }

    final NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
    if (!(descriptor instanceof ValueDescriptor)) {
      return;
    }

    DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
      return;
    }

    debugProcess
        .getManagerThread()
        .schedule(
            new NavigateCommand(debuggerContext, (ValueDescriptor) descriptor, debugProcess, e));
  }
  public void update(AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());

    boolean visible = false;
    boolean enabled = false;
    String text = DebuggerBundle.message("action.resume.thread.text.resume");

    if (selectedNodes != null && selectedNodes.length > 0) {
      visible = true;
      enabled = true;
      for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
        final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
        if (!(threadDescriptor instanceof ThreadDescriptorImpl)
            || !((ThreadDescriptorImpl) threadDescriptor).isSuspended()) {
          visible = false;
          break;
        }
      }
    }
    final Presentation presentation = e.getPresentation();
    presentation.setText(text);
    presentation.setVisible(visible);
    presentation.setEnabled(enabled);
  }
  public void removeWatch(DebuggerTreeNodeImpl node) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    LOG.assertTrue(node.getDescriptor() instanceof WatchItemDescriptor);

    DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getModel().getRoot();
    DebuggerTreeNodeImpl nodeToSelect = (DebuggerTreeNodeImpl) node.getNextSibling();

    getMutableModel().removeNodeFromParent(node);
    treeChanged();

    if (nodeToSelect == null && root.getChildCount() > 0) {
      nodeToSelect = (DebuggerTreeNodeImpl) root.getChildAt(root.getChildCount() - 1);
    }

    if (nodeToSelect != null) {
      setSelectionPath(new TreePath(nodeToSelect.getPath()));
    }
  }
 public int getWatchCount() {
   DebuggerTreeNodeImpl root = (DebuggerTreeNodeImpl) getModel().getRoot();
   return root != null ? root.getChildCount() : 0;
 }
 public static void setWatchNodeText(final DebuggerTreeNodeImpl node, TextWithImports text) {
   ((WatchItemDescriptor) node.getDescriptor()).setEvaluationText(text);
   node.calcValue();
 }
 protected void build(DebuggerContextImpl context) {
   for (DebuggerTreeNodeImpl node : getWatches()) {
     node.calcValue();
   }
 }
  public void editNode(final DebuggerTreeNodeImpl node) {
    final DebuggerContextImpl context = getContext();
    final DebuggerExpressionComboBox comboBox =
        new DebuggerExpressionComboBox(
            getProject(),
            PositionUtil.getContextElement(context),
            "evaluation",
            DefaultCodeFragmentFactory.getInstance());
    comboBox.setText(((WatchItemDescriptor) node.getDescriptor()).getEvaluationText());
    comboBox.selectAll();

    DebuggerTreeInplaceEditor editor =
        new DebuggerTreeInplaceEditor(node) {
          public JComponent createInplaceEditorComponent() {
            return comboBox;
          }

          public JComponent getPreferredFocusedComponent() {
            return comboBox.getPreferredFocusedComponent();
          }

          public Editor getEditor() {
            return comboBox.getEditor();
          }

          public JComponent getEditorComponent() {
            return comboBox.getEditorComponent();
          }

          public void doOKAction() {
            if (comboBox.isPopupVisible()) {
              comboBox.selectPopupValue();
            }

            TextWithImports text = comboBox.getText();
            if (!text.isEmpty()) {
              WatchDebuggerTree.setWatchNodeText(node, text);
              comboBox.addRecent(text);
            } else {
              getWatchTree().removeWatch(node);
            }
            try {
              super.doOKAction();
            } finally {
              comboBox.dispose();
            }
          }

          public void cancelEditing() {
            comboBox.setPopupVisible(false);
            if (((WatchItemDescriptor) node.getDescriptor()).getEvaluationText().isEmpty()) {
              getWatchTree().removeWatch(node);
            }

            try {
              super.cancelEditing();
            } finally {
              comboBox.dispose();
            }
          }
        };
    editor.show();
  }