Search code examples
eclipseeclipse-plugineclipse-rcpe4

Shell in Pure Eclipse E4


How to get a shell from workbench window in Eclipse e4 or else do we have to use the same which we following in eclipse 3.x?

Could anyone please help me? My aim is to develop a pure e4 project.


Solution

  • If you want to open a dialog or something like that from a handler you normally use the active shell. This is stored in the Eclipse context under the name IServiceConstants.ACTIVE_SHELL.

    You can get this in a handler by injecting it - something like:

    @Execute
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell)
    {
       ..
    }
    

    If you are not in an injected class you can use the Display method:

    Shell shell = Display.getDefault().getActiveShell();