GEF EditPartViewer 选择

发布于 2024-09-25 13:25:39 字数 406 浏览 0 评论 0原文

我正在尝试使用 GEF 开发拖放时出现一个奇怪的问题。 如果我开始对 org.eclipse.gef.ui.parts.TreeViewer 中尚未选定的元素进行拖动操作,则从 EditPartViewer.getSelectedEditPart() 获取的选定元素与通过 SWT Tree 控件 (Tree.getSelection ())。

仅当我开始拖动操作而不在开始操作之前选择树中的元素时,才会出现此情况: 重现步骤: - 在树视图中选择一个元素 - 开始拖动树的未选择元素,

现在方法 Tree.getSelection() 返回拖动的 TreeItem,但 EditPartViewer.getSelectedEditPart() 仍然返回选定的编辑部分,而不是拖动的编辑部分。

我该如何纠正这种行为?

I'm experimenting a strange issue developing Drag and Drop with GEF.
If I start a drag operation of a not yet selected element in a org.eclipse.gef.ui.parts.TreeViewer the selected element got from EditPartViewer.getSelectedEditPart() is different from the one obtained via the SWT Tree control (Tree.getSelection()).

This appens only when I start the drag operation without selecting an element in the tree before starting the operation:
steps to reproduce:
- select an element in a treeviewe
- start dragging an unselected element of the tree

now the method Tree.getSelection() return the dragged TreeItem but the EditPartViewer.getSelectedEditPart() still returns the selected editpart, not the dragged one.

How can I correct this behavior?

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

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

发布评论

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

评论(1

南风几经秋 2024-10-02 13:25:39

您选择的编辑部分的拖动跟踪器可能仅在 mouseUp 事件上应用viewer.setSelectedEditParts(eps),拖动本身从 mouseDown 事件开始。不完全确定,应该检查默认的 DragTracker 如何工作,或者如果您已覆盖它,请检查它是否正常工作。

It might be that the drag tracker of the editpart you select is only applying the viewer.setSelectedEditParts(eps) on mouseUp event, drag itself starts from mouseDown event. Not totally sure, should check how that default DragTracker works, or if you have overridden it, check that it is working correctly.

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