I am developing an Eclipse RCP Application. I know the method org.eclipse.ui.internal.Workbench.close() could close the workbench and if the workbench has an open editor with unsaved content, the user will be given the opportunity to save it.
But whether I have the ability to close the workbench directly without saving any unsaved conent and without any hint ?
CodePudding user response:
The IWorkbenchConfigurer
which is passed to the WorkbenchAdvisor and WorkbenchWindowAdvisor has an emergencyClose
which should do a close.
But note what the Javadoc for the method says:
Forces the workbench to close due to an emergency. This method should only be called when the workbench is in dire straights and cannot continue, and cannot even risk a normal workbench close (think "out of memory" or "unable to create shell"). When this method is called, an abbreviated workbench shutdown sequence is performed (less critical steps may be skipped). The workbench advisor is still called; however, it must not attempt to communicate with the user.
Also note that the Workbench
class is internal and should not be accessed directly - only with the IWorkbench
interface.