Java Code Examples for com.intellij.ui.components.JBTextField#setEnabled()

The following examples show how to use com.intellij.ui.components.JBTextField#setEnabled() . 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: 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 2
Source File: BuckSettingsUI.java    From buck with Apache License 2.0 4 votes vote down vote up
private JPanel initInstallSettingsSection() {
  runAfterInstall = new JCheckBox("Run after install (-r)");
  multiInstallMode = new JCheckBox("Multi-install mode (-x)");
  uninstallBeforeInstall = new JCheckBox("Uninstall before installing (-u)");
  customizedInstallSetting = new JCheckBox("Use customized install setting:  ");
  customizedInstallSettingField = new JBTextField();
  customizedInstallSettingField.getEmptyText().setText(CUSTOMIZED_INSTALL_FLAGS_HINT);
  customizedInstallSettingField.setEnabled(false);

  JPanel panel = new JPanel(new GridBagLayout());
  panel.setBorder(IdeBorderFactory.createTitledBorder("Install Settings", true));

  GridBagConstraints leftSide = new GridBagConstraints();
  leftSide.fill = GridBagConstraints.NONE;
  leftSide.anchor = GridBagConstraints.LINE_START;
  leftSide.gridx = 0;
  leftSide.weightx = 0;

  GridBagConstraints rightSide = new GridBagConstraints();
  rightSide.fill = GridBagConstraints.HORIZONTAL;
  rightSide.anchor = GridBagConstraints.LINE_START;
  leftSide.gridx = 1;
  rightSide.weightx = 1;

  leftSide.gridy = rightSide.gridy = 0;
  panel.add(runAfterInstall, leftSide);

  leftSide.gridy = rightSide.gridy = 1;
  panel.add(multiInstallMode, leftSide);

  leftSide.gridy = rightSide.gridy = 2;
  panel.add(uninstallBeforeInstall, leftSide);

  leftSide.gridy = rightSide.gridy = 3;
  panel.add(customizedInstallSetting, leftSide);
  panel.add(customizedInstallSettingField, rightSide);

  customizedInstallSetting.addItemListener(
      e -> {
        if (e.getStateChange() == ItemEvent.SELECTED) {
          customizedInstallSettingField.setEnabled(true);
          runAfterInstall.setEnabled(false);
          multiInstallMode.setEnabled(false);
          uninstallBeforeInstall.setEnabled(false);
        } else {
          customizedInstallSettingField.setEnabled(false);
          runAfterInstall.setEnabled(true);
          multiInstallMode.setEnabled(true);
          uninstallBeforeInstall.setEnabled(true);
        }
      });
  return panel;
}