Search in sources :

Example 1 with ColumnTreeBuilder

use of com.android.tools.adtui.common.ColumnTreeBuilder 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 2 with ColumnTreeBuilder

use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.

the class ClassHistogramView method createComponentsList.

@Override
public void createComponentsList(@NotNull List<Animatable> animatables) {
    myTreeModel = new DefaultTreeModel(myRoot);
    myTree = new Tree(myTreeModel);
    myTree.setRootVisible(false);
    myTree.setShowsRootHandles(true);
    ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Class").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(0, myRoot))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Count").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(1, myRoot)).setInitialOrder(SortOrder.DESCENDING).setComparator((MemoryInfoTreeNode a, MemoryInfoTreeNode b) -> a.getCount() - b.getCount()));
    builder.setTreeSorter((Comparator<MemoryInfoTreeNode> comparator, SortOrder sortOrder) -> {
        myRoot.sort(comparator);
        myTreeModel.nodeStructureChanged(myRoot);
    });
    myColumnTree = builder.build();
}
Also used : ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) MemoryInfoTreeNode(com.android.tools.idea.monitor.ui.memory.model.MemoryInfoTreeNode) Tree(com.intellij.ui.treeStructure.Tree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 3 with ColumnTreeBuilder

use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.

the class ApkViewPanel method createUIComponents.

private void createUIComponents() {
    myNameAsyncIcon = new AsyncProcessIcon("aapt xmltree manifest");
    mySizeAsyncIcon = new AsyncProcessIcon("estimating apk size");
    myTreeModel = new DefaultTreeModel(new LoadingNode());
    myTree = new Tree(myTreeModel);
    myTree.setShowsRootHandles(true);
    // show root node only when showing LoadingNode
    myTree.setRootVisible(true);
    myTree.setPaintBusy(true);
    TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, path -> {
        ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
        if (e == null) {
            return null;
        }
        return e.getPath();
    }, true);
    // Provides the percentage of the node size to the total size of the APK
    PercentRenderer.PercentProvider percentProvider = (jTree, value, row) -> {
        ApkEntry entry = ApkEntry.fromNode(value);
        ApkEntry rootEntry = ApkEntry.fromNode(jTree.getModel().getRoot());
        if (entry == null || rootEntry == null) {
            return 0;
        } else if (!entry.isCompressedSizeKnown() || !rootEntry.isCompressedSizeKnown()) {
            return 0;
        } else {
            return (double) entry.getCompressedSize() / rootEntry.getCompressedSize();
        }
    };
    ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Raw File Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(false))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Download Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(true))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("% of Total Download size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new PercentRenderer(percentProvider)));
    myColumnTreePane = (JScrollPane) builder.build();
    myTree.addTreeSelectionListener(this);
}
Also used : AllIcons(com.intellij.icons.AllIcons) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SdkConstants(com.android.SdkConstants) VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnimatedIcon(com.intellij.util.ui.AnimatedIcon) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) EdtExecutor(com.android.tools.idea.ddms.EdtExecutor) TreeSelectionListener(javax.swing.event.TreeSelectionListener) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) Disposer(com.intellij.openapi.util.Disposer) Tree(com.intellij.ui.treeStructure.Tree) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) AndroidBundle(org.jetbrains.android.util.AndroidBundle) DecimalFormat(java.text.DecimalFormat) com.intellij.ui(com.intellij.ui) FutureCallback(com.google.common.util.concurrent.FutureCallback) SearchUtil(com.intellij.ide.ui.search.SearchUtil) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Nullable(org.jetbrains.annotations.Nullable) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) AndroidIcons(icons.AndroidIcons) Function(com.intellij.util.Function) NotNull(org.jetbrains.annotations.NotNull) javax.swing(javax.swing) AsyncProcessIcon(com.intellij.util.ui.AsyncProcessIcon) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) Tree(com.intellij.ui.treeStructure.Tree)

Example 4 with ColumnTreeBuilder

use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.

the class MemoryDetailSegment method createComponentsList.

