Java SWT/JFace TreeViewer 通过在视图中拖/放来移动节点
我正在使用 TreeViewer 来显示我的树。我想通过让用户拖动节点并将其放在新位置来提供手动对节点进行排序的机会。
我正在寻找一种可能性来确定节点在哪些节点之间被删除,或者是否在控制边界和第一个节点处被删除。 是否有任何建议或常用方法来检测相对于其他节点(之前/之后)的放置位置?
我的想法是获取下降点,看看哪个节点在那里,以及该点是否位于项目边界的上半部分或下半部分(听起来很容易,但实现起来肯定很痛苦)。我将不胜感激任何其他可能性......
I am using a TreeViewer for displaying my tree. I would like to offer the opportunity to sort nodes by hand by letting the user drag a node and let him drop it at the new location.
I am looking for a possiblity for determining between which nodes the node was dropped or whether it was drop at the control-border and the first node.
Is there any suggest or usual way for detecting the drop location relative to the other nodes(before/after)?
My idea was to get the Point of the drop look whichh node is there an whether the point is in the upper or lower half of the items-boundary (sounds easy, but is sure painfully to implement). I would appreciate any other possibility...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据光标位置检测项目几乎是唯一的方法,您可能还需要在
dragOver()
期间执行此操作。 这里是一个示例。Detecting the item based on cursor location is pretty much the only way and you probably need to do this also during
dragOver()
. Here's an example.