问题
Is there a way for an eclipse plugin to get a notification when user clicks on the "Terminate Debug" button?
回答1:
You can call
DebugPlugin.getDefault().addDebugEventListener(listener);
to set up an IDebugEventSetListener
. The DebugEvent
passed to the handleDebugEvents
method of the listener has TERMINATE
as one of the event kinds.
For example this handler is from the Ant plugin:
@Override
public void handleDebugEvents(DebugEvent[] events) {
for (int i = 0; i < events.length; i++) {
DebugEvent event = events[i];
if (event.getKind() == DebugEvent.TERMINATE && event.getSource().equals(fProcess)) {
terminated();
}
}
}
来源:https://stackoverflow.com/questions/30148053/eclipse-plugin-get-notification-on-debug-terminate