diff --git a/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF index f28215054bf..b84817037d6 100644 --- a/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.core/META-INF/MANIFEST.MF @@ -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" diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProvider.java index 1a05bbb2438..7867d4942c3 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProvider.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProvider.java @@ -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> descEntry : configMap.entrySet()) { diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/launch/IRemoteLaunchConfigurationDelegate.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/launch/IRemoteLaunchConfigurationDelegate.java deleted file mode 100644 index 39fdf01c4d6..00000000000 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/launch/IRemoteLaunchConfigurationDelegate.java +++ /dev/null @@ -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 null 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 null - * @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 false is returned the launch will proceed without further - * building, and if true is returned an incremental build will - * be performed on the workspace before launching. - *

- * 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 - * ILaunchConfiguration.launch(String mode, IProgressMonitor monitor, boolean build). - *

- * @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 null. 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 - * preLaunchCheck() and buildForLaunch() 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 null. 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 null. 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 ILaunchManager - - * RUN_MODE or DEBUG_MODE. - * @param target the remote connection the configuration to launched on - * @param monitor progress monitor, or null progress monitor, or null. 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; - -} diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/launch/RemoteLaunchConfigurationDelegate.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/launch/RemoteLaunchConfigurationDelegate.java deleted file mode 100644 index c7c0f938515..00000000000 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/launch/RemoteLaunchConfigurationDelegate.java +++ /dev/null @@ -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. - } - -} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java index 29197d2586f..2c26c8be95a 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/BuildActiveCommandHandler.java @@ -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);