use of com.intellij.ide.util.TreeClassChooserFactory in project intellij-community by JetBrains.
the class ManifestFileUtil method selectMainClass.
@Nullable
public static PsiClass selectMainClass(Project project, @Nullable final 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();
}
use of com.intellij.ide.util.TreeClassChooserFactory in project intellij-community by JetBrains.
the class UiUtils method createAddRemoveTreeClassChooserPanel.
public static JPanel createAddRemoveTreeClassChooserPanel(final ListTable table, final String chooserTitle, @NonNls String... ancestorClasses) {
final ClassFilter filter;
if (ancestorClasses.length == 0) {
filter = ClassFilter.ALL;
} else {
filter = new SubclassFilter(ancestorClasses);
}
final JPanel panel = ToolbarDecorator.createDecorator(table).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final DataContext dataContext = DataManager.getInstance().getDataContext(table);
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final int rowIndex;
final ListWrappingTableModel tableModel = table.getModel();
if (project == null) {
tableModel.addRow();
rowIndex = tableModel.getRowCount() - 1;
} else {
final TreeClassChooserFactory chooserFactory = TreeClassChooserFactory.getInstance(project);
final TreeClassChooser classChooser = chooserFactory.createWithInnerClassesScopeChooser(chooserTitle, GlobalSearchScope.allScope(project), filter, null);
classChooser.showDialog();
final PsiClass selectedClass = classChooser.getSelected();
if (selectedClass == null) {
return;
}
final String qualifiedName = selectedClass.getQualifiedName();
final int index = tableModel.indexOf(qualifiedName, 0);
if (index < 0) {
tableModel.addRow(qualifiedName);
rowIndex = tableModel.getRowCount() - 1;
} else {
rowIndex = index;
}
}
editTableCell(table, rowIndex, table.getColumnCount() > 1 && project != null ? 1 : 0);
}
}).setRemoveAction(button -> TableUtil.removeSelectedItems(table)).disableUpDownActions().createPanel();
panel.setPreferredSize(JBUI.size(150, 100));
return panel;
}
Aggregations