in flutter-idea/src/io/flutter/view/DiagnosticsTreeCellRenderer.java [63:225]
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
) {
this.tree = tree;
this.selected = selected;
setOpaque(false);
setIconOpaque(false);
setTransparentIconBackground(true);
final Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
if (userObject instanceof String) {
appendText((String)userObject, SimpleTextAttributes.GRAYED_ATTRIBUTES);
return;
}
if (!(userObject instanceof DiagnosticsNode)) return;
final DiagnosticsNode node = (DiagnosticsNode)userObject;
boolean highlight = selected;
boolean isLinkedChild = false;
// Highlight nodes that exist in both the details and summary tree to
// show how the trees are linked together.
if (!highlight && panel.isHighlightNodesShownInBothTrees()) {
if (panel.detailsSubtree && panel.isCreatedByLocalProject(node)) {
isLinkedChild = panel.parentTree.hasDiagnosticsValue(node.getValueRef());
}
else {
if (panel.subtreePanel != null) {
isLinkedChild = panel.subtreePanel.hasDiagnosticsValue(node.getValueRef());
}
}
}
if (highlight) {
setOpaque(true);
setIconOpaque(false);
setTransparentIconBackground(true);
setBackground(HIGHLIGHT_COLOR);
// TODO(jacobr): consider using UIUtil.getTreeSelectionBackground() instead.
}
else if (isLinkedChild || panel.currentShowNode == value) {
setOpaque(true);
setIconOpaque(false);
setTransparentIconBackground(true);
setBackground(panel.currentShowNode == value ? SHOW_MATCH_COLOR : LINKED_COLOR);
}
final String name = node.getName();
SimpleTextAttributes textAttributes = InspectorPanel.textAttributesForLevel(node.getLevel());
if (node.isProperty()) {
// Display of inline properties.
final String propertyType = node.getPropertyType();
final JsonObject properties = node.getValuePropertiesJson();
if (panel.isCreatedByLocalProject(node)) {
textAttributes = textAttributes
.derive(SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES.getStyle(), null, null, null);
}
if (StringUtils.isNotEmpty(name) && node.getShowName()) {
appendText(name + node.getSeparator() + " ", textAttributes);
}
String description = node.getDescription();
if (propertyType != null && properties != null) {
switch (propertyType) {
case "Color": {
final int alpha = getIntMember(properties, "alpha");
final int red = getIntMember(properties, "red");
final int green = getIntMember(properties, "green");
final int blue = getIntMember(properties, "blue");
if (alpha == 255) {
description = String.format("#%02x%02x%02x", red, green, blue);
}
else {
description = String.format("#%02x%02x%02x%02x", alpha, red, green, blue);
}
//noinspection UseJBColor
final Color color = new Color(red, green, blue, alpha);
this.addIcon(colorIconMaker.getCustomIcon(color));
this.setIconOpaque(false);
this.setTransparentIconBackground(true);
break;
}
case "IconData": {
final int codePoint = getIntMember(properties, "codePoint");
if (codePoint > 0) {
final Icon icon = FlutterMaterialIcons.getIconForHex(String.format("%1$04x", codePoint));
if (icon != null) {
this.addIcon(icon);
this.setIconOpaque(false);
this.setTransparentIconBackground(true);
}
}
break;
}
}
}
if (SHOW_RENDER_OBJECT_PROPERTIES_AS_LINKS && propertyType.equals("RenderObject")) {
textAttributes = textAttributes
.derive(SimpleTextAttributes.LINK_ATTRIBUTES.getStyle(), JBColor.blue, null, null);
}
// TODO(jacobr): custom display for units, iterables, and padding.
appendText(description, textAttributes);
if (node.getLevel().equals(DiagnosticLevel.fine) && node.hasDefaultValue()) {
appendText(" ", textAttributes);
this.addIcon(panel.defaultIcon);
}
}
else {
// Non property, regular node case.
if (StringUtils.isNotEmpty(name) && node.getShowName() && !name.equals("child")) {
if (name.startsWith("child ")) {
appendText(name, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
else {
appendText(name, textAttributes);
}
if (node.getShowSeparator()) {
appendText(node.getSeparator(), SimpleTextAttributes.GRAY_ATTRIBUTES);
}
else {
appendText(" ", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
if (panel.detailsSubtree && panel.isCreatedByLocalProject(node) && !panel.isHighlightNodesShownInBothTrees()) {
textAttributes = textAttributes.derive(
SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES.getStyle(), null, null, null);
}
final String description = node.getDescription();
final Matcher match = primaryDescriptionPattern.matcher(description);
if (match.matches()) {
appendText(" ", SimpleTextAttributes.GRAY_ATTRIBUTES);
appendText(match.group(1), textAttributes);
appendText(" ", textAttributes);
appendText(match.group(2), SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
else if (!node.getDescription().isEmpty()) {
appendText(" ", SimpleTextAttributes.GRAY_ATTRIBUTES);
appendText(node.getDescription(), textAttributes);
}
// TODO(devoncarew): For widgets that are definied in the current project, we could consider
// appending the relative path to the defining library ('lib/src/foo_page.dart').
final Icon icon = node.getIcon();
if (icon != null) {
setIcon(icon);
}
}
}