Java Code Examples for com.intellij.openapi.ui.TextFieldWithBrowseButton#addBrowseFolderListener()

The following examples show how to use com.intellij.openapi.ui.TextFieldWithBrowseButton#addBrowseFolderListener() . 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: SelectPackageTemplateDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void makePathButton() {
        btnPath = new TextFieldWithBrowseButton();
        btnPath.setText(PackageTemplateHelper.getRootDirPath());
        btnPath.addBrowseFolderListener(Localizer.get("SelectPackageTemplate"), "", project, FileReaderUtil.getPackageTemplatesDescriptor());

//        panel.add(new SeparatorComponent(), new CC().growX().spanX().wrap());
        panel.add(btnPath, new CC().pushX().growX().spanX());
        addPathButtons();

        rbFromPath = new JBRadioButton(Localizer.get("label.FromPath"));
        rbFromPath.addItemListener(e -> {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                toggleSourcePath(
                        TemplateSourceType.PATH,
                        null,
                        btnPath
                );
            }
        });

        panel.add(rbFromPath, new CC().growX().spanX().wrap());
    }
 
Example 2
Source File: LibraryDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
private void initBinaryFilesTab() {
    pTabBinaryFiles = new JPanel(new MigLayout(new LC()));

    // List
    createBinaryFileList();

    //Content (right panel)
    JPanel panelBinaryFilesContent = new JPanel(new MigLayout());
    btnBinaryFilePath = new TextFieldWithBrowseButton();
    btnBinaryFilePath.setText("");
    btnBinaryFilePath.addBrowseFolderListener(Localizer.get("library.ChooseBinaryFile"), "", project, FileReaderUtil.getBinaryFileDescriptor());

    tfBinaryFileAlias = new EditorTextField("ExampleAlias");

    panelBinaryFilesContent.add(tfBinaryFileAlias, new CC().wrap());
    panelBinaryFilesContent.add(btnBinaryFilePath, new CC().wrap().gapY("8pt", "0"));

    //Splitter
    JBSplitter splitter = new JBSplitter(0.3f);
    splitter.setFirstComponent(listBinaryFiles);
    splitter.setSecondComponent(panelBinaryFilesContent);

    pTabBinaryFiles.add(splitter, new CC().push().grow());
    tabbedPane.addTab("Tab1", pTabBinaryFiles);
}
 
Example 3
Source File: SdkVersionSelectionDialog.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
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 4
Source File: SelectBinaryFileDialog.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
private void render() {
    btnPath = new TextFieldWithBrowseButton();

    if (binaryFile == null) {
        binaryFile = BinaryFile.newInstance();
        binaryFile.setSourcePath(PackageTemplateHelper.getRootDirPath());
    }

    btnPath.setText(binaryFile.getSourcePath());
    btnPath.addBrowseFolderListener(Localizer.get("library.ChooseBinaryFile"), "", project, FileReaderUtil.getBinaryFileDescriptor());

    panel.add(btnPath, new CC().wrap().pushX().growX());
}
 
Example 5
Source File: BashConfigForm.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
protected void initOwnComponents() {
    Project project = getProject();

    FileChooserDescriptor chooseInterpreterDescriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    chooseInterpreterDescriptor.setTitle("Choose Interpreter...");

    interpreterPathField = new TextFieldWithBrowseButton();
    interpreterPathField.addBrowseFolderListener(new MacroAwareTextBrowseFolderListener(chooseInterpreterDescriptor, project));

    interpreterPathComponent = LabeledComponent.create(createComponentWithMacroBrowse(interpreterPathField), "Interpreter path:");
    interpreterPathComponent.setLabelLocation(BorderLayout.WEST);

    projectInterpreterCheckbox = new JBCheckBox();
    projectInterpreterCheckbox.setToolTipText("If enabled then the interpreter path configured in the project settings will be used instead of a custom location.");
    projectInterpreterCheckbox.addChangeListener(e -> {
        boolean selected = projectInterpreterCheckbox.isSelected();
        UIUtil.setEnabled(interpreterPathComponent, !selected, true);
    });
    projectInterpreterLabeled = LabeledComponent.create(projectInterpreterCheckbox, "Use project interpreter");
    projectInterpreterLabeled.setLabelLocation(BorderLayout.WEST);

    interpreterParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), "Interpreter options");
    interpreterParametersComponent.setLabelLocation(BorderLayout.WEST);

    scriptNameField = new TextFieldWithBrowseButton();
    scriptNameField.addBrowseFolderListener(new MacroAwareTextBrowseFolderListener(FileChooserDescriptorFactory.createSingleLocalFileDescriptor(), project));

    scriptNameComponent = LabeledComponent.create(createComponentWithMacroBrowse(scriptNameField), "Script:");
    scriptNameComponent.setLabelLocation(BorderLayout.WEST);
}
 
