public void actionPerformed(ActionEvent e) {
final String initialPath = FileUtil.toSystemIndependentName(textWithBrowse.getText().trim());
final VirtualFile initialFile = initialPath.isEmpty() ? null : LocalFileSystem.getInstance().findFileByPath(initialPath);
final PsiFile initialPsiFile = initialFile == null ? null : PsiManager.getInstance(project).findFile(initialFile);
TreeFileChooser fileChooser = TreeFileChooserFactory.getInstance(project).createFileChooser(
DartBundle.message("choose.dart.main.file"),
initialPsiFile,
DartFileType.INSTANCE,
new TreeFileChooser.PsiFileFilter() {
public boolean accept(PsiFile file) {
return !DartWritingAccessProvider.isInDartSdkOrDartPackagesFolder(file);
}
}
);
fileChooser.showDialog();
final PsiFile selectedFile = fileChooser.getSelectedFile();
final VirtualFile virtualFile = selectedFile == null ? null : selectedFile.getVirtualFile();
if (virtualFile != null) {
final String path = FileUtil.toSystemDependentName(virtualFile.getPath());
textWithBrowse.setText(path);
}