0

I have a plugin into an eclipse rcp application. I need to detect a scenario whenever a particular perspective is closed or if the application is closed and based on the outcome, I may need to cancel the closing of the app or perspective. If I had access to the application's WorkbenchAdvisor class, this would be trivial. As a plugin to this app, how can I detect the event and how can I tell the main application/advisor that I need to have the close canceled?

Doug
  • 21
  • 1
  • 3

2 Answers2

1

Have you looked at installing an IWorkbenchListener and extending the preShutdown method? It appears you can veto a shutdown using this mechanism.

howlger
  • 31,050
  • 11
  • 59
  • 99
Mike Daniels
  • 8,582
  • 2
  • 31
  • 44
  • That works great for capturing the workbench shutdown when the app closes and may indeed be what I'm stuck with. I can't find anything to detect AND veto the closing of a perspective. I can use an IPerspectiveListener3 to detect the close, but it doesn't allow it to be canceled. – Doug Apr 23 '10 at 21:26
0

I think want you want to do is not possible. If a plug-in could prevent an rcp application to shut down (or the other way force it to should down) this can be a serious security problem. Also the app state would be unclear as it might has released some resources.

If an app wants to give control of program termination to a plug-in it should define an interface/extension point that can be used.

javalympics
  • 241
  • 2
  • 7