Example 6
Source File: GuiUtil.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a label and path selector and adds them to the configuration
 * window.
 *
 * @param settings Panel to add components to.
 * @param tool Which tool to configure.
 * @return The TextFieldWithBrowseButton created.
 */
public static TextFieldWithBrowseButton createExecutableOption(JPanel settings, String tool, Object constraints) {
    // Create UI elements.
    TextFieldWithBrowseButton tf = new TextFieldWithBrowseButton();
    tf.addBrowseFolderListener("Select " + tool + " path", "", null,
            FileChooserDescriptorFactory.createSingleLocalFileDescriptor());

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

    return tf;
}
 
Example 7
Source File: GuiUtil.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
public static void addFolderListener(final TextFieldWithBrowseButton textField,
                                     final String name,
                                     final Project project,
                                     final Condition<VirtualFile> fileFilter) {
    textField.addBrowseFolderListener("Select " + name + " path", "", project,
            FileChooserDescriptorFactory.createSingleLocalFileDescriptor().withFileFilter(fileFilter));
}
 
Example 8
Source File: BuckSettingsUI.java    From buck with Apache License 2.0 5 votes vote down vote up
private TextFieldWithBrowseButton createTextFieldWithBrowseButton(
    String emptyText, String title, String description, Project project) {
  JBTextField textField = new JBTextField();
  textField.getEmptyText().setText(emptyText);
  TextFieldWithBrowseButton field = new TextFieldWithBrowseButton(textField);
  FileChooserDescriptor fileChooserDescriptor =
      new FileChooserDescriptor(true, false, false, false, false, false);
  field.addBrowseFolderListener(
      title,
      description,
      project,
      fileChooserDescriptor,
      TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  return field;
}
 
Example 9
Source File: CustomizableActionsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static TextFieldWithBrowseButton createBrowseField(){
  TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
  textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
  textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
  final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
    public boolean isFileSelectable(VirtualFile file) {
      //noinspection HardCodedStringLiteral
      return file.getName().endsWith(".png");
    }
  };
  textField.addBrowseFolderListener(IdeBundle.message("title.browse.icon"), IdeBundle.message("prompt.browse.icon.for.selected.action"), null,
                                    fileChooserDescriptor);
  InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
  return textField;
}
 
Example 10
Source File: ExportToHTMLDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static LabeledComponent<TextFieldWithBrowseButton> assignLabel(TextFieldWithBrowseButton targetDirectoryField, Project project) {
  LabeledComponent<TextFieldWithBrowseButton> labeledComponent = new LabeledComponent<TextFieldWithBrowseButton>();
  labeledComponent.setText(CodeEditorBundle.message("export.to.html.output.directory.label"));
  targetDirectoryField.addBrowseFolderListener(CodeEditorBundle.message("export.to.html.select.output.directory.title"),
                                               CodeEditorBundle.message("export.to.html.select.output.directory.description"),
                                               project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
  labeledComponent.setComponent(targetDirectoryField);
  return labeledComponent;
}
 
Example 11
Source File: CrudDirSelectInfoStep.java    From crud-intellij-plugin with Apache License 2.0 4 votes vote down vote up
private void createUIComponents() {
    // TODO: place custom component creation code here
    TextFieldWithBrowseButton browseButton = new TextFieldWithBrowseButton();
    browseButton.addBrowseFolderListener(new TextBrowseFolderListener(new FileChooserDescriptor(false, true, false, false, false, false)));
    this.myMapperField = browseButton;
}
 
Example 12
Source File: TomcatSettingsEditor.java    From SmartTomcat with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
protected JComponent createEditor() {

    ComboboxWithBrowseButton tomcatField = runnerSetting.getTomcatField();
    TextFieldWithBrowseButton docBaseField = runnerSetting.getDocBaseField();

    JTextField contextPathField = runnerSetting.getContextPathField();
    JFormattedTextField portField = runnerSetting.getPortField();
    JFormattedTextField adminPort = runnerSetting.getAdminPort();

    JXButton configrationButton = runnerSetting.getConfigrationButton();
    configrationButton.addActionListener(e -> ShowSettingsUtil.getInstance().showSettingsDialog(project, TomcatSettingConfigurable.class));


    VirtualFile baseDir = VirtualFileManager.getInstance().getFileSystem("file").findFileByPath(project.getBasePath());

    FileChooserDescriptor chooserDescriptor = new IgnoreOutputFileChooserDescriptor(project).withRoots(baseDir);
    docBaseField.addBrowseFolderListener("webapp", "Choose Web Folder", project, chooserDescriptor);
    docBaseField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent documentEvent) {

            if (!documentEvent.getType().equals(DocumentEvent.EventType.REMOVE)) {
                String text = docBaseField.getText();
                if (text != null && !text.trim().equals("")) {
                    VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(new File(text));

                    Module module = ModuleUtilCore.findModuleForFile(fileByIoFile, project);
                    String contextPath = module == null ? "/" : "/" + module.getName();
                    contextPathField.setText(contextPath);
                }
            }

        }
    });

    portField.setValue(8080);
    adminPort.setValue(8005);
    DefaultFormatterFactory tf = new DefaultFormatterFactory();
    NumberFormat format = NumberFormat.getInstance();
    format.setGroupingUsed(false);
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(0);
    formatter.setMaximum(65535);
    tf.setDefaultFormatter(formatter);
    portField.setFormatterFactory(tf);
    adminPort.setFormatterFactory(tf);

    return runnerSetting.getMainPanel();
}
 
