Java Code Examples for com.intellij.openapi.fileEditor.FileEditorProvider#accept()
The following examples show how to use
com.intellij.openapi.fileEditor.FileEditorProvider#accept() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImplementationViewComponent.java From consulo with Apache License 2.0 | 6 votes |
private void updateEditorText() { disposeNonTextEditor(); final PsiElement elt = myElements[myIndex].getNavigationElement(); Project project = elt.getProject(); PsiFile psiFile = getContainingFile(elt); final VirtualFile vFile = psiFile.getVirtualFile(); 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; } } }
Example 2
Source File: FileEditorProviderManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public FileEditorProvider[] getProviders(@Nonnull final Project project, @Nonnull final VirtualFile file) { // Collect all possible editors List<FileEditorProvider> sharedProviders = new ArrayList<>(); boolean doNotShowTextEditor = false; for (final FileEditorProvider provider : myProviders) { ThrowableComputable<Boolean, RuntimeException> action = () -> { if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) { return false; } return provider.accept(project, file); }; if (AccessRule.read(action)) { 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()]); }