Currently I am working on RCP application
with view part
.
In application, user can able to open multiple instances of same view part
.
I am able to handle view parts close operation with menu selection
.
But I am unaware of handling the 'X' i.e tab close operation.
I tried with adding IPartListener
object to the view part object,(I refereed this link ),but in its partClosed()
method I am facing 2 issues,
view part object
.partClosed()
method only gets called after closing the tab, so I am not able to show the confirmation for closing the tab.What approach should I use to resolve above two questions.
Any help is appreciated.
Best regards,
Mandar
You may consider to implement the interface ISaveablePart2
to your ViewPart
. This interface is responsible to prompt the user if the part should be closed or not. Furthermore it decides what to do with the unsaved data.
You can promt the user if the view should be closed with a custom dialog in the method promptToSaveOnClose()
.
@Override
public boolean isDirty() {
return true;
}
@Override
public int promptToSaveOnClose() {
boolean close = MessageDialog.openConfirm(
Display.getCurrent().getActiveShell(), "Close?", "Really?");
if(close)
return YES;
return CANCEL;
}