use of com.intellij.openapi.fileEditor.FileEditorProvider 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);
}
use of com.intellij.openapi.fileEditor.FileEditorProvider in project intellij-community by JetBrains.
the class HistoryEntry method createLight.
@NotNull
static HistoryEntry createLight(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
EntryData entryData = parseEntry(project, e);
VirtualFilePointer pointer = new LightFilePointer(entryData.url);
HistoryEntry entry = new HistoryEntry(pointer, entryData.selectedProvider, null);
for (Pair<FileEditorProvider, FileEditorState> state : entryData.providerStates) {
entry.putState(state.first, state.second);
}
return entry;
}
use of com.intellij.openapi.fileEditor.FileEditorProvider in project intellij-community by JetBrains.
the class HistoryEntry method parseEntry.
@NotNull
private static EntryData parseEntry(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
if (!e.getName().equals(TAG)) {
throw new IllegalArgumentException("unexpected tag: " + e);
}
String url = e.getAttributeValue(FILE_ATTR);
List<Pair<FileEditorProvider, FileEditorState>> providerStates = new ArrayList<>();
FileEditorProvider selectedProvider = null;
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
for (Element _e : e.getChildren(PROVIDER_ELEMENT)) {
String typeId = _e.getAttributeValue(EDITOR_TYPE_ID_ATTR);
FileEditorProvider provider = FileEditorProviderManager.getInstance().getProvider(typeId);
if (provider == null) {
continue;
}
if (Boolean.valueOf(_e.getAttributeValue(SELECTED_ATTR_VALUE))) {
selectedProvider = provider;
}
Element stateElement = _e.getChild(STATE_ELEMENT);
if (stateElement == null) {
throw new InvalidDataException();
}
if (file != null) {
FileEditorState state = provider.readState(stateElement, project, file);
providerStates.add(Pair.create(provider, state));
}
}
return new EntryData(url, providerStates, selectedProvider);
}
use of com.intellij.openapi.fileEditor.FileEditorProvider in project intellij-community by JetBrains.
the class HistoryEntry method writeExternal.
/**
* @return element that was added to the {@code element}.
* Returned element has tag {@link #TAG}. Never null.
*/
public Element writeExternal(Element element, Project project) {
Element e = new Element(TAG);
element.addContent(e);
e.setAttribute(FILE_ATTR, myFilePointer.getUrl());
for (final Map.Entry<FileEditorProvider, FileEditorState> entry : myProvider2State.entrySet()) {
FileEditorProvider provider = entry.getKey();
Element providerElement = new Element(PROVIDER_ELEMENT);
if (provider.equals(mySelectedProvider)) {
providerElement.setAttribute(SELECTED_ATTR_VALUE, Boolean.TRUE.toString());
}
providerElement.setAttribute(EDITOR_TYPE_ID_ATTR, provider.getEditorTypeId());
Element stateElement = new Element(STATE_ELEMENT);
providerElement.addContent(stateElement);
provider.writeState(entry.getValue(), project, stateElement);
e.addContent(providerElement);
}
return e;
}
Aggregations