本文整理汇总了Java中com.intellij.openapi.fileChooser.FileChooserDialog.choose方法的典型用法代码示例。如果您正苦于以下问题:Java FileChooserDialog.choose方法的具体用法?Java FileChooserDialog.choose怎么用?Java FileChooserDialog.choose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileChooser.FileChooserDialog
的用法示例。
在下文中一共展示了FileChooserDialog.choose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的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);
}
示例2: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
@Nullable
private AddModuleWizard selectFileAndCreateWizard(@NotNull FileChooserDescriptor descriptor)
throws IOException, ConfigurationException {
FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
VirtualFile toSelect = null;
String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
if (lastLocation != null) {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
}
VirtualFile[] files = chooser.choose(null, toSelect);
if (files.length == 0) {
return null;
}
VirtualFile file = files[0];
PropertiesComponent.getInstance().setValue(LAST_IMPORTED_LOCATION, file.getPath());
return createImportWizard(file);
}
示例3: chooseDirectory
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
private void chooseDirectory() {
FileChooserDescriptor descriptor =
FileChooserDescriptorFactory.createSingleFolderDescriptor()
.withTitle("Export Directory Location")
.withDescription("Choose directory to export run configurations to")
.withHideIgnored(false);
FileChooserDialog chooser =
FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
final VirtualFile[] files;
File existingLocation = new File(getOutputDirectoryPath());
if (existingLocation.exists()) {
VirtualFile toSelect =
LocalFileSystem.getInstance().refreshAndFindFileByPath(existingLocation.getPath());
files = chooser.choose(null, toSelect);
} else {
files = chooser.choose(null);
}
if (files.length == 0) {
return;
}
VirtualFile file = files[0];
outputDirectoryPanel.setText(file.getPath());
}
示例4: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
@Nullable
public static AddModuleWizard selectFileAndCreateWizard(final 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(toSelect, project);
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);
}
示例5: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
@Nullable
public static AddModuleWizard selectFileAndCreateWizard(final Project project,
@Nullable Component dialogParent,
@Nonnull FileChooserDescriptor descriptor,
@Nonnull List<ModuleImportProvider> 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 == null ? VirtualFile.EMPTY_ARRAY : new VirtualFile[]{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);
}
示例6: chooseWorkspacePath
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
private void chooseWorkspacePath() {
FileChooserDescriptor descriptor =
new FileChooserDescriptor(true, false, false, false, false, false)
.withShowHiddenFiles(true) // Show root project view file
.withHideIgnored(false)
.withTitle("Select Project View File")
.withDescription("Select a project view file to import.")
.withFileFilter(
virtualFile ->
ProjectViewStorageManager.isProjectViewFile(new File(virtualFile.getPath())));
FileChooserDialog chooser =
FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
File startingLocation = null;
String projectViewPath = getProjectViewPath();
if (!projectViewPath.isEmpty()) {
File fileLocation = new File(projectViewPath);
if (fileLocation.exists()) {
startingLocation = fileLocation;
}
}
final VirtualFile[] files;
if (startingLocation != null) {
VirtualFile toSelect =
LocalFileSystem.getInstance().refreshAndFindFileByPath(startingLocation.getPath());
files = chooser.choose(null, toSelect);
} else {
files = chooser.choose(null);
}
if (files.length == 0) {
return;
}
VirtualFile file = files[0];
projectViewPathField.setText(file.getPath());
}
示例7: openFileChooserDialog
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
@Nullable
private PsiFile openFileChooserDialog(Project project) {
FileChooserDialog fileChooserDialog = FileChooserFactory.getInstance().createFileChooser(FileChooserDescriptorFactory.createSingleFileDescriptor(), project, null);
VirtualFile[] virtualFiles = fileChooserDialog.choose(project, selectedFile.getVirtualFile());
if (virtualFiles.length > 0) {
PsiFile xliffFile = PsiManager.getInstance(project).findFile(virtualFiles[0]);
if (xliffFile.isWritable() && xliffFile.isValid()) {
return xliffFile;
}
}
return null;
}
示例8: chooseWorkspacePath
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
private void chooseWorkspacePath() {
FileChooserDescriptor descriptor =
new FileChooserDescriptor(true, false, false, false, false, false)
.withShowHiddenFiles(true) // Show root project view file
.withHideIgnored(false)
.withTitle("Select Project View File")
.withDescription("Select a project view file to import.")
.withFileFilter(
virtualFile ->
ProjectViewStorageManager.isProjectViewFile(new File(virtualFile.getPath())));
FileChooserDialog chooser =
FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
WorkspacePathResolver workspacePathResolver =
builder.getWorkspaceOption().getWorkspacePathResolver();
File fileBrowserRoot = builder.getWorkspaceOption().getFileBrowserRoot();
File startingLocation = fileBrowserRoot;
String projectViewPath = getProjectViewPath();
if (!projectViewPath.isEmpty()) {
// If the user has typed part of the path then clicked the '...', try to start from the
// partial state
projectViewPath = StringUtil.trimEnd(projectViewPath, '/');
if (WorkspacePath.isValid(projectViewPath)) {
File fileLocation = workspacePathResolver.resolveToFile(new WorkspacePath(projectViewPath));
if (fileLocation.exists() && FileUtil.isAncestor(fileBrowserRoot, fileLocation, true)) {
startingLocation = fileLocation;
}
}
}
VirtualFile toSelect =
LocalFileSystem.getInstance().refreshAndFindFileByPath(startingLocation.getPath());
VirtualFile[] files = chooser.choose(null, toSelect);
if (files.length == 0) {
return;
}
VirtualFile file = files[0];
if (!FileUtil.isAncestor(fileBrowserRoot.getPath(), file.getPath(), true)) {
Messages.showErrorDialog(
String.format(
"You must choose a project view file under %s. "
+ "To use an external project view, please use the 'Copy external' option.",
fileBrowserRoot.getPath()),
"Cannot Use Project View File");
return;
}
String newWorkspacePath = FileUtil.getRelativePath(fileBrowserRoot, new File(file.getPath()));
projectViewPathField.setText(newWorkspacePath);
}
示例9: getFromFileChooser
import com.intellij.openapi.fileChooser.FileChooserDialog; //导入方法依赖的package包/类
public String getFromFileChooser() {
FileChooserDialog fileChooser = FileChooserFactoryImpl.getInstance().createFileChooser(
FileChooserDescriptorFactory.createSingleLocalFileDescriptor(), null, null);
VirtualFile[] chosenFile = fileChooser.choose(null);
return chosenFile[0].getUrl();
}