Search in sources :

Example 1 with ColoredTreeCellRenderer

use of com.intellij.ui.ColoredTreeCellRenderer in project android by JetBrains.

the class NlComponentTree method createCellRenderer.

private void createCellRenderer() {
    ColoredTreeCellRenderer renderer = new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (value instanceof NlComponent) {
                StructureTreeDecorator.decorate(this, (NlComponent) value);
            }
        }
    };
    renderer.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setCellRenderer(renderer);
}
Also used : ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ColoredTreeCellRenderer

use of com.intellij.ui.ColoredTreeCellRenderer in project android by JetBrains.

the class AppTrace method generateBottomUpTree.

private JComponent generateBottomUpTree(HNode<MethodUsage> graph) {
    AppStatTreeNode top = new AppStatTreeNode();
    convertGraphToTree(graph, top);
    JTree tree = new JTree(top);
    JComponent bottomUpColumnTree = new ColumnTreeBuilder(tree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Method").setRenderer(new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            AppStatTreeNode node = (AppStatTreeNode) value;
            append(generateNameForColumn(node.getMethodNamespace(), node.getMethodName(), getSeparator()));
        }
    })).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Exclusive stats").setRenderer(new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            AppStatTreeNode node = (AppStatTreeNode) value;
            append(String.format("%2.1f%%", node.getPercentageExclusive() * 100));
        }
    })).build();
    return bottomUpColumnTree;
}
Also used : AppStatTreeNode(com.android.tools.idea.monitor.ui.cpu.view.AppStatTreeNode) ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ColoredTreeCellRenderer

use of com.intellij.ui.ColoredTreeCellRenderer in project android by JetBrains.

the class VariantCheckboxTreeCellRenderer method appendModule.

protected void appendModule(@NotNull Module module, @Nullable String variant) {
    ColoredTreeCellRenderer textRenderer = getTextRenderer();
    textRenderer.append(module.getName());
    textRenderer.setIcon(GradleUtil.getModuleIcon(module));
    if (isNotEmpty(variant)) {
        textRenderer.append(" ", REGULAR_ATTRIBUTES);
        textRenderer.append("(" + variant + ")", GRAY_ATTRIBUTES);
    }
}
Also used : ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer)

Example 4 with ColoredTreeCellRenderer

use of com.intellij.ui.ColoredTreeCellRenderer in project android by JetBrains.

the class LicenseAgreementStep method createCellRenderer.

private ColoredTreeCellRenderer createCellRenderer() {
    return new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (row == 0) {
                append("Licenses", SimpleTextAttributes.REGULAR_ATTRIBUTES);
                return;
            }
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            if (!leaf) {
                License license = (License) node.getUserObject();
                appendLicenseText(license, license.getId());
            } else {
                Change change = (Change) node.getUserObject();
                if (change == null) {
                    return;
                }
                appendLicenseText(change.license, change.toString());
                setIcon(AllIcons.Actions.Download);
            }
        }

        private void appendLicenseText(@Nullable License license, String text) {
            boolean notAccepted = license != null && !myAcceptances.get(license.getId());
            if (notAccepted) {
                append("*", SimpleTextAttributes.ERROR_ATTRIBUTES);
                append(text, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
            } else {
                append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
            }
        }
    };
}
Also used : ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) License(com.android.repository.api.License) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with ColoredTreeCellRenderer

use of com.intellij.ui.ColoredTreeCellRenderer in project android by JetBrains.

the class AppTrace method generateTopdownTree.

// Convert a HNode tree into an AppStat tree (better suited for rendition in a ColumnTree).
private JComponent generateTopdownTree(HNode<MethodUsage> graph) {
    AppStatTreeNode top = new AppStatTreeNode();
    // Intentionally discard first child
    graph = graph.getFirstChild();
    convertGraphToTree(graph, top);
    JTree tree = new JTree(top);
    JComponent topdownColumnTree = new ColumnTreeBuilder(tree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Method").setRenderer(new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            AppStatTreeNode node = (AppStatTreeNode) value;
            append(generateNameForColumn(node.getMethodNamespace(), node.getMethodName(), getSeparator()));
        }
    })).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Inclusive stats").setRenderer(new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            AppStatTreeNode node = (AppStatTreeNode) value;
            append(String.format("%2.1f%%", node.getPercentageInclusive() * 100));
        }
    })).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Exclusive stats").setRenderer(new ColoredTreeCellRenderer() {

        @Override
        public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            AppStatTreeNode node = (AppStatTreeNode) value;
            append(String.format("%2.1f%%", node.getPercentageExclusive() * 100));
        }
    })).build();
    return topdownColumnTree;
}
Also used : AppStatTreeNode(com.android.tools.idea.monitor.ui.cpu.view.AppStatTreeNode) ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ColoredTreeCellRenderer (com.intellij.ui.ColoredTreeCellRenderer)11 NotNull (org.jetbrains.annotations.NotNull)6 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)2 AppStatTreeNode (com.android.tools.idea.monitor.ui.cpu.view.AppStatTreeNode)2 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)2 TreeSelectionListener (javax.swing.event.TreeSelectionListener)2 Nullable (org.jetbrains.annotations.Nullable)2 License (com.android.repository.api.License)1 DnDTransferItem (com.android.tools.idea.uibuilder.model.DnDTransferItem)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 PsiManager (com.intellij.psi.PsiManager)1 JBImageIcon (com.intellij.util.ui.JBImageIcon)1 ConfigFileSearcher (com.intellij.xml.config.ConfigFileSearcher)1 ConfigFilesTreeBuilder (com.intellij.xml.config.ConfigFilesTreeBuilder)1 IndexedRelevantResource (com.intellij.xml.index.IndexedRelevantResource)1 XsdNamespaceBuilder (com.intellij.xml.index.XsdNamespaceBuilder)1