Search in sources :

Example 21 with EditorFactory

use of com.intellij.openapi.editor.EditorFactory in project intellij-community by JetBrains.

the class IpnbEditorUtil method createPythonCodeEditor.

public static Editor createPythonCodeEditor(@NotNull final Project project, @NotNull final IpnbCodeSourcePanel codeSourcePanel) {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    assert editorFactory != null;
    final String text = codeSourcePanel.getCell().getSourceAsString().trim();
    final Module module = ProjectRootManagerEx.getInstanceEx(project).getFileIndex().getModuleForFile(codeSourcePanel.getIpnbCodePanel().getFileEditor().getVirtualFile());
    final IpnbPyFragment fragment = new IpnbPyFragment(project, text, true, codeSourcePanel);
    fragment.putUserData(ModuleUtilCore.KEY_MODULE, module);
    final Document document = PsiDocumentManager.getInstance(project).getDocument(fragment);
    assert document != null;
    EditorEx editor = (EditorEx) editorFactory.createEditor(document, project, fragment.getVirtualFile(), false);
    setupEditor(editor);
    return editor;
}
Also used : EditorFactory(com.intellij.openapi.editor.EditorFactory) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Module(com.intellij.openapi.module.Module) Document(com.intellij.openapi.editor.Document) IpnbPyFragment(org.jetbrains.plugins.ipnb.psi.IpnbPyFragment)

Aggregations

EditorFactory (com.intellij.openapi.editor.EditorFactory)21 Document (com.intellij.openapi.editor.Document)15 EditorEx (com.intellij.openapi.editor.ex.EditorEx)11 Editor (com.intellij.openapi.editor.Editor)10 Disposable (com.intellij.openapi.Disposable)5 EditorSettings (com.intellij.openapi.editor.EditorSettings)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 NotNull (org.jetbrains.annotations.NotNull)3 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)2 EmptyBorder (javax.swing.border.EmptyBorder)2 CodeStyleFacade (com.intellij.codeStyle.CodeStyleFacade)1 CommanderPanel (com.intellij.ide.commander.CommanderPanel)1 XmlFileHighlighter (com.intellij.ide.highlighter.XmlFileHighlighter)1 StartupManagerImpl (com.intellij.ide.startup.impl.StartupManagerImpl)1 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)1 StructureViewModel (com.intellij.ide.structureView.StructureViewModel)1 TreeBasedStructureViewBuilder (com.intellij.ide.structureView.TreeBasedStructureViewBuilder)1 FileStructureDialog (com.intellij.ide.util.FileStructureDialog)1 com.intellij.lang (com.intellij.lang)1 Language (com.intellij.lang.Language)1