8

Possible Duplicate:
How can I bind a specific key to different launch configurations in Eclipse?

I am launching certain programs many times from the little dropdown menu next to the green run-button in eclipse.

Is there a way to bind keys (like F1 - F12) to those run configurations?

I couldnt find something like this in the preferences under "Keys".

Community
  • 1
  • 1
clamp
  • 33,000
  • 75
  • 203
  • 299

1 Answers1

10

Currently there's no way to bind to a specific launch config (without writing the plugin code yourself). Here's an example of walking the launch configs looking for a named one:

public class LaunchRunAwayHandler extends AbstractHandler {
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        try {
            final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
            ILaunchConfiguration toLaunch = null;
            for (ILaunchConfiguration config :launchManager.getLaunchConfigurations()) {
                System.out.println(config.getName());
                if (config.getName().equals("RunAway")) {
                    toLaunch = config;
                }
            }
            DebugUITools.launch(toLaunch, ILaunchManager.RUN_MODE);
        } catch (CoreException e) {
            throw new ExecutionException("Failed to launch", e);
        }
        return null;
    }

}

In theory, you would write a command that provides takes a parameter to pick the name, and defines an org.eclipse.core.commands.IParameterValues so you could see all of your launch configs in the Keys preference page.

F11 is Debug Last Launched and CTRL+F11 is Run Last Launched. You might have to set a preference in Preferences>Run/Debug>Launching to "Always launch the previously launched application". But that will just launch the last one, not switch between launches.

Paul Webster
  • 10,614
  • 1
  • 25
  • 32
  • thanks! yep actually i want to launch very specific programs and not just the latest. – clamp May 16 '11 at 13:44
  • You answer saves me a lot of time. :) – Jacob Dam Jul 05 '13 at 10:08
  • 1
    IMO the "run last launched" is a very stupid key binding. what if i have two external tools, (for push build to integration, and for clean the build). Pressing the "run last launched" is like playing russian roulette... I *think* I ran the clean last time... – John Henckel Nov 18 '16 at 18:46