Search in sources :

Example 1 with VariantsCompletionAction

use of com.intellij.find.editorHeaderActions.VariantsCompletionAction in project intellij-community by JetBrains.

the class SearchReplaceComponent method updateReplaceComponent.

private void updateReplaceComponent(@NotNull String textToSet) {
    if (!updateTextComponent(false)) {
        String existingText = myReplaceTextComponent.getText();
        if (!existingText.equals(textToSet)) {
            myReplaceTextComponent.setText(textToSet);
            if (existingText.length() == 0)
                myReplaceTextComponent.selectAll();
        }
        return;
    }
    myReplaceTextComponent.setText(textToSet);
    myReplaceTextComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            ApplicationManager.getApplication().invokeLater(() -> replaceFieldDocumentChanged());
        }
    });
    if (!isMultiline()) {
        installReplaceOnEnterAction(myReplaceTextComponent);
    }
    new VariantsCompletionAction(myReplaceTextComponent);
    myReplaceFieldWrapper.revalidate();
    myReplaceFieldWrapper.repaint();
}
Also used : VariantsCompletionAction(com.intellij.find.editorHeaderActions.VariantsCompletionAction) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Example 2 with VariantsCompletionAction

use of com.intellij.find.editorHeaderActions.VariantsCompletionAction in project intellij-community by JetBrains.

the class SearchReplaceComponent method updateSearchComponent.

private void updateSearchComponent(@NotNull String textToSet) {
    if (!updateTextComponent(true)) {
        String existingText = mySearchTextComponent.getText();
        if (!existingText.equals(textToSet)) {
            mySearchTextComponent.setText(textToSet);
            // textToSet should be selected even if we have no selection before (if we have the selection then setText will remain it)
            if (existingText.length() == 0)
                mySearchTextComponent.selectAll();
        }
        return;
    }
    mySearchTextComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            ApplicationManager.getApplication().invokeLater(() -> searchFieldDocumentChanged());
        }
    });
    mySearchTextComponent.registerKeyboardAction(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (StringUtil.isEmpty(mySearchTextComponent.getText())) {
                close();
            } else {
                IdeFocusManager.getInstance(myProject).requestFocus(myTargetComponent, true);
                addTextToRecent(mySearchTextComponent);
            }
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, SystemInfo.isMac ? META_DOWN_MASK : CTRL_DOWN_MASK), JComponent.WHEN_FOCUSED);
    // It registers a shortcut set automatically on construction
    new VariantsCompletionAction(mySearchTextComponent);
}
Also used : VariantsCompletionAction(com.intellij.find.editorHeaderActions.VariantsCompletionAction) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

VariantsCompletionAction (com.intellij.find.editorHeaderActions.VariantsCompletionAction)2 DocumentAdapter (com.intellij.ui.DocumentAdapter)2 DocumentEvent (javax.swing.event.DocumentEvent)2