Eclipse eRCP 命令框架 - 无法动态更新命令标签

发布于 2024-09-27 08:22:51 字数 1142 浏览 2 评论 0原文

我在网上搜索了一整天,试图找到一个示例,说明如何实现我在这里读到的有关动态更改命令标签的内容:

http://wiki.eclipse.org/Platform_UI_Command_Design#Issue_102_-_Comm ands_implementation_of_label_changing

我有一个在我的plugin.xml中定义的命令,使用建议的模式:

<command
     description="Hoping to change my state"
     id="my.commandWithState"
     name="Command Wtih State">
  <state
        class="org.eclipse.jface.menus.TextState"
        id="NAME"/>
</command>

在我的处理程序中,我尝试了很多变体(包括在尝试设置它之前调用“getValue”以希望强制调用加载),但基本上要点is:

public Object execute(final ExecutionEvent pEvent) throws ExecutionException {
        pEvent.getCommand().getState("my.commandWithState").setValue("UPDATED!");
        return null;
    }

状态值本身被更新,但不被持久化。我在我的plugin.xml 的menuContribution 区域中指定了“push”样式,并且命令上的文本始终是“Command With State”,因为我没有指定标签(尽管我希望它会更改...)

我'我使用 Eclipse 3.6,所以我假设我有 3.3 版本的更新,据说允许这样做。

我能够在命令 ui 对象上设置文本的唯一方法是让我的处理程序实现 IElementUpdater,就像我使用 ToggleState 一样。当我第一次启动该产品时,这允许我总共更改文本 1 次。

我快要把头发扯下来了。

1) 命令“label”未更新并且 2) 即使 TextState 扩展了 PersistedState,状态值也不会持久化。

什么 d>_

I've scoured the web for the entire day trying to find an example on how to implement what I read concerning changing a command label dynamically here:

http:// wiki.eclipse.org/Platform_UI_Command_Design#Issue_102_-_Comm ands_implementation_of_label_changing

I have the a command defined in my plugin.xml that uses the suggested schema:

<command
     description="Hoping to change my state"
     id="my.commandWithState"
     name="Command Wtih State">
  <state
        class="org.eclipse.jface.menus.TextState"
        id="NAME"/>
</command>

In my handler, I have tried a lot of variations (including calling "getValue" before trying to set it in hopes of forcing a load to be called), but basically the gist is:

public Object execute(final ExecutionEvent pEvent) throws ExecutionException {
        pEvent.getCommand().getState("my.commandWithState").setValue("UPDATED!");
        return null;
    }

The state value itself is updated, but not persisted. I specified a style of "push" in the menuContribution area of my plugin.xml and the text on the command is always "Command With State" since I did not specify a label (though i expected it to change...)

I'm using Eclipse 3.6 so I assume I have the updates that supposedly allow this from 3.3.

The only way I have been able to set the text on the command ui object is to have my handler implement IElementUpdater like I'm working with a ToggleState. This allows me to change the text a total of 1 time, when I first start the product.

I'm about to tear my hair out.

1) The command "label" is not updated and
2) the state value is not persisted even though TextState extends PersistedState.

What d>_

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文