com.intellij.openapi.ui.TextComponentAccessor Java Examples

The following examples show how to use com.intellij.openapi.ui.TextComponentAccessor. 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: ImportFlutterModuleStep.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 #2
Source File: ImportFlutterModuleStep.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 #3
Source File: BaseCppRunSettingsEditor.java    From CppTools with Apache License 2.0 6 votes vote down vote up
protected void setupCommonUI(Project project) {
  ComboboxWithBrowseButton myExecutableName = getExecutableName();
  myExecutableName.getComboBox().setEditable(true);
  myExecutableName.addBrowseFolderListener(
    CHOOSE_EXECUTABLE_TITLE,
    CHOOSE_EXECUTABLE_TITLE,
    project,
    new FileChooserDescriptor(true, false, false, false, false, false) {
      @Override
      public boolean isFileSelectable(VirtualFile file) {
        return super.isFileSelectable(file);
      }
    },
    TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT
  );
}
 
Example #4
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 #5
Source File: GaugeConfig.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
JComponent createEditor() {
    FileChooserDescriptor homeFileDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
    homePath.addBrowseFolderListener(
            "",
            "Gauge Home Path",
            null,
            homeFileDescriptor,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);

    FileChooserDescriptor gaugePathFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
    gaugePath.addBrowseFolderListener(
            "",
            "Gauge Binary Path",
            null,
            gaugePathFileDescriptor,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);

    return configWindow;
}
 
Example #6
Source File: ModuleSelector.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private static TextComponentAccessor<EditorTextField> getTextComponentAccessor() {
    return new TextComponentAccessor<EditorTextField>() {
        @Override
        public String getText(EditorTextField component) {
            String text = component.getText();
            final VirtualFile file = VirtualFileManager.getInstance()
                            .findFileByUrl(VfsUtil.pathToUrl(text.replace(File.separatorChar, '/')));
            if (file != null && !file.isDirectory()) {
                final VirtualFile parent = file.getParent();
                assert parent != null;
                return parent.getPresentableUrl();
            }
            return text;
        }

        @Override
        public void setText(EditorTextField component, String text) {
            component.setText(text);
        }
    };
}
 
Example #7
Source File: CppRunSettingsEditor.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public CppRunSettingsEditor(Project project) {
  setupCommonUI(project);
  workingDirectoryTextField.addBrowseFolderListener(
    CHOOSE_WORKING_DIRECTORY_TITLE,
    CHOOSE_WORKING_DIRECTORY_TITLE,
    project,
    new FileChooserDescriptor(false, true, false, false, false, false),
    TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT
  );
}
 
Example #8
Source File: EditLogPatternDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
  myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0);
    }
  });
  return myWholePanel;
}
 
Example #9
Source File: TextFieldWithHistoryWithBrowseButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addBrowseFolderListener(@Nullable String title,
                                    @Nullable String description,
                                    @Nullable Project project,
                                    FileChooserDescriptor fileChooserDescriptor,
                                    TextComponentAccessor<TextFieldWithHistory> accessor,
                                    boolean autoRemoveOnHide) {
  super.addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor, autoRemoveOnHide);
  FileChooserFactory.getInstance().installFileCompletion(getChildComponent().getTextEditor(), fileChooserDescriptor, false, project);
}
 
Example #10
Source File: TextFieldWithHistoryWithBrowseButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void addBrowseFolderListener(@Nullable String title,
                                    @Nullable String description,
                                    @Nullable Project project,
                                    FileChooserDescriptor fileChooserDescriptor,
                                    TextComponentAccessor<TextFieldWithHistory> accessor) {
  super.addBrowseFolderListener(title, description, project, fileChooserDescriptor, accessor);
  FileChooserFactory.getInstance().installFileCompletion(getChildComponent().getTextEditor(), fileChooserDescriptor, false, project);
}
 
Example #11
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 #12
Source File: ConsoleOutputFileSettingsUi.java    From intellij with 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()));
}
 
