setting the current display [message #306385] |
Thu, 27 July 2006 10:03  |
Eclipse User |
|
|
|
Hi
Well, I'm using a third party swing application in my plugin. The swing JFrame
is a singleton that is never disposed, but is setVisible(true o false) according
if I want to activate or deactivate it.
When the editor is setVisible(false) then in my plugin's code I'm having a
nullPointer exception because Display.getCurrent()==null. So I need a way to set
the workbench' current display manually. How do I do that? I want to do something
like Display.setCurrent(...) but can't find how.
Hope you can understand my poor english.
Thanks in advance
|
|
|
Re: setting the current display [message #306389 is a reply to message #306385] |
Thu, 27 July 2006 15:27  |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Sebastian,
This sounds like a threading issue. That method returns the Display for
the current thread, so if you get null, you're on a thread without a
display and you won't be able to do much with a display from another
thread anyway. Perhaps code like this is what you want to be doing:
getSite().getShell().getDisplay().asyncExec
(new Runnable()
{
public void run()
{
// work with current display which will be the
editor's site's shell's display.
}
});
Sebastian Gurin wrote:
> Hi
>
> Well, I'm using a third party swing application in my plugin. The swing JFrame
> is a singleton that is never disposed, but is setVisible(true o false) according
> if I want to activate or deactivate it.
>
> When the editor is setVisible(false) then in my plugin's code I'm having a
> nullPointer exception because Display.getCurrent()==null. So I need a way to set
> the workbench' current display manually. How do I do that? I want to do something
> like Display.setCurrent(...) but can't find how.
>
> Hope you can understand my poor english.
>
> Thanks in advance
>
|
|
|
|
Re: setting the current display [message #306394 is a reply to message #306389] |
Thu, 27 July 2006 11:47  |
Eclipse User |
|
|
|
Thanks Paul and Ed for your very fast replies. thanks thanks.....
Ed: unfortunately, your code didn't work. It seems that swing/awt applications
are launched in an independent internal thread that I'm not able to control :(
Nevertheless, I have fixed (hardcoded) the problem thanks to your tips. When I
hide the swing application (the user temporarily ends using it) with
jFrame.setVisible(false), eclipse gains focus. So I added a window listener to
the eclipse current window and update my swt presentation part implementing
IWindowListener.windowActivated()
Well, again thank you: your tips about the problem help me figure out what the
problem was and fix it.
On Thu, 27 Jul 2006 15:27:33 -0400
Ed Merks <merks@ca.ibm.com> wrote:
> Sebastian,
>
> This sounds like a threading issue. That method returns the Display for
> the current thread, so if you get null, you're on a thread without a
> display and you won't be able to do much with a display from another
> thread anyway. Perhaps code like this is what you want to be doing:
>
> getSite().getShell().getDisplay().asyncExec
> (new Runnable()
> {
> public void run()
> {
> // work with current display which will be the
> editor's site's shell's display.
> }
> });
>
> Sebastian Gurin wrote:
> > Hi
> >
> > Well, I'm using a third party swing application in my plugin. The swing JFrame
> > is a singleton that is never disposed, but is setVisible(true o false) according
> > if I want to activate or deactivate it.
> >
> > When the editor is setVisible(false) then in my plugin's code I'm having a
> > nullPointer exception because Display.getCurrent()==null. So I need a way to set
> > the workbench' current display manually. How do I do that? I want to do something
> > like Display.setCurrent(...) but can't find how.
> >
> > Hope you can understand my poor english.
> >
> > Thanks in advance
> >
|
|
|
Powered by
FUDForum. Page generated in 0.02863 seconds