在 CoolBar 中添加自定义小部件?
是否可以在独立的 SWT/JFace 应用程序中在 CoolBarManager 中添加自定义小部件(例如文本框)?
我寻找 IContributionItem 但没有找到有用的示例。
HelpSearchContributionItem 似乎仅适用于 RCP 应用程序(例如,它使用 RCP 中的对象:IWorkbenchWindow)。
提前致谢
Is it possible in a standalone SWT/JFace application to add a custom widget in a CoolBarManager (a text box for exemple) ?
I look for IContributionItem but I didn't find useful examples.
HelpSearchContributionItem seems to work only with a RCP application (it uses objects from RCP : IWorkbenchWindow for example).
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该子类化 ControlContribution 并实现 createControl() 方法。
然后将
ToolBarManager/ToolBarManagerContributionItem
添加到 Coolbar,并将ControlContribution
的子类添加到ToolBarManager
。You should subclass ControlContribution and implement createControl() method.
Then add a
ToolBarManager/ToolBarManagerContributionItem
to the coolbar, and your subclass ofControlContribution
to theToolBarManager
.尽管不建议这样做,但您可以子类化 ToolItem 类并提供您自己的实现。为此,您还必须重写 checkSubclass 方法。
Although it is not recommended, you can subclass the ToolItem class and provide your own implementation. To do this you also have to override the checkSubclass method.