Example 13
Source File: BlazeEditProjectViewControl.java    From intellij with Apache License 2.0 4 votes vote down vote up
private void fillUi(JPanel canvas) {
  JLabel projectDataDirLabel = new JBLabel("Project data directory:");

  canvas.setPreferredSize(ProjectViewUi.getContainerSize());

  projectDataDirField = new TextFieldWithBrowseButton();
  projectDataDirField.setName("project-data-dir-field");
  projectDataDirField.addBrowseFolderListener(
      "",
      buildSystemName + " project data directory",
      null,
      PROJECT_FOLDER_DESCRIPTOR,
      TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
      false);
  final String dataDirToolTipText = "Directory in which to store the project's metadata.";
  projectDataDirField.setToolTipText(dataDirToolTipText);
  projectDataDirLabel.setToolTipText(dataDirToolTipText);

  canvas.add(projectDataDirLabel, UiUtil.getLabelConstraints(0));
  canvas.add(projectDataDirField, UiUtil.getFillLineConstraints(0));

  JLabel projectNameLabel = new JLabel("Project name:");
  projectNameField = new JTextField();
  final String projectNameToolTipText = "Project display name.";
  projectNameField.setToolTipText(projectNameToolTipText);
  projectNameField.setName("project-name-field");
  projectNameLabel.setToolTipText(projectNameToolTipText);
  canvas.add(projectNameLabel, UiUtil.getLabelConstraints(0));
  canvas.add(projectNameField, UiUtil.getFillLineConstraints(0));

  JLabel defaultNameLabel = new JLabel("Infer name from:");
  workspaceDefaultNameOption = new JRadioButton("Workspace");
  branchDefaultNameOption = new JRadioButton("Branch");
  importDirectoryDefaultNameOption = new JRadioButton("Import Directory");

  workspaceDefaultNameOption.setToolTipText("Infer default name from the workspace name");
  branchDefaultNameOption.setToolTipText(
      "Infer default name from the current branch of your workspace");
  importDirectoryDefaultNameOption.setToolTipText(
      "Infer default name from the directory used to import your project view");

  workspaceDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged());
  branchDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged());
  importDirectoryDefaultNameOption.addItemListener(e -> inferDefaultNameModeSelectionChanged());
  ButtonGroup buttonGroup = new ButtonGroup();
  buttonGroup.add(workspaceDefaultNameOption);
  buttonGroup.add(branchDefaultNameOption);
  buttonGroup.add(importDirectoryDefaultNameOption);
  canvas.add(defaultNameLabel, UiUtil.getLabelConstraints(0));
  canvas.add(workspaceDefaultNameOption, UiUtil.getLabelConstraints(0));
  canvas.add(branchDefaultNameOption, UiUtil.getLabelConstraints(0));
  canvas.add(importDirectoryDefaultNameOption, UiUtil.getLabelConstraints(0));
  canvas.add(new JPanel(), UiUtil.getFillLineConstraints(0));

  projectViewUi.fillUi(canvas);
}
 
