Search in sources :

Example 1 with TextFieldWithHistoryWithBrowseButton

use of com.intellij.ui.TextFieldWithHistoryWithBrowseButton in project intellij-plugins by JetBrains.

the class KarmaRunConfigurationEditor method createConfigurationFileTextField.

@NotNull
private static TextFieldWithHistoryWithBrowseButton createConfigurationFileTextField(@NotNull final Project project) {
    TextFieldWithHistoryWithBrowseButton textFieldWithHistoryWithBrowseButton = new TextFieldWithHistoryWithBrowseButton();
    final TextFieldWithHistory textFieldWithHistory = textFieldWithHistoryWithBrowseButton.getChildComponent();
    textFieldWithHistory.setHistorySize(-1);
    textFieldWithHistory.setMinimumAndPreferredWidth(0);
    SwingHelper.addHistoryOnExpansion(textFieldWithHistory, () -> {
        List<VirtualFile> newFiles = KarmaUtil.listPossibleConfigFilesInProject(project);
        List<String> newFilePaths = ContainerUtil.map(newFiles, file -> FileUtil.toSystemDependentName(file.getPath()));
        Collections.sort(newFilePaths);
        return newFilePaths;
    });
    SwingHelper.installFileCompletionAndBrowseDialog(project, textFieldWithHistoryWithBrowseButton, KarmaBundle.message("runConfiguration.config_file.browse_dialog.title"), FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
    return textFieldWithHistoryWithBrowseButton;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) TextFieldWithHistory(com.intellij.ui.TextFieldWithHistory) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with TextFieldWithHistoryWithBrowseButton

use of com.intellij.ui.TextFieldWithHistoryWithBrowseButton in project intellij-plugins by JetBrains.

the class PhoneGapUtil method createPhoneGapExecutableTextField.

@NotNull
public static TextFieldWithHistoryWithBrowseButton createPhoneGapExecutableTextField(@Nullable Project project) {
    TextFieldWithHistoryWithBrowseButton field = SwingHelper.createTextFieldWithHistoryWithBrowseButton(project, PhoneGapBundle.message("phonegap.conf.executable.name"), FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(), () -> getDefaultExecutablePaths());
    String executablePath = PhoneGapSettings.getInstance().getExecutablePath();
    setDefaultValue(field, executablePath);
    return field;
}
Also used : TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with TextFieldWithHistoryWithBrowseButton

use of com.intellij.ui.TextFieldWithHistoryWithBrowseButton in project intellij-community by JetBrains.

the class CopyFilesOrDirectoriesDialog method createNorthPanel.

@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 JBTextField();
        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) {
            getTargetDirectoryComponent().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);
        getTargetDirectoryComponent().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();
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) DocumentListener(javax.swing.event.DocumentListener) TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) DocumentAdapter(com.intellij.ui.DocumentAdapter) JBTextField(com.intellij.ui.components.JBTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Example 4 with TextFieldWithHistoryWithBrowseButton

use of com.intellij.ui.TextFieldWithHistoryWithBrowseButton in project intellij-community by JetBrains.

the class MoveFilesOrDirectoriesDialog method createNorthPanel.

@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();
}
Also used : TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) NonFocusableCheckBox(com.intellij.ui.NonFocusableCheckBox) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 5 with TextFieldWithHistoryWithBrowseButton

use of com.intellij.ui.TextFieldWithHistoryWithBrowseButton in project intellij-plugins by JetBrains.

the class PhoneGapUtil method createPhoneGapWorkingDirectoryField.

@NotNull
public static TextFieldWithHistoryWithBrowseButton createPhoneGapWorkingDirectoryField(@Nullable final Project project) {
    TextFieldWithHistoryWithBrowseButton field = SwingHelper.createTextFieldWithHistoryWithBrowseButton(project, PhoneGapBundle.message("phonegap.conf.work.dir.name"), FileChooserDescriptorFactory.createSingleFolderDescriptor(), () -> getDefaultWorkingDirectory(project));
    setDefaultValue(field, PhoneGapSettings.getInstance().getWorkingDirectory(project));
    return field;
}
Also used : TextFieldWithHistoryWithBrowseButton(com.intellij.ui.TextFieldWithHistoryWithBrowseButton) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TextFieldWithHistoryWithBrowseButton (com.intellij.ui.TextFieldWithHistoryWithBrowseButton)5 NotNull (org.jetbrains.annotations.NotNull)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 DocumentAdapter (com.intellij.ui.DocumentAdapter)2 DocumentEvent (javax.swing.event.DocumentEvent)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NonFocusableCheckBox (com.intellij.ui.NonFocusableCheckBox)1 TextFieldWithHistory (com.intellij.ui.TextFieldWithHistory)1 JBTextField (com.intellij.ui.components.JBTextField)1 FormBuilder (com.intellij.util.ui.FormBuilder)1 DocumentListener (javax.swing.event.DocumentListener)1