use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class PyDataViewerPanel method createEditorField.
@NotNull
private EditorTextField createEditorField() {
return new EditorTextField(EditorFactory.getInstance().createDocument(""), myProject, PythonFileType.INSTANCE, false, true) {
@Override
protected EditorEx createEditor() {
EditorEx editor = super.createEditor();
editor.getContentComponent().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
apply(mySliceTextField.getText());
}
}
});
return editor;
}
};
}
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 PyIntroduceDialog method setUpNameComboBox.
private void setUpNameComboBox(Collection<String> possibleNames) {
final EditorComboBoxEditor comboEditor = new StringComboboxEditor(myProject, PythonFileType.INSTANCE, myNameComboBox);
myNameComboBox.setEditor(comboEditor);
myNameComboBox.setRenderer(new EditorComboBoxRenderer(comboEditor));
myNameComboBox.setEditable(true);
myNameComboBox.setMaximumRowCount(8);
myNameComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
});
((EditorTextField) myNameComboBox.getEditor().getEditorComponent()).addDocumentListener(new DocumentListener() {
public void beforeDocumentChange(DocumentEvent event) {
}
public void documentChanged(DocumentEvent event) {
updateControls();
}
});
myContentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myNameComboBox, true);
});
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.ALT_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
for (String possibleName : possibleNames) {
myNameComboBox.addItem(possibleName);
}
}
Aggregations