2011-02-16 66 views
0

我正在研究Eclipse的一个小插件,以(重新)以编程方式启动LaunchConfigurations。Eclipse:如何重新启动LaunchConfiguration

我可以启动一个配置,但我想增强下面的代码,以便在启动之前首先关闭具有给定名称的所有正在运行的配置。

public void restartLaunchConfiguration(String configurationName) throws Exception { 
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();    

    for(final ILaunchConfiguration cfg : manager.getLaunchConfigurations()){ 
     final String cfgName = cfg.getName(); 

     if(!configurationName.equals(cfgName)) continue; 
     cfg.launch("debug", null); 

     break; 
    } 
} 

如何获取所有正在运行的配置?

如何停止正在运行的配置?

回答

6

我不能测试这个,但你可能能够得到所有正在运行的ILaunchConfigurations的列表。

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); 
ILaunch[] runningLaunches = manager.getLaunches(); 

ILaunch然后有你可以使用的方法,如.getProcesses()。从那里你可以杀死与发射相关的过程。

+0

是的,这样做:)谢谢! – TheIngo 2011-02-17 14:44:58