use of com.intellij.openapi.ui.TextBrowseFolderListener in project intellij-community by JetBrains.
the class StartBrowserPanel method setupUrlField.
public static void setupUrlField(@NotNull TextFieldWithBrowseButton field, @NotNull final Project project) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
return HtmlUtil.isHtmlFile(file) || virtualFileToUrl(file, project) != null;
}
};
descriptor.setTitle(XmlBundle.message("javascript.debugger.settings.choose.file.title"));
descriptor.setDescription(XmlBundle.message("javascript.debugger.settings.choose.file.subtitle"));
descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
field.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
if (chosenFile.isDirectory()) {
return chosenFile.getPath();
}
Url url = virtualFileToUrl(chosenFile, project);
return url == null ? chosenFile.getUrl() : url.toDecodedForm();
}
});
}
use of com.intellij.openapi.ui.TextBrowseFolderListener in project ballerina by ballerina-lang.
the class BallerinaRunUtil method installWorkingDirectoryChooser.
private static void installWorkingDirectoryChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field) {
FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
chooseDirectoryDescriptor.setShowFileSystemRoots(true);
chooseDirectoryDescriptor.withShowHiddenFiles(false);
if (field instanceof TextFieldWithBrowseButton) {
((TextFieldWithBrowseButton) field).addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project));
} else {
// noinspection unchecked
field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
}
}
Aggregations