Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Getting null display

I am trying to pop up a dialog (i.e. a FileDialog) in an Eclipse Plugin, actually before of an Acceleo transformation I am running through the related UI Launcher project (http://lowcoupling.com/post/51877317162/the-acceleo-ui-launcher-project)

I am trying to do this in the related doGenerate method...

public void doGenerate(IProgressMonitor monitor) throws IOException {

    Display display = Display.getCurrent();
    System.out.println(display);
    //....

but the display I get is null How should I do that?

like image 706
lowcoupling Avatar asked Oct 04 '13 21:10

lowcoupling


2 Answers

The documentation of IWorkbench#getDisplay() states:

Code should always ask the workbench for the display rather than rely on Display.getDefault().

So use:

PlatformUI.getWorkbench().getDisplay()

instead.

like image 117
Baz Avatar answered Oct 06 '22 18:10

Baz


I'm not sure if you looked at this yet, but in the documentation for the class Display, it says that Display.getCurrent() returns

null if the currently running thread is not a user-interface thread for any display.

This might be the problem, but without more information I can't tell.

like image 44
The Guy with The Hat Avatar answered Oct 06 '22 18:10

The Guy with The Hat