本文整理汇总了Java中com.intellij.openapi.fileChooser.FileChooserDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java FileChooserDescriptor类的具体用法?Java FileChooserDescriptor怎么用?Java FileChooserDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileChooserDescriptor类属于com.intellij.openapi.fileChooser包,在下文中一共展示了FileChooserDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unpackCourseArchive
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
private static void unpackCourseArchive(final Project project) {
FileChooserDescriptor descriptor =
new FileChooserDescriptor(true, true, true, true, true, false);
final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
if (virtualFile == null) {
return;
}
final String basePath = project.getBasePath();
if (basePath == null) return;
Course course = StudyProjectGenerator.getCourse(virtualFile.getPath());
if (course == null) {
Messages.showErrorDialog("This course is incompatible with current version", "Failed to Unpack Course");
return;
}
generateFromStudentCourse(project, course);
}
示例2: CreateCourseArchivePanel
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
setLayout(new BorderLayout());
add(myPanel, BorderLayout.CENTER);
myErrorIcon.setIcon(AllIcons.Actions.Lightning);
setState(false);
myDlg = dlg;
String sanitizedName = FileUtil.sanitizeFileName(name);
myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
myLocationField.setText(project.getBasePath());
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myLocationField.addBrowseFolderListener("Choose Location Folder", null, project, descriptor);
myLocationField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String location = myLocationField.getText();
File file = new File(location);
if (!file.exists() || !file.isDirectory()) {
myDlg.enableOKAction(false);
setError("Invalid location");
}
myDlg.enableOKAction(true);
}
});
}
示例3: createDirectory
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
public static PsiDirectory createDirectory(Project project, String title, String description) {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(title);
descriptor.setShowFileSystemRoots(false);
descriptor.setDescription(description);
descriptor.setHideIgnored(true);
descriptor.setRoots(project.getBaseDir());
descriptor.setForcedToUseIdeaFileChooser(true);
VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
if(Objects.isNull(file)){
Messages.showInfoMessage("Cancel " + title, "Error");
return null;
}
PsiDirectory psiDirectory = PsiDirectoryFactory.getInstance(project).createDirectory(file);
if(PsiDirectoryFactory.getInstance(project).isPackage(psiDirectory)){
return psiDirectory;
}else {
Messages.showInfoMessage("请选择正确的 package 路径。", "Error");
return createDirectory(project, title, description);
}
}
示例4: DeviceDriverForm
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
public DeviceDriverForm() {
author.setText(System.getProperty("user.name"));
license.addItem(new ComboItem(DriverLicenseType.GPL.name(), DriverLicenseType.GPL.name()));
license.addItem(new ComboItem(DriverLicenseType.BSD.name(), DriverLicenseType.BSD.name()));
license.addItem(new ComboItem(DriverLicenseType.DUAL.name(), DriverLicenseType.DUAL.name()));
kernelVersion.setText(KernelBundle.getString("kernel.version") + " " + System.getProperty("os.version"));
useHostKernelCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
kernelSourcePath.setEnabled(!useHostKernelCheckBox.isSelected());
}
});
TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
textFieldWithBrowseButton.addBrowseFolderListener(KernelBundle.getString("choose.kernel.sources"), null, null,
new FileChooserDescriptor(false, true, false, false, false, false));
kernelSourcePath.setComponent(textFieldWithBrowseButton);
kernelSourcePath.setEnabled(false);
kernelSourcePath.getComponent().setText("/usr/src/linux-headers-" + System.getProperty("os.version"));
}
示例5: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return;
}
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, true, false, false, false);
VirtualFile virtualFile = FileChooser.chooseFile(chooserDescriptor, project, null);
if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof DeltaHexFileEditor) {
((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
}
}
}
}
示例6: createComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
@Nullable
@Override
public JComponent createComponent() {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
imageFolder.addBrowseFolderListener(new TextBrowseFolderListener(descriptor) {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
String current = imageFolder.getText();
if (!current.isEmpty()) {
fc.setCurrentDirectory(new File(current));
}
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(rootPanel);
File file = fc.getSelectedFile();
String path = file == null
? ""
: file.getAbsolutePath();
imageFolder.setText(path);
}
});
autoChangeCheckBox.addActionListener(e -> intervalSpinner.setEnabled(autoChangeCheckBox.isSelected()));
return rootPanel;
}
示例7: createLibraryFromFiles
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
@Override
public NewLibraryConfiguration createLibraryFromFiles(@NotNull LibraryRootsComponentDescriptor descriptor,
@NotNull JComponent parentComponent,
@Nullable VirtualFile contextDirectory,
LibraryType<?> type,
final Project project) {
final FileChooserDescriptor chooserDescriptor = descriptor.createAttachFilesChooserDescriptor(null);
chooserDescriptor.setTitle("Select Library Files");
final VirtualFile[] rootCandidates = FileChooser.chooseFiles(chooserDescriptor, parentComponent, project, contextDirectory);
if (rootCandidates.length == 0) {
return null;
}
final List<OrderRoot> roots = RootDetectionUtil.detectRoots(Arrays.asList(rootCandidates), parentComponent, project, descriptor);
if (roots.isEmpty()) return null;
String name = suggestLibraryName(roots);
return doCreate(type, name, roots);
}
示例8: getHomeChooserDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
@Override
public FileChooserDescriptor getHomeChooserDescriptor() {
final FileChooserDescriptor baseDescriptor = super.getHomeChooserDescriptor();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(baseDescriptor) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
if (files.length > 0 && !JrtFileSystem.isSupported()) {
String path = files[0].getPath();
if (JrtFileSystem.isModularJdk(path) || JrtFileSystem.isModularJdk(adjustSelectedSdkHome(path))) {
throw new Exception(LangBundle.message("jrt.not.available.message"));
}
}
baseDescriptor.validateSelectedFiles(files);
}
};
descriptor.putUserData(KEY, Boolean.TRUE);
return descriptor;
}
示例9: createLogFileChooser
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
private void createLogFileChooser() {
myLogFile = new TextFieldWithHistory();
JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
FileChooser.chooseFiles(descriptor, myProject, null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath()));
}
});
}
});
myLogFileChooserPanel.setLayout(new BorderLayout());
myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
示例10: selectConfigurationDirectory
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
public static void selectConfigurationDirectory(@NotNull String path,
@NotNull final Consumer<String> dirConsumer,
final Project project,
@Nullable final Component component) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor()
.withTitle(SvnBundle.message("dialog.title.select.configuration.directory"))
.withDescription(SvnBundle.message("dialog.description.select.configuration.directory"))
.withShowFileSystemRoots(true)
.withHideIgnored(false)
.withShowHiddenFiles(true);
path = "file://" + path.replace(File.separatorChar, '/');
VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);
VirtualFile file = FileChooser.chooseFile(descriptor, component, project, root);
if (file == null) {
return;
}
final String resultPath = file.getPath().replace('/', File.separatorChar);
dirConsumer.consume(resultPath);
}
示例11: createUIComponents
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
private void createUIComponents() {
myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {
@Override
protected LanguageLevel getDefaultLevel() {
Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
if (sdk == null) return null;
JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
return version == null ? null : version.getMaxLanguageLevel();
}
};
final JTextField textField = new JTextField();
final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
outputPathsChooserDescriptor.setHideIgnored(false);
BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
示例12: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
@Nullable
public static AddModuleWizard selectFileAndCreateWizard(@Nullable Project project,
@Nullable Component dialogParent,
@NotNull FileChooserDescriptor descriptor,
ProjectImportProvider[] providers) {
FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, dialogParent);
VirtualFile toSelect = null;
String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
if (lastLocation != null) {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
}
VirtualFile[] files = chooser.choose(project, toSelect);
if (files.length == 0) {
return null;
}
final VirtualFile file = files[0];
PropertiesComponent.getInstance().setValue(LAST_IMPORTED_LOCATION, file.getPath());
return createImportWizard(project, dialogParent, file, providers);
}
示例13: createNewLibrary
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
if (files.length == 0) {
return null;
}
return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
for (VirtualFile file : files) {
editor.addRoot(file, OrderRootType.CLASSES);
}
}
};
}
示例14: BuildoutConfigPanel
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
public BuildoutConfigPanel(Module module, BuildoutFacetConfiguration config) {
myModule = module;
myConfiguration = config;
setLayout(new BorderLayout());
add(myPanel);
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
//descriptor.setRoot(myConfiguration.getRoot());
myScript.addBrowseFolderListener(
"Choose a buildout script", "Select the target script that will invoke your code",
null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT, false
);
myScript.getComboBox().setEditable(true);
initErrorValidation();
}
示例15: addSourcePath
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //导入依赖的package包/类
private void addSourcePath(SettingsStep settingsStep) {
Project project = settingsStep.getContext().getProject();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(IdeBundle.message("prompt.select.source.directory"));
mySourcePath.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
String contentEntryPath = myModuleBuilder.getContentEntryPath();
String path = chosenFile.getPath();
return contentEntryPath == null ? path : path.substring(StringUtil.commonPrefixLength(contentEntryPath, path));
}
});
myCreateSourceRoot.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mySourcePath.setEnabled(myCreateSourceRoot.isSelected());
}
});
settingsStep.addExpertPanel(myPanel);
}