Search in sources :

Example 6 with EditorTextField

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

the class ClassNameInputDialog method createUIComponents.

private void createUIComponents() {
    myEditorTextField1 = new EditorTextField("", myProject, StdFileTypes.JAVA);
    final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(myProject);
    PsiPackage defaultPackage = JavaPsiFacade.getInstance(myProject).findPackage("");
    final PsiCodeFragment fragment = factory.createReferenceCodeFragment("", defaultPackage, true, true);
    myEditorTextField1.setDocument(PsiDocumentManager.getInstance(myProject).getDocument(fragment));
}
Also used : EditorTextField(com.intellij.ui.EditorTextField)

Example 7 with EditorTextField

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

the class EditorTextFieldControl method navigate.

@Override
public void navigate(final DomElement element) {
    final EditorTextField field = getEditorTextField(getComponent());
    SwingUtilities.invokeLater(() -> {
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(field, true);
        });
        field.selectAll();
    });
}
Also used : EditorTextField(com.intellij.ui.EditorTextField)

Example 8 with EditorTextField

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

the class EditorTextFieldControl method createMainComponent.

@Override
protected T createMainComponent(T boundedComponent) {
    final Project project = getProject();
    boundedComponent = createMainComponent(boundedComponent, project);
    final EditorTextField editorTextField = getEditorTextField(boundedComponent);
    editorTextField.setSupplementary(true);
    editorTextField.getDocument().addDocumentListener(myListener);
    return boundedComponent;
}
Also used : Project(com.intellij.openapi.project.Project) EditorTextField(com.intellij.ui.EditorTextField)

Example 9 with EditorTextField

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

the class EditorTextFieldControl method updateComponent.

@Override
protected void updateComponent() {
    final DomElement domElement = getDomElement();
    if (domElement == null || !domElement.isValid())
        return;
    final EditorTextField textField = getEditorTextField(getComponent());
    final Project project = getProject();
    ApplicationManager.getApplication().invokeLater(() -> {
        if (!project.isOpen())
            return;
        if (!getDomWrapper().isValid())
            return;
        final DomElement domElement1 = getDomElement();
        if (domElement1 == null || !domElement1.isValid())
            return;
        final DomElementAnnotationsManager manager = DomElementAnnotationsManager.getInstance(project);
        final DomElementsProblemsHolder holder = manager.getCachedProblemHolder(domElement1);
        final List<DomElementProblemDescriptor> errorProblems = holder.getProblems(domElement1);
        final List<DomElementProblemDescriptor> warningProblems = new ArrayList<>(holder.getProblems(domElement1, true, HighlightSeverity.WARNING));
        warningProblems.removeAll(errorProblems);
        Color background = getDefaultBackground();
        if (errorProblems.size() > 0 && textField.getText().trim().length() == 0) {
            background = getErrorBackground();
        } else if (warningProblems.size() > 0) {
            background = getWarningBackground();
        }
        final Editor editor = textField.getEditor();
        if (editor != null) {
            final MarkupModel markupModel = editor.getMarkupModel();
            markupModel.removeAllHighlighters();
            if (!errorProblems.isEmpty() && editor.getDocument().getLineCount() > 0) {
                final TextAttributes attributes = SimpleTextAttributes.ERROR_ATTRIBUTES.toTextAttributes();
                attributes.setEffectType(EffectType.WAVE_UNDERSCORE);
                attributes.setEffectColor(attributes.getForegroundColor());
                markupModel.addLineHighlighter(0, 0, attributes);
                editor.getContentComponent().setToolTipText(errorProblems.get(0).getDescriptionTemplate());
            }
        }
        textField.setBackground(background);
    });
}
Also used : Project(com.intellij.openapi.project.Project) DomElementsProblemsHolder(com.intellij.util.xml.highlighting.DomElementsProblemsHolder) DomElement(com.intellij.util.xml.DomElement) EditorTextField(com.intellij.ui.EditorTextField) DomElementProblemDescriptor(com.intellij.util.xml.highlighting.DomElementProblemDescriptor) ArrayList(java.util.ArrayList) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) Editor(com.intellij.openapi.editor.Editor) MarkupModel(com.intellij.openapi.editor.markup.MarkupModel) DomElementAnnotationsManager(com.intellij.util.xml.highlighting.DomElementAnnotationsManager)

Example 10 with EditorTextField

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

the class ParameterNameHintsConfigurable method createEditorField.

@NotNull
private static EditorTextField createEditorField(@NotNull String text) {
    Document document = EditorFactory.getInstance().createDocument(text);
    EditorTextField field = new EditorTextField(document, null, FileTypes.PLAIN_TEXT, false, false);
    field.setPreferredSize(new Dimension(200, 350));
    field.addSettingsProvider(editor -> {
        editor.setVerticalScrollbarVisible(true);
        editor.setHorizontalScrollbarVisible(true);
        editor.getSettings().setAdditionalLinesCount(2);
    });
    return field;
}
Also used : EditorTextField(com.intellij.ui.EditorTextField) Document(com.intellij.openapi.editor.Document) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

EditorTextField (com.intellij.ui.EditorTextField)47 Document (com.intellij.openapi.editor.Document)11 NotNull (org.jetbrains.annotations.NotNull)11 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)9 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)7 EditorEx (com.intellij.openapi.editor.ex.EditorEx)5 EditorComboBoxEditor (com.intellij.ui.EditorComboBoxEditor)5 EditorComboBoxRenderer (com.intellij.ui.EditorComboBoxRenderer)5 StringComboboxEditor (com.intellij.ui.StringComboboxEditor)5 JBLabel (com.intellij.ui.components.JBLabel)4 Editor (com.intellij.openapi.editor.Editor)3 DocumentListener (com.intellij.openapi.editor.event.DocumentListener)3 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 Project (com.intellij.openapi.project.Project)3 ComboBox (com.intellij.openapi.ui.ComboBox)3 FixedSizeButton (com.intellij.openapi.ui.FixedSizeButton)3 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)2 InlayParameterHintsProvider (com.intellij.codeInsight.hints.InlayParameterHintsProvider)2 Language (com.intellij.lang.Language)2