Eclipse插件扩展点org.Eclipse.ui.command:如何更改文本?
编辑:这是完整的plugin.xmlEclipse插件扩展点org.Eclipse.ui.command:如何更改文本?,eclipse,eclipse-plugin,Eclipse,Eclipse Plugin,编辑:这是完整的plugin.xml <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.ui.commands"> <category name="TB Category" id="TBPlugin.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
name="TB Category"
id="TBPlugin.commands.category">
</category>
<command
name="fubar1"
categoryId="TBPlugin.commands.category"
id="TBPlugin.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="TBPlugin.commands.sampleCommand"
class="tbplugin.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="TBPlugin.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="TB"
mnemonic="M"
id="TBPlugin.menus.sampleMenu">
<command
commandId="TBPlugin.commands.sampleCommand"
mnemonic="S"
id="TBPlugin.menus.sampleCommand">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="TBPlugin.toolbars.sampleToolbar">
<command
commandId="TBPlugin.commands.sampleCommand"
icon="icons/sample.png"
tooltip="TB"
id="TBPlugin.toolbars.sampleCommand">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>
我希望fubar会出现在某个地方,但我看到的是“示例命令”,例如,我单击菜单栏中的新项,而不是“fubar”。此外,搜索代码、xml文件等时,不会显示特定字符串“Sample Command”。该字符串定义在哪里?如何更改它?命令中的
名称
值是命令的默认名称。它可能被菜单定义覆盖
如果使用org.eclipse.ui.menus
扩展点来定义菜单,您可能会遇到如下情况:
label
设置显示的名称,该名称是可选的,默认为命令名
如果
label
以%
开头,则它是插件包本地化属性文件中属性的id(通常是plugin.properties
或OSGI-INF/i10n/bundle.properties),那么sampleCommand会变成“Sample Command”?另外,虽然我不知道它是如何工作的,但是否存在某种缓存,使得plugin.xml的更改不会立即可见?我从Eclipse本身运行Eclipse的测试版本,所以我不知道任何信息将缓存在哪里,但我似乎在观察caching.btw,我停止并重新启动eclipse的测试版本——在这之前,我根本不希望出现任何更改。有缓存,但当eclipse创建用于测试的运行配置时,它通常会添加-clean
参数来清除缓存。检查您的运行配置。clean不在那里,但即使添加了,我也看不到更改。如果这很重要的话,使用氧气。实际上我不明白你在说什么变化。我的答案只是谈论代码中已经存在的东西。在这里测试这个plugin.xml会在主菜单中创建一个菜单“TB”,其中有一个菜单项标记为“fubar1”。请确保您使用的运行配置在“参数”选项卡的“程序参数”部分指定了-clean
,并且不包括可能导致混淆的其他插件(并且您正在运行正确的运行配置),非常感谢您的测试。我将按照你的建议进行调查,尽管我确信那里是干净的。