简体   繁体   English

Eclipse插件和编辑器

[英]Eclipse plugin and editor

How to open a file outside of the project programically in a new editor window ? 如何在新的编辑器窗口中以编程方式在项目外部打开文件? I've been searching all over the internet and nothing seems to work. 我一直在互联网上搜寻,似乎没有任何反应。 I have eclipse 4.4. 我有月食4.4。
I thought something so simple as opening a file will be easy but somehow it keeps me awake at night. 我认为打开文件这样的简单操作很容易,但是以某种方式它却使我彻夜难眠。 Please help. 请帮忙。

I cannot comment as yet, so adding my question/suggestion as an answer. 我目前还不能发表评论,因此添加我的问题/建议作为答案。

What do you mean by your question? 您的问题是什么意思? You mean something like a command to open a target file in some editor that is installed on your computer. 您的意思是类似于在计算机上安装的某些编辑器中打开目标文件的命令。

You could try using 您可以尝试使用

Process process = Runtime.getRuntime ().exec ("<path to editor>/some_editor.exe");

If the program allows taking file to open as parameter, you could place that too in commmand above towards the end. 如果程序允许将文件作为参数打开,则也可以将其放在命令末尾。

I hope this is what you are looking for. 我希望这是您要寻找的。

To open an editor on a file which is not in the current workspace use: 要打开不在当前工作空间中的文件的编辑器,请使用:

String path = ... path to file

IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(path));

IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

IDE.openInternalEditorOnFileStore(page, fileStore);

Note: some editors may not support files that are not in the workspace. 注意:某些编辑器可能不支持工作空间中没有的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM