在自定义 RCP 应用程序中使用 org.eclipse 剪切/复制/粘贴
我正在开发一个 RCP 应用程序,我需要在此应用程序中剪切/复制/粘贴。由于已经有 eclipse 提供的命令(org.eclipse.ui.edit.copy,...),我想在编辑器中使用它们(例如,我已经将它们添加到工具栏)。 我玩了一下,但我不明白如何对复制/粘贴命令做出反应。例如,如果复制或粘贴了某些内容,我如何在编辑器中得到通知?
有没有一种简单的方法来使用“保存命令”等命令。在那里,我只需要实现 ISaveablePart,然后调用 doSave() 或 doSaveAs() 方法...我真的很喜欢这个,但我没有找到 ICopyablePart,...接口;)
I am developing a RCP application and I need cut/copy/paste in this app. As there are already commands which are delivered by eclipse (org.eclipse.ui.edit.copy, ...) I want to use them (I already added them to the toolbar, e.g.) in an editor.
I played around a little, but I don't get it how I can react to the copy/paste command. E.g. how do I get informed in an editor if something was copied or pasted?
Is there an easy way to use the commands like the Save Command. There I just have to implement the ISaveablePart and then the doSave() or doSaveAs() methods are called...I really like this, but I didn't find ICopyablePart,... interfaces ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要在编辑器或视图中复制特定行为(或任何命令),您可以为其激活一个处理程序。通常在您的
createPartControl(Composite)
方法中:另一种常见的方法是通过您的plugin.xml 提供一个处理程序:
然后在您的处理程序中,您将获取活动部分并在其上调用您的复制实现。前任:
If you need specific behaviour to copy (or any command) within your editor or view, you would activate a handler for it. Usually in your
createPartControl(Composite)
method:The other common way is to provide a handler through your plugin.xml:
Then in your handler, you would get the active part and call your copy implementation on it. ex: