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 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)); } }
private JPanel createExeRow(final String ext, final String path, final String args) { final JLabel extLabel = new JLabel(EXT_LABEL); final JTextField extField = new JTextField(); extField.setToolTipText(EXT_TOOLTIP); extField.setText(ext); final JLabel pathLabel = new JLabel(FILE_PATH_LABEL); final TextFieldWithBrowseButton pathField = new TextFieldWithBrowseButton(); pathField.setToolTipText("e.g. C:\\rustLS\\rls.exe"); pathField.setText(path); pathField.addBrowseFolderListener(new TextBrowseFolderListener(new FileChooserDescriptor(true, false, true, true, true, false).withShowHiddenFiles(true))); final JLabel argsLabel = new JLabel("Args"); final JTextField argsField = new JTextField(); argsField.setToolTipText("e.g. -stdio"); argsField.setText(args); final List<JComponent> components = Arrays.asList(extLabel, extField, pathLabel, pathField, argsLabel, argsField); final JPanel panel = createRow(components, ExeLanguageServerDefinition$.MODULE$.getPresentableTyp()); final scala.collection.mutable.LinkedHashMap<String, JComponent> map = new scala.collection.mutable.LinkedHashMap<>(); map.put(EXT, extField); map.put(PATH, pathField); map.put(ARGS, argsField); rows.add(new ServersGUIRow(panel, ExeLanguageServerDefinition$.MODULE$.typ(), map)); return panel; }
private JPanel createCommandRow(final String ext, final String command) { final JLabel extLabel = new JLabel(EXT_LABEL); final JTextField extField = new JTextField(); extField.setToolTipText(EXT_TOOLTIP); extField.setText(ext); final JLabel commandLabel = new JLabel("Command"); final TextFieldWithBrowseButton commandField = new TextFieldWithBrowseButton(); commandField.setText(command); commandField.setToolTipText("e.g. python.exe -m C:\\python-ls\\pyls"); commandField.addBrowseFolderListener(new TextBrowseFolderListener(new FileChooserDescriptor(true, false, true, true, true, false).withShowHiddenFiles(true))); final List<JComponent> components = Arrays.asList(extLabel, extField, commandLabel, commandField); final JPanel panel = createRow(components, RawCommandServerDefinition$.MODULE$.getPresentableTyp()); final scala.collection.mutable.LinkedHashMap<String, JComponent> map = new scala.collection.mutable.LinkedHashMap<>(); map.put(EXT, extField); map.put(COMMAND, commandField); rows.add(new ServersGUIRow(panel, RawCommandServerDefinition$.MODULE$.typ(), map)); return panel; }
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)); } }
public MonkeyConfigurable() { this.monkeyOptions = MonkeyOptions.getInstance(); FileChooserDescriptor chooserDescriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor() .withTitle("Choose File for Developer Key") .withDescription("This file will be used as a developer key or to generate one. Make a copy of your key!"); TextBrowseFolderListener listener = new TextBrowseFolderListener(chooserDescriptor); keyPathField.addBrowseFolderListener(listener); keyPathField.setText(getActiveKeyPath().orElse("")); generateKeyButton.addActionListener(e -> { String keyPathStr = keyPathField.getText(); if (StringUtils.isEmpty(keyPathStr)) { throw new IllegalArgumentException("Please set Developer Key output path first (including filename)"); } Path path = FileSystems.getDefault().getPath(keyPathStr); KeyGenerator.generate(path); }); }
public void initComponents(Module module) { ModulesComboBox modulesComboBox = moduleComponent.getComponent(); modulesComboBox.fillModules(project, MonkeyModuleType.getInstance()); fillTargetDevices(module); fillDeploymentTargets(); FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); fileChooserDescriptor.setTitle("Select Device Path"); getDeviceDirectoryField().addBrowseFolderListener(new TextBrowseFolderListener(fileChooserDescriptor, this.project)); }