use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class CodeFragmentTableCellEditorBase method createEditorField.
protected EditorTextField createEditorField(Document document) {
EditorTextField field = new EditorTextField(document, myProject, myFileType) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
field.setBorder(new EmptyBorder(1, 1, 1, 1));
return field;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class CodeFragmentTableCellRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, final boolean hasFocus, int row, int column) {
PsiCodeFragment codeFragment = (PsiCodeFragment) value;
final EditorTextField editorTextField;
Document document = null;
if (codeFragment != null) {
document = PsiDocumentManager.getInstance(myProject).getDocument(codeFragment);
editorTextField = new EditorTextField(document, myProject, myFileType) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
} else {
editorTextField = new EditorTextField("", myProject, myFileType) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
}
if (!table.isShowing()) {
editorTextField.ensureWillComputePreferredSize();
}
editorTextField.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
editorTextField.setBorder((hasFocus || isSelected) ? BorderFactory.createLineBorder(table.getSelectionBackground()) : IdeBorderFactory.createEmptyBorder(1));
if (isSelected && document != null) {
final Color bg = table.getSelectionBackground();
final Color fg = table.getSelectionForeground();
editorTextField.setBackground(bg);
editorTextField.setForeground(fg);
editorTextField.setAsRendererWithSelection(bg, fg);
}
return editorTextField;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class NameSuggestionsField method createTextFieldForName.
private JComponent createTextFieldForName(String[] nameSuggestions, FileType fileType) {
final String text;
if (nameSuggestions != null && nameSuggestions.length > 0 && nameSuggestions[0] != null) {
text = nameSuggestions[0];
} else {
text = "";
}
EditorTextField field = new EditorTextField(text, myProject, fileType);
field.selectAll();
return field;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class StringTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
final EditorTextField editorTextField = new EditorTextField((String) value, myProject, StdFileTypes.JAVA) {
@Override
protected boolean shouldHaveBorder() {
return false;
}
};
myDocument = editorTextField.getDocument();
if (myDocument != null) {
for (DocumentListener listener : myListeners) {
editorTextField.addDocumentListener(listener);
}
}
return editorTextField;
}
use of com.intellij.ui.EditorTextField in project intellij-community by JetBrains.
the class PsiClassTableCellEditor method getTableCellEditorComponent.
public final Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
final Document document = JavaReferenceEditorUtil.createDocument(value == null ? "" : (String) value, myProject, true);
myEditor = new EditorTextField(document, myProject, StdFileTypes.JAVA) {
protected boolean shouldHaveBorder() {
return false;
}
public void addNotify() {
super.addNotify();
final JComponent editorComponent = getEditor().getContentComponent();
editorComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER");
editorComponent.getActionMap().put("ENTER", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
stopCellEditing();
}
});
}
};
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(myEditor);
final FixedSizeButton button = new FixedSizeButton(myEditor);
panel.add(button, BorderLayout.EAST);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createInheritanceClassChooser(UIBundle.message("choose.class"), mySearchScope, null, true, true, Conditions.alwaysTrue());
chooser.showDialog();
final PsiClass psiClass = chooser.getSelected();
if (psiClass != null) {
myEditor.setText(psiClass.getQualifiedName());
}
}
});
panel.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
if (!e.isTemporary() && myEditor != null) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myEditor, true);
});
}
}
public void focusLost(FocusEvent e) {
}
});
myEditor.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
}
public void focusLost(FocusEvent e) {
if (!e.isTemporary()) {
stopCellEditing();
}
}
});
return panel;
}
Aggregations