Java Code Examples for com.intellij.openapi.fileChooser.FileChooserDescriptorFactory

The following examples show how to use com.intellij.openapi.fileChooser.FileChooserDescriptorFactory. These examples are extracted from open source projects. 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 Project: reasonml-idea-plugin   Source File: OclProjectJdkWizardStep.java    License: MIT License 6 votes vote down vote up
@Override
public void _init() {
    for (String sdk : SDKS) {
        c_selDownload.addItem(sdk);
    }

    if (c_selExistingSdk.getItemCount() == 0) {
        c_rdSelectExisting.setEnabled(false);
        c_selExistingSdk.setEnabled(false);
        c_rdDownloadSdk.setSelected(true);
    }

    String value = PropertiesComponent.getInstance().getValue(SDK_HOME);
    if (value == null) {
        VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
        value = userHomeDir == null ? "" : userHomeDir.getCanonicalPath() + "/odk";
    }
    c_sdkHome.setText(value);

    c_sdkHome.addBrowseFolderListener("Choose Sdk Home Directory: ", null, m_context.getProject(),
                                      FileChooserDescriptorFactory.createSingleFolderDescriptor());
}
 
Example 2
Source Project: CodeGen   Source File: PsiUtil.java    License: MIT License 6 votes vote down vote up
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 3
Source Project: mule-intellij-plugins   Source File: OpenSampleAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    logger.debug("Loading sample!");

    final Project project = anActionEvent.getProject();
    final PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE);

    VirtualFile sample = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
            project, null);
    if (sample == null)
        return;

    try {
        final String text = new String(sample.contentsToByteArray(), sample.getCharset());

        new WriteCommandAction.Simple(project, psiFile) {
            @Override
            protected void run() throws Throwable {
                document.setText(text);
            }
        }.execute();
    } catch (Exception e) {
        logger.error(e);
    }

}
 
