I have an editor in Eclipse. When the user chooses to close it, a dialog shall appear with several options. One of them is "Cancel" and should cancel the close event. How can I do that?
The partial code I have so far:
...
IEditorPart openEditor = page.openEditor(input, CS_STRINGEDITOR_ID);
openEditor.getEditorSite().getPage()
.addPartListener(new IPartListener() {
public void partOpened(IWorkbenchPart part) {}
public void partDeactivated(IWorkbenchPart part) {}
public void partClosed(IWorkbenchPart part) {
Shell sh = new Shell(cv.getViewSite().getShell());
// My MessageDialog with the options, one being "cancel"
CloseDialog closeDialog = new CloseDialog(sh);
closeDialog.open();
int returnCode = closeDialog.getReturnCode();
switch (returnCode) {
case CloseDialog.CANCEL_ID:
// Abort the close event and keep the editor alive
break;
}
}