Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » ActiveWorkbenchWindow is null called from thread
ActiveWorkbenchWindow is null called from thread [message #175976] Thu, 06 March 2008 11:20 Go to next message
Eclipse UserFriend
Originally posted by: novak.igor.gmail.com

Hi!

I'm trying to refresh domain model (I get domain data from external corba
source) from a thread (every few minutes) and I get NullPointerException
from:

PlatformUI.getWorkbench().getActiveWorkbenchWindow();

but if I run it from action (pressing button on gui) everything is ok.

I'm using AbstractTransactionalCommand to manipulate domain model and I
need TransactionalEditingDomain.

I do it like this:

TransactionalEditingDomain editingDomain =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor().getDiagramEditPart().getEditingDo main();


AbstractTransactionalCommand command = new
AbstractTransactionalCommand(editingDomain, "Changing domain model", null);

then I execute command and if I do it from gui everything is ok, but if
the above code is called from thread it does not work.

Any suggestions, am I doing something wrong?

Thanks in advance,
Igor Novak
Re: ActiveWorkbenchWindow is null called from thread [message #175986 is a reply to message #175976] Thu, 06 March 2008 11:32 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Igor,

I suggest you use Display.getDefault().syncExec() to run your code.

Cheers,
Dimitrios

Igor Novak wrote:
> Hi!
>
> I'm trying to refresh domain model (I get domain data from external
> corba source) from a thread (every few minutes) and I get
> NullPointerException from:
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
>
> but if I run it from action (pressing button on gui) everything is ok.
>
> I'm using AbstractTransactionalCommand to manipulate domain model and I
> need TransactionalEditingDomain.
>
> I do it like this:
>
> TransactionalEditingDomain editingDomain =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor().getDiagramEditPart().getEditingDo main();
>
>
>
> AbstractTransactionalCommand command = new
> AbstractTransactionalCommand(editingDomain, "Changing domain model", null);
>
> then I execute command and if I do it from gui everything is ok, but if
> the above code is called from thread it does not work.
>
> Any suggestions, am I doing something wrong?
>
> Thanks in advance, Igor Novak
>
Previous Topic:problems with semantic changes
Next Topic:how to let a label appear outside of a graphics?
Goto Forum:
  


Current Time: Fri Apr 26 02:42:59 GMT 2024

Powered by FUDForum. Page generated in 0.03324 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top