Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » setting the current display
setting the current display [message #306385] Thu, 27 July 2006 10:03 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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 #306390 is a reply to message #306385] Thu, 27 July 2006 15:26 Go to previous message
Eclipse UserFriend
When Display.getCurrent()==null that means you are access the Display
from a non-UI thread.

You need to make sure your UI calls are in the UI thread.

Later,
PW
Re: setting the current display [message #306394 is a reply to message #306389] Thu, 27 July 2006 11:47 Go to previous message
Eclipse UserFriend
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
> >
Previous Topic:Connection between IProject and ILaunchConfiguration
Next Topic:FieldEditorPreferencePage and preference "scopes": how to use together?
Goto Forum:
  


Current Time: Sun May 11 11:51:01 EDT 2025

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

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

Back to the top