com.intellij.openapi.ui.TextFieldWithBrowseButton Java Examples

The following examples show how to use com.intellij.openapi.ui.TextFieldWithBrowseButton. 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: ArmaPluginSettingsForm.java    From arma-intellij-plugin with MIT License 6 votes vote down vote up
private void createUIComponents() {
	tfArmaToolsDir = new JTextField(40);
	{
		panelForTfArmaToolsDir = new TextFieldWithBrowseButton(tfArmaToolsDir, e -> {
			JFileChooser fc = new JFileChooser();
			fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
			fc.showDialog(panelRoot, getBundle().getString("ApplicationSettings.ArmaToolsConfig.select"));
			File file = fc.getSelectedFile();

			if (file == null) {
				return;
			}
			tfArmaToolsDir.setText(file.getAbsolutePath());
		});
	}
}
 
Example #3
Source File: MergeBranchForm.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL
 */
private void $$$setupUI$$$() {
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
    sourceBranchLabel = new JLabel();
    this.$$$loadLabelText$$$(sourceBranchLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("MergeBranchDialog.Source"));
    contentPanel.add(sourceBranchLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    sourceText = new TextFieldWithBrowseButton.NoPathCompletion();
    contentPanel.add(sourceText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JLabel label1 = new JLabel();
    label1.setEnabled(true);
    this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("MergeBranchDialog.Target"));
    contentPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    targetCombo = new JComboBox();
    contentPanel.add(targetCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    changesToMergePanel = new JPanel();
    changesToMergePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(changesToMergePanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    changesToMergePanel.setBorder(BorderFactory.createTitledBorder(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("MergeBranchDialog.ChangesToMerge")));
    changesTypeCombo = new JComboBox();
    changesToMergePanel.add(changesTypeCombo, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    changesetsPanel = new JPanel();
    changesetsPanel.setLayout(new CardLayout(0, 0));
    changesToMergePanel.add(changesetsPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    label1.setLabelFor(targetCombo);
}
 
Example #4
Source File: ComboBoxFieldPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void createComponent() {
  super.createComponent();
  TextFieldWithBrowseButton.MyDoClickAction doClickAction = getDoClickAction();
  if (doClickAction != null) {
    doClickAction.registerShortcut(myComboBox);
  }

  myComboBox.setMaximumRowCount(8);

  myComboBox.setEditable(true);
  final JTextField editorComponent = (JTextField)myComboBox.getEditor().getEditorComponent();
  editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      final String text = getText();
      if (!Comparing.equal(text, oldText, true)) {
        oldText = text;
        final Runnable changeListener = getChangeListener();
        if (changeListener != null) {
          changeListener.run();
        }
      }
    }
  });
}
 
Example #5
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 #6
Source File: CommonProgramParametersPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Deprecated // use MacroComboBoxWithBrowseButton instead
protected JComponent createComponentWithMacroBrowse(@Nonnull final TextFieldWithBrowseButton textAccessor) {
  final FixedSizeButton button = new FixedSizeButton(textAccessor);
  button.setIcon(AllIcons.RunConfigurations.Variables);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      //noinspection unchecked
      final JList list = new JBList(myWorkingDirectoryComboBox.getChildComponent().getModel());
      JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(() -> {
        final Object value = list.getSelectedValue();
        if (value instanceof String) {
          textAccessor.setText((String)value);
        }
      }).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
    }
  });

  JPanel panel = new JPanel(new BorderLayout());
  panel.add(textAccessor, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
 
Example #7
Source File: ArmaPluginSettingsForm.java    From arma-intellij-plugin with MIT License 6 votes vote down vote up
private void createUIComponents() {
	tfArmaToolsDir = new JTextField(40);
	{
		panelForTfArmaToolsDir = new TextFieldWithBrowseButton(tfArmaToolsDir, e -> {
			JFileChooser fc = new JFileChooser();
			fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
			fc.showDialog(panelRoot, getBundle().getString("ApplicationSettings.ArmaToolsConfig.select"));
			File file = fc.getSelectedFile();

			if (file == null) {
				return;
			}
			tfArmaToolsDir.setText(file.getAbsolutePath());
		});
	}
}
 
Example #8
Source File: SimpleCheckoutForm.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL
 */
private void $$$setupUI$$$() {
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.setMinimumSize(new Dimension(500, 180));
    final JLabel label1 = new JLabel();
    label1.setText("Directory Name:");
    contentPanel.add(label1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    directoryName = new JTextField();
    contentPanel.add(directoryName, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
    final JLabel label2 = new JLabel();
    label2.setText("Repository Url:");
    contentPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    repoUrl = new JTextField();
    repoUrl.setEditable(false);
    contentPanel.add(repoUrl, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
    parentDirectory = new TextFieldWithBrowseButton();
    contentPanel.add(parentDirectory, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(150, -1), null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText("Parent Directory:");
    contentPanel.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
 
Example #9
Source File: ExternalDiffSettingsConfigurable.java    From consulo with 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 #10
Source File: LogConfigurationPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public LogFileCellEditor(LogFileOptions options) {
  myLogFileOptions = options;
  myComponent = new CellEditorComponentWithBrowseButton<JTextField>(new TextFieldWithBrowseButton(), this);
  getChildComponent().setEditable(false);
  getChildComponent().setBorder(null);
  myComponent.getComponentWithButton().getButton().addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      showEditorDialog(myLogFileOptions);
      JTextField textField = getChildComponent();
      textField.setText(myLogFileOptions.getName());
      IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(textField);
      myModel.fireTableDataChanged();
    }
  });
}
 
Example #11
Source File: DirDiffPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void createUIComponents() {
  mySourceDirField = new TextFieldWithBrowseButton(null, this);
  myTargetDirField = new TextFieldWithBrowseButton(null, this);

  final AtomicBoolean callUpdate = new AtomicBoolean(true);
  myRootPanel = new JPanel(new BorderLayout()) {
    @Override
    protected void paintChildren(Graphics g) {
      super.paintChildren(g);
      if (callUpdate.get()) {
        callUpdate.set(false);
        myModel.reloadModel(false);
      }
    }
  };
}
 
Example #12
Source File: HaskellToolsConfigurable.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
Tool(Project project, String command, ToolKey key, TextFieldWithBrowseButton pathField,
     RawCommandLineEditor flagsField, JButton autoFindButton, JTextField versionField, String versionParam,
     @Nullable Topic<SettingsChangeNotifier> topic) {
    this.project = project;
    this.command = command;
    this.key = key;
    this.pathField = pathField;
    this.flagsField = flagsField;
    this.versionField = versionField;
    this.versionParam = versionParam;
    this.autoFindButton = autoFindButton;
    this.topic = topic;
    this.publisher = topic == null ? null : project.getMessageBus().syncPublisher(topic);

    this.propertyFields = Arrays.asList(
            new PropertyField(key.pathKey, pathField),
            new PropertyField(key.flagsKey, flagsField));

    GuiUtil.addFolderListener(pathField, command);
    GuiUtil.addApplyPathAction(autoFindButton, pathField, command);
    updateVersion();
}
 
Example #13
Source File: BuckSettingsUI.java    From buck with Apache License 2.0 6 votes vote down vote up
private JButton createExecutableFieldTestingButton(
    String executableName,
    Optional<String> defaultExecutable,
    TextFieldWithBrowseButton executableField) {
  JButton button = new JButton();
  button.setText("Test " + executableName);
  button.setToolTipText("Verify that the supplied " + executableName + " is a valid executable");
  button.addActionListener(
      new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          checkFieldIsExecutable(
              executableName, executableField.getTextField(), defaultExecutable);
        }
      });
  return button;
}
 
Example #14
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 #15
Source File: ArmaAddonsSettingsForm.java    From arma-intellij-plugin with MIT License 5 votes vote down vote up
private void createUIComponents() {
	bundle = ResourceBundle.getBundle("com.kaylerrenslow.armaplugin.ProjectSettingsBundle");

	tfWithBrowseReferenceDirectory = new TextFieldWithBrowseButton(new JTextField(40));

	treeAddonsRoots_rootNode = new RootTreeNode();
	treeAddonsRoots = new Tree(treeAddonsRoots_rootNode);
	treeAddonsRoots.setCellRenderer(new MyColoredTreeCellRenderer());
	treeAddonsRoots.setHoldSize(true);
	treeAddonsRoots.addTreeSelectionListener(e -> {
		System.out.println("ArmaAddonsSettingsForm.createUIComponents e=" + e);
	});
}
 
Example #16
Source File: FlutterProjectStepFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public File getLocationInFileSystem() {
  final TextFieldWithBrowseButton locationField = getLocationField();
  return execute(new GuiQuery<File>() {
    @Override
    protected File executeInEDT() {
      String location = locationField.getText();
      assertThat(location).isNotEmpty();
      return new File(location);
    }
  });
}
 
Example #17
Source File: FolderSelectionForm.java    From decompile-and-attach with MIT License 5 votes vote down vote up
public FolderSelectionForm(Project project) {
    super(project);
    init();
    setTitle(title);
    setOKActionEnabled(false);
    descriptionLabel.setText(description);
    workingDirComponent.setComponent(new TextFieldWithBrowseButton(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (!workingDirComponent.getComponent().getText().isEmpty()) {
                setOKActionEnabled(true);
            }
        }
    }));
    workingDirComponent.getComponent().addBrowseFolderListener(
            "Test Title", "", project,
            new FileChooserDescriptor(false, true, false, false, false, false) {
                @Override
                public boolean isFileSelectable(VirtualFile file) {
                    if (!super.isFileSelectable(file)) return false;
                    return true;
                }
            });
    workingDirComponent.getComponent().setEditable(false);
    workingDirComponent.getComponent().setTextFieldPreferredWidth(50);
}
 
