@Nullable
 public static PsiClass selectMainClass(Project project, final @Nullable String initialClassName) {
   final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project);
   final GlobalSearchScope searchScope = GlobalSearchScope.allScope(project);
   final PsiClass aClass =
       initialClassName != null
           ? JavaPsiFacade.getInstance(project).findClass(initialClassName, searchScope)
           : null;
   final TreeClassChooser chooser =
       chooserFactory.createWithInnerClassesScopeChooser(
           "Select Main Class", searchScope, new MainClassFilter(), aClass);
   chooser.showDialog();
   return chooser.getSelected();
 }
Ejemplo n.º 2
0
 @Override
 public void actionPerformed(AnActionEvent e) {
   final DataContext dataContext = e.getDataContext();
   final Project project = DataKeys.PROJECT.getData(dataContext);
   if (project == null) {
     return;
   }
   final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project);
   final TreeClassChooser classChooser =
       chooserFactory.createWithInnerClassesScopeChooser(
           chooserTitle, GlobalSearchScope.allScope(project), myFilter, null);
   classChooser.showDialog();
   final PsiClass selectedClass = classChooser.getSelected();
   if (selectedClass == null) {
     return;
   }
   final String qualifiedName = selectedClass.getQualifiedName();
   final ListWrappingTableModel tableModel = table.getModel();
   final int index = tableModel.indexOf(qualifiedName, 0);
   final int rowIndex;
   if (index < 0) {
     tableModel.addRow(qualifiedName);
     rowIndex = tableModel.getRowCount() - 1;
   } else {
     rowIndex = index;
   }
   final ListSelectionModel selectionModel = table.getSelectionModel();
   selectionModel.setSelectionInterval(rowIndex, rowIndex);
   EventQueue.invokeLater(
       new Runnable() {
         public void run() {
           final Rectangle rectangle = table.getCellRect(rowIndex, 0, true);
           table.scrollRectToVisible(rectangle);
         }
       });
 }