如何在eclipse的标准java编辑器中编程打开java文件。我不想从插件中使用它,而是从方法中使用它。我正在搜索类似这样的东西:
String absolutePath = "C:\\dummfile.java";
// Getting Editor from Workbench or something like that
Editor javaEditor = Workbench.getJavaEditor();
javaEditor.setInput(absolutePath);
// show and set focus
javaEditor.openEditor();我尝试过this,但无法从文件转换为IFile。
谢谢!
发布于 2015-06-03 18:35:45
要将File转换为IFile:
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IPath location= Path.fromOSString(file.getAbsolutePath());
IFile ifile= workspace.getRoot().getFileForLocation(location);发布于 2015-06-03 18:38:12
http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_programmatically%3F
你看过这个了吗?由于您拥有文件的绝对路径,因此此链接中的代码示例应该适用于您。
https://stackoverflow.com/questions/30617471
复制相似问题