Search in sources :

Example 1 with XDebuggerTreeNode

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

the class XDebuggerTreeRenderer method customizeCellRenderer.

public void customizeCellRenderer(@NotNull final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
    myHaveLink = false;
    myLink.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    XDebuggerTreeNode node = (XDebuggerTreeNode) value;
    node.appendToComponent(this);
    setIcon(node.getIcon());
    Rectangle treeVisibleRect = tree.getParent() instanceof JViewport ? ((JViewport) tree.getParent()).getViewRect() : tree.getVisibleRect();
    TreePath path = tree.getPathForRow(row);
    int rowX = path != null ? getRowX((BasicTreeUI) tree.getUI(), row, path.getPathCount() - 1) : 0;
    if (myHaveLink) {
        setupLinkDimensions(treeVisibleRect, rowX);
    } else {
        int visibleRectRightX = treeVisibleRect.x + treeVisibleRect.width;
        int notFittingWidth = rowX + super.getPreferredSize().width - visibleRectRightX;
        if (node instanceof XValueNodeImpl && notFittingWidth > 0) {
            // text does not fit visible area - show link
            String rawValue = DebuggerUIUtil.getNodeRawValue((XValueNodeImpl) node);
            if (!StringUtil.isEmpty(rawValue) && tree.isShowing()) {
                Point treeRightSideOnScreen = new Point(visibleRectRightX, 0);
                SwingUtilities.convertPointToScreen(treeRightSideOnScreen, tree);
                Rectangle screen = ScreenUtil.getScreenRectangle(treeRightSideOnScreen);
                // text may fit the screen in ExpandableItemsHandler
                if (screen.x + screen.width < treeRightSideOnScreen.x + notFittingWidth) {
                    myLongTextLink.setupComponent(rawValue, ((XDebuggerTree) tree).getProject());
                    append(myLongTextLink.getLinkText(), myLongTextLink.getTextAttributes(), myLongTextLink);
                    setupLinkDimensions(treeVisibleRect, rowX);
                    myLinkWidth = 0;
                }
            }
        }
    }
    putClientProperty(ExpandableItemsHandler.RENDERER_DISABLED, myHaveLink);
}
Also used : TreePath(javax.swing.tree.TreePath) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) BasicTreeUI(javax.swing.plaf.basic.BasicTreeUI) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode)

Example 2 with XDebuggerTreeNode

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

the class XDebuggerTreeSpeedSearch method findElement.

@Nullable
@Override
protected Object findElement(String s) {
    String string = s.trim();
    XDebuggerTreeNode node = ObjectUtils.tryCast(myComponent.getLastSelectedPathComponent(), XDebuggerTreeNode.class);
    if (node == null) {
        node = ObjectUtils.tryCast(myComponent.getModel().getRoot(), XDebuggerTreeNode.class);
        if (node == null) {
            return null;
        }
    }
    return findPath(string, node, true);
}
Also used : XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with XDebuggerTreeNode

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

the class CustomFieldInplaceEditor method editNew.

public static void editNew(@NotNull XValueNodeImpl parentNode) {
    ValueDescriptorImpl descriptor = ((JavaValue) parentNode.getValueContainer()).getDescriptor();
    EnumerationChildrenRenderer renderer = EnumerationChildrenRenderer.getCurrent(descriptor);
    XDebuggerTreeNode newNode = parentNode.addTemporaryEditorNode();
    DebuggerUIUtil.invokeLater(() -> new CustomFieldInplaceEditor(newNode, null, renderer) {

        @Override
        public void cancelEditing() {
            super.cancelEditing();
            parentNode.removeTemporaryEditorNode(newNode);
        }

        @Override
        protected List<Pair<String, TextWithImports>> getRendererChildren() {
            if (myRenderer != null) {
                return myRenderer.getChildren();
            }
            String name = getTypeName(descriptor);
            EnumerationChildrenRenderer enumerationChildrenRenderer = new EnumerationChildrenRenderer();
            enumerationChildrenRenderer.setAppendDefaultChildren(true);
            Renderer lastRenderer = descriptor.getLastRenderer();
            if (lastRenderer instanceof CompoundNodeRenderer && NodeRendererSettings.getInstance().getCustomRenderers().contains((NodeRenderer) lastRenderer) && !(((CompoundNodeRenderer) lastRenderer).getChildrenRenderer() instanceof ExpressionChildrenRenderer)) {
                ((CompoundNodeRenderer) lastRenderer).setChildrenRenderer(enumerationChildrenRenderer);
            } else {
                NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, enumerationChildrenRenderer);
                renderer.setEnabled(true);
                NodeRendererSettings.getInstance().getCustomRenderers().addRenderer(renderer);
                NodeRendererSettings.getInstance().fireRenderersChanged();
            }
            return enumerationChildrenRenderer.getChildren();
        }
    }.show());
}
Also used : ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) JavaValue(com.intellij.debugger.engine.JavaValue) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) Pair(com.intellij.openapi.util.Pair)

Example 4 with XDebuggerTreeNode

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

the class CustomFieldInplaceEditor method doOKAction.

@Override
public void doOKAction() {
    List<Pair<String, TextWithImports>> children = getRendererChildren();
    TextWithImports newText = TextWithImportsImpl.fromXExpression(myExpressionEditor.getExpression());
    if (myDescriptor == null) {
        children.add(0, Pair.create("", newText));
    } else {
        int index = myDescriptor.getEnumerationIndex();
        children.set(index, Pair.create(children.get(index).first, newText));
    }
    myTree.putClientProperty(XDebuggerTreeRestorer.SELECTION_PATH_PROPERTY, createDummySelectionTreePath(newText.getText(), (XDebuggerTreeNode) myNode.getParent()));
    XDebuggerUtilImpl.rebuildTreeAndViews(myTree);
    super.doOKAction();
}
Also used : TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) Pair(com.intellij.openapi.util.Pair)

Example 5 with XDebuggerTreeNode

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

the class IdeFrameFixture method debuggerTreeRootToChildrenTexts.

@NotNull
private static String[] debuggerTreeRootToChildrenTexts(XDebuggerTreeNode treeRoot) {
    List<? extends TreeNode> children = treeRoot.getChildren();
    String[] childrenTexts = new String[children.size()];
    int i = 0;
    for (TreeNode child : children) {
        childrenTexts[i] = ((XDebuggerTreeNode) child).getText().toString();
        ++i;
    }
    return childrenTexts;
}
Also used : TreeNode(javax.swing.tree.TreeNode) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XDebuggerTreeNode (com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode)15 TreePath (javax.swing.tree.TreePath)4 TreeNode (javax.swing.tree.TreeNode)3 Pair (com.intellij.openapi.util.Pair)2 WatchesRootNode (com.intellij.xdebugger.impl.ui.tree.nodes.WatchesRootNode)2 NotNull (org.jetbrains.annotations.NotNull)2 DebugToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.DebugToolWindowFixture)1 ExecutionToolWindowFixture (com.android.tools.idea.tests.gui.framework.fixture.ExecutionToolWindowFixture)1 JavaValue (com.intellij.debugger.engine.JavaValue)1 TextWithImports (com.intellij.debugger.engine.evaluation.TextWithImports)1 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)1 ValueDescriptorImpl (com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 WatchNode (com.intellij.xdebugger.impl.ui.tree.nodes.WatchNode)1 WatchNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.WatchNodeImpl)1 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 BasicTreeUI (javax.swing.plaf.basic.BasicTreeUI)1 Assert.assertNotNull (junit.framework.Assert.assertNotNull)1