本文整理汇总了Java中com.intellij.openapi.fileChooser.FileChooser.chooseFiles方法的典型用法代码示例。如果您正苦于以下问题:Java FileChooser.chooseFiles方法的具体用法?Java FileChooser.chooseFiles怎么用?Java FileChooser.chooseFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileChooser.FileChooser
的用法示例。
在下文中一共展示了FileChooser.chooseFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onExportAction
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@Override
public void onExportAction(String path) {
VirtualFile[] files = FileChooser.chooseFiles(FileReaderUtil.getDirectoryDescriptor(), project,
null);
//todo remove
// LocalFileSystem.getInstance().findFileByIoFile(new File("E:" + File.separator + "Downloads")));
if (files.length <= 0) {
return;
}
PackageTemplate pt = PackageTemplateHelper.getPackageTemplate(path);
VirtualFile directoryToExport = files[0];
PackageTemplateHelper.exportPackageTemplate(project, pt, directoryToExport.getPath());
}
示例2: invoke
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final MavenDomDependency dep = getDependency(file, editor);
final VirtualFile[] files;
if (myFileChooser == null) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, true, false, false);
final PsiFile currentValue = dep != null ? dep.getSystemPath().getValue() : null;
final VirtualFile toSelect = currentValue == null ? null : currentValue.getVirtualFile();
files = FileChooser.chooseFiles(descriptor, project, toSelect);
}
else {
files = myFileChooser.produce();
}
if (files == null || files.length == 0) return;
final PsiFile selectedFile = PsiManager.getInstance(project).findFile(files[0]);
if (selectedFile == null) return;
if (dep != null) {
new WriteCommandAction(project) {
protected void run(@NotNull Result result) throws Throwable {
dep.getSystemPath().setValue(selectedFile);
}
}.execute();
}
}
示例3: createNewLibrary
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的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);
}
}
};
}
示例4: getGitRootsFromUser
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@NotNull
private static List<VirtualFile> getGitRootsFromUser(@NotNull Project project) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, true, false, true);
VirtualFile[] virtualFiles = FileChooser.chooseFiles(descriptor, project, null);
if (virtualFiles.length == 0) {
return Collections.emptyList();
}
List<VirtualFile> correctRoots = ContainerUtil.newArrayList();
for (VirtualFile vf : virtualFiles) {
if (GitUtil.isGitRoot(new File(vf.getPath()))) {
correctRoots.add(vf);
}
}
return correctRoots;
}
示例5: createLibraryFromFiles
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的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);
}
示例6: selectSdkHome
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public static void selectSdkHome(@NotNull final SdkType sdkType, @NotNull final Consumer<String> consumer) {
final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor();
if (ApplicationManager.getApplication().isUnitTestMode()) {
Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(sdkType);
if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found");
consumer.consume(sdk.getHomePath());
return;
}
FileChooser.chooseFiles(descriptor, null, getSuggestedSdkRoot(sdkType), new Consumer<List<VirtualFile>>() {
@Override
public void consume(final List<VirtualFile> chosen) {
final String path = chosen.get(0).getPath();
if (sdkType.isValidSdkHome(path)) {
consumer.consume(path);
return;
}
final String adjustedPath = sdkType.adjustSelectedSdkHome(path);
if (sdkType.isValidSdkHome(adjustedPath)) {
consumer.consume(adjustedPath);
}
}
});
}
示例7: createFileChooserListener
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public static ActionListener createFileChooserListener(final TextFieldWithBrowseButton parent, final @Nullable Project project,
final FileChooserDescriptor descriptor) {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
// final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createAllButJarContentsDescriptor();
// DataContext dataContext = DataManager.getInstance().getDataContextFromFocus().getResult();
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parent, project,
(project == null) && !parent.getText().isEmpty() ? LocalFileSystem.getInstance().findFileByPath(parent.getText()) : null);
if (files.length > 0) {
final StringBuilder builder = new StringBuilder();
for (VirtualFile file : files) {
if (builder.length() > 0) {
builder.append(File.pathSeparator);
}
builder.append(FileUtil.toSystemDependentName(file.getPath()));
}
parent.setText(builder.toString());
}
}
};
}
示例8: actionPerformed
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e){
FileChooserDescriptor fileChooserDescriptor = (FileChooserDescriptor)myFileChooserDescriptor.clone();
if (myTitle != null) {
fileChooserDescriptor.setTitle(myTitle);
}
if (myDescription != null) {
fileChooserDescriptor.setDescription(myDescription);
}
VirtualFile initialFile = getInitialFile();
FileChooser.chooseFiles(fileChooserDescriptor, myProject, initialFile, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
onFileChoosen(files.get(0));
}
});
}
示例9: actionPerformed
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
String selectedText = myTextField.getSelectedText();
VirtualFile virtualFile;
if (selectedText != null ) {
virtualFile = LocalFileSystem.getInstance().findFileByPath(selectedText.replace(File.separatorChar, '/'));
}
else {
virtualFile = null;
}
//TODO use from openapi
//FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.commandLine.insertPath");
VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTextField, getEventProject(e), virtualFile);
if (files.length != 0) {
myTextField.replaceSelection(files[0].getPresentableUrl());
}
}
示例10: doAdd
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
private VirtualFile[] doAdd() {
VirtualFile baseDir = myAddBaseDir;
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel));
if (baseDir == null && project != null) {
baseDir = project.getBaseDir();
}
VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myPanel, project, baseDir);
files = adjustAddedFileSet(myPanel, files);
List<VirtualFile> added = new ArrayList<VirtualFile>(files.length);
for (VirtualFile vFile : files) {
if (addElement(vFile)) {
added.add(vFile);
}
}
return VfsUtil.toVirtualFileArray(added);
}
示例11: invoke
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final MavenDomDependency dep = getDependency(file, editor);
final VirtualFile[] files;
if (myFileChooser == null) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, true, false, false);
final PsiFile currentValue = dep != null ? dep.getSystemPath().getValue() : null;
final VirtualFile toSelect = currentValue == null ? null : currentValue.getVirtualFile();
files = FileChooser.chooseFiles(descriptor, project, toSelect);
}
else {
files = myFileChooser.produce();
}
if (files == null || files.length == 0) return;
final PsiFile selectedFile = PsiManager.getInstance(project).findFile(files[0]);
if (selectedFile == null) return;
if (dep != null) {
new WriteCommandAction(project) {
protected void run(Result result) throws Throwable {
dep.getSystemPath().setValue(selectedFile);
}
}.execute();
}
}
示例12: createNewLibrary
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent jComponent, @Nullable VirtualFile virtualFile,
@NotNull Project project) {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createAllButJarContentsDescriptor();
descriptor.setTitle(LuaBundle.message("new.library.file.chooser.title"));
descriptor.setDescription(LuaBundle.message("new.library.file.chooser.description"));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, jComponent, project, virtualFile);
if (files.length == 0) {
return null;
}
return new NewLibraryConfiguration("Lua Library", this, new DummyLibraryProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
for (VirtualFile file : files) {
editor.addRoot(file, OrderRootType.CLASSES);
}
}
};
}
示例13: browseForFile
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
private boolean browseForFile(@NotNull final JTextField target, FileChooserDescriptor descriptor, String title) {
descriptor.setHideIgnored(false);
descriptor.setTitle(title);
String text = target.getText();
final VirtualFile toSelect = text == null || text.isEmpty() ? getProject().getBaseDir()
: LocalFileSystem.getInstance().findFileByPath(text);
// 10.5 does not have #chooseFile
VirtualFile[] virtualFile = FileChooser.chooseFiles(descriptor, getProject(), toSelect);
if (virtualFile != null && virtualFile.length > 0) {
target.setText(virtualFile[0].getPath());
return true;
}
return false;
}
示例14: actionPerformed
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
String selectedText = myTextField.getSelectedText();
VirtualFile virtualFile;
if (selectedText != null ) {
virtualFile = LocalFileSystem.getInstance().findFileByPath(selectedText.replace(File.separatorChar, '/'));
}
else {
virtualFile = null;
}
//TODO use from openapi
//FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.commandLine.insertPath");
VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myTextField, getEventProject(e), virtualFile);
if (files.length != 0) {
myTextField.replaceSelection(files[0].getPresentableUrl());
}
}
示例15: doAdd
import com.intellij.openapi.fileChooser.FileChooser; //导入方法依赖的package包/类
private VirtualFile[] doAdd() {
VirtualFile baseDir = myAddBaseDir;
Project project = DataManager.getInstance().getDataContext(myComponent).getData(CommonDataKeys.PROJECT);
if (baseDir == null && project != null) {
baseDir = project.getBaseDir();
}
VirtualFile[] files = FileChooser.chooseFiles(myDescriptor, myComponent, project, baseDir);
files = adjustAddedFileSet(myComponent, files);
List<VirtualFile> added = new ArrayList<VirtualFile>(files.length);
for (VirtualFile vFile : files) {
if (addElement(vFile)) {
added.add(vFile);
}
}
return VfsUtil.toVirtualFileArray(added);
}