[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform] openEditor call inside a Job ?
|
I want to open a file in a Editor, normally the attached code do this, but
in this case I started a Job.
And after the Job finished I want to open the Editor, but I got a
NullPointer from getActiveWorkbenchWindow();
I also added a IJobChangeListener, and tried it in the done() Method, but
the same effect.
Is there a other way to retriev the ActiveWorkbenchWindow ? Or can I open a
Editor in a other way ?
run() {
showReadme(); // Works fine
Job job = new Job("Generate Projects") {
protected IStatus run(IProgressMonitor monitor) {
showReadme(); // Fails
}
}
void showReadme() {
IFile file = (IFile) getProject().getFile("readme.txt");
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditor(page,
new FileEditorInput(file),
PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
file.getFullPath().toString()).getId()
);
} catch (PartInitException e) {
e.printStackTrace();
}
}