Example 4
public ImportFlutterModuleStep(FlutterProjectModel model, String title, Icon icon, FlutterProjectType type) {
  super(model, title, icon);

  myValidatorPanel = new ValidatorPanel(this, myPanel);

  String initialLocation = WizardUtils.getProjectLocationParent().getPath();
  // Directionality matters. Let the bindings set the model's value from the text field.
  myFlutterModuleLocationField.getChildComponent().setText(initialLocation);
  TextProperty locationText = new TextProperty(myFlutterModuleLocationField.getChildComponent());
  myBindings.bind(model.projectLocation(), locationText);

  myFlutterModuleLocationField
    .addBrowseFolderListener(FlutterBundle.message("flutter.module.import.settings.location.select"), null, null,
                             FileChooserDescriptorFactory.createSingleFolderDescriptor(),
                             TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  myValidatorPanel.registerValidator(model.projectLocation(), ImportFlutterModuleStep::validateFlutterModuleLocation);

  myRootPanel = new StudioWizardStepPanel(myValidatorPanel);
  FormScalingUtil.scaleComponentTree(this.getClass(), myRootPanel);
}
 
Example 5
public ImportFlutterModuleStep(FlutterProjectModel model, String title, Icon icon, FlutterProjectType type) {
  super(model, title, icon);

  myValidatorPanel = new ValidatorPanel(this, myPanel);

  String initialLocation = WizardUtils.getProjectLocationParent().getPath();
  // Directionality matters. Let the bindings set the model's value from the text field.
  myFlutterModuleLocationField.getChildComponent().setText(initialLocation);
  TextProperty locationText = new TextProperty(myFlutterModuleLocationField.getChildComponent());
  myBindings.bind(model.projectLocation(), locationText);

  myFlutterModuleLocationField
    .addBrowseFolderListener(FlutterBundle.message("flutter.module.import.settings.location.select"), null, null,
                             FileChooserDescriptorFactory.createSingleFolderDescriptor(),
                             TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  myValidatorPanel.registerValidator(model.projectLocation(), ImportFlutterModuleStep::validateFlutterModuleLocation);

  myRootPanel = new StudioWizardStepPanel(myValidatorPanel);
  FormScalingUtil.scaleComponentTree(this.getClass(), myRootPanel);
}
 
Example 6
Source Project: consulo   Source File: BuildElementsEditor.java    License: Apache License 2.0 6 votes vote down vote up
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 7
TestForm(@NotNull Project project) {
  scope.setModel(new DefaultComboBoxModel<>(new Scope[]{DIRECTORY, FILE, NAME}));
  scope.addActionListener((ActionEvent e) -> {
    final Scope next = getScope();
    updateFields(next);
    render(next);
  });
  scope.setRenderer(new ListCellRendererWrapper<Scope>() {
    @Override
    public void customize(final JList list,
                          final Scope value,
                          final int index,
                          final boolean selected,
                          final boolean hasFocus) {
      setText(value.getDisplayName());
    }
  });

  initDartFileTextWithBrowse(project, testFile);
  testDir.addBrowseFolderListener("Test Directory", null, project,
                                  FileChooserDescriptorFactory.createSingleFolderDescriptor());
}
 
Example 8
TestForm(@NotNull Project project) {
  scope.setModel(new DefaultComboBoxModel<>(new Scope[]{DIRECTORY, FILE, NAME}));
  scope.addActionListener((ActionEvent e) -> {
    final Scope next = getScope();
    updateFields(next);
    render(next);
  });
  scope.setRenderer(new ListCellRendererWrapper<Scope>() {
    @Override
    public void customize(final JList list,
                          final Scope value,
                          final int index,
                          final boolean selected,
                          final boolean hasFocus) {
      setText(value.getDisplayName());
    }
  });

  initDartFileTextWithBrowse(project, testFile);
  testDir.addBrowseFolderListener("Test Directory", null, project,
                                  FileChooserDescriptorFactory.createSingleFolderDescriptor());
}
 
Example 9
Source Project: WIFIADB   Source File: RootWindow.java    License: Apache License 2.0 6 votes vote down vote up
private void specifyADBPath() {
    final String adbPath = Global.instance().adbPath();
    final VirtualFile toSelect;

    if (Utils.isBlank(adbPath)) {
        toSelect = null;
    } else {
        toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(adbPath);
    }

    final VirtualFile vFile = FileChooser.chooseFile(
            FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), Global.instance().project(), toSelect);

    if (vFile == null || !vFile.exists()) {
        return;
    }

    mPresenter.chooseADBPath(vFile);
}
 
Example 10
Source Project: consulo   Source File: ToolEditorDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
                                               FixedSizeButton browseDirectoryButton,
                                               JTextField tfCommandWorkingDirectory) {
  browseDirectoryButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);

        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = files.size() > 0 ? files.get(0) : null;
            if (file != null) {
              myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
            }
          }
        });
      }
    }
  );
}
 
Example 11
Source Project: consulo   Source File: RunAnythingChooseContextAction.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  Application.get().invokeLater(() -> {
    Project project = e.getProject();

    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setUseApplicationDialog();

    PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, project, e.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT));

    chooser.chooseAsync(project.getBaseDir()).doWhenDone(virtualFiles -> {
      List<String> recentDirectories = RunAnythingContextRecentDirectoryCache.getInstance(project).getState().paths;

      String path = ArrayUtil.getFirstElement(virtualFiles).getPath();

      if (recentDirectories.size() >= Registry.intValue("run.anything.context.recent.directory.number")) {
        recentDirectories.remove(0);
      }

      recentDirectories.add(path);

      setSelectedContext(new RunAnythingContext.RecentDirectoryContext(path));
    });
  });
}
 
Example 12
Source Project: intellij   Source File: ExportRunConfigurationDialog.java    License: Apache License 2.0 6 votes vote down vote up
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 13
Source Project: idea-php-shopware-plugin   Source File: ShopwareSettingsForm.java    License: MIT License 6 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
    defaultCliToolsPathButton.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            cliToolsPharPathTextField.getTextField().setText(ShopwareApplicationSettings.DEFAULT_CLI_URL);
        }
    });

    cliToolsPharPathTextField.getButton().addMouseListener(createPathButtonMouseListener(
        cliToolsPharPathTextField.getTextField(),
        FileChooserDescriptorFactory.createSingleFileDescriptor("phar"))
    );

    return panel;
}
 
