Hi all,
I am writing an Eclipse plugin for a college project and need to be able to run code when the user exits and I can't find the correct Listener to enable me do this. An example of similar code is shown below where I listen for successfully completed save events and call a method when this occurs.
public class ExecutionListener implements IExecutionListener{
private DataCollector dataCollector;
public ExecutionListener(DataCollector dataCollector)
{
this.dataCollector = dataCollector;
}
public void postExecuteSuccess(String action, Object arg1)
{
if (action.equals("org.eclipse.ui.file.save")) {
dataCollector.writeDatabase();
}
}
So what I want is a Listener which will allow me to listen for exit events and call a method to run my code when this happens. I suppose I wont be able to ensure the exit is successfully completed before running the code but a 'pre-exit' Listener would work just fine. Also if someone does know of the correct Listener could they also tell me the commandId I will need for the exit event (e.g. the commandId for the save event in the above example is "org.eclipse.ui.file.save").
Thanks, Jacob
EDIT: To reply to javamonkey79's question:
I add the listener like this:
/* Adds a listener to listen for file save events if needed. */
if (executionListener == null) {
ICommandService service = (ICommandService) Activator.getDefault().getWorkbench().
getService(ICommandService.class);
executionListener = new ExecutionListener();
service.addExecutionListener(executionListener);
}