Search in sources :

Example 1 with FileTransferHandler

use of com.google.classyshark.gui.panel.FileTransferHandler in project android-classyshark by google.

the class MethodsCountPanel method setup.

private void setup() {
    this.setLayout(new BorderLayout());
    treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null));
    jTree = new JTree(treeModel);
    jTree.setRootVisible(false);
    jTree.setCellRenderer(new CellRenderer());
    theme.applyTo(jTree);
    DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
    cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20));
    jTree.setCellRenderer(cellRenderer);
    jTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            Object selection = jTree.getLastSelectedPathComponent();
            DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
            ClassNode node = (ClassNode) defaultMutableTreeNode.getUserObject();
            viewerController.onSelectedMethodCount(node);
        }
    });
    JScrollPane jScrollPane = new JScrollPane(jTree);
    this.setBorder(new EmptyBorder(0, 0, 0, 0));
    this.add(jScrollPane, BorderLayout.CENTER);
    theme.applyTo(jScrollPane);
    jTree.setDragEnabled(true);
    jTree.setTransferHandler(new FileTransferHandler(viewerController));
}
Also used : JScrollPane(javax.swing.JScrollPane) ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CellRenderer(com.google.classyshark.gui.panel.tree.CellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) FileTransferHandler(com.google.classyshark.gui.panel.FileTransferHandler) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Font(java.awt.Font) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

FileTransferHandler (com.google.classyshark.gui.panel.FileTransferHandler)1 CellRenderer (com.google.classyshark.gui.panel.tree.CellRenderer)1 ClassNode (com.google.classyshark.silverghost.methodscounter.ClassNode)1 BorderLayout (java.awt.BorderLayout)1 Font (java.awt.Font)1 JScrollPane (javax.swing.JScrollPane)1 JTree (javax.swing.JTree)1 EmptyBorder (javax.swing.border.EmptyBorder)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1