Java Code Examples for org.eclipse.debug.core.model.IDebugTarget#isDisconnected()

The following examples show how to use org.eclipse.debug.core.model.IDebugTarget#isDisconnected() . 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: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void reconnectDebugger() {
	// First check if there is a launch and it is registered
	if (launch != null) {
		ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
		for (ILaunch launchItem : launchManager.getLaunches()) {
			if (launch.equals(launchItem)) {
				// Check if the debugger is still attached (for Liberty, a small change to the app does not require a server restart)
				IDebugTarget debugTarget = launch.getDebugTarget();
				if (debugTarget == null || debugTarget.isDisconnected()) {
					// Clean up
					clearDebugger();
					// Reconnect the debugger
					connectDebugger();
				}
			}
		}
	}
}
 
Example 2
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void clearDebugger() {
	if (launch != null) {
		IDebugTarget debugTarget = launch.getDebugTarget();
		if (debugTarget != null && !debugTarget.isDisconnected()) {
			try {
				debugTarget.disconnect();
			} catch (DebugException e) {
				Logger.logError("An error occurred while disconnecting the debugger for project: " + name, e); //$NON-NLS-1$
			}
		}
	}
	setLaunch(null);
}
 
Example 3
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public boolean canAttachDebugger() {
	if (projectLanguage.isJava()) {
		IDebugTarget debugTarget = getDebugTarget();
		return (debugTarget == null || debugTarget.isDisconnected());
	} else {
		IDebugLauncher launcher = CodewindCorePlugin.getDebugLauncher(projectLanguage.getId());
		if (launcher != null) {
			return launcher.canAttachDebugger(this);
		}
	}
	return false;
	
}
 
Example 4
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void attachDebugger() {
	// Check to see if already attached
	if (launch != null) {
		IDebugTarget debugTarget = launch.getDebugTarget();
		if (debugTarget != null && !debugTarget.isDisconnected()) {
			// Already attached
			return;
		}
	}
	clearDebugger();
	connectDebugger();
}
 
Example 5
Source File: NodeJSDebugLauncher.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean canAttachDebugger(CodewindEclipseApplication app) {
	if (useBuiltinDebugger()) {
		ILaunch launch = app.getLaunch();
		IDebugTarget debugTarget = launch == null ? null : launch.getDebugTarget();
		return (debugTarget == null || debugTarget.isDisconnected());
	}
	
	String host = app.getDebugConnectHost();
	int debugPort = app.getDebugConnectPort();
	
	if (app instanceof RemoteEclipseApplication && debugPort == -1) {
		// If the port forward is not running then the debugger cannot already be attached
		return true;
	}
	
	// If a debugger is already attached then the devtools url field will not be included in the result
	try {
		URI uri = new URI("http", null, host, debugPort, DEBUG_INFO, null, null); //$NON-NLS-1$
		HttpResult result = HttpUtil.get(uri);
		if (result.isGoodResponse) {
			String response = result.response;
			JSONArray array = new JSONArray(response);
			JSONObject info = array.getJSONObject(0);
			if (info.has(DEVTOOLS_URL_FIELD)) {
				String url = info.getString(DEVTOOLS_URL_FIELD);
				if (url != null && !url.isEmpty()) {
					return true;
				}
			}
		}
	} catch (Exception e) {
		Logger.log("Failed to retrieve the debug information for the " + app.name + " app: " + e.getMessage()); //$NON-NLS-1$  //$NON-NLS-2$
	}
	
	return false;
}