Search in sources :

Example 31 with DocumentImpl

use of com.intellij.openapi.editor.impl.DocumentImpl in project azure-tools-for-java by Microsoft.

the class AzureSdkArtifactGroupPanel method buildCodeViewer.

private EditorTextField buildCodeViewer() {
    final Project project = ProjectManager.getInstance().getOpenProjects()[0];
    final DocumentImpl document = new DocumentImpl("", true);
    final EditorTextField viewer = new EditorTextField(document, project, XmlFileType.INSTANCE, true, false);
    viewer.addSettingsProvider(editor -> {
        // add scrolling/line number features
        editor.setHorizontalScrollbarVisible(true);
        editor.setVerticalScrollbarVisible(true);
        editor.getSettings().setLineNumbersShown(true);
    });
    return viewer;
}
Also used : Project(com.intellij.openapi.project.Project) EditorTextField(com.intellij.ui.EditorTextField) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl)

Example 32 with DocumentImpl

use of com.intellij.openapi.editor.impl.DocumentImpl 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

DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)32 Document (com.intellij.openapi.editor.Document)13 NotNull (org.jetbrains.annotations.NotNull)6 RangeMarker (com.intellij.openapi.editor.RangeMarker)4 TextRange (com.intellij.openapi.util.TextRange)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiFile (com.intellij.psi.PsiFile)3 EditorEx (com.intellij.openapi.editor.ex.EditorEx)2 FrozenDocument (com.intellij.openapi.editor.impl.FrozenDocument)2 Project (com.intellij.openapi.project.Project)2 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)2 FileComparisonFailure (com.intellij.rt.execution.junit.FileComparisonFailure)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 ArrayList (java.util.ArrayList)2 CloudLineBreakpointType (com.google.cloud.tools.intellij.debugger.CloudLineBreakpointType)1 InlayInfo (com.intellij.codeInsight.hints.InlayInfo)1 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)1 ResultItem (com.intellij.execution.filters.Filter.ResultItem)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1