|
|
|
Re: UI methods in normal Job [message #35683 is a reply to message #35615] |
Thu, 04 December 2008 11:40 |
Eclipse User |
|
|
|
Originally posted by: Marcus.Ilgner.gerig.de
Matthias Kohles wrote:
> Hey,
> thank you for your answer.
> I tried your code but it did not work for me.
> i have a normal NonUI eclipe Job. In this job i need the information of
> what file from which project is opened in the active editor. So i tried
> your code within this job but i receive a NullPointerException in
> Display.getCurrent().
> Display.getCurrent().syncExec(new Runnable()
> {
> public void run()
> {
> editorPart =
>
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
> }
> });
> JavaDoc says that when i call Display.getCurrent() in a non-UI thread it
> will return always null.
> is there another way to use this syncExec within my job?
> best regards,
> Matthias
Hi,
have you tried
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShel l().getDisplay()
instead of
Display.getCurrent()
Afaik that would be the way to go...
HTH
Marcus
|
|
|
|
Re: UI methods in normal Job [message #35751 is a reply to message #35717] |
Thu, 04 December 2008 13:50 |
Eclipse User |
|
|
|
Originally posted by: Marcus.Ilgner.gerig.de
Matthias Kohles wrote:
> thanks for your message,
> this didn't work either.
> Same NullPointerException in getDisplay :(
> regards Matthias
Duh... that shouldn't happen. Where does the NPE occur exactly? In
getDisplay() or before that (activeWorkbenchWindow could be null)? Do you
have a stacktrace?
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03645 seconds