Java Code Examples for com.intellij.ui.TextFieldWithHistory

The following examples show how to use com.intellij.ui.TextFieldWithHistory. 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: 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 2
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 3
Source Project: intellij   Source File: UseExistingBazelWorkspaceOption.java    License: Apache License 2.0 5 votes vote down vote up
public UseExistingBazelWorkspaceOption(BlazeNewProjectBuilder builder) {
  directoryField = new TextFieldWithHistory();
  directoryField.setName("workspace-directory-field");
  directoryField.setHistory(builder.getWorkspaceHistory(BuildSystem.Bazel));
  directoryField.setHistorySize(BlazeNewProjectBuilder.HISTORY_SIZE);
  directoryField.setText(builder.getLastImportedWorkspace(BuildSystem.Bazel));
  directoryField.setMinimumAndPreferredWidth(MINIMUM_FIELD_WIDTH);

  JButton button = new JButton("...");
  button.addActionListener(action -> this.chooseDirectory());
  int buttonSize = this.directoryField.getPreferredSize().height;
  button.setPreferredSize(new Dimension(buttonSize, buttonSize));

  JPanel canvas = new JPanel(new VerticalLayout(4));
  canvas.setPreferredSize(ProjectViewUi.getContainerSize());
  canvas.add(new JLabel("Select an existing Bazel workspace"));
  canvas.add(new JSeparator());

  // Explicitly specify alignment, so preferred widths of children are honored.
  JPanel content =
      new JPanel(new VerticalLayout(/* gap= */ 12, /* alignment= */ SwingConstants.LEFT));
  content.setBorder(Borders.empty(20, 20, 0, 0));

  JComponent box =
      UiUtil.createHorizontalBox(
          BlazeWizardOption.HORIZONTAL_LAYOUT_GAP,
          getIconComponent(),
          new JLabel("Workspace:"),
          this.directoryField,
          button);
  UiUtil.setPreferredWidth(box, BlazeWizardOption.PREFERRED_COMPONENT_WIDTH);
  content.add(box);
  canvas.add(content);
  this.component = canvas;
}
 
Example 4
Source Project: react-templates-plugin   Source File: RTSettingsPage.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 5
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 6
Source Project: jscs-plugin   Source File: JscsSettingsPage.java    License: MIT License 5 votes vote down vote up
private void configJscsRcField() {
    TextFieldWithHistory textFieldWithHistory = configWithDefaults(jscsrcFile);
    SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() {
        @NotNull
        public List<String> produce() {
            return JscsFinder.searchForJscsRCFiles(getProjectPath());
        }
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, jscsrcFile, "Select JSCS config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
 
Example 7
Source Project: jscs-plugin   Source File: JscsSettingsPage.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 8
Source Project: react-templates-plugin   Source File: RTSettingsPage.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 9
Source Project: eslint-plugin   Source File: ESLintSettingsPage.java    License: MIT License 5 votes vote down vote up
private void configESLintRulesField() {
    TextFieldWithHistory textFieldWithHistory = rulesPathField.getChildComponent();
    SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() {
        @NotNull
        public List<String> produce() {
            return ESLintFinder.tryFindRulesAsString(getProjectPath());
        }
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, rulesPathField, "Select Built in Rules", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
 
Example 10
Source Project: eslint-plugin   Source File: ESLintSettingsPage.java    License: MIT License 5 votes vote down vote up
private void configESLintRcField() {
    TextFieldWithHistory textFieldWithHistory = configWithDefaults(eslintrcFile);
    SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() {
        @NotNull
        public List<String> produce() {
            return ESLintFinder.searchForESLintRCFiles(getProjectPath());
        }
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, eslintrcFile, "Select ESLint Config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
}
 
Example 11
Source Project: eslint-plugin   Source File: ESLintSettingsPage.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 12
Source Project: intellij-haskforce   Source File: GuiUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a label and text field input and adds them to the configuration
 * window.
 *
 * @param settings Panel to add components to.
 * @param labelText Which text to show to the left of the field.
 * @return The TextFieldWithBrowseButton created.
 */
public static TextFieldWithHistory createTextfield(JPanel settings, String labelText, Object constraints) {
    // Create UI elements.
    TextFieldWithHistory tf = new TextFieldWithHistory();

    // Add elements to Panel.
    JPanel subPanel = new JPanel(new GridBagLayout());
    subPanel.add(new JLabel(labelText + ':'));
    subPanel.add(tf, ExternalSystemUiUtil.getFillLineConstraints(0));
    settings.add(subPanel, constraints);

    return tf;
}
 
Example 13
Source Project: sass-lint-plugin   Source File: SassLintSettingsPage.java    License: MIT License 4 votes vote down vote up
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithBrowseButton field) {
    TextFieldWithHistory textFieldWithHistory = field.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    return textFieldWithHistory;
}
 
Example 14
Source Project: react-templates-plugin   Source File: RTSettingsPage.java    License: MIT License 4 votes vote down vote up
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithBrowseButton field) {
    TextFieldWithHistory textFieldWithHistory = field.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    return textFieldWithHistory;
}
 
Example 15
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithBrowseButton field) {
    TextFieldWithHistory textFieldWithHistory = field.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    return textFieldWithHistory;
}
 
Example 16
Source Project: jscs-plugin   Source File: JscsSettingsPage.java    License: MIT License 4 votes vote down vote up
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithBrowseButton field) {
    TextFieldWithHistory textFieldWithHistory = field.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    return textFieldWithHistory;
}
 
Example 17
Source Project: react-templates-plugin   Source File: RTSettingsPage.java    License: MIT License 4 votes vote down vote up
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithBrowseButton field) {
    TextFieldWithHistory textFieldWithHistory = field.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    return textFieldWithHistory;
}
 
