Opening a file in an GMF RCP application [message #514594] |
Mon, 15 February 2010 21:40 |
jh vdv Messages: 2 Registered: February 2010 |
Junior Member |
|
|
Dear List,
Solving this one caused me a lot of headaches, but finally I turned to freenode #eclipse and there rcjsuen helped me to solve the problem.
What was the problem? I wanted to open an editor on a file from within another editor.
It sounds simple, but RCP apps usually do not have IProjects and IFiles.
The crux of the matter was to construct the right call to IDE.openEditor (with the right editor id, which was easy in my case, as it was my own).
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.util.URI;
// not java.net.URI
[...]
String fileName = "String from current editor or view";
URI uri = URI.createFileURI(fileName);
URIEditorInput uei = new URIEditorInput(uri);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditor(page, uei, "The EditorID");
} catch (PartInitException e) {
e.printStackTrace();
}
As always it looks extremely simple when it is done.
|
|
|
Powered by
FUDForum. Page generated in 0.03274 seconds