ActiveWorkbenchWindow is null called from thread [message #175976] |
Thu, 06 March 2008 06:20  |
Eclipse User |
|
|
|
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 06:32  |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.10639 seconds