@Override
public void createComponentsList(@NotNull List<Animatable> animatables) {
    mTreeModel = new DefaultTreeModel(mRoot);
    mTree = new Tree(mTreeModel);
    mTree.setRootVisible(false);
    mTree.setShowsRootHandles(true);
    ColumnTreeBuilder builder = new ColumnTreeBuilder(mTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Class").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(0, mRoot))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Count").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(1, mRoot)).setInitialOrder(SortOrder.DESCENDING).setComparator((MemoryInfoTreeNode a, MemoryInfoTreeNode b) -> a.getCount() - b.getCount()));
    builder.setTreeSorter((Comparator<MemoryInfoTreeNode> comparator, SortOrder sortOrder) -> {
        mRoot.sort(comparator);
        mTreeModel.nodeStructureChanged(mRoot);
    });
    mColumnTree = builder.build();
}
Also used : ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) MemoryInfoTreeNode(com.android.tools.idea.monitor.ui.memory.model.MemoryInfoTreeNode) Tree(com.intellij.ui.treeStructure.Tree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Comparator(java.util.Comparator)

Example 5 with ColumnTreeBuilder

use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.

the class ApkDiffPanel method createUIComponents.

private void createUIComponents() {
    myTreeModel = new DefaultTreeModel(new LoadingNode());
    myTree = new Tree(myTreeModel);
    myTree.setShowsRootHandles(true);
    // show root node only when showing LoadingNode
    myTree.setRootVisible(true);
    myTree.setPaintBusy(true);
    Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() {

        @Override
        public String convert(TreePath path) {
            ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
            if (e == null) {
                return null;
            }
            return e.getPath();
        }
    };
    TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, convertor, true);
    ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Old Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getOldSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("New Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getNewSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Diff Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkEntry::getSize)));
    myColumnTreePane = (JScrollPane) builder.build();
}
Also used : SizeRenderer(com.android.tools.idea.apk.viewer.ApkViewPanel.SizeRenderer) NameRenderer(com.android.tools.idea.apk.viewer.ApkViewPanel.NameRenderer) TreeSpeedSearch(com.intellij.ui.TreeSpeedSearch) LoadingNode(com.intellij.ui.LoadingNode) ApkEntry(com.android.tools.idea.apk.viewer.ApkEntry) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Convertor(com.intellij.util.containers.Convertor) TreePath(javax.swing.tree.TreePath) ColumnTreeBuilder(com.android.tools.adtui.common.ColumnTreeBuilder) Tree(com.intellij.ui.treeStructure.Tree)

Aggregations

ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)8 Tree (com.intellij.ui.treeStructure.Tree)6 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)6 Comparator (java.util.Comparator)3 TreePath (javax.swing.tree.TreePath)3 NotNull (org.jetbrains.annotations.NotNull)3 AppStatTreeNode (com.android.tools.idea.monitor.ui.cpu.view.AppStatTreeNode)2 MemoryInfoTreeNode (com.android.tools.idea.monitor.ui.memory.model.MemoryInfoTreeNode)2 ColoredTreeCellRenderer (com.intellij.ui.ColoredTreeCellRenderer)2 SdkConstants (com.android.SdkConstants)1 ApkEntry (com.android.tools.idea.apk.viewer.ApkEntry)1 NameRenderer (com.android.tools.idea.apk.viewer.ApkViewPanel.NameRenderer)1 SizeRenderer (com.android.tools.idea.apk.viewer.ApkViewPanel.SizeRenderer)1 EdtExecutor (com.android.tools.idea.ddms.EdtExecutor)1 ClassObject (com.android.tools.profilers.memory.adapters.ClassObject)1 InstanceAttribute (com.android.tools.profilers.memory.adapters.ClassObject.InstanceAttribute)1 FieldObject (com.android.tools.profilers.memory.adapters.FieldObject)1 ClassAttribute (com.android.tools.profilers.memory.adapters.HeapObject.ClassAttribute)1 InstanceObject (com.android.tools.profilers.memory.adapters.InstanceObject)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1