Search in sources :

Example 1 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.

the class DebuggerTreeBase method createToolTip.

@Nullable
public JComponent createToolTip(MouseEvent e) {
    final DebuggerTreeNodeImpl node = getNodeToShowTip(e);
    if (node == null) {
        return null;
    }
    if (myCurrentTooltip != null && myCurrentTooltip.isShowing() && myCurrentTooltipNode == node) {
        return myCurrentTooltip;
    }
    myCurrentTooltipNode = node;
    final String toolTipText = getTipText(node);
    if (toolTipText == null) {
        return null;
    }
    final JComponent tipContent = createTipContent(toolTipText, node);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tipContent);
    scrollPane.setBorder(null);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final Point point = e.getPoint();
    SwingUtilities.convertPointToScreen(point, e.getComponent());
    Rectangle tipRectangle = new Rectangle(point, tipContent.getPreferredSize());
    final Rectangle screen = ScreenUtil.getScreenRectangle(point.x, point.y);
    final JToolTip toolTip = new JToolTip();
    tipContent.addMouseListener(new HideTooltip(toolTip));
    final Border tooltipBorder = toolTip.getBorder();
    if (tooltipBorder != null) {
        final Insets borderInsets = tooltipBorder.getBorderInsets(this);
        tipRectangle.setSize(tipRectangle.width + borderInsets.left + borderInsets.right, tipRectangle.height + borderInsets.top + borderInsets.bottom);
    }
    toolTip.setLayout(new BorderLayout());
    toolTip.add(scrollPane, BorderLayout.CENTER);
    tipRectangle.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height;
    tipRectangle.width += scrollPane.getVerticalScrollBar().getPreferredSize().width;
    final int maxWidth = (int) (screen.width - screen.width * .25);
    if (tipRectangle.width > maxWidth) {
        tipRectangle.width = maxWidth;
    }
    final Dimension prefSize = tipRectangle.getSize();
    ScreenUtil.cropRectangleToFitTheScreen(tipRectangle);
    if (prefSize.width > tipRectangle.width) {
        final int delta = prefSize.width - tipRectangle.width;
        tipRectangle.x -= delta;
        if (tipRectangle.x < screen.x) {
            tipRectangle.x = screen.x + maxWidth / 2;
            tipRectangle.width = screen.width - maxWidth / 2;
        } else {
            tipRectangle.width += delta;
        }
    }
    toolTip.setPreferredSize(tipRectangle.getSize());
    myCurrentTooltip = toolTip;
    return myCurrentTooltip;
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) Border(javax.swing.border.Border) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.

the class DebuggerTreeCreatorImpl method createDescriptorByNode.

@Override
public void createDescriptorByNode(Object node, final ResultConsumer<Pair<NodeDescriptorImpl, String>> resultConsumer) {
    if (node instanceof DebuggerTreeNodeImpl) {
        final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl) node;
        final DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
        context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {

            @Override
            public void threadAction() {
                try {
                    final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(debuggerTreeNode, context);
                    resultConsumer.onSuccess(Pair.create(debuggerTreeNode.getDescriptor(), evaluationText.getText()));
                } catch (EvaluateException e) {
                    resultConsumer.onFailure(e);
                }
            }
        });
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 3 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.

the class InterruptThreadAction method update.

public void update(AnActionEvent e) {
    final DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());
    boolean visible = false;
    boolean enabled = false;
    if (selectedNodes != null && selectedNodes.length > 0) {
        visible = true;
        enabled = true;
        for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
            final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
            if (!(threadDescriptor instanceof ThreadDescriptorImpl)) {
                visible = false;
                break;
            }
        }
        if (visible) {
            for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
                final ThreadDescriptorImpl threadDescriptor = (ThreadDescriptorImpl) selectedNode.getDescriptor();
                if (threadDescriptor.isFrozen() || threadDescriptor.isSuspended()) {
                    enabled = false;
                    break;
                }
            }
        }
    }
    final Presentation presentation = e.getPresentation();
    presentation.setText(DebuggerBundle.message("action.interrupt.thread.text"));
    presentation.setEnabledAndVisible(visible && enabled);
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) Presentation(com.intellij.openapi.actionSystem.Presentation) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 4 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.

the class JavaMarkObjectActionHandler method perform.

