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);
}
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);
}
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());
}
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();
}
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;
}
Aggregations