首页 > 解决方案 > 如何在eclipse中获取外部工具列表

问题描述

Eclipse 知道外部工具(菜单运行-> 外部工具),我想在我的视图中右键单击显示外部工具列表,以便用户可以选择我然后执行的工具。

然而,我根本找不到外部工具。
我现在拥有的代码转储了命令(并且有很多),但我没有找到我创建的外部工具。

ICommandService commandService=PlatformUI.getWorkbench().getService(ICommandService.class);
Command[] allCommands = commandService.getDefinedCommands();
for(Command curCommand :allCommands) {
    Category cat = curCommand.getCategory();
    System.out.print(cat.getName()+"  ");
    System.out.println(curCommand.getName());
}

在哪里可以找到外部工具列表?

标签: eclipseeclipse-plugineclipse-pde

解决方案


根据 greg 的信息,我发现以下内容适用于我的情况。

ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type =     manager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); //$NON-NLS-1$
ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type);

这适用于程序启动配置,因为我使用密钥(“org.eclipse.ui.externaltools.ProgramLaunchConfigurationType”。
如果您不知道您的命令是哪种类型,请使用 getLaunchConfigurationTypes() 查找所有类型并列出名称以查找类型你需要。
有很多。


推荐阅读