简体   繁体   English

eclipse RCP4 添加工具栏到零件

[英]eclipse RCP4 Add Toolbar to Parts

How to model a toolbar ONCE and render it in some Parts/Views (not in the default place which is the window?)?如何 model 一次工具栏并在某些部分/视图中呈现它(不在默认位置 window?)? Using the model level (and maybe Addons?)使用 model 关卡(也许还有 Addons?)

I have currently我目前有

  1. Eclipse 2022.03-4.23 Eclipse 2022.03-4.23
  2. Application.e4xmi with that Toolbar but带有该工具栏的 Application.e4xmi 但是
  3. Gets added dynamically using an Addon that listens to "PART_ADDED" event topic which使用侦听“PART_ADDED”事件主题的插件动态添加
  4. Leads to a NPE due to other event topic "UIEvents.Part.TOPIC_TOOLBAR" within a framework method in a class called LazyStackRenderer由于 class 中名为 LazyStackRenderer 的框架方法中的其他事件主题“UIEvents.Part.TOPIC_TOOLBAR”导致 NPE

So the guy before me had written an Addon to dynamically add the Toolbar to the parts.所以我之前的那个人写了一个插件来动态地将工具栏添加到部件中。 Maybe to make the buttons save/print per part or because the main layout has two stacks and only the parts stack is relevant.也许是为了让按钮按零件保存/打印,或者因为主布局有两个堆栈,只有零件堆栈是相关的。

Appreciate any help!感谢任何帮助! I searched a lot but no success!我搜索了很多但没有成功!

I solved it so far.到目前为止我解决了它。 The dynamically created MParts were not added as children to the container (in my case the PartStack) in the first place and also had to comment the adding of placeholder objects that carry the same information of the parts.动态创建的 MPart 最初没有作为子元素添加到容器(在我的例子中是 PartStack)中,而且还必须注释添加带有相同部件信息的占位符对象。 This dynamic step was done as a reaction to the topic @UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE) in some written Addon.这个动态步骤是作为对某些书面插件中主题@UIEventTopic(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE)的反应而完成的。

I am not a 100% sure that discarding the placeholders is safe but still this is the best trail I have ever reached.我不是 100% 确定丢弃占位符是安全的,但这仍然是我所达到的最佳路线。

I hope this would help others!我希望这会帮助别人!

Thank you @greg-449谢谢@greg-449

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

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