com.intellij.openapi.fileChooser.FileChooserDialog Java Examples
The following examples show how to use
com.intellij.openapi.fileChooser.FileChooserDialog.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginSettingTable.java From ycy-intellij-plugin with GNU General Public License v3.0 | 6 votes |
/** * 添加表格行 */ @Override public void addRow() { FileChooserDescriptor descriptor = PluginSettingConfig.IMAGE_FILE_CHOOSER; FileChooserDialog dialog = FileChooserFactory.getInstance().createFileChooser(descriptor, null, null); VirtualFile[] files = dialog.choose(null); List<String> chosenImageUrlList = Stream.of(files) .map(imageFile -> { try { return VfsUtil.toUri(imageFile).toURL().toString(); } catch (MalformedURLException e) { LOG.error("parse the image \"" + imageFile.getName() + "\" to URL error", e); return null; } }) .filter(Objects::nonNull) .filter(imageUrl -> !imageUrlList.contains(imageUrl)) .collect(Collectors.toList()); if (chosenImageUrlList.size() != 0) { imageUrlList.addAll(chosenImageUrlList); LOG.info("add rows: " + chosenImageUrlList); super.fireTableRowsInserted(imageUrlList.size() - 1 - files.length, imageUrlList.size() - 1); } else { LOG.info("choose no files"); } }
Example #2
Source File: ExportRunConfigurationDialog.java From intellij with Apache License 2.0 | 6 votes |
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()); }
Example #3
Source File: CopyExternalProjectViewOption.java From intellij with Apache License 2.0 | 5 votes |
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()))); // File filters are broken for the native Mac file chooser. descriptor.setForcedToUseIdeaFileChooser(true); 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()); }
Example #4
Source File: DesktopFileChooseDialogProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public FileChooserDialog createFileChooser(@Nonnull FileChooserDescriptor descriptor, @Nullable Project project, @Nullable Component parent) { if (parent != null) { return new FileChooserDialogImpl(descriptor, parent, project); } else { return new FileChooserDialogImpl(descriptor, project); } }
Example #5
Source File: ImportFromWorkspaceProjectViewOption.java From intellij with Apache License 2.0 | 4 votes |
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()))); // File filters are broken for the native Mac file chooser. descriptor.setForcedToUseIdeaFileChooser(true); FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, null, null); WorkspacePathResolver workspacePathResolver = builder.getWorkspaceData().workspacePathResolver(); File fileBrowserRoot = builder.getWorkspaceData().fileBrowserRoot(); 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.startsWith(file.getPath(), fileBrowserRoot.getPath())) { 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); }
Example #6
Source File: FileChooseDialogProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull FileChooserDialog createFileChooser(@Nonnull FileChooserDescriptor descriptor, @Nullable Project project, @Nullable Component parent);
Example #7
Source File: FileChooser.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @RequiredUIAccess public static AsyncResult<VirtualFile[]> chooseFiles(@Nonnull FileChooserDescriptor descriptor, @Nullable Component parent, @Nullable Project project, @Nullable VirtualFile toSelect) { final FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, parent); return chooser.chooseAsync(project, toSelect == null ? VirtualFile.EMPTY_ARRAY : new VirtualFile[]{toSelect}); }
Example #8
Source File: PathEditor.java From consulo with Apache License 2.0 | 4 votes |
public PathEditor(final FileChooserDescriptor descriptor) { myDescriptor = descriptor; myDescriptor.putUserData(FileChooserDialog.PREFER_LAST_OVER_TO_SELECT, Boolean.TRUE); myModel = createListModel(); }
Example #9
Source File: WebFileChooseDialogProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public FileChooserDialog createFileChooser(@Nonnull FileChooserDescriptor descriptor, @Nullable Project project, @Nullable Component parent) { return new WebPathChooserDialog(project, descriptor); }
Example #10
Source File: WindowsFileChooseDialogProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public FileChooserDialog createFileChooser(@Nonnull FileChooserDescriptor descriptor, @Nullable Project project, @Nullable Component parent) { return new WinPathChooserDialog(descriptor, parent, project); }
Example #11
Source File: MacFileChooseDialogProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public FileChooserDialog createFileChooser(@Nonnull FileChooserDescriptor descriptor, @Nullable Project project, @Nullable Component parent) { return new MacPathChooserDialog(descriptor, parent, project); }