Question

I have a TableView with four rows and I try to test that my drag and drop implementation works. I have the following test:

TableViewDock table = ...;

//the four rows, using the first cell for the DnD
TableCellItemDock[] rows = {new TableCellItemDock(table.asTable(), 0, 0),
                            new TableCellItemDock(table.asTable(), 1, 0),
                            new TableCellItemDock(table.asTable(), 2, 0),
                            new TableCellItemDock(table.asTable(), 3, 0)};

Wrap target = rows[3].wrap();
rows[0].drag().dnd(target, target.getClickPoint());

But the call to dnd blocks: I need to manually move the mouse to "unblock" it and allow the drag and drop action to start (it then completes as expected).

What do I need to do to let dnd do its job on its own?

Note: JemmyFX version = 20120928

Was it helpful?

Solution 2

Thanks to Sergey, I managed to get it to work with the following method:

protected void dragAndDrop(Wrap<? extends Object> from, Wrap<? extends Object> to) throws InterruptedException {
    Point start = scene.wrap().toLocal(from.toAbsolute(from.getClickPoint()));
    Point end = scene.wrap().toLocal(to.toAbsolute(to.getClickPoint()));

    scene.mouse().move(start);
    scene.mouse().press();
    scene.mouse().move(end);
    scene.mouse().release();
}

I haven't managed to do a progressive move with a loop as he suggested: the code gets stuck at the second iteration when move is called again.

OTHER TIPS

There is an issue RT-25057 in product which prevented jemmy from correctly using drag-and-drop on some platforms. I'm afraid for now you need to use a workaround using mouse move and press/release:

rows[0].mouse().move();
rows[0].mouse().press();
Point from = rows[0].wrap().getClickPoint();
Point to = target.getClickPoint();
int steps = 10;
for(int i = 1; i<= steps; i++) {
    rows[0].mouse().move(new Point(
        from.x + i*(to.x - from.x)/steps, 
        from.y + i*(to.y - from.y)/steps));
}
rows[0].mouse().release();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top