Example 14
Source File: BuckSettingsUI.java    From Buck-IntelliJ-Plugin with Apache License 2.0 4 votes vote down vote up
private void init() {
  setLayout(new BorderLayout());
  JPanel container = this;

  mBuckPathField = new TextFieldWithBrowseButton();
  FileChooserDescriptor fileChooserDescriptor =
      new FileChooserDescriptor(true, false, false, false, false, false);
  mBuckPathField.addBrowseFolderListener(
      "",
      "Buck Executable Path",
      null,
      fileChooserDescriptor,
      TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT,
      false
  );
  mCustomizedInstallSettingField = new JBTextField();
  mCustomizedInstallSettingField.getEmptyText().setText(CUSTOMIZED_INSTALL_COMMAND_HINT);
  mCustomizedInstallSettingField.setEnabled(false);

  mRunAfterInstall = new JCheckBox("Run after install (-r)");
  mMultiInstallMode = new JCheckBox("Multi-install mode (-x)");
  mUninstallBeforeInstall = new JCheckBox("Uninstall before installing (-u)");
  mCustomizedInstallSetting = new JCheckBox("Use customized install setting:  ");
  initCustomizedInstallCommandListener();

  JPanel buckSettings = new JPanel(new GridBagLayout());
  buckSettings.setBorder(IdeBorderFactory.createTitledBorder("Buck Settings", true));
  container.add(container = new JPanel(new BorderLayout()), BorderLayout.NORTH);
  container.add(buckSettings, BorderLayout.NORTH);
  final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 0, 0,
      GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);

  buckSettings.add(new JLabel("Buck Executable Path:"), constraints);
  constraints.gridx = 1;
  constraints.weightx = 1;
  constraints.fill = GridBagConstraints.HORIZONTAL;
  buckSettings.add(mBuckPathField, constraints);

  JPanel installSettings = new JPanel(new BorderLayout());
  installSettings.setBorder(IdeBorderFactory.createTitledBorder("Buck Install Settings", true));
  container.add(container = new JPanel(new BorderLayout()), BorderLayout.SOUTH);
  container.add(installSettings, BorderLayout.NORTH);

  installSettings.add(mRunAfterInstall, BorderLayout.NORTH);
  installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);

  installSettings.add(mMultiInstallMode, BorderLayout.NORTH);
  installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);

  installSettings.add(mUninstallBeforeInstall, BorderLayout.NORTH);
  installSettings.add(installSettings = new JPanel(new BorderLayout()), BorderLayout.SOUTH);

  final GridBagConstraints customConstraints = new GridBagConstraints(0, 0, 1, 1, 0, 0,
      GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
  JPanel customizedInstallSetting = new JPanel(new GridBagLayout());
  customizedInstallSetting.add(mCustomizedInstallSetting, customConstraints);
  customConstraints.gridx = 1;
  customConstraints.weightx = 1;
  customConstraints.fill = GridBagConstraints.HORIZONTAL;
  customizedInstallSetting.add(mCustomizedInstallSettingField, customConstraints);
  installSettings.add(customizedInstallSetting, BorderLayout.NORTH);
}
 
Example 15
Source File: MongoRunConfigurationEditor.java    From nosql4idea with Apache License 2.0 4 votes vote down vote up
private void createUIComponents() {
    shellWorkingDirField = new TextFieldWithBrowseButton();
    shellWorkingDirField.addBrowseFolderListener("Mongo shell working directory", "", null,
            new FileChooserDescriptor(false, true, false, false, false, false));
    shellWorkingDirField.setName("shellWorkingDirField");
}
 
Example 16
Source File: ExtractIncludeDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new VerticalFlowLayout());

  JLabel nameLabel = new JLabel();
  panel.add(nameLabel);

  myNameField = new JTextField();
  nameLabel.setLabelFor(myNameField);
  myNameField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      validateOKButton();
    }
  });
  panel.add(myNameField);
  nameLabel.setText(getNameLabel());

  myTargetDirLabel = new JLabel();
  panel.add(myTargetDirLabel);

  myTargetDirectoryField = new TextFieldWithBrowseButton();
  myTargetDirectoryField.setText(myCurrentDirectory.getVirtualFile().getPresentableUrl());
  myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"),
                                                 RefactoringBundle.message("select.target.directory.description"),
                                                 null, FileChooserDescriptorFactory.createSingleFolderDescriptor());

  myTargetDirLabel.setText(RefactoringBundle.message("extract.to.directory"));
  panel.add(myTargetDirectoryField);

  myTargetDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      validateOKButton();
    }
  });

  validateOKButton();

  return panel;
}