简体   繁体   English

Eclipse插件:如何指定项目属性中显示的启动配置?

[英]Eclipse plugin: How to specify what launch configurations appear in a project's properties?

I have an Eclipse plugin with a launch delegate, a launch shortcut (which has enablement set to appear when a project has a certain nature), and a launch configuration tab group. 我有一个带有启动委托的Eclipse插件,一个启动快捷方式(当项目具有某种性质时,它会启用启用设置)和一个启动配置选项卡组。 They all work just as I want them to, except for one fact. 除了一个事实,它们都按照我希望的方式工作。 When you go into a project's properties, in "Run/Debug Settings", there's a list of configurations that could apply to this project. 当您进入项目的属性时,在“运行/调试设置”中,有一个可应用于该项目的配置列表。 The problem is, when it's of my project nature, the list it shows consists of ALL the configurations of my type. 问题是,当属于我的项目性质时,它显示的列表由我类型的所有配置组成。

My launch configurations specify what project they apply to, by storing it in a custom attribute, but there's no way for Eclipse to know this, which begs the question: How do you filter what configurations appear in "Run/Debug Settings"? 我的启动配置通过将其存储在定制属性中来指定它们要应用的项目,但是Eclipse无法知道这一点,这引出了一个问题:如何过滤“运行/调试设置”中出现的配置? The Eclipse documentation is seemingly silent on this topic. Eclipse文档似乎对这个主题保持沉默。

With major thanks to greg-449, I have a solution. 非常感谢greg-449,我有一个解决方案。 The problem was that the launch configuration needed to define a resource mapping. 问题在于启动配置需要定义资源映射。 Every launch configuration has a list of resources that "belong" to the configuration, and the "Run/Debug Settings" menu only shows launch configurations that have that resource as a mapping. 每个启动配置都有一个“属于”该配置的资源列表,“运行/调试设置”菜单仅显示具有该资源作为映射的启动配置。 If there is no mapping in the launch configuration, it is assumed to be applicable to all resources. 如果启动配置中没有映射,则假定它适用于所有资源。

In my custom ILaunchConfigurationTabGroup , I failed to add any resource mappings based on the project. 在我的自定义ILaunchConfigurationTabGroup ,我无法基于项目添加任何资源映射。 All it took was the addition of this line to performApply : performApply就是添加这一行到performApply

configuration.setMappedResources(new IResource[] {project});

Where project is whatever resources you want the launch config to appear in. project是您希望启动配置出现在其中的任何资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM