本文整理汇总了Java中com.intellij.openapi.fileEditor.FileEditorProvider类的典型用法代码示例。如果您正苦于以下问题:Java FileEditorProvider类的具体用法?Java FileEditorProvider怎么用?Java FileEditorProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileEditorProvider类属于com.intellij.openapi.fileEditor包,在下文中一共展示了FileEditorProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openFileInPanel
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
/**
* 打开类文件
*
* @param filePath
* @param project
*/
public static void openFileInPanel(final String filePath, final Project project) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
if (file != null && file.isValid()) {
FileEditorProvider[] providers = FileEditorProviderManager.getInstance()
.getProviders(project, file);
if (providers.length != 0) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
FileEditorManager.getInstance(project).openTextEditor(descriptor, false);
}
}
}
});
}
示例2: HistoryEntry
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
public HistoryEntry(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
myFile = getVirtualFile(e);
myProvider2State = new HashMap<FileEditorProvider, FileEditorState>();
List providers = e.getChildren(PROVIDER_ELEMENT);
for (final Object provider1 : providers) {
Element _e = (Element)provider1;
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))) {
mySelectedProvider = provider;
}
Element stateElement = _e.getChild(STATE_ELEMENT);
if (stateElement == null) {
throw new InvalidDataException();
}
FileEditorState state = provider.readState(stateElement, project, myFile);
putState(provider, state);
}
}
示例3: writeExternal
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
/**
* @return element that was added to the <code>element</code>.
* 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, myFile.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;
}
示例4: getSelectedEditorWithProvider
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@Override
@NotNull
public Pair<FileEditor, FileEditorProvider> getSelectedEditorWithProvider() {
LOG.assertTrue(myEditors.length > 0, myEditors.length);
if (myEditors.length == 1) {
LOG.assertTrue(myTabbedPaneWrapper == null);
return Pair.create(myEditors[0], myProviders[0]);
}
else { // we have to get myEditor from tabbed pane
LOG.assertTrue(myTabbedPaneWrapper != null);
int index = myTabbedPaneWrapper.getSelectedIndex();
if (index == -1) {
index = 0;
}
LOG.assertTrue(index >= 0, index);
LOG.assertTrue(index < myEditors.length, index);
return Pair.create(myEditors[index], myProviders[index]);
}
}
示例5: createNewDockContainerFor
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@NotNull
public Pair<FileEditor[], FileEditorProvider[]> createNewDockContainerFor(@NotNull VirtualFile file, @NotNull FileEditorManagerImpl fileEditorManager) {
DockContainer container = getFactory(DockableEditorContainerFactory.TYPE).createContainer(null);
register(container);
final DockWindow window = createWindowFor(null, container);
window.show(true);
final EditorWindow editorWindow = ((DockableEditorTabbedContainer)container).getSplitters().getOrCreateCurrentWindow(file);
final Pair<FileEditor[], FileEditorProvider[]> result = fileEditorManager.openFileImpl2(editorWindow, file, true);
container.add(EditorTabbedContainer.createDockableEditor(myProject, null, file, new Presentation(file.getName()), editorWindow), null);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
window.myUiContainer.setPreferredSize(null);
}
});
return result;
}
示例6: getSelectedEditorWithProvider
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@NotNull
public Pair<FileEditor, FileEditorProvider> getSelectedEditorWithProvider() {
LOG.assertTrue(myEditors.length > 0, myEditors.length);
if(myEditors.length==1){
LOG.assertTrue(myTabbedPaneWrapper==null);
return Pair.create (myEditors[0], myProviders [0]);
}
else{ // we have to get myEditor from tabbed pane
LOG.assertTrue(myTabbedPaneWrapper!=null);
int index = myTabbedPaneWrapper.getSelectedIndex();
if (index == -1) {
index = 0;
}
LOG.assertTrue(index>=0, index);
LOG.assertTrue(index<myEditors.length, index);
return Pair.create (myEditors[index], myProviders [index]);
}
}
示例7: createNewDockContainerFor
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
public Pair<FileEditor[], FileEditorProvider[]> createNewDockContainerFor(VirtualFile file, FileEditorManagerImpl fileEditorManager) {
DockContainer container = getFactory(DockableEditorContainerFactory.TYPE).createContainer(null);
register(container);
final DockWindow window = createWindowFor(null, container);
window.show(true);
final EditorWindow editorWindow = ((DockableEditorTabbedContainer)container).getSplitters().getOrCreateCurrentWindow(file);
final Pair<FileEditor[], FileEditorProvider[]> result = fileEditorManager.openFileImpl2(editorWindow, file, true);
container.add(EditorTabbedContainer.createDockableEditor(myProject, null, file, new Presentation(file.getName()), editorWindow), null);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
window.myUiContainer.setPreferredSize(null);
}
});
return result;
}
示例8: updateEditorText
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
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;
}
}
}
示例9: doOpen
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
private static boolean doOpen(final String path, final int line, final int column) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
Pair<VirtualFile, Project> data = new File(path).isAbsolute() ? findByAbsolutePath(path) : findByRelativePath(path);
if (data == null) return;
FileEditorProvider[] providers = FileEditorProviderManager.getInstance().getProviders(data.second, data.first);
if (providers.length == 0) return;
OpenFileDescriptor descriptor = new OpenFileDescriptor(data.second, data.first, line, column);
FileEditorManager.getInstance(data.second).openTextEditor(descriptor, true);
}
});
return true;
}
示例10: getBuilderFromEditorProvider
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@NotNull
private static Builder getBuilderFromEditorProvider(@NotNull final FileEditorProvider provider,
@NotNull final Project project,
@NotNull final VirtualFile file) {
if (provider instanceof AsyncFileEditorProvider) {
return ((AsyncFileEditorProvider)provider).createEditorAsync(project, file);
}
else {
return new Builder() {
@Override
public FileEditor build() {
return provider.createEditor(project, file);
}
};
}
}
示例11: createHeavy
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@Nonnull
public static HistoryEntry createHeavy(@Nonnull Project project,
@Nonnull VirtualFile file,
@Nonnull FileEditorProvider[] providers,
@Nonnull FileEditorState[] states,
@Nonnull 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;
}
示例12: writeExternal
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
/**
* @return element that was added to the <code>element</code>.
* 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;
}
示例13: getSelectedEditorWithProvider
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@Override
@Nonnull
public Pair<FileEditor, FileEditorProvider> getSelectedEditorWithProvider() {
LOG.assertTrue(myEditors.length > 0, myEditors.length);
if (myEditors.length == 1) {
LOG.assertTrue(myTabbedPaneWrapper == null);
return Pair.create(myEditors[0], myProviders[0]);
}
else { // we have to get myEditor from tabbed pane
LOG.assertTrue(myTabbedPaneWrapper != null);
int index = myTabbedPaneWrapper.getSelectedIndex();
if (index == -1) {
index = 0;
}
LOG.assertTrue(index >= 0, index);
LOG.assertTrue(index < myEditors.length, index);
return Pair.create(myEditors[index], myProviders[index]);
}
}
示例14: getProvider
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
@Override
@Nullable
public FileEditorProvider getProvider(@NotNull String editorTypeId) {
for (FileEditorProvider provider : myProviders) {
if (provider.getEditorTypeId().equals(editorTypeId)) {
return provider;
}
}
return null;
}
示例15: registerProvider
import com.intellij.openapi.fileEditor.FileEditorProvider; //导入依赖的package包/类
private void registerProvider(@NotNull FileEditorProvider provider) {
String editorTypeId = provider.getEditorTypeId();
if (getProvider(editorTypeId) != null) {
throw new IllegalArgumentException("attempt to register provider with non unique editorTypeId: " + editorTypeId);
}
myProviders.add(provider);
}