Example #18
Source File: PropertiesPartUI.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
private static File nullEmptyGet(TextFieldWithBrowseButton field) {
    String t = field.getText().trim();
    if (t.isEmpty()) {
        return null;
    }
    return new File(t);
}
 
Example #19
Source File: FilePartUI.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
private void setupUI() {
    rootPanel = new JPanel(new BorderLayout());

    fileLocation = new TextFieldWithBrowseButton();
    // TODO make these keys conform to the standards.
    fileLocation.setText(P4Bundle.getString("config.file.location.tooltip"));
    fileLocation.setToolTipText(P4Bundle.getString("configuration.p4config.chooser"));
    fileLocation.setEditable(true);

    JLabel label = SwingUtil.createLabelFor(P4Bundle.getString("configuration.p4config"), fileLocation);
    label.setHorizontalAlignment(SwingConstants.TRAILING);

    rootPanel.add(label, BorderLayout.WEST);
    rootPanel.add(fileLocation, BorderLayout.CENTER);
}
 
Example #20
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 #21
Source File: FieldPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void createComponent() {
  super.createComponent();
  TextFieldWithBrowseButton.MyDoClickAction doClickAction = getDoClickAction();
  if (doClickAction != null) {
    doClickAction.registerShortcut(getTextField());
  }

  myTextField.getDocument().addDocumentListener(new DocumentAdapter() {
    public void textChanged(DocumentEvent event) {
      if (getChangeListener() != null) {
        getChangeListener().run();
      }
    }
  });
}
 
