Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Closing editor from a job
Closing editor from a job [message #490162] Wed, 07 October 2009 11:32 Go to next message
chris snow is currently offline chris snow
Messages: 16
Registered: July 2009
Junior Member
I'm trying to close an editor from a job,

IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage pg = win.getActivePage();
pg.closeEditor(editor, false);

The problem is that from within the job I don't appear to have an ActiveWorkbenchWindow as it is null.

How can I close an editor from within a job?

Many thanks in advance,

Chris
Re: Closing editor from a job [message #490248 is a reply to message #490162] Thu, 08 October 2009 01:14 Go to previous message
Prakash G.R. is currently offline Prakash G.R.
Messages: 621
Registered: July 2009
Senior Member
chris snow wrote:
> IWorkbench wb = PlatformUI.getWorkbench();
> IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
> IWorkbenchPage pg = win.getActivePage();
> pg.closeEditor(editor, false);
>
> The problem is that from within the job I don't appear to have an
> ActiveWorkbenchWindow as it is null.

Are you calling it from the UI thread? If not you have to use
Display.syncExec()


- Prakash

Platform UI Team, IBM
http://blog.eclipse-tips.com
Previous Topic:Export feature without jnlp files generated
Next Topic:How do I restrict or limit the size of a MasterDetailsBlock
Goto Forum:
  


Current Time: Sat Aug 02 02:43:54 EDT 2014

Powered by FUDForum. Page generated in 0.01401 seconds