user1011113
user1011113

Reputation: 1365

Have Eclipse perform an action on shutdown

I am trying to have Eclipse perform a concrete action on shutdown (halt an external system that would need to be switched off manually otherwise). I understand there is an extension allowing to activate a plugin on startup ( org.eclipse.ui.IStartup ), but haven't found one to do so when closing Eclipse. Does such an extension even exist? If it doesn't, is there a way to have a script executed or to run some code when closing Eclipse?

Thank you.

Upvotes: 2

Views: 212

Answers (1)

Andrew Eisenberg
Andrew Eisenberg

Reputation: 28757

The simplest answer is to add some code to the stop() method of your plugin. On a normal shutdown, then this method will be called at some point during the shutdown process.

One caveat, though. On abnormal shutdowns, the stop methods of bundles are not called. This will happen, for example, when someone presses CTRL-C from on the command line, or Force Quits from the task manager. I don't think there will be any easy way around this part, though.

For normal shutdowns, adding code to stop should be sufficient.

Upvotes: 3

Related Questions