Project: Eclipse_Platform_UI
Bug 82309 [Workbench] Feature request: test for Workbench closing
Reported: 2005-01-06 05:00:04 | Status: verified fixed

I shall be grateful if org.eclipse.ui.IWorkbench2 could be created which extends org.eclipse.ui.IWorkbench by adding: isClosing() which is already implemented as org.eclipse.ui.internal.Workbench.isClosing(). (Conceivably, someone else might want isStarting() too.) When a document closes, I need to know if the user explicity closed it (so it won't be automatically opened the next time the Workbench starts) or if it is being closed implicitly as part of the Workbench shutdown (so it will be automatically opened the next time the Workbench starts). Currently, I'm doing this in my EditorPart.dispose(): IWorkbench iworkbench = PlatformUI.getWorkbench(); if (iworkbench instanceof org.eclipse.ui.internal.Workbench) { org.eclipse.ui.internal.Workbench workbench = (org.eclipse.ui.internal.Workbench)iworkbench; if (workbench.isClosing()) { // Document will be opened automatically upon next startup // Keep server lock and keep locally cached document // ... } else { // User closed this editor specifically // Free server lock and discard locally cached document // ... } } else { // dispare! :-) }

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/internal/Workbench.java