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));
}
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();
});
}
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;
}
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);
});
}
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;
}
Aggregations