Search in sources :

Example 6 with FileEditorProvider

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

the class HistoryEntry method createHeavy.

@NotNull
static HistoryEntry createHeavy(@NotNull Project project, @NotNull VirtualFile file, @NotNull FileEditorProvider[] providers, @NotNull FileEditorState[] states, @NotNull FileEditorProvider selectedProvider) {
    if (project.isDisposed())
        return createLight(file, providers, states, selectedProvider);
    Disposable disposable = Disposer.newDisposable();
    VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(file, disposable, null);
    HistoryEntry entry = new HistoryEntry(pointer, selectedProvider, disposable);
    for (int i = 0; i < providers.length; i++) {
        FileEditorProvider provider = providers[i];
        FileEditorState state = states[i];
        if (provider != null && state != null) {
            entry.putState(provider, state);
        }
    }
    return entry;
}
Also used : Disposable(com.intellij.openapi.Disposable) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) FileEditorState(com.intellij.openapi.fileEditor.FileEditorState) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with FileEditorProvider

use of com.intellij.openapi.fileEditor.FileEditorProvider 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 8 with FileEditorProvider

use of com.intellij.openapi.fileEditor.FileEditorProvider in project android by JetBrains.

the class ConnectionDetailsView method update.

/**
   * Updates the view to show given data. If given {@code httpData} is not null, show the details and set the view to be visible;
   * otherwise, clears the view and set view to be invisible.
   */
public void update(@Nullable HttpData httpData) {
    setBackground(JBColor.background());
    myEditorPanel.removeAll();
    myFieldsPanel.removeAll();
    myCallstackView.setText("");
    if (httpData != null) {
        VirtualFile payloadVirtualFile = httpData.getResponsePayloadFile() != null ? LocalFileSystem.getInstance().findFileByIoFile(httpData.getResponsePayloadFile()) : null;
        if (payloadVirtualFile != null) {
            // TODO: Find proper project to refactor this.
            Project project = ProjectManager.getInstance().getDefaultProject();
            // TODO: Investigate when the editor provider is null.
            FileEditorProvider[] editorProviders = FileEditorProviderManager.getInstance().getProviders(project, payloadVirtualFile);
            FileEditor editor = editorProviders.length > 0 ? editorProviders[0].createEditor(project, payloadVirtualFile) : null;
            if (editor != null) {
                myEditorPanel.add(editor.getComponent(), BorderLayout.CENTER);
            }
        }
        int row = 0;
        myFieldsPanel.add(new NoWrapBoldLabel("Request"), new TabularLayout.Constraint(row, 0));
        myFieldsPanel.add(new JLabel(HttpData.getUrlName(httpData.getUrl())), new TabularLayout.Constraint(row, 2));
        String contentType = httpData.getResponseField(HttpData.FIELD_CONTENT_TYPE);
        if (contentType != null) {
            row++;
            myFieldsPanel.add(new NoWrapBoldLabel("Content type"), new TabularLayout.Constraint(row, 0));
            // Content type looks like "type/subtype;" or "type/subtype; parameters".
            // Always convert to "type"
            contentType = contentType.split(";")[0];
            myFieldsPanel.add(new JLabel(contentType), new TabularLayout.Constraint(row, 2));
        }
        HyperlinkLabel urlLabel = new HyperlinkLabel(httpData.getUrl());
        urlLabel.setHyperlinkTarget(httpData.getUrl());
        row++;
        myFieldsPanel.add(new NoWrapBoldLabel("URL"), new TabularLayout.Constraint(row, 0));
        myFieldsPanel.add(urlLabel, new TabularLayout.Constraint(row, 2));
        String contentLength = httpData.getResponseField(HttpData.FIELD_CONTENT_LENGTH);
        if (contentLength != null) {
            contentLength = contentLength.split(";")[0];
            row++;
            myFieldsPanel.add(new NoWrapBoldLabel("Content length"), new TabularLayout.Constraint(row, 0));
            myFieldsPanel.add(new JLabel(contentLength), new TabularLayout.Constraint(row, 2));
        }
        // TODO: We are showing the callstack but we can't currently click on any of the links to
        // navigate to the code.
        myCallstackView.setText(httpData.getTrace());
        repaint();
    }
    setVisible(httpData != null);
    revalidate();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) TabularLayout(com.android.tools.adtui.TabularLayout) HyperlinkLabel(com.intellij.ui.HyperlinkLabel)

Example 9 with FileEditorProvider

use of com.intellij.openapi.fileEditor.FileEditorProvider in project android by JetBrains.

the class NetworkDetailedView method showConnectionDetails.

public void showConnectionDetails(@NotNull VirtualFile payloadFile) {
    if (myEditor != null) {
        remove(myEditor.getComponent());
    }
    FileEditorProvider editorProvider = FileEditorProviderManager.getInstance().getProviders(myProject, payloadFile)[0];
    myEditor = editorProvider.createEditor(myProject, payloadFile);
    add(myEditor.getComponent());
}
Also used : FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider)

Example 10 with FileEditorProvider

use of com.intellij.openapi.fileEditor.FileEditorProvider in project android by JetBrains.

the class LayeredImageEditorProvider method createEditor.

@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile file) {
    // Use the default image editor to reuse the standard zoom UI, etc.
    FileEditorProvider provider = FileEditorProviderManager.getInstance().getProvider("images");
    // There is always a standard images provider
    assert provider != null;
    FileEditor editor = provider.createEditor(project, new EmptyVirtualFile(file));
    return new LayeredImageEditor(project, file, editor);
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) FileEditorProvider(com.intellij.openapi.fileEditor.FileEditorProvider) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FileEditorProvider (com.intellij.openapi.fileEditor.FileEditorProvider)14 NotNull (org.jetbrains.annotations.NotNull)6 FileEditorState (com.intellij.openapi.fileEditor.FileEditorState)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 Disposable (com.intellij.openapi.Disposable)3 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)3 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 WeighedFileEditorProvider (com.intellij.openapi.fileEditor.WeighedFileEditorProvider)2 TextEditorProvider (com.intellij.openapi.fileEditor.impl.text.TextEditorProvider)2 Project (com.intellij.openapi.project.Project)2 Element (org.jdom.Element)2 Nullable (org.jetbrains.annotations.Nullable)2 TabularLayout (com.android.tools.adtui.TabularLayout)1 Document (com.intellij.openapi.editor.Document)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 FileEditorProviderManager (com.intellij.openapi.fileEditor.ex.FileEditorProviderManager)1 UIBasedFileType (com.intellij.openapi.fileTypes.UIBasedFileType)1