Example 18
Source Project: eslint-plugin   Source File: ESLintSettingsPage.java    License: MIT License 4 votes vote down vote up
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithBrowseButton field) {
    TextFieldWithHistory textFieldWithHistory = field.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    return textFieldWithHistory;
}
 
Example 19
Source Project: intellij-haskforce   Source File: GuiUtil.java    License: Apache License 2.0 4 votes vote down vote up
public static TextFieldWithHistory createTextfield(JPanel settings, String labelText) {
    return createTextfield(settings, labelText, ExternalSystemUiUtil.getFillLineConstraints(0));
}
 
Example 20
Source Project: intellij-xquery   Source File: AlternativeJREPanel.java    License: Apache License 2.0 4 votes vote down vote up
public AlternativeJREPanel() {
    myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox"));

    myFieldWithHistory = new TextFieldWithHistory();
    myFieldWithHistory.setHistorySize(-1);
    final List<String> foundJDKs = new ArrayList<>();
    final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks();

    String javaHomeOfCurrentProcess = System.getProperty("java.home");
    if (javaHomeOfCurrentProcess != null && !javaHomeOfCurrentProcess.isEmpty()) {
        foundJDKs.add(javaHomeOfCurrentProcess);
    }

    for (Sdk sdk : allJDKs) {
        String name = sdk.getName();
        if (!foundJDKs.contains(name)) {
            foundJDKs.add(name);
        }
    }

    for (Sdk jdk : allJDKs) {
        String homePath = jdk.getHomePath();

        if (!SystemInfo.isMac) {
            final File jre = new File(jdk.getHomePath(), "jre");
            if (jre.isDirectory()) {
                homePath = jre.getPath();
            }
        }

        if (!foundJDKs.contains(homePath)) {
            foundJDKs.add(homePath);
        }
    }

    myFieldWithHistory.setHistory(foundJDKs);
    myPathField = new ComponentWithBrowseButton<>(myFieldWithHistory, null);
    myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"),
            ExecutionBundle.message("run.configuration.select.jre.dir.label"),
            null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
            TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);

    setLayout(new MigLayout("ins 0, gap 10, fill, flowx"));
    add(myCbEnabled, "shrinkx");
    add(myPathField, "growx, pushx");

    InsertPathAction.addTo(myFieldWithHistory.getTextEditor());

    myCbEnabled.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            enabledChanged();
        }
    });
    enabledChanged();

    setAnchor(myCbEnabled);

    updateUI();
}
 
Example 21
Source Project: consulo   Source File: TextComponentAccessor.java    License: Apache License 2.0 4 votes vote down vote up
public String getText(TextFieldWithHistory textField) {
  return textField.getText();
}
 
Example 22
Source Project: consulo   Source File: TextComponentAccessor.java    License: Apache License 2.0 4 votes vote down vote up
public void setText(TextFieldWithHistory textField, String text) {
  textField.setText(text);
}