Search in sources :

Example 1 with XDebuggerTree

use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.

the class ViewTextAction method createCollector.

@NotNull
@Override
protected ValueCollector createCollector(@NotNull AnActionEvent e) {
    XValueNodeImpl node = getStringNode(e);
    return new ValueCollector(XDebuggerTree.getTree(e.getDataContext())) {

        MyDialog dialog = null;

        @Override
        public void handleInCollector(Project project, String value, XDebuggerTree tree) {
            String text = StringUtil.unquoteString(value);
            if (dialog == null) {
                dialog = new MyDialog(project, text, node);
                dialog.setTitle(ActionsBundle.message(node != null ? "action.Debugger.ViewEditText.text" : "action.Debugger.ViewText.text"));
                dialog.show();
            }
            dialog.setText(text);
        }
    };
}
Also used : Project(com.intellij.openapi.project.Project) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with XDebuggerTree

use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.

the class XVariablesViewBase method buildTreeAndRestoreState.

protected void buildTreeAndRestoreState(@NotNull final XStackFrame stackFrame) {
    XSourcePosition position = stackFrame.getSourcePosition();
    XDebuggerTree tree = getTree();
    tree.setSourcePosition(position);
    createNewRootNode(stackFrame);
    final Project project = tree.getProject();
    project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo());
    clearInlays(tree);
    Object newEqualityObject = stackFrame.getEqualityObject();
    if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) && myTreeState != null) {
        disposeTreeRestorer();
        myTreeRestorer = myTreeState.restoreState(tree);
    }
    if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) {
        registerInlineEvaluator(stackFrame, position, project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)

Example 3 with XDebuggerTree

use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.

the class XWatchesViewImpl method update.

@Override
public boolean update(final DnDEvent aEvent) {
    Object object = aEvent.getAttachedObject();
    boolean possible = false;
    if (object instanceof XValueNodeImpl[]) {
        possible = true;
        // do not add new watch if node is dragged to itself
        if (((XValueNodeImpl[]) object).length == 1) {
            Point point = aEvent.getPoint();
            XDebuggerTree tree = getTree();
            TreePath path = tree.getClosestPathForLocation(point.x, point.y);
            if (path != null && path.getLastPathComponent() == ((XValueNodeImpl[]) object)[0]) {
                // the same item is under pointer, filter out place below the tree
                Rectangle pathBounds = tree.getPathBounds(path);
                possible = pathBounds != null && pathBounds.y + pathBounds.height < point.y;
            }
        }
    } else if (object instanceof EventInfo) {
        possible = ((EventInfo) object).getTextForFlavor(DataFlavor.stringFlavor) != null;
    }
    aEvent.setDropPossible(possible, XDebuggerBundle.message("xdebugger.drop.text.add.to.watches"));
    return true;
}
Also used : TreePath(javax.swing.tree.TreePath) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)

Example 4 with XDebuggerTree

use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.

the class XDebuggerEvaluationDialog method evaluate.

private void evaluate() {
    final XDebuggerEditorBase inputEditor = getInputEditor();
    int offset = -1;
    //try to save caret position
    Editor editor = inputEditor.getEditor();
    if (editor != null) {
        offset = editor.getCaretModel().getOffset();
    }
    final XDebuggerTree tree = myTreePanel.getTree();
    tree.markNodesObsolete();
    tree.setRoot(new EvaluatingExpressionRootNode(this, tree), false);
    myResultPanel.invalidate();
    //editor is already changed
    editor = inputEditor.getEditor();
    //selectAll puts focus back
    inputEditor.selectAll();
    //try to restore caret position and clear selection
    if (offset >= 0 && editor != null) {
        offset = Math.min(editor.getDocument().getTextLength(), offset);
        editor.getCaretModel().moveToOffset(offset);
        editor.getSelectionModel().setSelection(offset, offset);
    }
}
Also used : EvaluatingExpressionRootNode(com.intellij.xdebugger.impl.ui.tree.nodes.EvaluatingExpressionRootNode) XDebuggerEditorBase(com.intellij.xdebugger.impl.ui.XDebuggerEditorBase) Editor(com.intellij.openapi.editor.Editor) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)

Example 5 with XDebuggerTree

use of com.intellij.xdebugger.impl.ui.tree.XDebuggerTree in project intellij-community by JetBrains.

the class XWatchesViewImpl method installEditListeners.

