Search in sources :

Example 16 with StringProperty

use of javafx.beans.property.StringProperty in project dolphin-platform by canoo.

the class FXBinderTest method testJavaFXStringBidirectional.

@Test
public void testJavaFXStringBidirectional() {
    Property<String> stringDolphinProperty = new MockedProperty<>();
    StringProperty stringJavaFXProperty = new SimpleStringProperty();
    stringDolphinProperty.set("Hello");
    assertNotEquals(stringJavaFXProperty.get(), "Hello");
    Binding binding = FXBinder.bind(stringJavaFXProperty).bidirectionalTo(stringDolphinProperty);
    assertEquals(stringJavaFXProperty.get(), "Hello");
    stringDolphinProperty.set("Hello World");
    assertEquals(stringJavaFXProperty.get(), "Hello World");
    stringDolphinProperty.set(null);
    assertEquals(stringJavaFXProperty.get(), null);
    stringJavaFXProperty.set("Hello from JavaFX");
    assertEquals(stringDolphinProperty.get(), "Hello from JavaFX");
    stringJavaFXProperty.setValue(null);
    assertEquals(stringDolphinProperty.get(), null);
    binding.unbind();
    stringDolphinProperty.set("Hello Dolphin");
    assertEquals(stringJavaFXProperty.get(), null);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Test(org.testng.annotations.Test)

Example 17 with StringProperty

use of javafx.beans.property.StringProperty in project dolphin-platform by canoo.

the class FXBinderTest method testUnidirectionalChain.

@Test
public void testUnidirectionalChain() {
    Property<String> stringDolphinProperty1 = new MockedProperty<>();
    StringProperty stringJavaFXProperty1 = new SimpleStringProperty();
    Property<String> stringDolphinProperty2 = new MockedProperty<>();
    StringProperty stringJavaFXProperty2 = new SimpleStringProperty();
    Binding binding1 = FXBinder.bind(stringDolphinProperty1).to(stringJavaFXProperty1);
    Binding binding2 = FXBinder.bind(stringJavaFXProperty2).to(stringDolphinProperty1);
    Binding binding3 = FXBinder.bind(stringDolphinProperty2).to(stringJavaFXProperty2);
    stringJavaFXProperty1.setValue("Hello");
    assertEquals(stringDolphinProperty1.get(), "Hello");
    assertEquals(stringDolphinProperty2.get(), "Hello");
    assertEquals(stringJavaFXProperty1.get(), "Hello");
    assertEquals(stringJavaFXProperty2.get(), "Hello");
    binding2.unbind();
    stringJavaFXProperty1.setValue("Hello World");
    assertEquals(stringDolphinProperty1.get(), "Hello World");
    assertEquals(stringDolphinProperty2.get(), "Hello");
    assertEquals(stringJavaFXProperty1.get(), "Hello World");
    assertEquals(stringJavaFXProperty2.get(), "Hello");
    binding1.unbind();
    binding3.unbind();
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Test(org.testng.annotations.Test)

Example 18 with StringProperty

use of javafx.beans.property.StringProperty in project dolphin-platform by canoo.

the class FXBinderTest method testBidirectionalChain.

@Test
public void testBidirectionalChain() {
    Property<String> stringDolphinProperty1 = new MockedProperty<>();
    StringProperty stringJavaFXProperty1 = new SimpleStringProperty();
    Property<String> stringDolphinProperty2 = new MockedProperty<>();
    StringProperty stringJavaFXProperty2 = new SimpleStringProperty();
    Binding binding1 = FXBinder.bind(stringDolphinProperty1).bidirectionalTo(stringJavaFXProperty1);
    Binding binding2 = FXBinder.bind(stringJavaFXProperty2).bidirectionalTo(stringDolphinProperty1);
    Binding binding3 = FXBinder.bind(stringDolphinProperty2).bidirectionalTo(stringJavaFXProperty2);
    stringJavaFXProperty1.setValue("Hello");
    assertEquals(stringDolphinProperty1.get(), "Hello");
    assertEquals(stringDolphinProperty2.get(), "Hello");
    assertEquals(stringJavaFXProperty1.get(), "Hello");
    assertEquals(stringJavaFXProperty2.get(), "Hello");
    stringDolphinProperty1.set("Hello World");
    assertEquals(stringDolphinProperty1.get(), "Hello World");
    assertEquals(stringDolphinProperty2.get(), "Hello World");
    assertEquals(stringJavaFXProperty1.get(), "Hello World");
    assertEquals(stringJavaFXProperty2.get(), "Hello World");
    stringJavaFXProperty2.setValue("Hello");
    assertEquals(stringDolphinProperty1.get(), "Hello");
    assertEquals(stringDolphinProperty2.get(), "Hello");
    assertEquals(stringJavaFXProperty1.get(), "Hello");
    assertEquals(stringJavaFXProperty2.get(), "Hello");
    stringDolphinProperty2.set("Hello World");
    assertEquals(stringDolphinProperty1.get(), "Hello World");
    assertEquals(stringDolphinProperty2.get(), "Hello World");
    assertEquals(stringJavaFXProperty1.get(), "Hello World");
    assertEquals(stringJavaFXProperty2.get(), "Hello World");
    binding2.unbind();
    stringJavaFXProperty1.setValue("Hello");
    assertEquals(stringDolphinProperty1.get(), "Hello");
    assertEquals(stringDolphinProperty2.get(), "Hello World");
    assertEquals(stringJavaFXProperty1.get(), "Hello");
    assertEquals(stringJavaFXProperty2.get(), "Hello World");
    binding1.unbind();
    binding3.unbind();
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Test(org.testng.annotations.Test)

Example 19 with StringProperty

use of javafx.beans.property.StringProperty in project Malai by arnobl.

the class BindingTask method call.

@Override
protected Boolean call() {
    final DoubleProperty progProp = cmd instanceof ProgressableCmd ? ((ProgressableCmd) cmd).progress() : null;
    final StringProperty textProp = cmd instanceof ProgressableCmd ? ((ProgressableCmd) cmd).textProgress() : null;
    if (progProp != null) {
        progProp.addListener(updateProgress);
    }
    if (textProp != null) {
        textProp.addListener(updateTextProgress);
    }
    final boolean ok = cmd.doIt();
    if (progProp != null) {
        progProp.removeListener(updateProgress);
    }
    if (textProp != null) {
        textProp.removeListener(updateTextProgress);
    }
    return ok;
}
Also used : StringProperty(javafx.beans.property.StringProperty) DoubleProperty(javafx.beans.property.DoubleProperty) ProgressableCmd(org.malai.javafx.command.ProgressableCmd)

Example 20 with StringProperty

use of javafx.beans.property.StringProperty in project Gargoyle by callakrsos.

the class TextBaseDiffAppController method initialize.

@FXML
public void initialize() {
    /* initControls */
    ivReviced = new ImageView();
    ivpReviced = new ImageViewPane(ivReviced);
    ivpReviced.setPrefWidth(200);
    ivpReviced.setPrefHeight(150);
    ivOrigin = new ImageView();
    ivpOrigin = new ImageViewPane(ivOrigin);
    ivpOrigin.setPrefWidth(200);
    ivpOrigin.setPrefHeight(150);
    gpSnap.add(ivpReviced, 0, 0);
    gpSnap.add(ivpOrigin, 1, 0);
    lvOrinal.setCellFactory(param -> new DefaultTextFieldListCell(ORIGINAL));
    lvRevice.setCellFactory(param -> new DefaultTextFieldListCell(REVICED));
    fileCompareResultProperty.addListener(compareResultListener);
    lvRevice.setOnMouseClicked(event -> {
        if (event.getClickCount() == 2) {
            int movePosition = -1;
            ChunkWrapper selectedItem = lvRevice.getSelectionModel().getSelectedItem();
            Delta delta = selectedItem.getDelta();
            if (delta != null && delta.getOriginal() != null) {
                movePosition = selectedItem.getPosition();
                lvOrinal.scrollTo(movePosition - 1);
                lvOrinal.getSelectionModel().select(movePosition);
            }
        }
    });
    lvOrinal.setOnMouseClicked(event -> {
        if (event.getClickCount() == 2) {
            int movePosition = -1;
            ChunkWrapper selectedItem = lvOrinal.getSelectionModel().getSelectedItem();
            if (selectedItem != null) {
                Delta delta = selectedItem.getDelta();
                if (delta != null && delta.getRevised() != null) {
                    movePosition = delta.getRevised().getPosition();
                    lvRevice.scrollTo(movePosition - 1);
                    lvRevice.getSelectionModel().select(movePosition);
                }
            }
        }
    });
    lvOrinal.addEventFilter(ScrollEvent.SCROLL, event -> {
        snappOriginShot();
    });
    lvRevice.addEventFilter(ScrollEvent.SCROLL, event -> {
        snappReviceShot();
    });
    btnCompare.setOnMouseClicked(event -> {
        String ori = txtOrigin.getText();
        String rev = txtRevice.getText();
        if (!(ori.isEmpty() && rev.isEmpty())) {
            clear();
            try {
                this.compare.setOriginal(ori);
                this.compare.setRevised(rev);
                CompareResult chunkResult = this.compare.getChunkResult();
                this.fileCompareResultProperty.set(chunkResult);
                snappOriginShot();
                snappReviceShot();
            } catch (Exception e) {
                LOGGER.error(ValueUtil.toString(e));
            }
        }
    });
    colStatus.setCellValueFactory(new Callback<CellDataFeatures<ChunkWrapper, String>, ObservableValue<String>>() {

        @Override
        public ObservableValue<String> call(CellDataFeatures<ChunkWrapper, String> param) {
            TYPE type = param.getValue().getType();
            StringProperty prop = new SimpleStringProperty();
            if (type != null)
                prop.set(type.name());
            return prop;
        }
    });
    colPosition.setCellValueFactory(param -> new SimpleIntegerProperty(new Integer(param.getValue().getPosition() + 1)));
    colRevice.setCellValueFactory(param -> {
        Delta delta = param.getValue().getDelta();
        SimpleStringProperty prop = new SimpleStringProperty();
        if (delta != null) {
            Chunk c = delta.getRevised();
            prop.setValue(c.getLines().toString());
        }
        return prop;
    });
    colOrigin.setCellValueFactory(param -> {
        Delta delta = param.getValue().getDelta();
        SimpleStringProperty prop = new SimpleStringProperty();
        if (delta != null) {
            Chunk c = delta.getOriginal();
            prop.setValue(c.getLines().toString());
        }
        return prop;
    });
}
Also used : CellDataFeatures(javafx.scene.control.TableColumn.CellDataFeatures) ObservableValue(javafx.beans.value.ObservableValue) ChunkWrapper(com.kyj.fx.voeditor.visual.diff.ChunkWrapper) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) Chunk(difflib.Chunk) CompareResult(com.kyj.fx.voeditor.visual.diff.CompareResult) IOException(java.io.IOException) Delta(difflib.Delta) ImageView(javafx.scene.image.ImageView) TYPE(difflib.Delta.TYPE) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) FXML(javafx.fxml.FXML)

Aggregations

StringProperty (javafx.beans.property.StringProperty)40 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)37 DoubleProperty (javafx.beans.property.DoubleProperty)26 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)25 ObjectProperty (javafx.beans.property.ObjectProperty)24 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)24 Dimension2D (javafx.geometry.Dimension2D)23 BooleanProperty (javafx.beans.property.BooleanProperty)20 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)20 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)14 Color (javafx.scene.paint.Color)14 IntegerProperty (javafx.beans.property.IntegerProperty)11 List (java.util.List)8 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)4 Binding (com.canoo.platform.core.functional.Binding)4 Section (eu.hansolo.enzo.common.Section)4 IOException (java.io.IOException)4 Test (org.testng.annotations.Test)4 ChunkWrapper (com.kyj.fx.voeditor.visual.diff.ChunkWrapper)3 CompareResult (com.kyj.fx.voeditor.visual.diff.CompareResult)3