@Override
  protected JComponent createCenterPanel() {
    final FileChooserDescriptor descriptor =
        FileChooserDescriptorFactory.createAllButJarContentsDescriptor();
    calculateRoots();
    final ArrayList<VirtualFile> list = new ArrayList<VirtualFile>(myRoots);
    final Comparator<VirtualFile> comparator =
        new Comparator<VirtualFile>() {
          @Override
          public int compare(VirtualFile o1, VirtualFile o2) {
            final boolean isDir1 = o1.isDirectory();
            final boolean isDir2 = o2.isDirectory();
            if (isDir1 != isDir2) return isDir1 ? -1 : 1;

            final String module1 = myModulesSet.get(o1);
            final String path1 = module1 != null ? module1 : o1.getPath();
            final String module2 = myModulesSet.get(o2);
            final String path2 = module2 != null ? module2 : o2.getPath();
            return path1.compareToIgnoreCase(path2);
          }
        };
    descriptor.setRoots(list);
    myTree = new Tree();
    myTree.setMinimumSize(new Dimension(200, 200));
    myTree.setBorder(BORDER);
    myTree.setShowsRootHandles(true);
    myTree.setRootVisible(true);
    myTree.getExpandableItemsHandler().setEnabled(false);
    final MyCheckboxTreeCellRenderer cellRenderer =
        new MyCheckboxTreeCellRenderer(
            mySelectionManager, myModulesSet, myProject, myTree, myRoots);
    final FileSystemTreeImpl fileSystemTree =
        new FileSystemTreeImpl(
            myProject,
            descriptor,
            myTree,
            cellRenderer,
            null,
            new Convertor<TreePath, String>() {
              @Override
              public String convert(TreePath o) {
                final DefaultMutableTreeNode lastPathComponent =
                    ((DefaultMutableTreeNode) o.getLastPathComponent());
                final Object uo = lastPathComponent.getUserObject();
                if (uo instanceof FileNodeDescriptor) {
                  final VirtualFile file = ((FileNodeDescriptor) uo).getElement().getFile();
                  final String module = myModulesSet.get(file);
                  if (module != null) return module;
                  return file == null ? "" : file.getName();
                }
                return o.toString();
              }
            });
    final AbstractTreeUi ui = fileSystemTree.getTreeBuilder().getUi();
    ui.setNodeDescriptorComparator(
        new Comparator<NodeDescriptor>() {
          @Override
          public int compare(NodeDescriptor o1, NodeDescriptor o2) {
            if (o1 instanceof FileNodeDescriptor && o2 instanceof FileNodeDescriptor) {
              final VirtualFile f1 = ((FileNodeDescriptor) o1).getElement().getFile();
              final VirtualFile f2 = ((FileNodeDescriptor) o2).getElement().getFile();
              return comparator.compare(f1, f2);
            }
            return o1.getIndex() - o2.getIndex();
          }
        });
    myRoot = (DefaultMutableTreeNode) myTree.getModel().getRoot();

    new ClickListener() {
      @Override
      public boolean onClick(@NotNull MouseEvent e, int clickCount) {
        int row = myTree.getRowForLocation(e.getX(), e.getY());
        if (row < 0) return false;
        final Object o = myTree.getPathForRow(row).getLastPathComponent();
        if (myRoot == o || getFile(o) == null) return false;

        Rectangle rowBounds = myTree.getRowBounds(row);
        cellRenderer.setBounds(rowBounds);
        Rectangle checkBounds = cellRenderer.myCheckbox.getBounds();
        checkBounds.setLocation(rowBounds.getLocation());

        if (checkBounds.height == 0) checkBounds.height = rowBounds.height;

        if (checkBounds.contains(e.getPoint())) {
          mySelectionManager.toggleSelection((DefaultMutableTreeNode) o);
          myTree.revalidate();
          myTree.repaint();
        }
        return true;
      }
    }.installOn(myTree);

    myTree.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SPACE) {
              TreePath[] paths = myTree.getSelectionPaths();
              if (paths == null) return;
              for (TreePath path : paths) {
                if (path == null) continue;
                final Object o = path.getLastPathComponent();
                if (myRoot == o || getFile(o) == null) return;
                mySelectionManager.toggleSelection((DefaultMutableTreeNode) o);
              }

              myTree.revalidate();
              myTree.repaint();
              e.consume();
            }
          }
        });

    JBPanel panel = new JBPanel(new BorderLayout());
    panel.add(new JBScrollPane(fileSystemTree.getTree()), BorderLayout.CENTER);
    mySelectedLabel = new JLabel("");
    mySelectedLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
    panel.add(mySelectedLabel, BorderLayout.SOUTH);

    mySelectionManager.setSelectionChangeListener(
        new PlusMinus<VirtualFile>() {
          @Override
          public void plus(VirtualFile virtualFile) {
            mySelectedFiles.add(virtualFile);
            recalculateErrorText();
          }

          private void recalculateErrorText() {
            checkEmpty();
            if (mySelectionManager.canAddSelection()) {
              mySelectedLabel.setText("");
            } else {
              mySelectedLabel.setText(CAN_NOT_ADD_TEXT);
            }
            mySelectedLabel.revalidate();
          }

          @Override
          public void minus(VirtualFile virtualFile) {
            mySelectedFiles.remove(virtualFile);
            recalculateErrorText();
          }
        });
    return panel;
  }
 public void setBorder(Border border) {
   super.setBorder(border);
   myBorder = border;
 }
  protected JComponent createCenterPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    myModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    createTreeModel();
    myTree = new Tree(myModel);

    UIUtil.setLineStyleAngled(myTree);
    myTree.setCellRenderer(
        new DefaultTreeCellRenderer() {
          public Component getTreeCellRendererComponent(
              JTree tree,
              Object value,
              boolean sel,
              boolean expanded,
              boolean leaf,
              int row,
              boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
            setIcon(expanded ? Icons.PACKAGE_OPEN_ICON : Icons.PACKAGE_ICON);

            if (value instanceof DefaultMutableTreeNode) {
              DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
              Object object = node.getUserObject();
              if (object instanceof PsiPackage) {
                String name = ((PsiPackage) object).getName();
                if (name != null && name.length() > 0) {
                  setText(name);
                } else {
                  setText(IdeBundle.message("node.default"));
                }
              }
            }
            return this;
          }
        });

    myTree.setBorder(BorderFactory.createEtchedBorder());
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
    scrollPane.setPreferredSize(new Dimension(500, 300));

    new TreeSpeedSearch(
        myTree,
        new Convertor<TreePath, String>() {
          public String convert(TreePath path) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            Object object = node.getUserObject();
            if (object instanceof PsiPackage) return ((PsiPackage) object).getName();
            else return "";
          }
        });

    myTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                PsiPackage selection = getTreeSelection();
                if (selection != null) {
                  String name = selection.getQualifiedName();
                  setTitle(
                      myTitle
                          + " - "
                          + ("".equals(name) ? IdeBundle.message("node.default.package") : name));
                } else {
                  setTitle(myTitle);
                }
              }
            });

    panel.add(scrollPane, BorderLayout.CENTER);
    DefaultActionGroup group = createActionGroup(myTree);

    ActionToolbar toolBar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    panel.add(toolBar.getComponent(), BorderLayout.NORTH);
    toolBar.getComponent().setAlignmentX(JComponent.LEFT_ALIGNMENT);

    return panel;
  }