title: Eclipse e4 - Hiding Parts while Dialog is open
body: <p>We are currently developing a Application in pure e4.</p>
  
  <p>We have the Use Case that a ProgressMonitorDialog should be opened, while all open Parts are getting hidden.</p>
  
  <p>Code:</p>
  
  <pre><code>IRunnableWithProgress runnable = monitor -&gt; {
      Collection&lt;MPart&gt; allParts = partService.getParts();
      monitor.beginTask("Do Stuff", allParts.size());
      for (MPart part : allParts) {
        partService.hidePart(part);
        monitor.worked(1);
      }
      monitor.done();
    };
  
  ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
  dialog.setCancelable(false);
  dialog.setOpenOnRun(true);
  dialog.run(true, false, runnable);
  </code></pre>
  
  <p>The Problem is, that during the Execution (when trying to hide a part for the first time) an Exception is thrown:</p>
  
  <pre><code>java.lang.IllegalStateException: Application does not have an active window
  at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.getActiveWindowService(ApplicationPartServiceImpl.java:46)
  at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.hidePart(ApplicationPartServiceImpl.java:145)
  at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.hidePart(ApplicationPartServiceImpl.java:145)
  at mine.lambda$3(Handler.java:100)
  at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:37)
  at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
  at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4213)
  at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3820)
  at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:165)
  at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:369)
  at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:483)
  at mine.showProgressDialog(Helper.java:160)
  at mine.execute(Handler.java:82)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
  at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:305)
  at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:239)
  at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
  at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
  at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
  at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
  at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
  at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:431)
  at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:446)
  at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:472)
  at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
  at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4428)
  at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
  at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4238)
  at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3817)
  at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1150)
  at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
  at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1039)
  at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
  at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:162)
  at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
  at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
  at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
  at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
  at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
  at org.eclipse.equinox.launcher.Main.main(Main.java:1472)
  </code></pre>
  
  <p>I also tried running the executing code with the UiSynchronize, but still getting the same exception.</p>
  
  <p>Is there anything I can do to work with the PartService and with Parts while a Dialog is open?</p>
  
  <p>Thanks in advance!</p>