本文介绍了重命名后以编程方式打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我导出一个文件,导出时,我重命名现有文件并创建一个新文件。如果现有文件在eclipse中打开,它将从它关闭,我必须手动打开该文件。如何以编程方式打开文件,重命名后打开编辑器?
解决方案
p>这应该有助于:
IFile file = ...;
IEditorDescriptor desc = PlatformUI.getWorkbench()。
getEditorRegistry()。getDefaultEditor(file.getName());
page.openEditor(new FileEditorInput(file),desc.getId());
如果还有其他问题打开询问或看看
I am exporting a file and while exporting ,I am renaming the existing file and creating a new one.If the existing file is open in eclipse ,it closes from it and I have to open the file again manually.
How can I open the file programmatically which is open it editor after renaming ?
解决方案
This should help:
IFile file = ...;
IEditorDescriptor desc = PlatformUI.getWorkbench().
getEditorRegistry().getDefaultEditor(file.getName());
page.openEditor(new FileEditorInput(file), desc.getId());
If there are any more questions open ask or look at http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_programmatically%3F
这篇关于重命名后以编程方式打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!