Example #13
Source File: FileSelectorWithStoredHistory.java    From intellij with Apache License 2.0 5 votes vote down vote up
private FileSelectorWithStoredHistory(TextFieldWithStoredHistory textField, String title) {
  super(textField, null);

  addBrowseFolderListener(
      title,
      "",
      null,
      BrowseFilesListener.SINGLE_FILE_DESCRIPTOR,
      TextComponentAccessor.TEXT_FIELD_WITH_STORED_HISTORY_WHOLE_TEXT);
}
 
Example #14
Source File: FlutterSmallIDEGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #15
Source File: FlutterSmallIDEGeneratorPeer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #16
Source File: AlternativeJREPanel.java    From intellij-xquery with 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 #17
Source File: DojoSettingsConfigurable.java    From needsmoredojo with Apache License 2.0 4 votes vote down vote up
public ProjectSourcesChosen(@Nullable String title, @Nullable String description, FileChooserDescriptor fileChooserDescriptor) {
    super(title, description, projectSourcesText, null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
}
 
Example #18
Source File: DojoSettingsConfigurable.java    From needsmoredojo with Apache License 2.0 4 votes vote down vote up
public DojoSourcesChosen(@Nullable String title, @Nullable String description, FileChooserDescriptor fileChooserDescriptor) {
    super(title, description, dojoSourcesText, null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
}
 
Example #19
Source File: ConfigurationFilePanel.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
public ConfigurationFilePanel() {
    configFile.addBrowseFolderListener("Choose file", null, null, createSingleFileNoJarsDescriptor(),
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT, false);
    configFile.getTextField().setName(CONFIG_FILE);
    configurationEnabled.addActionListener(getConfigEnabledListener());
}
 
Example #20
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 #21
Source File: ComboboxWithBrowseButton.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void addBrowseFolderListener(Project project, FileChooserDescriptor descriptor) {
  addBrowseFolderListener(null, null, project, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
}
 
Example #22
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 #23
Source File: MoveFilesOrDirectoriesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true);

  myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
  final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
  if (recentEntries != null) {
    myTargetDirectoryField.getChildComponent().setHistory(recentEntries);
  }
  final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"),
                                                 RefactoringBundle.message("the.file.will.be.moved.to.this.directory"),
                                                 myProject,
                                                 descriptor,
                                                 TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
  final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor();
  FileChooserFactory.getInstance().installFileCompletion(textField, descriptor, true, getDisposable());
  textField.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      validateOKButton();
    }
  });
  myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH);
  Disposer.register(getDisposable(), myTargetDirectoryField);

  String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));

  myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references"));
  myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE);

  myOpenInEditorCb = new NonFocusableCheckBox("Open moved files in editor");
  myOpenInEditorCb.setSelected(isOpenInEditor());

  return FormBuilder.createFormBuilder().addComponent(myNameLabel)
          .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP)
          .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText))
          .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP)
          .addComponentToRightColumn(myOpenInEditorCb, UIUtil.LARGE_VGAP)
          .getPanel();
}
 
Example #24
Source File: CopyFilesOrDirectoriesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected JComponent createNorthPanel() {
  myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true);
  final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel).addVerticalGap(
    UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP);
  DocumentListener documentListener = new DocumentAdapter() {
    @Override
    public void textChanged(DocumentEvent event) {
      validateOKButton();
    }
  };

  if (myShowNewNameField) {
    myNewNameField = new JTextField();
    myNewNameField.getDocument().addDocumentListener(documentListener);
    formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField);
  }

  if (myShowDirectoryField) {
    myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton();
    myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH);
    final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS);
    if (recentEntries != null) {
      myTargetDirectoryField.getChildComponent().setHistory(recentEntries);
    }
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"),
                                                   RefactoringBundle.message("the.file.will.be.copied.to.this.directory"),
                                                   myProject, descriptor,
                                                   TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);
    myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() {
      @Override
      protected void textChanged(DocumentEvent e) {
        validateOKButton();
      }
    });
    formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField);

    String shortcutText =
      KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION));
    formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText));
  }

  final JPanel wrapper = new JPanel(new BorderLayout());
  wrapper.add(myOpenFilesInEditor, BorderLayout.EAST);
  formBuilder.addComponent(wrapper);
  return formBuilder.getPanel();
}