@Override
public void perform(@NotNull Project project, AnActionEvent event) {
    final DebuggerTreeNodeImpl node = DebuggerAction.getSelectedNode(event.getDataContext());
    if (node == null) {
        return;
    }
    final NodeDescriptorImpl descriptor = node.getDescriptor();
    if (!(descriptor instanceof ValueDescriptorImpl)) {
        return;
    }
    final DebuggerTree tree = node.getTree();
    tree.saveState(node);
    final Component parent = event.getData(CONTEXT_COMPONENT);
    final ValueDescriptorImpl valueDescriptor = ((ValueDescriptorImpl) descriptor);
    final DebuggerContextImpl debuggerContext = tree.getDebuggerContext();
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    final ValueMarkup markup = valueDescriptor.getMarkup(debugProcess);
    debugProcess.getManagerThread().invoke(new DebuggerContextCommandImpl(debuggerContext) {

        public Priority getPriority() {
            return Priority.HIGH;
        }

        public void threadAction() {
            boolean sessionRefreshNeeded = true;
            try {
                if (markup != null) {
                    valueDescriptor.setMarkup(debugProcess, null);
                } else {
                    final String defaultText = valueDescriptor.getName();
                    final Ref<Pair<ValueMarkup, Boolean>> result = new Ref<>(null);
                    try {
                        final boolean suggestAdditionalMarkup = canSuggestAdditionalMarkup(debugProcess, valueDescriptor.getValue());
                        SwingUtilities.invokeAndWait(() -> {
                            ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(parent, defaultText, suggestAdditionalMarkup);
                            if (dialog.showAndGet()) {
                                result.set(Pair.create(dialog.getConfiguredMarkup(), dialog.isMarkAdditionalFields()));
                            }
                        });
                    } catch (InterruptedException ignored) {
                    } catch (InvocationTargetException e) {
                        LOG.error(e);
                    }
                    final Pair<ValueMarkup, Boolean> pair = result.get();
                    if (pair != null) {
                        valueDescriptor.setMarkup(debugProcess, pair.first);
                        if (pair.second) {
                            final Value value = valueDescriptor.getValue();
                            final Map<ObjectReference, ValueMarkup> additionalMarkup = suggestMarkup((ObjectReference) value);
                            if (!additionalMarkup.isEmpty()) {
                                final Map<ObjectReference, ValueMarkup> map = NodeDescriptorImpl.getMarkupMap(debugProcess);
                                if (map != null) {
                                    for (Map.Entry<ObjectReference, ValueMarkup> entry : additionalMarkup.entrySet()) {
                                        final ObjectReference key = entry.getKey();
                                        if (!map.containsKey(key)) {
                                            map.put(key, entry.getValue());
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        sessionRefreshNeeded = false;
                    }
                }
            } finally {
                final boolean _sessionRefreshNeeded = sessionRefreshNeeded;
                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        tree.restoreState(node);
                        final TreeBuilder model = tree.getMutableModel();
                        refreshLabelsRecursively(model.getRoot(), model, valueDescriptor.getValue());
                        if (_sessionRefreshNeeded) {
                            final DebuggerSession session = debuggerContext.getDebuggerSession();
                            if (session != null) {
                                session.refresh(true);
                            }
                        }
                    }

                    private void refreshLabelsRecursively(Object node, TreeBuilder model, Value value) {
                        if (node instanceof DebuggerTreeNodeImpl) {
                            final DebuggerTreeNodeImpl _node = (DebuggerTreeNodeImpl) node;
                            final NodeDescriptorImpl descriptor = _node.getDescriptor();
                            if (descriptor instanceof ValueDescriptor && Comparing.equal(value, ((ValueDescriptor) descriptor).getValue())) {
                                _node.labelChanged();
                            }
                        }
                        final int childCount = model.getChildCount(node);
                        for (int idx = 0; idx < childCount; idx++) {
                            refreshLabelsRecursively(model.getChild(node, idx), model, value);
                        }
                    }
                });
            }
        }
    });
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl) Pair(com.intellij.openapi.util.Pair) DebuggerTree(com.intellij.debugger.ui.impl.watch.DebuggerTree) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup) InvocationTargetException(java.lang.reflect.InvocationTargetException) TreeBuilder(com.intellij.debugger.ui.impl.tree.TreeBuilder) Ref(com.intellij.openapi.util.Ref) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) HashMap(com.intellij.util.containers.HashMap) Map(java.util.Map) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 5 with DebuggerTreeNodeImpl

use of com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl in project intellij-community by JetBrains.

the class JumpToObjectAction method actionPerformed.

@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));
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Aggregations

DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)26 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)11 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)10 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)9 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)7 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)6 Nullable (org.jetbrains.annotations.Nullable)6 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)5 Project (com.intellij.openapi.project.Project)5 SourcePosition (com.intellij.debugger.SourcePosition)4 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)4 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)3 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)2 FieldDescriptorImpl (com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl)2 ValueDescriptorImpl (com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl)2 NodeDescriptor (com.intellij.debugger.ui.tree.NodeDescriptor)2 Document (com.intellij.openapi.editor.Document)2