By | 2015年11月18日

只需要给workbench添加一个Listener,此逻辑可以添加到ApplicationWorkbenchWindowAdvisor ::postWindowCreate(),

    final IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();

    workbench.addWorkbenchListener(new IWorkbenchListener() {
      public boolean preShutdown(IWorkbench workbench, boolean forced) {
        activePage.closeEditors(activePage.getEditorReferences(), true);
        // Tips: View cannot be closed (disposed), because a view can be used in multiple perspective.
        // When a view is hide in all perspective, this view will be disposed automatically.
        for (IViewReference viewReference : activePage.getViewReferences()) {
        return true;

      public void postShutdown(IWorkbench workbench) {
        // Do nothing.