A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://plugins.jetbrains.com/docs/intellij/editor-components.html below:

Editor Components | IntelliJ Platform Plugin SDK

Editor Components EditorTextField

Compared to Swing JTextArea, the IntelliJ Platform's editor component has a ton of advantages: syntax highlighting support, code completion, code folding, and much more. Editors are normally displayed in editor tabs, but they can be embedded in dialogs or tool windows, too. This is enabled by the EditorTextField component.

The following attributes can be specified:

Further customizations are possible by subclassing and overriding createEditor() and applying EditorCustomization. Several commonly needed customization implementations exist, including:

EditorTextField has a number of subclasses that can be used as needed for additional features.

If you want to use an editor as an input field in a dialog, then consider using LanguageTextField as it provides a more accessible API.

Providing Completion

If you want to add autocompletion to the editor, then use TextFieldWithCompletion. The constructor takes as an argument a class that implements TextCompletionProvider to provide autocompletion variants. Use TextFieldCompletionProvider to create your own provider. For this, override addCompletionVariants() and add completion variants using CompletionResultSet.addElement().

See also TextFieldCompletionProviderDumbAware for completion even at the indexing stage.

See Code Completion to learn more about completion.

Java

If your plugin depends on Java functionality, see Java.

A common use case for EditorTextField is entering the name of a Java class or package. This can be accomplished with the following steps:

PsiFile psiFile = PsiDocumentManager.getInstance(project) .getPsiFile(editor.getDocument()); PsiElement element = psiFile.findElementAt(editor.getCaretModel().getOffset()); PsiExpressionCodeFragment code = JavaCodeFragmentFactory.getInstance(project) .createExpressionCodeFragment("", element, null, true); Document document = PsiDocumentManager.getInstance(project).getDocument(code); EditorTextField editorTextField = new EditorTextField(document, project, JavaFileType.INSTANCE);

Tips

29 April 2025


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4