private void installEditListeners() {
    final XDebuggerTree watchTree = getTree();
    final Alarm quitePeriod = new Alarm();
    final Alarm editAlarm = new Alarm();
    final ClickListener mouseListener = new ClickListener() {

        @Override
        public boolean onClick(@NotNull MouseEvent event, int clickCount) {
            if (!SwingUtilities.isLeftMouseButton(event) || ((event.getModifiers() & (InputEvent.SHIFT_MASK | InputEvent.ALT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK)) != 0)) {
                return false;
            }
            boolean sameRow = isAboveSelectedItem(event, watchTree, false);
            if (!sameRow || clickCount > 1) {
                editAlarm.cancelAllRequests();
                return false;
            }
            final AnAction editWatchAction = ActionManager.getInstance().getAction(XDebuggerActions.XEDIT_WATCH);
            Presentation presentation = editWatchAction.getTemplatePresentation().clone();
            DataContext context = DataManager.getInstance().getDataContext(watchTree);
            final AnActionEvent actionEvent = new AnActionEvent(null, context, "WATCH_TREE", presentation, ActionManager.getInstance(), 0);
            Runnable runnable = () -> editWatchAction.actionPerformed(actionEvent);
            if (editAlarm.isEmpty() && quitePeriod.isEmpty()) {
                editAlarm.addRequest(runnable, UIUtil.getMultiClickInterval());
            } else {
                editAlarm.cancelAllRequests();
            }
            return false;
        }
    };
    final ClickListener mouseEmptySpaceListener = new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent event) {
            if (!isAboveSelectedItem(event, watchTree, true)) {
                myRootNode.addNewWatch();
                return true;
            }
            return false;
        }
    };
    ListenerUtil.addClickListener(watchTree, mouseListener);
    ListenerUtil.addClickListener(watchTree, mouseEmptySpaceListener);
    final FocusListener focusListener = new FocusListener() {

        @Override
        public void focusGained(@NotNull FocusEvent e) {
            quitePeriod.addRequest(EmptyRunnable.getInstance(), UIUtil.getMultiClickInterval());
        }

        @Override
        public void focusLost(@NotNull FocusEvent e) {
            editAlarm.cancelAllRequests();
        }
    };
    ListenerUtil.addFocusListener(watchTree, focusListener);
    final TreeSelectionListener selectionListener = new TreeSelectionListener() {

        @Override
        public void valueChanged(@NotNull TreeSelectionEvent e) {
            quitePeriod.addRequest(EmptyRunnable.getInstance(), UIUtil.getMultiClickInterval());
        }
    };
    watchTree.addTreeSelectionListener(selectionListener);
    myDisposables.add(new Disposable() {

        @Override
        public void dispose() {
            ListenerUtil.removeClickListener(watchTree, mouseListener);
            ListenerUtil.removeClickListener(watchTree, mouseEmptySpaceListener);
            ListenerUtil.removeFocusListener(watchTree, focusListener);
            watchTree.removeTreeSelectionListener(selectionListener);
        }
    });
}
Also used : CompositeDisposable(com.intellij.openapi.CompositeDisposable) Disposable(com.intellij.openapi.Disposable) MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener) TreeSelectionListener(javax.swing.event.TreeSelectionListener) XDebuggerTree(com.intellij.xdebugger.impl.ui.tree.XDebuggerTree) NotNull(org.jetbrains.annotations.NotNull) FocusEvent(java.awt.event.FocusEvent) Alarm(com.intellij.util.Alarm) EmptyRunnable(com.intellij.openapi.util.EmptyRunnable) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) FocusListener(java.awt.event.FocusListener) DoubleClickListener(com.intellij.ui.DoubleClickListener) ClickListener(com.intellij.ui.ClickListener)

Aggregations

XDebuggerTree (com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)19 NotNull (org.jetbrains.annotations.NotNull)6 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)5 Project (com.intellij.openapi.project.Project)4 XDebugSession (com.intellij.xdebugger.XDebugSession)3 TreePath (javax.swing.tree.TreePath)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)2 XWatchesView (com.intellij.xdebugger.impl.frame.XWatchesView)2 XInspectDialog (com.intellij.xdebugger.impl.ui.tree.XInspectDialog)2 ResultConsumer (com.intellij.concurrency.ResultConsumer)1 CompositeDisposable (com.intellij.openapi.CompositeDisposable)1 Disposable (com.intellij.openapi.Disposable)1 Editor (com.intellij.openapi.editor.Editor)1 Condition (com.intellij.openapi.util.Condition)1 EmptyRunnable (com.intellij.openapi.util.EmptyRunnable)1 Pair (com.intellij.openapi.util.Pair)1 ClickListener (com.intellij.ui.ClickListener)1 DoubleClickListener (com.intellij.ui.DoubleClickListener)1 Tree (com.intellij.ui.treeStructure.Tree)1 Alarm (com.intellij.util.Alarm)1