Search in sources :

Example 1 with FileEditorProviderManager

use of com.intellij.openapi.fileEditor.ex.FileEditorProviderManager in project intellij-community by JetBrains.

the class StructureViewWrapperImpl method createTempFileEditor.

@Nullable
private FileEditor createTempFileEditor(@NotNull VirtualFile file) {
    if (file.getLength() > PersistentFSConstants.getMaxIntellisenseFileSize())
        return null;
    FileEditorProviderManager editorProviderManager = FileEditorProviderManager.getInstance();
    final FileEditorProvider[] providers = editorProviderManager.getProviders(myProject, file);
    return providers.length == 0 ? null : providers[0].createEditor(myProject, file);
}
Also used : FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) FileEditorProviderManager(com.intellij.openapi.fileEditor.ex.FileEditorProviderManager) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with FileEditorProviderManager

use of com.intellij.openapi.fileEditor.ex.FileEditorProviderManager in project intellij-community by JetBrains.

the class FileEditorManagerImpl method newEditorComposite.

@Nullable
EditorWithProviderComposite newEditorComposite(final VirtualFile file) {
    if (file == null) {
        return null;
    }
    final FileEditorProviderManager editorProviderManager = FileEditorProviderManager.getInstance();
    final FileEditorProvider[] providers = editorProviderManager.getProviders(myProject, file);
    if (providers.length == 0)
        return null;
    final FileEditor[] editors = new FileEditor[providers.length];
    for (int i = 0; i < providers.length; i++) {
        final FileEditorProvider provider = providers[i];
        LOG.assertTrue(provider != null);
        LOG.assertTrue(provider.accept(myProject, file));
        final FileEditor editor = provider.createEditor(myProject, file);
        editors[i] = editor;
        LOG.assertTrue(editor.isValid());
        editor.addPropertyChangeListener(myEditorPropertyChangeListener);
    }
    final EditorWithProviderComposite newComposite = new EditorWithProviderComposite(file, editors, providers, this);
    final EditorHistoryManager editorHistoryManager = EditorHistoryManager.getInstance(myProject);
    for (int i = 0; i < editors.length; i++) {
        final FileEditor editor = editors[i];
        final FileEditorProvider provider = providers[i];
        // Restore myEditor state
        FileEditorState state = editorHistoryManager.getState(file, provider);
        if (state != null) {
            editor.setState(state);
        }
    }
    return newComposite;
}
Also used : FileEditorProviderManager(com.intellij.openapi.fileEditor.ex.FileEditorProviderManager) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileEditorProviderManager (com.intellij.openapi.fileEditor.ex.FileEditorProviderManager)2 Nullable (org.jetbrains.annotations.Nullable)2 FileEditorProvider (com.intellij.openapi.fileEditor.FileEditorProvider)1