Example #22
Source File: BashProjectSettingsPane.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
private void createUIComponents() {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleLocalFileDescriptor();
    descriptor.setTitle("Chooser Bash Interpreter...");

    this.interpreterPath = new TextFieldWithBrowseButton(null, this);
    this.interpreterPath.addBrowseFolderListener("Choose Bash Interpreter...", null, project, descriptor);
}
 
Example #23
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 #24
Source File: AbstractFieldPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void createComponent() {
  removeAll();
  setLayout(new GridBagLayout());

  if (myLabelText != null) {
    myLabel = new JLabel(myLabelText);
    this.add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
    myLabel.setLabelFor(myComponent);
  }

  this.add(myComponent, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

  if (myBrowseButtonActionListener != null) {
    FixedSizeButton browseButton = new FixedSizeButton(getComponent());
    myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(browseButton);
    browseButton.setFocusable(false);
    browseButton.addActionListener(myBrowseButtonActionListener);
    myButtons.add(browseButton);
    this.add(browseButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0));
  }
  if (myViewerDialogTitle != null) {
    final FixedSizeButton showViewerButton = new FixedSizeButton(getComponent());
    if (myBrowseButtonActionListener == null) {
      LOG.assertTrue(myDoClickAction == null);
      myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(showViewerButton);
    }
    showViewerButton.setFocusable(false);
    showViewerButton.setIcon(AllIcons.Actions.ShowViewer);
    showViewerButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        Viewer viewer = new Viewer();
        viewer.setTitle(myViewerDialogTitle);
        viewer.show();
      }
    });
    myButtons.add(showViewerButton);
    this.add(showViewerButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  }
}
 
