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;
}
}
}
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()]);
}
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);
}
});
}
Aggregations