Reputation:
For my Eclipse plugin I have created a new perspective. This perspective consists of two views that I have created and a third view that is the default editor (as I assume). Now I want to open a source code file in the default editor. For this source code file I have only the source code in a String. So I may have first to create a temporary file. But more important: How can I access the default editor from my view? Couldn't find any documentation.
Upvotes: 1
Views: 1169
Reputation: 19443
You have lots of options, but one of them is to call IDE.openEditor(). There are lots of variants of this, but they generally use a resource. BTW, and editor (EditorPart) and view (ViewPart) are different things in Eclipse, they are both implementations of a IWorkbenchPart.
You can also create a "hidden" resource if you like so that the file that you want to open is not visible in the workspace. If you just want a text editor the default editor can be fine, but you can also construct an IEditorInput to have more control over which sort of editor you want.
Specifically to create a resource:
IProject project = ResourcesPlugin.getWorkspace().getRoot().findProject("projectName");
IFile file = project.getFile("filename");
file.create(inputStream, true, null);
Upvotes: 3