Example #25
Source File: CppSupportLoader.java    From CppTools with Apache License 2.0 5 votes vote down vote up
static void setupEditPredefinesList(final String title, final TextFieldWithBrowseButton editPredefinesList) {
  editPredefinesList.getButton().setToolTipText(title);
  editPredefinesList.getButton().addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      StringListEditor pathesComponent = new MacrosListEditor(title, editPredefinesList.getText());
      pathesComponent.show();
      if (pathesComponent.isOK()) editPredefinesList.setText(pathesComponent.getText());
    }
  });
}
 
Example #26
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 #27
Source File: GuiUtils.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static JPanel constructFieldWithBrowseButton(final JComponent aComponent, final ActionListener aActionListener, int delta) {
  JPanel result = new JPanel(new GridBagLayout());
  result.add(aComponent, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,0));
  FixedSizeButton browseButton = new FixedSizeButton(aComponent.getPreferredSize().height - delta);//ignore border in case of browse button
  TextFieldWithBrowseButton.MyDoClickAction.addTo(browseButton, aComponent);
  result.add(browseButton, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0), 0,0));
  browseButton.addActionListener(aActionListener);

  return result;
}
 
Example #28
Source File: OptionsDialogWrapper.java    From intellij-thrift with Apache License 2.0 5 votes vote down vote up
public OptionsDialogWrapper(Project project, Generator generator) {
  super(project, false, IdeModalityType.IDE);
  myProject = project;
  myGenerator = generator;
  myOutputFolderChooser = new TextFieldWithBrowseButton(new JBTextField());
  setTitle("Generator configuration");
  getPeer().getWindow().setMinimumSize(new Dimension(400, 40));
  setResizable(false);
  init();
}
 
Example #29
Source File: NoSqlConfigurable.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private LabeledComponent<TextFieldWithBrowseButton> createShellPathField(DatabaseVendor databaseVendor) {
    LabeledComponent<TextFieldWithBrowseButton> shellPathField = new LabeledComponent<>();
    TextFieldWithBrowseButton component = new TextFieldWithBrowseButton();
    component.getChildComponent().setName("shellPathField");
    shellPathField.setComponent(component);
    shellPathField.getComponent().addBrowseFolderListener(String.format("%s CLI configuration", databaseVendor.name), "", null,
            new FileChooserDescriptor(true, false, false, false, false, false));

    shellPathField.getComponent().setText(configuration.getShellPath(databaseVendor));

    return shellPathField;
}
 
Example #30
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;
}