Monday, May 1, 2017

Adding an Exit Dialog to your NetBeans Platform based RCP

Over time numerous requests to add an Exit Dialog box accumulated in my list of requested enhancements. I have always thought about where to hook up such a Dialog and after reading through the NetBeans Wiki I realized the ModuleInstaller class is a good candidate (rather than using the LifeCycleManager).

The DevFaqModulesStartupActions is mentioning the closing() method of each ModuleInstaller of each module has VETO rights to prevent the application from exiting.

So adding an instance of a ModuleInstaller in one of your modules of your RCP as described in the above DevFaqModulesStartupActions Wiki entry and overriding the closing() method with code asking the user if it is OK to exit in a modal dialog. If not, return false and VETO the exit sequence. My code turned out to look like below:

No comments:

Post a Comment