Search in sources :

Example 6 with EditorFactory

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

the class CallerChooserBase method createEditor.

private Editor createEditor() {
    final EditorFactory editorFactory = EditorFactory.getInstance();
    final Document document = editorFactory.createDocument("");
    final Editor editor = editorFactory.createViewer(document, myProject);
    ((EditorEx) editor).setHighlighter(HighlighterFactory.createHighlighter(myProject, myFileName));
    return editor;
}
Also used : EditorFactory(com.intellij.openapi.editor.EditorFactory) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Document(com.intellij.openapi.editor.Document) Editor(com.intellij.openapi.editor.Editor)

Example 7 with EditorFactory

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

the class QuickDocOnMouseOverManager method setEnabled.

/**
   * Instructs the manager to enable or disable 'show quick doc automatically when the mouse goes over an editor element' mode.
   *
   * @param enabled  flag that identifies if quick doc should be automatically shown
   */
public void setEnabled(boolean enabled) {
    myEnabled = enabled;
    myApplicationActive = enabled;
    if (!enabled) {
        closeQuickDocIfPossible();
        myAlarm.cancelAllRequests();
    }
    EditorFactory factory = EditorFactory.getInstance();
    if (factory == null) {
        return;
    }
    for (Editor editor : factory.getAllEditors()) {
        if (enabled) {
            registerListeners(editor);
        } else {
            unRegisterListeners(editor);
        }
    }
}
Also used : EditorFactory(com.intellij.openapi.editor.EditorFactory) Editor(com.intellij.openapi.editor.Editor)

Example 8 with EditorFactory

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

the class AnalyzeStacktraceUtil method createEditorPanel.

public static StacktraceEditorPanel createEditorPanel(Project project, @NotNull Disposable parentDisposable) {
    EditorFactory editorFactory = EditorFactory.getInstance();
    Document document = editorFactory.createDocument("");
    Editor editor = editorFactory.createEditor(document, project);
    EditorSettings settings = editor.getSettings();
    settings.setFoldingOutlineShown(false);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(false);
    settings.setRightMarginShown(false);
    StacktraceEditorPanel editorPanel = new StacktraceEditorPanel(project, editor);
    editorPanel.setPreferredSize(JBUI.size(600, 400));
    Disposer.register(parentDisposable, editorPanel);
    return editorPanel;
}
Also used : EditorFactory(com.intellij.openapi.editor.EditorFactory) EditorSettings(com.intellij.openapi.editor.EditorSettings) Document(com.intellij.openapi.editor.Document) Editor(com.intellij.openapi.editor.Editor)

Example 9 with EditorFactory

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

the class FileStructureDialogTest method testFileStructureForClass.

public void testFileStructureForClass() throws Exception {
    final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(getPackageDirectory());
    assertNotNull(aPackage);
    final PsiClass psiClass = aPackage.getClasses()[0];
    final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
    assertNotNull(virtualFile);
    final StructureViewBuilder structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(virtualFile.getFileType(), virtualFile, myProject);
    assertNotNull(structureViewBuilder);
    final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder) structureViewBuilder).createStructureViewModel(null);
    final EditorFactory factory = EditorFactory.getInstance();
    assertNotNull(factory);
    final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
    assertNotNull(document);
    final Editor editor = factory.createEditor(document, myProject);
    try {
        final FileStructureDialog dialog = new FileStructureDialog(structureViewModel, editor, myProject, psiClass, new Disposable() {

            @Override
            public void dispose() {
                structureViewModel.dispose();
            }
        }, true);
        try {
            final CommanderPanel panel = dialog.getPanel();
            assertListsEqual((ListModel) panel.getModel(), "Inner1\n" + "Inner2\n" + "__method(): void\n" + "_myField1: int\n" + "_myField2: String\n");
        } finally {
            dialog.close(0);
        }
    } finally {
        factory.releaseEditor(editor);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) EditorFactory(com.intellij.openapi.editor.EditorFactory) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) Document(com.intellij.openapi.editor.Document) CommanderPanel(com.intellij.ide.commander.CommanderPanel) FileStructureDialog(com.intellij.ide.util.FileStructureDialog) Editor(com.intellij.openapi.editor.Editor)

Example 10 with EditorFactory

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

the class EditorPlaceHolder method setContent.

public void setContent(final DiffContent content) {
    runRegisteredDisposables();
    myContent = content;
    if (myContent != null) {
        Document document = myContent.getDocument();
        if (myContent.isBinary() || document == null || myContent.getContentType() instanceof UIBasedFileType) {
            final VirtualFile file = myContent.getFile();
            if (file != null) {
                final FileEditorProvider[] providers = FileEditorProviderManager.getInstance().getProviders(getProject(), file);
                if (providers.length > 0) {
                    myFileEditor = providers[0].createEditor(getProject(), file);
                    if (myFileEditor instanceof TextEditor) {
                        myEditor = (EditorEx) ((TextEditor) myFileEditor).getEditor();
                        ContentDocumentListener.install(myContent, this);
                    }
                    myFileEditorProvider = providers[0];
                    addDisposable(new Disposable() {

                        @Override
                        public void dispose() {
                            myFileEditorProvider.disposeEditor(myFileEditor);
                            myFileEditor = null;
                            myFileEditorProvider = null;
                            myEditor = null;
                        }
                    });
                } else {
                    document = new DocumentImpl("Can not show", true);
                    final EditorFactory editorFactory = EditorFactory.getInstance();
                    myEditor = DiffUtil.createEditor(document, getProject(), true, content.getContentType());
                    addDisposable(new Disposable() {

                        public void dispose() {
                            editorFactory.releaseEditor(myEditor);
                            myEditor = null;
                        }
                    });
                }
            }
        } else {
            final EditorFactory editorFactory = EditorFactory.getInstance();
            myEditor = DiffUtil.createEditor(document, getProject(), false, content.getContentType());
            addDisposable(new Disposable() {

                public void dispose() {
                    editorFactory.releaseEditor(myEditor);
                    myEditor = null;
                }
            });
            ContentDocumentListener.install(myContent, this);
        }
    }
    fireContentChanged();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) UIBasedFileType(com.intellij.openapi.fileTypes.UIBasedFileType) EditorFactory(com.intellij.openapi.editor.EditorFactory) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) Document(com.intellij.openapi.editor.Document) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl)

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