use of io.flutter.inspector.DiagnosticsNode in project flutter-intellij by flutter.
the class InspectorTreeMouseListener method mouseClicked.
@Override
public void mouseClicked(MouseEvent event) {
final DefaultMutableTreeNode node = getClosestTreeNode(event);
// TODO(jacobr): support clicking on a property.
// It would be reasonable for that to trigger selecting the parent of the
// property.
final DiagnosticsNode diagnostic = TreeUtils.maybeGetDiagnostic(node);
if (diagnostic != null && !diagnostic.isProperty()) {
// A double click triggers forcing changing the subtree root.
if (event.getClickCount() == 2) {
if (panel.isSummaryTree) {
panel.applyNewSelection(diagnostic, diagnostic, true, false);
} else if (panel.parentTree != null) {
panel.parentTree.applyNewSelection(panel.firstAncestorInParentTree(node), diagnostic, true, false);
}
}
}
event.consume();
}
use of io.flutter.inspector.DiagnosticsNode in project flutter-intellij by flutter.
the class InspectorTreeUI method paintExpandControl.
@Override
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
final boolean isPathSelected = tree.getSelectionModel().isPathSelected(path);
boolean isPropertyNode = false;
if (!isLeaf(row)) {
final Object lastPathComponent = path.getLastPathComponent();
if (lastPathComponent instanceof DefaultMutableTreeNode) {
final DiagnosticsNode diagnostic = maybeGetDiagnostic((DefaultMutableTreeNode) lastPathComponent);
if (diagnostic != null) {
isPropertyNode = diagnostic.isProperty();
}
}
if (isPropertyNode) {
setExpandedIcon(FlutterIcons.CollapseProperty);
setCollapsedIcon(FlutterIcons.ExpandProperty);
} else {
setExpandedIcon(UIUtil.getTreeNodeIcon(true, false, false));
setCollapsedIcon(UIUtil.getTreeNodeIcon(false, false, false));
}
}
super.paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
}
use of io.flutter.inspector.DiagnosticsNode in project flutter-intellij by flutter.
the class InspectorTreeUI method paintVerticalPartOfLeg.
@Override
protected void paintVerticalPartOfLeg(final Graphics g, final Rectangle clipBounds, final Insets insets, final TreePath path) {
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
if (node.getChildCount() < 2) {
// to more of an emphasis of lines for nodes with multiple children.
return;
}
final DiagnosticsNode diagnostic = maybeGetDiagnostic(node);
if (diagnostic != null && !diagnostic.hasChildren()) {
// This avoids drawing lines for nodes with only property children.
return;
}
final int depth = path.getPathCount() - 1;
if (depth == 0 && !getShowsRootHandles() && !isRootVisible()) {
return;
}
int lineX = getRowX(-1, depth);
if (leftToRight) {
lineX = lineX - getRightChildIndent() + insets.left;
} else {
lineX = tree.getWidth() - lineX - insets.right + getRightChildIndent() - 1;
}
final int clipLeft = clipBounds.x;
final int clipRight = clipBounds.x + (clipBounds.width - 1);
if (lineX >= clipLeft && lineX <= clipRight) {
final int clipTop = clipBounds.y;
final int clipBottom = clipBounds.y + clipBounds.height;
Rectangle parentBounds = getPathBounds(tree, path);
boolean previousDashed = false;
int top;
if (parentBounds == null) {
top = Math.max(insets.top + getVerticalLegBuffer(), clipTop);
} else {
top = Math.max(parentBounds.y + parentBounds.height + getVerticalLegBuffer(), clipTop);
}
if (depth == 0 && !isRootVisible()) {
final TreeModel model = getModel();
if (model != null) {
final Object root = model.getRoot();
if (model.getChildCount(root) > 0) {
parentBounds = getPathBounds(tree, path.pathByAddingChild(model.getChild(root, 0)));
if (parentBounds != null) {
top = Math.max(insets.top + getVerticalLegBuffer(), parentBounds.y + parentBounds.height / 2);
}
}
}
}
for (int i = 0; i < node.getChildCount(); ++i) {
final DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
final DiagnosticsNode childDiagnostic = maybeGetDiagnostic(child);
boolean dashed = false;
if (childDiagnostic != null) {
dashed = childDiagnostic.getStyle() == DiagnosticsTreeStyle.offstage;
}
final Rectangle childBounds = getPathBounds(tree, path.pathByAddingChild(child));
if (childBounds == null) // This shouldn't happen, but if the model is modified
// in another thread it is possible for this to happen.
// Swing isn't multithreaded, but I'll add this check in
// anyway.
{
continue;
}
final int bottom = Math.min(childBounds.y + (childBounds.height / 2), clipBottom);
if (top <= bottom && bottom >= clipTop && top <= clipBottom) {
g.setColor(JBColor.GRAY);
paintVerticalLine(g, tree, lineX, top, bottom, dashed);
}
top = bottom;
previousDashed = dashed;
}
}
}
use of io.flutter.inspector.DiagnosticsNode in project flutter-intellij by flutter.
the class WidgetPerfLinter method addNodesToMap.
private void addNodesToMap(DiagnosticsNode node) {
final int id = node.getLocationId();
if (id >= 0) {
nodesForLocation.put(id, node);
}
final ArrayList<DiagnosticsNode> children = node.getChildren().getNow(null);
if (children != null) {
for (DiagnosticsNode child : children) {
addNodesToMap(child);
}
}
}
use of io.flutter.inspector.DiagnosticsNode in project flutter-intellij by flutter.
the class PerfTipRule method countSubtreeMatches.
// TODO(jacobr): this method might be slow in degenerate cases if an extreme
// number of locations in a source file match a rule. We could memoize match
// counts to avoid a possible O(n^2) algorithm worst case.
private int countSubtreeMatches(DiagnosticsNode candidate, Map<Integer, SummaryStats> statsInFile) {
final int id = candidate.getLocationId();
int matches = 0;
if (id >= 0) {
final SummaryStats stats = statsInFile.get(id);
if (stats != null && maybeMatches(stats)) {
matches += 1;
}
}
final ArrayList<DiagnosticsNode> children = candidate.getChildren().getNow(null);
if (children != null) {
for (DiagnosticsNode child : children) {
matches += countSubtreeMatches(child, statsInFile);
}
}
return matches;
}
Aggregations