Search in sources :

Example 11 with EditorSettings

use of com.intellij.openapi.editor.EditorSettings in project intellij by bazelbuild.

the class ProjectViewUi method createEditor.

private static EditorEx createEditor(String tooltip) {
    Project project = getProject();
    LightVirtualFile virtualFile = new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");
    final Document document = ((EditorFactoryImpl) EditorFactory.getInstance()).createDocument(true);
    ((DocumentImpl) document).setAcceptSlashR(true);
    FileDocumentManagerImpl.registerDocument(document, virtualFile);
    FileManager fileManager = ((PsiManagerEx) PsiManager.getInstance(project)).getFileManager();
    fileManager.setViewProvider(virtualFile, fileManager.createFileViewProvider(virtualFile, true));
    if (project.isDefault()) {
        // Undo-redo doesn't work with the default project.
        // Explicitly turn it off to avoid error dialogs.
        UndoUtil.disableUndoFor(document);
    }
    EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project, ProjectViewFileType.INSTANCE, false);
    final EditorSettings settings = editor.getSettings();
    settings.setLineNumbersShown(false);
    settings.setLineMarkerAreaShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setRightMarginShown(false);
    settings.setAdditionalPageAtBottom(false);
    editor.getComponent().setMinimumSize(getEditorSize());
    editor.getComponent().setPreferredSize(getEditorSize());
    editor.getComponent().setToolTipText(tooltip);
    editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
    editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
    return editor;
}
Also used : Project(com.intellij.openapi.project.Project) EditorSettings(com.intellij.openapi.editor.EditorSettings) EditorEx(com.intellij.openapi.editor.ex.EditorEx) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Document(com.intellij.openapi.editor.Document) EditorFactoryImpl(com.intellij.openapi.editor.impl.EditorFactoryImpl) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) FileManager(com.intellij.psi.impl.file.impl.FileManager) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Aggregations

EditorSettings (com.intellij.openapi.editor.EditorSettings)11 Editor (com.intellij.openapi.editor.Editor)6 EditorEx (com.intellij.openapi.editor.ex.EditorEx)6 Document (com.intellij.openapi.editor.Document)5 EditorFactory (com.intellij.openapi.editor.EditorFactory)4 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 NotNull (org.jetbrains.annotations.NotNull)2 CvsConfigurationsListEditor (com.intellij.cvsSupport2.config.ui.CvsConfigurationsListEditor)1 Disposable (com.intellij.openapi.Disposable)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)1 LayeredLexerEditorHighlighter (com.intellij.openapi.editor.ex.util.LayeredLexerEditorHighlighter)1 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 EditorFactoryImpl (com.intellij.openapi.editor.impl.EditorFactoryImpl)1 FileType (com.intellij.openapi.fileTypes.FileType)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)1 FileManager (com.intellij.psi.impl.file.impl.FileManager)1