public static void installFileChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field, boolean directory, boolean showFileSystemRoots, @Nullable Condition<VirtualFile> fileFilter) { FileChooserDescriptor chooseDirectoryDescriptor = directory ? FileChooserDescriptorFactory.createSingleFolderDescriptor() : FileChooserDescriptorFactory.createSingleLocalFileDescriptor(); chooseDirectoryDescriptor.setRoots(project.getBaseDir()); chooseDirectoryDescriptor.setShowFileSystemRoots(showFileSystemRoots); chooseDirectoryDescriptor.withFileFilter(fileFilter); if (field instanceof TextFieldWithBrowseButton) { ((TextFieldWithBrowseButton)field).addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project)); } else { //noinspection unchecked field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT)); } }
private static void installFileChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field, @Nullable Condition<VirtualFile> fileFilter) { FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor(BallerinaFileType.INSTANCE); chooseDirectoryDescriptor.setRoots(project.getBaseDir()); chooseDirectoryDescriptor.setShowFileSystemRoots(false); chooseDirectoryDescriptor.withShowHiddenFiles(false); chooseDirectoryDescriptor.withFileFilter(fileFilter); if (field instanceof TextFieldWithBrowseButton) { ((TextFieldWithBrowseButton) field).addBrowseFolderListener( new TextBrowseFolderListener(chooseDirectoryDescriptor, project)); } else { //noinspection unchecked field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT)); } }
private static void installWorkingDirectoryChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field) { FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); chooseDirectoryDescriptor.setShowFileSystemRoots(true); chooseDirectoryDescriptor.withShowHiddenFiles(false); if (field instanceof TextFieldWithBrowseButton) { ((TextFieldWithBrowseButton) field).addBrowseFolderListener( new TextBrowseFolderListener(chooseDirectoryDescriptor, project)); } else { //noinspection unchecked field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT)); } }
fcd.setHideIgnored(false); pathImports.addActionListener(new TextFieldWithBrowseButton.BrowseFolderActionListener<>(fcd.getTitle(), fcd.getDescription(), pathImports, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); pathStringImports.addActionListener(new TextFieldWithBrowseButton.BrowseFolderActionListener<>(fcd.getTitle(), fcd.getDescription(), pathStringImports, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); pathDocumentation.addActionListener(new TextFieldWithBrowseButton.BrowseFolderActionListener<>(fcd.getTitle(), fcd.getDescription(), pathDocumentation, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); pathHeaderDir.addActionListener(new TextFieldWithBrowseButton.BrowseFolderActionListener<>(fcd.getTitle(), fcd.getDescription(), pathHeaderDir, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT));
@NotNull @Override protected JComponent createEditor() { final FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(DlangBundle.INSTANCE.message("dmd.run.config.selectworkingdir.title")); fcd.setDescription(DlangBundle.INSTANCE.message("dmd.run.config.selectworkingdir.description")); fcd.setHideIgnored(false); pathWorkingDir.addActionListener(new TextFieldWithBrowseButton.BrowseFolderActionListener<>(fcd.getTitle(), fcd.getDescription(), pathWorkingDir, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); return myMainPanel; }
@NotNull @Override protected JComponent createEditor() { final FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(DlangBundle.INSTANCE.message("dmd.run.config.selectworkingdir.title")); fcd.setDescription(DlangBundle.INSTANCE.message("dmd.run.config.selectworkingdir.description")); fcd.setHideIgnored(false); pathWorkingDir.addActionListener(new TextFieldWithBrowseButton.BrowseFolderActionListener<>(fcd.getTitle(), fcd.getDescription(), pathWorkingDir, null, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)); return myMainPanel; }
private TextFieldWithBrowseButton createShellWorkingDirField() { TextFieldWithBrowseButton shellWorkingDirField = new TextFieldWithBrowseButton(); FileChooserDescriptor dirChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false); ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> browseFolderActionListener = new ComponentWithBrowseButton.BrowseFolderActionListener<>("Mongo Shell Working Directory", null, shellWorkingDirField, project, dirChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); shellWorkingDirField.addBrowseFolderListener(null, browseFolderActionListener, false); shellWorkingDirField.setName("shellWorkingDirField"); return shellWorkingDirField; }
private TextFieldWithBrowseButton createPrivateKeyField() { TextFieldWithBrowseButton privateKeyPathField = new TextFieldWithBrowseButton(); FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) .withShowHiddenFiles(true); ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> privateKeyBrowseFolderActionListener = new ComponentWithBrowseButton.BrowseFolderActionListener<>("Private Key Path", null, privateKeyPathField, project, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); privateKeyPathField.addBrowseFolderListener(null, privateKeyBrowseFolderActionListener, false); return privateKeyPathField; }
private void createUIComponents() { documentToImportTextField = new TextFieldWithBrowseButton(); FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false); ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> privateKeyBrowseFolderActionListener = new ComponentWithBrowseButton.BrowseFolderActionListener<>("Mongo Shell Working Directory", null, documentToImportTextField, null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); documentToImportTextField.addBrowseFolderListener(null, privateKeyBrowseFolderActionListener, false); } }