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