private void initEditor() { myEditor = new EditorComboBoxEditor(getProject(), getEditorsProvider().getFileType()) { @Override public void setItem(Object anObject) { if (anObject == null) { anObject = XExpressionImpl.EMPTY_EXPRESSION; } XExpression expression = (XExpression) anObject; getEditorComponent() .setNewDocumentAndFileType(getFileType(expression), createDocument(expression)); } @Override protected void onEditorCreate(EditorEx editor) { editor.putUserData(DebuggerCopyPastePreprocessor.REMOVE_NEWLINES_ON_PASTE, true); editor.getColorsScheme().setEditorFontSize(myComboBox.getFont().getSize()); } }; myEditor.getEditorComponent().setFontInheritedFromLAF(false); myComboBox.setEditor(myEditor); // myEditor.setItem(myExpression); myComboBox.setRenderer(new EditorComboBoxRenderer(myEditor)); myComboBox.setMaximumRowCount(XDebuggerHistoryManager.MAX_RECENT_EXPRESSIONS); }
@Override protected void doSetText(XExpression text) { if (myComboBox.getItemCount() > 0) { myComboBox.setSelectedIndex(0); } // if (myComboBox.isEditable()) { myEditor.setItem(text); // } myExpression = text; }
@Override public XExpression getExpression() { Object document = myEditor.getItem(); if (document instanceof Document) { // sometimes null on Mac return getEditorsProvider() .createExpression( getProject(), (Document) document, myExpression.getLanguage(), myExpression.getMode()); } return myExpression; }
public JComponent getEditorComponent() { return myEditor.getEditorComponent(); }
@Nullable public Editor getEditor() { return myEditor.getEditor(); }