Example 14
@Override
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws
      IncorrectOperationException {
  ApplicationManager.getApplication().invokeLater(() -> {
    Collection<VirtualFile> virtualFiles =
          FileTypeIndex.getFiles(SimpleFileType.INSTANCE, GlobalSearchScope.allScope(project) );
    if (virtualFiles.size() == 1) {
      createProperty(project, virtualFiles.iterator().next());
    } else {
      final FileChooserDescriptor descriptor =
            FileChooserDescriptorFactory.createSingleFileDescriptor(SimpleFileType.INSTANCE);
      descriptor.setRoots(ProjectUtil.guessProjectDir(project));
      final VirtualFile file1 = FileChooser.chooseFile(descriptor, project, null);
      if (file1 != null) {
        createProperty(project, file1);
      }
    }
  });
}
 
Example 15
Source Project: idea-php-symfony2-plugin   Source File: UiSettingsUtil.java    License: MIT License 6 votes vote down vote up
@Nullable
public static String getPathDialog(@NotNull Project project, @NotNull FileType fileType, @Nullable String current) {
    VirtualFile projectDirectory = ProjectUtil.getProjectDir(project);

    VirtualFile selectedFileBefore = null;
    if(current != null) {
        selectedFileBefore = VfsUtil.findRelativeFile(current, projectDirectory);
    }

    VirtualFile selectedFile = FileChooser.chooseFile(
            FileChooserDescriptorFactory.createSingleFileDescriptor(fileType),
            project,
            selectedFileBefore
    );

    if (null == selectedFile) {
        return null;
    }

    String path = VfsUtil.getRelativePath(selectedFile, projectDirectory, '/');
    if (null == path) {
        path = selectedFile.getPath();
    }

    return path;
}
 
Example 16
Source Project: idea-php-symfony2-plugin   Source File: SettingsForm.java    License: MIT License 6 votes vote down vote up
public JComponent createComponent() {
    pathToTranslationRootTextField.addBrowseFolderListener(createBrowseFolderListener(pathToTranslationRootTextField.getTextField(), FileChooserDescriptorFactory.createSingleFolderDescriptor()));
    pathToTranslationRootTextFieldReset.addMouseListener(createResetPathButtonMouseListener(pathToTranslationRootTextField.getTextField(), Settings.DEFAULT_TRANSLATION_PATH));

    directoryToApp.addBrowseFolderListener(createBrowseFolderListener(directoryToApp.getTextField(), FileChooserDescriptorFactory.createSingleFolderDescriptor()));
    directoryToAppReset.addMouseListener(createResetPathButtonMouseListener(directoryToApp.getTextField(), Settings.DEFAULT_APP_DIRECTORY));

    directoryToWeb.addBrowseFolderListener(createBrowseFolderListener(directoryToWeb.getTextField(), FileChooserDescriptorFactory.createSingleFolderDescriptor()));
    directoryToWebReset.addMouseListener(createResetPathButtonMouseListener(directoryToWeb.getTextField(), Settings.DEFAULT_WEB_DIRECTORY));

    enableSchedulerCheckBox.setEnabled(WebDeploymentUtil.isEnabled(project));

    buttonReindex.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            IndexUtil.forceReindex();
            super.mouseClicked(e);
        }
    });

    return panel1;
}
 
Example 17
Source Project: consulo   Source File: VcsMappingConfigurationDialog.java    License: Apache License 2.0 6 votes vote down vote up
public VcsMappingConfigurationDialog(final Project project, final String title) {
  super(project, false);
  myProject = project;
  myVcsManager = ProjectLevelVcsManager.getInstance(myProject);
  final VcsDescriptor[] vcsDescriptors = myVcsManager.getAllVcss();
  myVcses = new HashMap<>();
  for (VcsDescriptor vcsDescriptor : vcsDescriptors) {
    myVcses.put(vcsDescriptor.getName(), vcsDescriptor);
  }
  myVCSComboBox.setModel(VcsDirectoryConfigurationPanel.buildVcsWrappersModel(project));
  myDirectoryTextField.addActionListener(new MyBrowseFolderListener("Select Directory", "Select directory to map to a VCS",
                                                                    myDirectoryTextField, project,
                                                                    FileChooserDescriptorFactory.createSingleFolderDescriptor()));
  myMappingCopy = new VcsDirectoryMapping("", "");
  setTitle(title);
  init();
  myVCSComboBox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      updateVcsConfigurable();
    }
  });
}
 
