I am trying to open a file in eclipse programmatically. the associated editor for the file is defined in an external plugin which I don't have control over the source code.
I use the code snippet shown below to open the file. However I always got
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "AWT-Windows"
I tried to increase the memory available for eclipse run configuration, but that didn't help. Any ideas what can cause this?
private void openFiles(final IPath filePath ) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IFile iFileInput = workspace.getRoot().getFileForLocation(filePath);
IEditorInput editorInput = new FileEditorInput(iFileInput);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
try {
iFileInput.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e1) {
e1.printStackTrace();
}
try {
String editorID = "xxxxx";
IDE.openEditor(page, editorInput, editorID);
} catch (PartInitException e) {
e.printStackTrace();
}
}
});
}