public static JPanel createTreeClassChooserList(final Collection<String> collection,
                                                  @NlsContexts.Label String borderTitle,
                                                  final @NlsContexts.DialogTitle String chooserTitle,
                                                  String... ancestorClasses) {
    final ClassFilter filter;
    if (ancestorClasses.length == 0) {
      filter = ClassFilter.ALL;
    }
    else {
      filter = new SubclassFilter(ancestorClasses);
    }
    final JBList<String> list = new JBList<>(collection);
    list.setBorder(JBUI.Borders.empty());

    final JPanel panel = ToolbarDecorator.createDecorator(list)
      .setToolbarPosition(ActionToolbarPosition.LEFT)
      .disableUpDownActions()
      .setAddAction(new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton anActionButton) {
          final DataContext dataContext = DataManager.getInstance().getDataContext(list);
          final Project project = CommonDataKeys.PROJECT.getData(dataContext);
          if (project == null) {
            return;
          }
          final TreeClassChooser chooser = TreeClassChooserFactory.getInstance(project)
            .createNoInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null);
          chooser.showDialog();
          final PsiClass selected = chooser.getSelected();
          if (selected == null) {
            return;
          }
          final String qualifiedName = selected.getQualifiedName();
          final DefaultListModel<String> model = (DefaultListModel<String>)list.getModel();
          final int index = model.indexOf(qualifiedName);
          if (index < 0) {
            model.addElement(qualifiedName);
            collection.add(qualifiedName);
          }
          else {
            list.setSelectedIndex(index);
          }
        }
      })
      .setRemoveAction(new AnActionButtonRunnable() {
        @Override
        public void run(AnActionButton anActionButton) {
          collection.remove(list.getSelectedValue());
          ListUtil.removeSelectedItems(list);
        }
      }).createPanel();
    panel.setMinimumSize(InspectionOptionsPanel.getMinimumListSize());
    panel.setPreferredSize(InspectionOptionsPanel.getMinimumListSize());
    return UI.PanelFactory.panel(panel).withLabel(borderTitle).moveLabelOnTop().resizeY(true).createPanel();
  }
public static JPanel createTreeClassChooserList(final Collection<String> collection,
                                                  @NlsContexts.Label String borderTitle,
                                                  final @NlsContexts.DialogTitle String chooserTitle,
                                                  String... ancestorClasses)