Java Code Examples for com.intellij.openapi.fileChooser.FileChooserDescriptor#setDescription()
The following examples show how to use
com.intellij.openapi.fileChooser.FileChooserDescriptor#setDescription() .
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: PsiUtil.java From CodeGen with MIT License | 6 votes |
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); } }
Example 2
Source File: MuleUIUtils.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@Nullable public static MuleSdk selectSdk(@NotNull JComponent parentComponent) { final VirtualFile initial = findFile(System.getenv("MULE_HOME")); final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) { @Override public boolean isFileSelectable(VirtualFile file) { return super.isFileSelectable(file) && MuleSdk.isValidMuleHome(file.getCanonicalPath()); } }; descriptor.setTitle("Mule SDK"); descriptor.setDescription("Choose a directory containing Mule distribution"); final VirtualFile dir = FileChooser.chooseFile(descriptor, parentComponent, null, initial); if (dir == null || !MuleSdk.isValidMuleHome(dir.getCanonicalPath())) { return null; } return new MuleSdk(dir.getCanonicalPath()); }
Example 3
Source File: ModuleImportProcessor.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static FileChooserDescriptor createAllImportDescriptor(boolean isModuleImport) { FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, false, false) { @Override public Image getIcon(VirtualFile file) { for (ModuleImportProvider importProvider : ModuleImportProviders.getExtensions(isModuleImport)) { if (importProvider.canImport(VfsUtilCore.virtualToIoFile(file))) { return importProvider.getIcon(); } } return super.getIcon(file); } }; descriptor.setHideIgnored(false); descriptor.setTitle("Select File or Directory to Import"); String description = getFileChooserDescription(isModuleImport); descriptor.setDescription(description); return descriptor; }
Example 4
Source File: PsiUtil.java From CodeGen with MIT License | 5 votes |
public static VirtualFile chooseFolder(@Nullable Project project, String title, String description, boolean showFileSystemRoots, boolean hideIgnored, @Nullable VirtualFile toSelect){ final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); descriptor.setTitle(title); descriptor.setDescription(description); descriptor.setShowFileSystemRoots(showFileSystemRoots); descriptor.setHideIgnored(hideIgnored); return FileChooser.chooseFile(descriptor, project, toSelect); }
Example 5
Source File: PsiUtil.java From CodeGen with MIT License | 5 votes |
public static VirtualFile chooseFile(@Nullable Project project, String title, String description, boolean showFileSystemRoots, boolean hideIgnored, @Nullable VirtualFile toSelect){ final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(); descriptor.setTitle(title); descriptor.setDescription(description); descriptor.setShowFileSystemRoots(showFileSystemRoots); descriptor.setHideIgnored(hideIgnored); return FileChooser.chooseFile(descriptor, project, toSelect); }
Example 6
Source File: ChooseComponentsToExportDialog.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @RequiredUIAccess public static AsyncResult<String> chooseSettingsFile(String oldPath, Component parent, final String title, final String description) { FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor(); chooserDescriptor.setDescription(description); chooserDescriptor.setHideIgnored(false); chooserDescriptor.setTitle(title); VirtualFile initialDir; if (oldPath != null) { final File oldFile = new File(oldPath); initialDir = LocalFileSystem.getInstance().findFileByIoFile(oldFile); if (initialDir == null && oldFile.getParentFile() != null) { initialDir = LocalFileSystem.getInstance().findFileByIoFile(oldFile.getParentFile()); } } else { initialDir = null; } final AsyncResult<String> result = AsyncResult.undefined(); AsyncResult<VirtualFile[]> fileAsyncResult = FileChooser.chooseFiles(chooserDescriptor, null, parent, initialDir); fileAsyncResult.doWhenDone(files -> { VirtualFile file = files[0]; if (file.isDirectory()) { result.setDone(file.getPath() + '/' + new File(DEFAULT_PATH).getName()); } else { result.setDone(file.getPath()); } }); fileAsyncResult.doWhenRejected((Runnable)result::setRejected); return result; }
Example 7
Source File: LibraryRootsComponentDescriptor.java From consulo with Apache License 2.0 | 5 votes |
/** * @return descriptor for the file chooser which will be shown when 'Attach Files' button is pressed * @param libraryName */ @Nonnull public FileChooserDescriptor createAttachFilesChooserDescriptor(@Nullable String libraryName) { final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true); descriptor.setTitle(StringUtil.isEmpty(libraryName) ? ProjectBundle.message("library.attach.files.action") : ProjectBundle.message("library.attach.files.to.library.action", libraryName)); descriptor.setDescription(ProjectBundle.message("library.attach.files.description")); return descriptor; }
Example 8
Source File: ChooserBasedAttachRootButtonDescriptor.java From consulo with Apache License 2.0 | 5 votes |
@Override public VirtualFile[] selectFiles(final @Nonnull JComponent parent, @Nullable VirtualFile initialSelection, final @Nullable Module contextModule, @Nonnull LibraryEditor libraryEditor) { final FileChooserDescriptor chooserDescriptor = createChooserDescriptor(); chooserDescriptor.setTitle(getChooserTitle(libraryEditor.getName())); chooserDescriptor.setDescription(getChooserDescription()); if (contextModule != null) { chooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, contextModule); } return FileChooser.chooseFiles(chooserDescriptor, parent, contextModule != null ? contextModule.getProject() : null, initialSelection); }
Example 9
Source File: ContentEntriesEditor.java From consulo with Apache License 2.0 | 5 votes |
public AddContentEntryAction() { super(ProjectBundle.message("module.paths.add.content.action"), ProjectBundle.message("module.paths.add.content.action.description"), AllIcons.Modules.AddContentEntry); myDescriptor = new FileChooserDescriptor(false, true, true, false, true, true) { @Override public void validateSelectedFiles(VirtualFile[] files) throws Exception { validateContentEntriesCandidates(files); } }; myDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, getModule()); myDescriptor.setTitle(ProjectBundle.message("module.paths.add.content.title")); myDescriptor.setDescription(ProjectBundle.message("module.paths.add.content.prompt")); myDescriptor.putUserData(FileChooserKeys.DELETE_ACTION_AVAILABLE, false); }
Example 10
Source File: LibraryRootsComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor(); descriptor.setTitle("Exclude from Library"); descriptor.setDescription("Select directories which should be excluded from the library content. Content of excluded directories won't be processed by IDE."); Set<VirtualFile> roots = getNotExcludedRoots(); descriptor.setRoots(roots.toArray(new VirtualFile[roots.size()])); if (roots.size() < 2) { descriptor.setIsTreeRootVisible(true); } VirtualFile toSelect = null; for (Object o : getSelectedElements()) { Object itemElement = o instanceof ExcludedRootElement ? ((ExcludedRootElement)o).getParentDescriptor() : o; if (itemElement instanceof ItemElement) { toSelect = VirtualFileManager.getInstance().findFileByUrl(((ItemElement)itemElement).getUrl()); break; } } final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myPanel, myProject, toSelect); if (files.length > 0) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { for (VirtualFile file : files) { getLibraryEditor().addExcludedRoot(file.getUrl()); } } }); myLastChosen = files[0]; libraryChanged(true); } }
Example 11
Source File: DependencyViewer.java From gradle-view with Apache License 2.0 | 5 votes |
private void promptForGradleBaseDir() { FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle("Choose a Project Folder"); fcd.setDescription("Pick the top level directory to use when viewing dependencies (in case you have a multi-module project)."); fcd.setHideIgnored(false); FileChooser.chooseFiles(fcd, project, project.getBaseDir(), new Consumer<List<VirtualFile>>() { @Override public void consume(List<VirtualFile> files) { gradleBaseDir = files.get(0).getPath(); } }); }
Example 12
Source File: SelectFolder.java From floobits-intellij with Apache License 2.0 | 4 votes |
public static void build(String owner, String workspace, final RunLater<String> runLater) { FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false); descriptor.setTitle("Select Folder For Workspace"); descriptor.setDescription("NOTE: Floobits will NOT make a new, root directory inside the folder you choose. If you have cloned the project already, select that folder."); FloorcJson floorcJson; try { floorcJson = Settings.get(); } catch (Exception e) { Flog.errorMessage("Your floorc.json has invalid json.", null); return; } File file = null; String shareDir = floorcJson.share_dir; if (shareDir != null) { if (shareDir.substring(0, 2).equals("~/")) { shareDir = shareDir.replaceFirst("~/", System.getProperty("user.home") + "/"); } file = createDir(shareDir, owner, workspace); if (file == null) { Flog.errorMessage(String.format("Your floorc.json share_dir setting %s did not work, using default ~/floobits", floorcJson.share_dir), null); } } if (file == null) { file = createDir(Constants.shareDir, owner, workspace); } if (file == null) { Flog.errorMessage(String.format("Could not create a directory for this workspace, tried %s", Constants.shareDir), null); return; } VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file); VirtualFile[] vFiles = FileChooser.chooseFiles(descriptor, null, virtualFile); if (vFiles.length == 0) { return; } if (vFiles.length > 1) { Flog.errorMessage("You can only select one directory!", null); return; } final String selectedPath = vFiles[0].getPath(); runLater.run(selectedPath); }
Example 13
Source File: ViewOfflineResultsAction.java From consulo with Apache License 2.0 | 4 votes |
@Override public void actionPerformed(AnActionEvent event) { final Project project = event.getData(CommonDataKeys.PROJECT); LOG.assertTrue(project != null); final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false){ @Override public Image getIcon(VirtualFile file) { if (file.isDirectory()) { if (file.findChild(InspectionApplication.DESCRIPTIONS + ".xml") != null) { return AllIcons.Nodes.InspectionResults; } } return super.getIcon(file); } }; descriptor.setTitle("Select Path"); descriptor.setDescription("Select directory which contains exported inspections results"); final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null); if (virtualFile == null || !virtualFile.isDirectory()) return; final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap = new HashMap<String, Map<String, Set<OfflineProblemDescriptor>>>(); final String [] profileName = new String[1]; final Runnable process = new Runnable() { @Override public void run() { final VirtualFile[] files = virtualFile.getChildren(); try { for (final VirtualFile inspectionFile : files) { if (inspectionFile.isDirectory()) continue; final String shortName = inspectionFile.getNameWithoutExtension(); final String extension = inspectionFile.getExtension(); if (shortName.equals(InspectionApplication.DESCRIPTIONS)) { profileName[0] = ApplicationManager.getApplication().runReadAction( new Computable<String>() { @Override @Nullable public String compute() { return OfflineViewParseUtil.parseProfileName(inspectionFile); } } ); } else if (XML_EXTENSION.equals(extension)) { resMap.put(shortName, ApplicationManager.getApplication().runReadAction( new Computable<Map<String, Set<OfflineProblemDescriptor>>>() { @Override public Map<String, Set<OfflineProblemDescriptor>> compute() { return OfflineViewParseUtil.parse(inspectionFile); } } )); } } } catch (final Exception e) { //all parse exceptions SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Messages.showInfoMessage(e.getMessage(), InspectionsBundle.message("offline.view.parse.exception.title")); } }); throw new ProcessCanceledException(); //cancel process } } }; ProgressManager.getInstance().runProcessWithProgressAsynchronously(project, InspectionsBundle.message("parsing.inspections.dump.progress.title"), process, new Runnable() { @Override public void run() { SwingUtilities.invokeLater(new Runnable(){ @Override public void run() { final String name = profileName[0]; showOfflineView(project, name, resMap, InspectionsBundle.message("offline.view.title") + " (" + (name != null ? name : InspectionsBundle.message("offline.view.editor.settings.title")) +")"); } }); } }, null, new PerformAnalysisInBackgroundOption(project)); }