« Agile vs. RUP - Practicing Resonance: Part 2 | Main | The Wedding Pictures »

February 11, 2005

Getting your Eclipse SWT Shell

Eclipse dialogs (MessageDialog, MessageDialogWithToggle, ...) require the SWT org.eclipse.swt.widgets.Shell class to show themselves.  Occasionally I forget how to get the default Shell.  Maybe Google will start returning this tip.  Here's how to do it:

PlatformUI.getWorkbench().
                getActiveWorkbenchWindow().getShell();

Don't forget to add a dependency on org.eclipse.ui to your plugin.

An improvement over this is to subclass your favorite Eclipse dialog and provide a new static "open...()" method that doesn't ask for the Shell param and uses the default.

Eclipse

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83455a82969e200d8350da8c653ef

Listed below are links to weblogs that reference Getting your Eclipse SWT Shell:

Comments

Effectively, this tip is already appearing in Google :).
Thanks!

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment