Search in sources :

Example 1 with TextEditorProvider

use of com.intellij.openapi.fileEditor.impl.text.TextEditorProvider in project intellij-community by JetBrains.

the class ImplementationViewComponent method updateEditorText.

private void updateEditorText() {
    disposeNonTextEditor();
    final PsiElement foundElement = myElements[myIndex];
    final PsiElement elt = foundElement.getNavigationElement();
    LOG.assertTrue(elt != null, foundElement);
    final Project project = foundElement.getProject();
    final PsiFile psiFile = getContainingFile(elt);
    final VirtualFile vFile = psiFile != null ? psiFile.getVirtualFile() : null;
    if (vFile == null)
        return;
    final FileEditorProvider[] providers = FileEditorProviderManager.getInstance().getProviders(project, vFile);
    for (FileEditorProvider provider : providers) {
        if (provider instanceof TextEditorProvider) {
            updateTextElement(elt);
            myBinarySwitch.show(myViewingPanel, TEXT_PAGE_KEY);
            break;
        } else if (provider.accept(project, vFile)) {
            myCurrentNonTextEditorProvider = provider;
            myNonTextEditor = myCurrentNonTextEditorProvider.createEditor(project, vFile);
            myBinaryPanel.removeAll();
            myBinaryPanel.add(myNonTextEditor.getComponent());
            myBinarySwitch.show(myViewingPanel, BINARY_PAGE_KEY);
            break;
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) TextEditorProvider(com.intellij.openapi.fileEditor.impl.text.TextEditorProvider)

Example 2 with TextEditorProvider

use of com.intellij.openapi.fileEditor.impl.text.TextEditorProvider in project intellij-community by JetBrains.

the class FileEditorProviderManagerImpl method getProviders.

@Override
@NotNull
public FileEditorProvider[] getProviders(@NotNull final Project project, @NotNull final VirtualFile file) {
    // Collect all possible editors
    List<FileEditorProvider> sharedProviders = new ArrayList<>();
    boolean doNotShowTextEditor = false;
    for (final FileEditorProvider provider : myProviders) {
        if (ReadAction.compute(() -> {
            if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) {
                return false;
            }
            return provider.accept(project, file);
        })) {
            sharedProviders.add(provider);
            doNotShowTextEditor |= provider.getPolicy() == FileEditorPolicy.HIDE_DEFAULT_EDITOR;
        }
    }
    // Throw out default editors provider if necessary
    if (doNotShowTextEditor) {
        ContainerUtil.retainAll(sharedProviders, provider -> !(provider instanceof TextEditorProvider));
    }
    // Sort editors according policies
    Collections.sort(sharedProviders, MyComparator.ourInstance);
    return sharedProviders.toArray(new FileEditorProvider[sharedProviders.size()]);
}
Also used : WeighedFileEditorProvider(com.intellij.openapi.fileEditor.WeighedFileEditorProvider) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) TextEditorProvider(com.intellij.openapi.fileEditor.impl.text.TextEditorProvider) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with TextEditorProvider

use of com.intellij.openapi.fileEditor.impl.text.TextEditorProvider in project intellij-community by JetBrains.

the class TestEditorManagerImpl method closeFile.

@Override
public void closeFile(@NotNull final VirtualFile file) {
    Editor editor = myVirtualFile2Editor.remove(file);
    if (editor != null) {
        TextEditorProvider editorProvider = TextEditorProvider.getInstance();
        editorProvider.disposeEditor(editorProvider.getTextEditor(editor));
        EditorFactory.getInstance().releaseEditor(editor);
    }
    if (Comparing.equal(file, myActiveFile)) {
        myActiveFile = null;
    }
    modifyTabWell(new Runnable() {

        @Override
        public void run() {
            myTestEditorSplitter.closeFile(file);
        }
    });
}
Also used : TextEditorProvider(com.intellij.openapi.fileEditor.impl.text.TextEditorProvider) com.intellij.openapi.fileEditor(com.intellij.openapi.fileEditor) Editor(com.intellij.openapi.editor.Editor)

Aggregations

TextEditorProvider (com.intellij.openapi.fileEditor.impl.text.TextEditorProvider)3 FileEditorProvider (com.intellij.openapi.fileEditor.FileEditorProvider)2 Editor (com.intellij.openapi.editor.Editor)1 com.intellij.openapi.fileEditor (com.intellij.openapi.fileEditor)1 WeighedFileEditorProvider (com.intellij.openapi.fileEditor.WeighedFileEditorProvider)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NotNull (org.jetbrains.annotations.NotNull)1