mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45:37 +02:00
Re-add the remote launch config service. PTP is using it.
This commit is contained in:
parent
4ca5d9b494
commit
5fce7bf604
4 changed files with 122 additions and 0 deletions
|
@ -14,6 +14,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0",
|
|||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.remote.core,
|
||||
org.eclipse.remote.core.exception,
|
||||
org.eclipse.remote.core.launch,
|
||||
org.eclipse.remote.internal.core;x-friends:="org.eclipse.remote.ui,org.eclipse.remote.jsch.core",
|
||||
org.eclipse.remote.internal.core.preferences;x-friends:="org.eclipse.remote.ui"
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core.launch;
|
||||
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
|
||||
/**
|
||||
* Manages and persists the mapping between launch configurations and
|
||||
* remote connections that they run on. Each launch configuration has an
|
||||
* active remote connection.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteLaunchConfigService {
|
||||
|
||||
/**
|
||||
* Sets the active remote connection for the given launch configuration.
|
||||
*
|
||||
* @param launchConfig launch configuration
|
||||
* @param connection active remote connection
|
||||
*/
|
||||
void setActiveConnection(ILaunchConfiguration launchConfig, IRemoteConnection connection);
|
||||
|
||||
/**
|
||||
* Gets the active remote connection for the given launch configuration
|
||||
* @param launchConfig launch configuration
|
||||
* @return active remote connection
|
||||
*/
|
||||
IRemoteConnection getActiveConnection(ILaunchConfiguration launchConfig);
|
||||
|
||||
/**
|
||||
* For a given launch configuration type, get the remote connection that was last
|
||||
* used by a launch configuration of that type.
|
||||
*
|
||||
* This is used for new launch configurations with the assumption that the user
|
||||
* will want to use the same remote connection.
|
||||
*
|
||||
* @param launchConfigType launch configuration type
|
||||
* @return last active remote configuration
|
||||
*/
|
||||
IRemoteConnection getLastActiveConnection(ILaunchConfigurationType launchConfigType);
|
||||
|
||||
}
|
|
@ -18,6 +18,8 @@ import org.eclipse.core.runtime.IStatus;
|
|||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
|
||||
import org.eclipse.remote.internal.core.launch.RemoteLaunchConfigService;
|
||||
import org.eclipse.remote.internal.core.preferences.Preferences;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
@ -108,6 +110,7 @@ public class RemoteCorePlugin extends Plugin {
|
|||
super.start(context);
|
||||
plugin = this;
|
||||
context.registerService(IRemoteServicesManager.class, new RemoteServicesManager(), null);
|
||||
context.registerService(IRemoteLaunchConfigService.class, new RemoteLaunchConfigService(), null);
|
||||
RemoteDebugOptions.configure(context);
|
||||
ResourcesPlugin.getWorkspace().addSaveParticipant(getUniqueIdentifier(), new ISaveParticipant() {
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package org.eclipse.remote.internal.core.launch;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class RemoteLaunchConfigService implements IRemoteLaunchConfigService {
|
||||
|
||||
private static final String REMOTE_LAUNCH_CONFIG = "remoteLaunchConfig"; //$NON-NLS-1$
|
||||
private static final String REMOTE_LAUNCH_TYPE = "remoteLaunchType"; //$NON-NLS-1$
|
||||
|
||||
private Preferences getPreferences(String node) {
|
||||
return InstanceScope.INSTANCE.getNode(RemoteCorePlugin.getUniqueIdentifier()).node(node);
|
||||
}
|
||||
|
||||
private IRemoteConnection getRemoteConnection(String remoteId) {
|
||||
if (remoteId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] ids = remoteId.split(":"); //$NON-NLS-1$
|
||||
if (ids.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IRemoteServicesManager manager = RemoteCorePlugin.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType connectionType = manager.getConnectionType(ids[0]);
|
||||
if (connectionType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return connectionType.getConnection(ids[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveConnection(ILaunchConfiguration launchConfig, IRemoteConnection connection) {
|
||||
String remoteId = connection.getConnectionType().getId() + ":" + connection.getName(); //$NON-NLS-1$
|
||||
getPreferences(REMOTE_LAUNCH_CONFIG).put(launchConfig.getName(), remoteId);
|
||||
try {
|
||||
getPreferences(REMOTE_LAUNCH_TYPE).put(launchConfig.getType().getIdentifier(), remoteId);
|
||||
} catch (CoreException e) {
|
||||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getActiveConnection(ILaunchConfiguration launchConfig) {
|
||||
String remoteId = getPreferences(REMOTE_LAUNCH_CONFIG).get(launchConfig.getName(), null);
|
||||
return getRemoteConnection(remoteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getLastActiveConnection(ILaunchConfigurationType launchConfigType) {
|
||||
String remoteId = getPreferences(REMOTE_LAUNCH_TYPE).get(launchConfigType.getIdentifier(), null);
|
||||
return getRemoteConnection(remoteId);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue