Project: Eclipse_Platform_UI
Bug 71701 [Workbench] Allow plugins to veto shutdown
Reported: 2004-08-10 04:24:58 | Status: verified fixed

The WorkbenchAdvisor should be accessible from Plugins to catch the workbench's lifecycle events. In an RCP application a plugin should be asked if the platform may shutdown on File-Quit (e.g. a view might have unsaved data (sometimes an editor cannot be used as long as there is no way from stopping an editor from being closed by the user)). Right now in WorkbenchAdvisor.preShutdown() I ask the views to prompt the user if the platform may shutdown. IPartListener cannot stop the platform from shutting down. The views I find in my WorkbenchAdvisor via configurer.getWindow().getActivePage().findView(IDVIEW). This works, but results in a dependency of RCPWorkbenchAdvisor to the views. So I thought of having the views register themselves in RCPWorkbenchAdvisor. But there is no way to access the WorkbenchAdvisor from a plugin. There should be a method, e.g. IWorkbench.getAdvisor(). Right now there is Workbench.getAdvisor() but it is package private.

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbench.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkbenchListener.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java tests/org.eclipse.ui.tests.rcp/Eclipse RCP Tests/org/eclipse/ui/tests/rcp/RcpTestSuite.java tests/org.eclipse.ui.tests.rcp/Eclipse RCP Tests/org/eclipse/ui/tests/rcp/WorkbenchListenerTest.java