mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Remove the special launch config delegate for remote.
It's too hard to replicate the entire debug platform launch sequence in order to insert the target this way. We'll need to come up with something better if we want to share launch configs between targets. But that will have to wait until Neon at the earliest. Change-Id: I208eed527961e172316f0b12b869be5665a6aca5
This commit is contained in:
parent
f6e8b921c3
commit
456b2f42b5
5 changed files with 25 additions and 206 deletions
|
@ -12,5 +12,4 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.launchbar.core,
|
||||
org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui",
|
||||
org.eclipse.launchbar.core.launch
|
||||
org.eclipse.launchbar.core.internal;x-friends:="org.eclipse.launchbar.core.tests,org.eclipse.launchbar.ui"
|
||||
|
|
|
@ -7,7 +7,10 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.launchbar.core.internal.Activator;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
|
||||
public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfigProvider {
|
||||
|
||||
|
@ -44,6 +47,26 @@ public abstract class PerTargetLaunchConfigProvider extends AbstractLaunchConfig
|
|||
workingCopy.setAttribute(ATTR_CONNECTION_NAME, target.getName());
|
||||
}
|
||||
|
||||
public static IRemoteConnection getTarget(ILaunchConfiguration configuration) throws CoreException {
|
||||
IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
|
||||
String connectionTypeId = configuration.getAttribute(ATTR_CONNECTION_TYPE, ""); //$NON-NLS-1$
|
||||
if (connectionTypeId.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IRemoteConnectionType connectionType = remoteManager.getConnectionType(connectionTypeId);
|
||||
if (connectionType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String connectionName = configuration.getAttribute(ATTR_CONNECTION_NAME, ""); //$NON-NLS-1$
|
||||
if (connectionName.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return connectionType.getConnection(connectionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
|
||||
for (Entry<ILaunchDescriptor, Map<IRemoteConnection, ILaunchConfiguration>> descEntry : configMap.entrySet()) {
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* 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 Software Systems - initial
|
||||
* IBM and others who contributed to ILaunchConfigurationDelegate2
|
||||
* and ILaunchConfigurationDelegate
|
||||
*******************************************************************************/
|
||||
package org.eclipse.launchbar.core.launch;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
|
||||
/**
|
||||
* A launch configuration delegate that accepts a IRemoteConnection as an additional
|
||||
* parameter to the launch functions. Delegates who want to receive this parameter from
|
||||
* the LaunchBar launch actions need to implement this interface.
|
||||
*/
|
||||
public interface IRemoteLaunchConfigurationDelegate extends ILaunchConfigurationDelegate2 {
|
||||
|
||||
/**
|
||||
* Returns a launch object to use when launching the given launch
|
||||
* configuration in the given mode, or <code>null</code> if a new default
|
||||
* launch object should be created by the debug platform. If a launch object
|
||||
* is returned, its launch mode must match that of the mode specified in
|
||||
* this method call.
|
||||
*
|
||||
* @param configuration the configuration being launched
|
||||
* @param mode the mode the configuration is being launched in
|
||||
* @param target the remote connection to launch on
|
||||
* @return a launch object or <code>null</code>
|
||||
* @throws CoreException if unable to launch
|
||||
*/
|
||||
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode, IRemoteConnection target) throws CoreException;
|
||||
|
||||
/**
|
||||
* Optionally performs any required building before launching the given
|
||||
* configuration in the specified mode, and returns whether the debug platform
|
||||
* should perform an incremental workspace build before the launch continues.
|
||||
* If <code>false</code> is returned the launch will proceed without further
|
||||
* building, and if <code>true</code> is returned an incremental build will
|
||||
* be performed on the workspace before launching.
|
||||
* <p>
|
||||
* This method is only called if the launch is invoked with flag indicating
|
||||
* building should take place before the launch. This is done via the
|
||||
* method
|
||||
* <code>ILaunchConfiguration.launch(String mode, IProgressMonitor monitor, boolean build)</code>.
|
||||
* </p>
|
||||
* @param configuration the configuration being launched
|
||||
* @param mode the mode the configuration is being launched in
|
||||
* @param target the remote connection the configuration is being launched on
|
||||
* @param monitor progress monitor, or <code>null</code>. A cancelable progress monitor is provided by the Job
|
||||
* framework. It should be noted that the setCanceled(boolean) method should never be called on the provided
|
||||
* monitor or the monitor passed to any delegates from this method; due to a limitation in the progress monitor
|
||||
* framework using the setCanceled method can cause entire workspace batch jobs to be canceled, as the canceled flag
|
||||
* is propagated up the top-level parent monitor. The provided monitor is not guaranteed to have been started.
|
||||
* @return whether the debug platform should perform an incremental workspace
|
||||
* build before the launch
|
||||
* @throws CoreException if an exception occurs while building
|
||||
*/
|
||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IRemoteConnection target, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether a launch should proceed. This method is called after
|
||||
* <code>preLaunchCheck()</code> and <code>buildForLaunch()</code> providing
|
||||
* a final chance for this launch delegate to abort a launch if required.
|
||||
* For example, a delegate could cancel a launch if it discovered compilation
|
||||
* errors that would prevent the launch from succeeding.
|
||||
*
|
||||
* @param configuration the configuration being launched
|
||||
* @param mode launch mode
|
||||
* @param target the remote connection the configuration is being launched on
|
||||
* @param monitor progress monitor, or <code>null</code>. A cancelable progress monitor is provided by the Job
|
||||
* framework. It should be noted that the setCanceled(boolean) method should never be called on the provided
|
||||
* monitor or the monitor passed to any delegates from this method; due to a limitation in the progress monitor
|
||||
* framework using the setCanceled method can cause entire workspace batch jobs to be canceled, as the canceled flag
|
||||
* is propagated up the top-level parent monitor. The provided monitor is not guaranteed to have been started.
|
||||
* @return whether the launch should proceed
|
||||
* @throws CoreException if an exception occurs during final checks
|
||||
*/
|
||||
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IRemoteConnection target, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* Returns whether a launch should proceed. This method is called first
|
||||
* in the launch sequence providing an opportunity for this launch delegate
|
||||
* to abort the launch.
|
||||
*
|
||||
* @param configuration configuration being launched
|
||||
* @param mode launch mode
|
||||
* @param target the remote connection the configuration is being launched on
|
||||
* @param monitor progress monitor, or <code>null</code>. A cancelable progress monitor is provided by the Job
|
||||
* framework. It should be noted that the setCanceled(boolean) method should never be called on the provided
|
||||
* monitor or the monitor passed to any delegates from this method; due to a limitation in the progress monitor
|
||||
* framework using the setCanceled method can cause entire workspace batch jobs to be canceled, as the canceled flag
|
||||
* is propagated up the top-level parent monitor. The provided monitor is not guaranteed to have been started.
|
||||
* @return whether the launch should proceed
|
||||
* @throws CoreException if an exception occurs while performing pre-launch checks
|
||||
*/
|
||||
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IRemoteConnection target, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* Launches the given configuration in the specified mode, contributing
|
||||
* debug targets and/or processes to the given launch object. The
|
||||
* launch object has already been registered with the launch manager.
|
||||
*
|
||||
* @param configuration the configuration to launch
|
||||
* @param mode the mode in which to launch, one of the mode constants
|
||||
* defined by <code>ILaunchManager</code> -
|
||||
* <code>RUN_MODE</code> or <code>DEBUG_MODE</code>.
|
||||
* @param target the remote connection the configuration to launched on
|
||||
* @param monitor progress monitor, or <code>null</code> progress monitor, or <code>null</code>. A cancelable progress
|
||||
* monitor is provided by the Job framework. It should be noted that the setCanceled(boolean) method should
|
||||
* never be called on the provided monitor or the monitor passed to any delegates from this method; due to a
|
||||
* limitation in the progress monitor framework using the setCanceled method can cause entire workspace batch
|
||||
* jobs to be canceled, as the canceled flag is propagated up the top-level parent monitor.
|
||||
* The provided monitor is not guaranteed to have been started.
|
||||
* @param launch the launch object to contribute processes and debug
|
||||
* targets to
|
||||
* @exception CoreException if launching fails
|
||||
*/
|
||||
public void launch(ILaunchConfiguration configuration, String mode, IRemoteConnection target, ILaunch launch, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* 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 Software Systems - initial
|
||||
*******************************************************************************/
|
||||
package org.eclipse.launchbar.core.launch;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
|
||||
public abstract class RemoteLaunchConfigurationDelegate extends LaunchConfigurationDelegate
|
||||
implements IRemoteLaunchConfigurationDelegate {
|
||||
|
||||
@Override
|
||||
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode, IRemoteConnection target)
|
||||
throws CoreException {
|
||||
return getLaunch(configuration, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IRemoteConnection target,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
return buildForLaunch(configuration, mode, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IRemoteConnection target,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
return finalLaunchCheck(configuration, mode, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IRemoteConnection target,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
return preLaunchCheck(configuration, mode, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(ILaunchConfiguration configuration, String mode, IRemoteConnection target, ILaunch launch,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
launch(configuration, mode, launch, monitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
// do nothing by default assuming the subclass has implemented a proper remote launch() method.
|
||||
}
|
||||
|
||||
}
|
|
@ -35,10 +35,8 @@ import org.eclipse.debug.core.ILaunchMode;
|
|||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
|
||||
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
|
||||
import org.eclipse.launchbar.core.internal.LaunchBarManager;
|
||||
import org.eclipse.launchbar.core.launch.IRemoteLaunchConfigurationDelegate;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
@ -59,7 +57,6 @@ public class BuildActiveCommandHandler extends AbstractHandler {
|
|||
LaunchBarManager launchBarManager = Activator.getDefault().getLaunchBarUIManager().getManager();
|
||||
final ILaunchConfiguration config = launchBarManager.getActiveLaunchConfiguration();
|
||||
final ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
|
||||
final IRemoteConnection target = launchBarManager.getActiveLaunchTarget();
|
||||
|
||||
new UIJob(Display.getDefault(), Messages.BuildActiveCommandHandler_0) {
|
||||
@Override
|
||||
|
@ -90,17 +87,7 @@ public class BuildActiveCommandHandler extends AbstractHandler {
|
|||
if (delegate == null)
|
||||
delegate = config.getType().getDelegates(modes)[0];
|
||||
ILaunchConfigurationDelegate configDel = delegate.getDelegate();
|
||||
if (configDel instanceof IRemoteLaunchConfigurationDelegate) {
|
||||
IRemoteLaunchConfigurationDelegate configDel2 = (IRemoteLaunchConfigurationDelegate)configDel;
|
||||
boolean ret;
|
||||
ret = configDel2.preLaunchCheck(config, mode, target, monitor);
|
||||
if (!ret) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
if (!configDel2.buildForLaunch(config, mode, target, monitor)) {
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
} else if (configDel instanceof ILaunchConfigurationDelegate2) {
|
||||
if (configDel instanceof ILaunchConfigurationDelegate2) {
|
||||
ILaunchConfigurationDelegate2 configDel2 = (ILaunchConfigurationDelegate2)configDel;
|
||||
boolean ret;
|
||||
ret = configDel2.preLaunchCheck(config, mode, monitor);
|
||||
|
|
Loading…
Add table
Reference in a new issue