Tree组件如何实现拖拽Item来调整顺序和层级,版本为7.1.4

需要实现类似 Administration > Access Groups 的左边Tree的功能,Tree的Item可以拖动,来调整顺序和层级,我查看了一下GroupBrowse.java源码是继承了AbstractWindow,用Companion来实现的,但我看了7.1的文档说AbstractWindow是GUI历史版本API,那么我用7.1的情况下该如何实现呢,我的Controller是继承StandardLookup的

CUBA 7.1 使用了 Vaadin8,所以可以使用 Vaadin 的 Drag-n-Drop。但是要注意,Vaadin8 的 Tree 本身不支持拖拽,只有 TreeGrid 支持,正好 tree 内部也是用的 TreeGrid。所以需要使用 getCompositionRoot() 获取 tree 内部的 TreeGrid 就可以实现了。

例如,在 CUBA 中设置 tree 节点可拖拽:

    @Inject
    private Tree<Group> groupTree;

    @Subscribe
    private void onInit(InitEvent event) {

        CubaTree vtree = (CubaTree)groupTree.unwrap(com.vaadin.ui.Tree.class);

        CubaTreeGrid groupTreeGrid = vtree.getCompositionRoot();

        GridRowDragger<Group> gridRowDragger = new GridRowDragger<>(groupTreeGrid);

    }