为什么我的 Eclipse 插件 ICommand IParameter 的值没有显示在 Preferences/Keys 设置中?
我正在尝试开发一个 Eclipse 插件,它将以可键绑定命令的形式启动特定目标。
这是 plugin.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<category name="Custom Launcher" id="Eclipse_Keybound_Launch_Plugin.commands.category"/>
<command
categoryId="Eclipse_Keybound_Launch_Plugin.commands.category"
defaultHandler="eclipse_keybound_launch_plugin.handlers.CustomLaunchCommandHandler"
description="Launch/terminate then relaunch a custom target in debug mode"
id="Eclipse_Keybound_Launch_Plugin.commands.terminateLaunch"
name="Launch">
<commandParameter
id="Eclipse Keybound Launch Plugin.launchTarget"
name="target"
optional="false"
/>
</command>
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="Eclipse_Keybound_Launch_Plugin.commands.terminateLaunch"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6">
<parameter id="Eclipse Keybound Launch Plugin.launchTarget" value="RunMe"/>
</key>
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="Eclipse_Keybound_Launch_Plugin.commands.terminateLaunch"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+7">
<parameter id="Eclipse Keybound Launch Plugin.launchTarget" value="RunMeAlso"/>
</key>
</extension>
</plugin>
为了完整起见,它在扩展视图中的样子如下:
当我对其进行测试时,该插件可以正常工作;参数值在ExecutionEvent
中可用。但是,该值未显示在“首选项/键”设置中:
为什么会出现这种情况?我需要做什么才能让 Eclipse 不仅显示名称 (target:
),还显示参数的值 (RunMe
和 RunMeAlso
在这种情况下)?
请注意,我使用的是 Eclipse SDK 版本:3.6.1,构建 ID:M20100909-0800。
I'm trying to develop an Eclipse plugin that will launch specific targets as key-bindable commands.
Here's the plugin.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.commands">
<category name="Custom Launcher" id="Eclipse_Keybound_Launch_Plugin.commands.category"/>
<command
categoryId="Eclipse_Keybound_Launch_Plugin.commands.category"
defaultHandler="eclipse_keybound_launch_plugin.handlers.CustomLaunchCommandHandler"
description="Launch/terminate then relaunch a custom target in debug mode"
id="Eclipse_Keybound_Launch_Plugin.commands.terminateLaunch"
name="Launch">
<commandParameter
id="Eclipse Keybound Launch Plugin.launchTarget"
name="target"
optional="false"
/>
</command>
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="Eclipse_Keybound_Launch_Plugin.commands.terminateLaunch"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6">
<parameter id="Eclipse Keybound Launch Plugin.launchTarget" value="RunMe"/>
</key>
</extension>
<extension point="org.eclipse.ui.bindings">
<key commandId="Eclipse_Keybound_Launch_Plugin.commands.terminateLaunch"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+7">
<parameter id="Eclipse Keybound Launch Plugin.launchTarget" value="RunMeAlso"/>
</key>
</extension>
</plugin>
For completeness, here's how it looks like in the Extension view:
The plugin works when I put it to the test; the parameter value is available in the ExecutionEvent
. However, the value is not shown in the Preferences/Keys setting:
Why is this the case? What do I need to do to have Eclipse show not just the name (target:
) but also the values of the parameters (RunMe
and RunMeAlso
in this case)?
Note that I'm using Eclipse SDK Version: 3.6.1, Build id: M20100909-0800.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
定义 commandParameter 时,使用 values 元素提供
org.eclipse.core.commands.IParameterValues
。该类将命令参数中的信息映射到人类可读的标签。请参阅 org.eclipse.ui.internal.registry.PerspectiveParameterValues 和 org.eclipse.ui.internal.registry.ViewParameterValues 作为示例,但基本上您返回的是标签映射至身份证:
When you define your commandParameter, use the values element to provide a
org.eclipse.core.commands.IParameterValues
. That class is what maps the information in a command parameter to a human-readable label.See
org.eclipse.ui.internal.registry.PerspectiveParameterValues
andorg.eclipse.ui.internal.registry.ViewParameterValues
as examples, but basically you are returning a map of label to ID: