コード例 #1
0
  public void updateClassTree() {
    val splitPane = this;

    val classTreeRoot = new DefaultMutableTreeNode(openedFile_Filename);
    addClassesToTree(classTreeRoot, openedFile.getDexFile().getClasses());
    val classTree = new WebTree(classTreeRoot);
    classTree.setShowsRootHandles(true);
    classTree.setVisibleRowCount(4);
    classTree.setCellRenderer(new ClassTreeRenderer());
    javax.swing.ToolTipManager.sharedInstance().registerComponent(classTree);

    // set selection listener
    classTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    TreeListener =
        new TreeSelectionListener() {
          @Override
          public void valueChanged(TreeSelectionEvent e) {
            val node = (DefaultMutableTreeNode) classTree.getLastSelectedPathComponent();
            if (node != null) {
              val obj = node.getUserObject();

              if (obj instanceof DexClass) {
                splitPane.setRightComponent(selectedClassPanel);
                selectedClassPanel.changeClass((DexClass) obj);
              } else if (obj instanceof DexMethod) {
                splitPane.setRightComponent(selectedMethodPanel);
                selectedMethodPanel.changeMethod((DexMethod) obj);
              }
            }
          }
        };
    classTree.addTreeSelectionListener(TreeListener);

    val classTreeScroll = new WebScrollPane(classTree);
    classTreeScroll.setMinimumSize(new Dimension(300, 200));
    splitPane.setLeftComponent(classTreeScroll);
  }