Search in sources :

Example 1 with NodeBinder

use of org.malai.javafx.binding.NodeBinder in project Malai by arnobl.

the class MoveShape method testCanCancelDnDWithObsList.

@Test
public void testCanCancelDnDWithObsList() {
    new NodeBinder<>(MoveShape.class, new DnD(true, true), instrument).map(i -> new MoveShape((Rectangle) i.getSrcObject().get())).on(widget1.getChildren()).first((c, i) -> Platform.runLater(() -> i.getSrcObject().get().requestFocus())).then((c, i) -> c.setCoord(((Rectangle) i.getSrcObject().get()).getX() + (i.getEndScenePt().getX() - i.getSrcScenePoint().getX()), ((Rectangle) i.getSrcObject().get()).getY() + (i.getEndScenePt().getY() - i.getSrcScenePoint().getY()))).end((c, i) -> fail("")).exec().bind();
    Rectangle rec2 = new Rectangle(200d, 200d, 70d, 50d);
    Platform.runLater(() -> widget1.getChildren().addAll(rec2));
    WaitForAsyncUtils.waitForFxEvents();
    drag(rec2).moveBy(100, 100).type(KeyCode.ESCAPE).sleep(50L);
    assertEquals(0, instrument.exec.get());
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) KeyCode(javafx.scene.input.KeyCode) NodeBinder(org.malai.javafx.binding.NodeBinder) Undoable(org.malai.undo.Undoable) Rectangle(javafx.scene.shape.Rectangle) DoubleProperty(javafx.beans.property.DoubleProperty) CommandImpl(org.malai.command.CommandImpl) WaitForAsyncUtils(org.testfx.util.WaitForAsyncUtils) Platform(javafx.application.Platform) Test(org.junit.jupiter.api.Test) Stage(javafx.stage.Stage) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DnD(org.malai.javafx.interaction.library.DnD) Pane(javafx.scene.layout.Pane) Rectangle(javafx.scene.shape.Rectangle) DnD(org.malai.javafx.interaction.library.DnD) Test(org.junit.jupiter.api.Test)

Aggregations

Platform (javafx.application.Platform)1 DoubleProperty (javafx.beans.property.DoubleProperty)1 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)1 KeyCode (javafx.scene.input.KeyCode)1 Pane (javafx.scene.layout.Pane)1 Rectangle (javafx.scene.shape.Rectangle)1 Stage (javafx.stage.Stage)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.fail (org.junit.jupiter.api.Assertions.fail)1 Test (org.junit.jupiter.api.Test)1 CommandImpl (org.malai.command.CommandImpl)1 NodeBinder (org.malai.javafx.binding.NodeBinder)1 DnD (org.malai.javafx.interaction.library.DnD)1 Undoable (org.malai.undo.Undoable)1 WaitForAsyncUtils (org.testfx.util.WaitForAsyncUtils)1