如何结合 Eclipse 数据绑定和 UndoableOperations?

发布于 2024-09-04 06:27:43 字数 466 浏览 2 评论 0 原文

在我的 RCP - 项目中,我使用 eclipse 数据绑定将 ui 与后端连接起来。我希望打开的编辑器中的每个更改都是不可撤销的。我的 Domainmodell 和 UI 分开在两个不同的插件中。

我当前的方法是为数据绑定实现我自己的 UpdateValueStrategy 类。我扩展了正常的 UpdateValueStrategy 并重写了 doSet 方法。

从那里我得到了OperationHistory和Global UndoContext,然后我创建了一个新的操作。我有各种操作,例如“ChangeCustomerName”和“ChangeCustomerNote”。

问题:

  1. 我是否需要自己实现撤消/重做逻辑,或者框架是否以某种方式支持我这样做?
  2. 有没有比 UpdateValue - Strategy 类的 doSet() 更好的地方或方法来创建可撤消的操作。要访问已更改的文本字段并不容易。

in my RCP - Project i'm using eclipse databinding to connect the ui with the backend. I want every change in an open editor to be undoable. My Domainmodell and UI are seperated in two different plugins.

My current approach is to implement my own UpdateValueStrategy class for the databinding. I extend the normal UpdateValueStrategy and override the doSet Methode.

From there i get the OperationHistory and the Global UndoContext, then i create a new Operation. I have various Operations like "ChangeCustomerName" and "ChangeCustomerNote".

Questions:

  1. Do i need to implement the undo/redo - logic by my own, or is the framework somehow supporting my with this?
  2. Is there a better place or way to create the undoable Operation then the doSet() of the UpdateValue - Strategy class. To access the textfield, which was changed is not to easy.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾其所爱 2024-09-11 06:27:44

您将得到的大部分答案是:使用 EMF.Edit,它包含了开箱即用的 org.eclipse.emf.databinding.edit,并且有一个出色的 教程在网上。

Eclipse bugtracker 中有一个关于包含撤消/重做的开放功能请求也在没有 EMF 的 JFace 数据绑定中,但它还没有完成。它也在 eclipse 论坛中进行了讨论

The answer you will get mostly is: Use EMF.Edit, it includes it out of the box with org.eclipse.emf.databinding.edit and there's an excellent tutorial on the net.

There is an open feature request in the Eclipse bugtracker about including undo/redo also in JFace databinding without EMF but it's not finished yet. It has also be discussed in the eclipse forum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文