Example 18
Source Project: buck   Source File: BuckSettingsUI.java    License: Apache License 2.0 6 votes vote down vote up
private void discoverCells() {
  final FileChooserDescriptor dirChooser =
      FileChooserDescriptorFactory.createSingleFolderDescriptor()
          .withTitle("Select any directory within a buck cell");
  Project project = buckProjectSettingsProvider.getProject();
  Optional.ofNullable(
          FileChooser.chooseFile(dirChooser, BuckSettingsUI.this, project, project.getBaseDir()))
      .ifPresent(
          defaultCell ->
              ProgressManager.getInstance()
                  .run(
                      new Modal(project, "Autodetecting buck cells", true) {
                        @Override
                        public void run(@NotNull ProgressIndicator progressIndicator) {
                          discoverCells(
                              buckExecutableForAutoDiscovery(), defaultCell, progressIndicator);
                        }
                      }));
}
 
Example 19
Source Project: consulo   Source File: ExternalDiffSettingsConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
public ToolPath(JCheckBox checkBox, TextFieldWithBrowseButton textField, @javax.annotation.Nullable JTextField parameters,
                StringProperty pathProperty, BooleanProperty enabledProperty, @javax.annotation.Nullable StringProperty parametersProperty) {
  myCheckBox = checkBox;
  myTextField = textField;
  myPathProperty = pathProperty;
  myEnabledProperty = enabledProperty;
  myParameters = parameters;
  myParametersProperty = parametersProperty;
  final ButtonModel model = myCheckBox.getModel();
  model.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      updateEnabledEffect();
    }
  });
  myTextField.addBrowseFolderListener(DiffBundle.message("select.external.diff.program.dialog.title"), null, null,
                                      FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
                                      TextComponentAccessor.TEXT_FIELD_SELECTED_TEXT);
}
 
Example 20
Source Project: reasonml-idea-plugin   Source File: ReasonSettingsConfigurable.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public JComponent createComponent() {
    f_bsLocation.addBrowseFolderListener("Choose bs-platform directory: ", null, m_settings.getProject(),
            FileChooserDescriptorFactory.createSingleFolderDescriptor());

    f_workingDir.addBrowseFolderListener("Choose a working directory: ", null, m_settings.getProject(),
            FileChooserDescriptorFactory.createSingleFolderDescriptor());

    return f_rootPanel;
}
 
Example 21
Source Project: CodeGen   Source File: PsiUtil.java    License: MIT License 5 votes vote down vote up
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 22
Source Project: CodeGen   Source File: PsiUtil.java    License: MIT License 5 votes vote down vote up
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 23
public SdkVersionSelectionDialog(JComponent parent, String title, String name, List<String> scalaVersions)
{
    super(parent, false);
    setTitle(title);
    //Create and populate the panel.
    centerPanel = new JPanel(new SpringLayout());

    versionLabel = new JLabel(name, JLabel.TRAILING);
    versionComboBox = new ComboBox(new DefaultComboBoxModel<>(scalaVersions.toArray()));
    versionLabel.setLabelFor(versionComboBox);

    centerPanel.add(versionLabel);
    centerPanel.add(versionComboBox);

    destination = new TextFieldWithBrowseButton();
    destination.addBrowseFolderListener("Select new Mule distribution destination", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor());
    destinationLabel = new JLabel("Destination:", JLabel.TRAILING);
    destinationLabel.setLabelFor(destination);

    //By default, should be ~/mule-distro
    File distro = new File(SystemProperties.getUserHome(), "mule-distro");
    destination.setText(distro.getAbsolutePath());

    centerPanel.add(destinationLabel);
    centerPanel.add(destination);

    //Lay out the panel.
    SpringUtilities.makeCompactGrid(centerPanel,
            2, 2, //rows, cols
            6, 6,        //initX, initY
            6, 6);       //xPad, yPad

    init();
}
 
Example 24
@Override
void perform() {
  // Defaults to ~/flutter
  final FileChooserDescriptor descriptor =
    new FileChooserDescriptor(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
      @Override
      public void validateSelectedFiles(@NotNull VirtualFile[] files) {
        for (VirtualFile file : files) {
          // Eliminate some false positives, which occurs when an existing directory is deleted.
          VfsUtil.markDirtyAndRefresh(false, true, true, file);
          if (file.findChild("flutter") != null) {
            throw new IllegalArgumentException("A file called 'flutter' already exists in this location.");
          }
        }
      }
    }.withTitle("Flutter SDK Directory").withDescription("Choose a directory to install the Flutter SDK");

  final VirtualFile installTarget = FileChooser.chooseFile(descriptor, null, null);
  if (installTarget != null) {
    FlutterInitializer.sendAnalyticsAction(ANALYTICS_KEY);
    installTo(installTarget);
  }
  else {
    // A valid SDK may have been deleted before the FileChooser was cancelled.
    validatePeer();
  }
}
 
Example 25
public FlutterSmallIDEGeneratorPeer() {
  sdkPathComboWithBrowse = new ComboboxWithBrowseButton(new ComboBox<>());
  sdkPathComboWithBrowse.getComboBox().setEditable(true);
  FlutterSdkUtil.addKnownSDKPathsToCombo(sdkPathComboWithBrowse.getComboBox());

  sdkPathComboWithBrowse.addBrowseFolderListener(
    FlutterBundle.message("flutter.sdk.browse.path.label"), null, null,
    FileChooserDescriptorFactory.createSingleFolderDescriptor(),
    TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);

  settingsFields = new FlutterCreateAdditionalSettingsFields();
}
 
Example 26
@Override
void perform() {
  // Defaults to ~/flutter
  final FileChooserDescriptor descriptor =
    new FileChooserDescriptor(FileChooserDescriptorFactory.createSingleFolderDescriptor()) {
      @Override
      public void validateSelectedFiles(@NotNull VirtualFile[] files) {
        for (VirtualFile file : files) {
          // Eliminate some false positives, which occurs when an existing directory is deleted.
          VfsUtil.markDirtyAndRefresh(false, true, true, file);
          if (file.findChild("flutter") != null) {
            throw new IllegalArgumentException("A file called 'flutter' already exists in this location.");
          }
        }
      }
    }.withTitle("Flutter SDK Directory").withDescription("Choose a directory to install the Flutter SDK");

  final VirtualFile installTarget = FileChooser.chooseFile(descriptor, null, null);
  if (installTarget != null) {
    FlutterInitializer.sendAnalyticsAction(ANALYTICS_KEY);
    installTo(installTarget);
  }
  else {
    // A valid SDK may have been deleted before the FileChooser was cancelled.
    validatePeer();
  }
}
 
Example 27
Source Project: sass-lint-plugin   Source File: SassLintSettingsPage.java    License: MIT License 5 votes vote down vote up
private void configLintBinField() {
    configWithDefaults(sasslintBinField);
    SwingHelper.addHistoryOnExpansion(sasslintBinField.getChildComponent(), new NotNullProducer<List<String>>() {
        @NotNull
        public List<String> produce() {
            List<File> newFiles = SassLintFinder.searchForSassLintExe(getProjectPath());
            return FileUtils.toAbsolutePath(newFiles);
        }
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, sasslintBinField, "Select Sass Lint Exe", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
 
Example 28
Source Project: sass-lint-plugin   Source File: SassLintSettingsPage.java    License: MIT License 5 votes vote down vote up
private void configConfigFileField() {
    TextFieldWithHistory textFieldWithHistory = configWithDefaults(sassLintConfigFile);
    SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() {
        @NotNull
        public List<String> produce() {
            return SassLintFinder.searchForConfigFiles(getProjectPath());
        }
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, sassLintConfigFile, "Select Sass Lint Config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
 
Example 29
Source Project: sass-lint-plugin   Source File: SassLintSettingsPage.java    License: MIT License 5 votes vote down vote up
private void configNodeField() {
    TextFieldWithHistory textFieldWithHistory = configWithDefaults(nodeInterpreterField);
    SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() {
        @NotNull
        public List<String> produce() {
            List<File> newFiles = NodeDetectionUtil.listAllPossibleNodeInterpreters();
            return FileUtils.toAbsolutePath(newFiles);
        }
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, nodeInterpreterField, "Select Node Interpreter", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
 
Example 30
Source Project: intellij   Source File: ConsoleOutputFileSettingsUi.java    License: Apache License 2.0 5 votes vote down vote up
public ConsoleOutputFileSettingsUi() {
  outputFile.addBrowseFolderListener(
      "Choose File to Save Console Output",
      "Console output would be saved to the specified file",
      /* project= */ null,
      FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
      TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  saveToFile.addActionListener(e -> outputFile.setEnabled(uiEnabled && saveToFile.isSelected()));
}