Am I The Last ??


I learned recently the clean way to replace all my Display.getDefault() method calls:

PlatformUI.getWorkbench().getDisplay();

Here is the Javadoc for this method :

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

Am I the last not aware about this method ?? If no, this post may be can help someone else for example spending time to know why there is no active WorkbenchWindow associated to the default Display :) …

Thanks to Xavier for pointing me to this cleaner method.

Advertisements
This entry was posted in Uncategorized by Manuel. Bookmark the permalink.

6 thoughts on “Am I The Last ??

  1. The Display.getDefault() method returns the first DIsplay created or creates a new one if it doesn’t exist.

    In an Eclipse environment it doesn’t guaranty that the returned display is the Workbench’s one so you can’t rely on this method.

    I haven’t yet encounter a concrete case where it can cause problems but I’am pretty sure such cases exists … Anyone with such an example ?

    Manu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s