org.eclipse.debug.core.IDebugEventSetListener Java Examples

The following examples show how to use org.eclipse.debug.core.IDebugEventSetListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * When a Server runtime server is started and terminated, and the project has a GWT Facet, start and stop the GWT
 * Super Dev Mode Code Server with runtime server.
 */
@Override
public void start(BundleContext context) throws Exception {
  super.start(context);

  // Observe launch events that are from the WTP server
  serverProcessListener = new IDebugEventSetListener() {
    @Override
    public void handleDebugEvents(DebugEvent[] events) {
      if (events != null) {
        onDebugEvents(events);
      }
    }
  };
  DebugPlugin.getDefault().addDebugEventListener(serverProcessListener);
}
 
Example #2
Source File: RemoteLaunchConfigDelegate.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void addDebugEventListener(final ILaunch launch) {
	// Add the debug listener
	DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
		@Override
		public void handleDebugEvents(DebugEvent[] events) {
			for (DebugEvent event : events) {
				if (event.getKind() == DebugEvent.TERMINATE && event.getSource() instanceof IDebugTarget
						&& ((IDebugTarget) event.getSource()).getLaunch() == launch) {
					// Remove this listener
					DebugPlugin.getDefault().removeDebugEventListener(this);

					// Make sure the port forward is terminated
					Arrays.stream(launch.getProcesses()).filter(process -> !process.isTerminated()).forEach(process -> {
						try {
							process.terminate();
						} catch (DebugException e) {
							Logger.logError("An error occurred trying to terminate the process: " + process.getLabel(), e);
						}
					});

					// No need to process the rest of the events
					break;
				}
			}
		}
	});
}
 
Example #3
Source File: DebugEarlyStartup.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void earlyStartup() {
    //Note: preferences are in the PydevPlugin, not in the debug plugin.
    IEclipsePreferences preferenceStore = PydevPrefs.getEclipsePreferences();
    preferenceStore.addPreferenceChangeListener(new IPreferenceChangeListener() {

        @Override
        public void preferenceChange(PreferenceChangeEvent event) {
            if (DebugPluginPrefsInitializer.DEBUG_SERVER_STARTUP.equals(event.getKey())) {
                //On a change in the preferences, re-check if it should be always on...
                checkAlwaysOnJob.schedule(200);
            }
        }
    });

    RemoteDebuggerServer.getInstance().addListener(new IRemoteDebuggerListener() {

        @Override
        public void stopped(RemoteDebuggerServer remoteDebuggerServer) {
            //When it stops, re-check if it should be always on.
            checkAlwaysOnJob.schedule(200);
        }
    });
    checkAlwaysOnJob.schedule(500); //wait a little bit more to enable on startup.

    DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {

        @Override
        public void handleDebugEvents(DebugEvent[] events) {
            if (events != null) {
                for (DebugEvent debugEvent : events) {
                    if (debugEvent.getKind() == DebugEvent.SUSPEND) {
                        if (debugEvent.getDetail() == DebugEvent.BREAKPOINT) {
                            if (debugEvent.getSource() instanceof PyThread) {

                                IPreferenceStore preferenceStore2 = PyDevUiPrefs.getPreferenceStore();
                                final int forceOption = preferenceStore2
                                        .getInt(DebugPluginPrefsInitializer.FORCE_SHOW_SHELL_ON_BREAKPOINT);

                                if (forceOption != DebugPluginPrefsInitializer.FORCE_SHOW_SHELL_ON_BREAKPOINT_MAKE_NOTHING) {
                                    Runnable r = new Runnable() {

                                        @Override
                                        public void run() {
                                            Shell activeShell = UIUtils.getActiveShell();
                                            if (activeShell != null) {
                                                forceActive(activeShell, forceOption);
                                            }
                                        }
                                    };
                                    boolean runNowIfInUiThread = true;
                                    RunInUiThread.async(r, runNowIfInUiThread);
                                }
                            }
                        }
                    }
                }
            }
        }
    });
}