Java Code Examples for com.intellij.openapi.fileChooser.FileChooserDescriptor#setHideIgnored()
The following examples show how to use
com.intellij.openapi.fileChooser.FileChooserDescriptor#setHideIgnored() .
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: 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 3
Source File: BuildElementsEditor.java From consulo with Apache License 2.0 | 6 votes |
private CommitableFieldPanel createOutputPathPanel(final String title, final CommitPathRunnable commitPathRunnable) { final JTextField textField = new JTextField(); final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); outputPathsChooserDescriptor.setHideIgnored(false); InsertPathAction.addTo(textField, outputPathsChooserDescriptor); FileChooserFactory.getInstance().installFileCompletion(textField, outputPathsChooserDescriptor, true, null); CommitableFieldPanel commitableFieldPanel = new CommitableFieldPanel(textField, null, null, new BrowseFilesListener(textField, title, "", outputPathsChooserDescriptor), null); commitableFieldPanel.myCommitRunnable = new Runnable() { @Override public void run() { if (!getModel().isWritable()) { return; } String url = commitableFieldPanel.getUrl(); commitPathRunnable.saveUrl(url); } }; return commitableFieldPanel; }
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: ProjectSettingsForm.java From EclipseCodeFormatter with Apache License 2.0 | 5 votes |
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; }
Example 7
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 8
Source File: NamePathComponent.java From consulo with Apache License 2.0 | 5 votes |
public NamePathComponent(String nameLabelText, String pathLabelText, final String pathChooserTitle, final String pathChooserDescription, boolean hideIgnored, boolean bold) { super(new GridBagLayout()); myTfName = new JTextField(); myTfName.setDocument(new NameFieldDocument()); myTfName.setPreferredSize(new Dimension(200, myTfName.getPreferredSize().height)); myTfPath = new JTextField(); myTfPath.setDocument(new PathFieldDocument()); myTfPath.setPreferredSize(new Dimension(200, myTfPath.getPreferredSize().height)); myNameLabel = new JLabel(nameLabelText); if (bold) myNameLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); myNameLabel.setLabelFor(myTfName); Insets insets = new Insets(0, 0, 5, 4); this.add(myNameLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); insets = new Insets(0, 0, 5, 0); this.add(myTfName, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insets, 0, 0)); // todo: review texts final FileChooserDescriptor chooserDescriptor = (FileChooserDescriptor)BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR.clone(); chooserDescriptor.setHideIgnored(hideIgnored); final BrowseFilesListener browseButtonActionListener = new BrowseFilesListener(myTfPath, pathChooserTitle, pathChooserDescription, chooserDescriptor) { @Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); myIsPathChangedByUser = true; } }; myPathPanel = new FieldPanel(myTfPath, null, null, browseButtonActionListener, null); myPathLabel = new JLabel(pathLabelText); myPathLabel.setLabelFor(myTfPath); if (bold) myPathLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)); insets = new Insets(0, 0, 5, 4); this.add(myPathLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); insets = new Insets(0, 0, 5, 0); this.add(myPathPanel, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, insets, 0, 0)); }
Example 9
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 10
Source File: ProjectConfigurable.java From consulo with Apache License 2.0 | 4 votes |
private void init() { myPanel = new JPanel(new VerticalFlowLayout(true, false)); final JPanel namePanel = new JPanel(new BorderLayout()); final JLabel label = new JLabel("<html><body><b>Project name:</b></body></html>", SwingConstants.LEFT); namePanel.add(label, BorderLayout.NORTH); myProjectName = new JTextField(); myProjectName.setColumns(40); final JPanel nameFieldPanel = new JPanel(); nameFieldPanel.setLayout(new BoxLayout(nameFieldPanel, BoxLayout.X_AXIS)); nameFieldPanel.add(Box.createHorizontalStrut(4)); nameFieldPanel.add(myProjectName); namePanel.add(nameFieldPanel, BorderLayout.CENTER); final JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.LEFT)); wrapper.add(namePanel); wrapper.setAlignmentX(0); myPanel.add(wrapper); myPanel.add(new JLabel(ProjectBundle.message("project.compiler.output"))); 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); myProjectCompilerOutput.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { if (myFreeze) return; myModulesConfigurator.processModuleCompilerOutputChanged(getCompilerOutputUrl()); } }); myPanel.add(myProjectCompilerOutput); myPanel.add(ScrollPaneFactory.createScrollPane(myErrorsComponent, true)); }