Search in sources :

Example 41 with SimpleBooleanProperty

use of javafx.beans.property.SimpleBooleanProperty in project Smartcity-Smarthouse by TechnionYP5777.

the class SendMessageController method addStringField.

private void addStringField(String fieldName) {
    ObservableList<String> s = FXCollections.observableArrayList();
    Label label = new Label(fieldName + ":");
    TableView<String> table = new TableView<>(s);
    TableColumn<String, String> valueCol = new TableColumn<String, String>("Value");
    valueCol.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue()));
    TableColumn<String, Boolean> deleteCol = new TableColumn<String, Boolean>();
    deleteCol.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue() != null));
    deleteCol.setCellFactory(p -> {
        final ButtonCell $ = new ButtonCell();
        $.setAction(__1 -> s.remove($.getTableView().getItems().get($.getIndex())));
        $.setAlignment(Pos.CENTER);
        return $;
    });
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setPrefSize(100, 100);
    table.getColumns().setAll(Arrays.asList(valueCol, deleteCol));
    Group group = new Group(table);
    VBox.setVgrow(group, Priority.NEVER);
    TextField addValue = new TextField();
    Button addButton = new Button("Add");
    addButton.setOnAction(__1 -> {
        s.add(addValue.getText());
        addValue.clear();
    });
    HBox hb = new HBox(addValue, addButton);
    hb.setSpacing(3);
    VBox vbox = new VBox(label, table, hb);
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    mainPane.getChildren().add(vbox);
    consumers.add(l -> {
        if (!s.isEmpty())
            l.put(fieldName, s);
        else {
            this.encounterdIssue = true;
            issues.add("in " + fieldName + " must contain at least one String");
        }
    });
}
Also used : Group(javafx.scene.Group) ToggleGroup(javafx.scene.control.ToggleGroup) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) Label(javafx.scene.control.Label) TableColumn(javafx.scene.control.TableColumn) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) TextField(javafx.scene.control.TextField) VBox(javafx.scene.layout.VBox) TableView(javafx.scene.control.TableView)

Example 42 with SimpleBooleanProperty

use of javafx.beans.property.SimpleBooleanProperty in project cryptomator by cryptomator.

the class VaultModuleTest method setup.

@BeforeEach
public void setup(@TempDir Path tmpDir) {
    Mockito.when(vaultSettings.mountName()).thenReturn(Bindings.createStringBinding(() -> "TEST"));
    Mockito.when(vaultSettings.usesReadOnlyMode()).thenReturn(new SimpleBooleanProperty(true));
    Mockito.when(vaultSettings.displayName()).thenReturn(new SimpleStringProperty("Vault"));
    System.setProperty("user.home", tmpDir.toString());
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 43 with SimpleBooleanProperty

use of javafx.beans.property.SimpleBooleanProperty in project trex-stateless-gui by cisco-system-traffic-generator.

the class ConnectDialogController method initialize.

@Override
public void initialize(URL url, ResourceBundle rb) {
    initializeConnections();
    isConnectionInProgress = new SimpleBooleanProperty(false);
    isConnectionInProgress.addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
        if (newValue != null) {
            mainViewContainer.setDisable(newValue);
            mainViewContainer.getScene().setCursor(newValue ? Cursor.WAIT : Cursor.DEFAULT);
        }
    });
    timeoutField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*")) {
            timeoutField.setText(newValue.replaceAll("[^\\d]", ""));
        }
    });
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ObservableValue(javafx.beans.value.ObservableValue)

Example 44 with SimpleBooleanProperty

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

the class FXBinderTest method testJavaFXBooleanBidirectional.

@Test
public void testJavaFXBooleanBidirectional() {
    Property<Boolean> booleanDolphinProperty = new MockedProperty<>();
    BooleanProperty booleanJavaFXProperty = new SimpleBooleanProperty();
    booleanDolphinProperty.set(true);
    assertNotEquals(booleanJavaFXProperty.get(), true);
    Binding binding = FXBinder.bind(booleanJavaFXProperty).bidirectionalTo(booleanDolphinProperty);
    assertEquals(booleanJavaFXProperty.get(), true);
    booleanDolphinProperty.set(false);
    assertEquals(booleanJavaFXProperty.get(), false);
    booleanDolphinProperty.set(null);
    assertEquals(booleanJavaFXProperty.get(), false);
    booleanJavaFXProperty.set(true);
    assertEquals(booleanDolphinProperty.get().booleanValue(), true);
    booleanJavaFXProperty.setValue(null);
    assertEquals(booleanDolphinProperty.get().booleanValue(), false);
    binding.unbind();
    booleanDolphinProperty.set(true);
    assertEquals(booleanJavaFXProperty.get(), false);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Test(org.testng.annotations.Test)

Example 45 with SimpleBooleanProperty

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

the class FXBinderTest method testJavaFXBooleanUnidirectional.

@Test
public void testJavaFXBooleanUnidirectional() {
    Property<Boolean> booleanDolphinProperty = new MockedProperty<>();
    BooleanProperty booleanJavaFXProperty = new SimpleBooleanProperty();
    WritableBooleanValue writableBooleanValue = new SimpleBooleanProperty();
    booleanDolphinProperty.set(true);
    assertNotEquals(booleanJavaFXProperty.get(), true);
    Binding binding = FXBinder.bind(booleanJavaFXProperty).to(booleanDolphinProperty);
    assertEquals(booleanJavaFXProperty.get(), true);
    booleanDolphinProperty.set(false);
    assertEquals(booleanJavaFXProperty.get(), false);
    booleanDolphinProperty.set(null);
    assertEquals(booleanJavaFXProperty.get(), false);
    binding.unbind();
    booleanDolphinProperty.set(true);
    assertEquals(booleanJavaFXProperty.get(), false);
    binding = FXBinder.bind(writableBooleanValue).to(booleanDolphinProperty);
    assertEquals(writableBooleanValue.get(), true);
    booleanDolphinProperty.set(false);
    assertEquals(writableBooleanValue.get(), false);
    booleanDolphinProperty.set(null);
    assertEquals(writableBooleanValue.get(), false);
    binding.unbind();
    booleanDolphinProperty.set(true);
    assertEquals(writableBooleanValue.get(), false);
}
Also used : Binding(com.canoo.platform.core.functional.Binding) MockedProperty(com.canoo.dp.impl.remoting.MockedProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) WritableBooleanValue(javafx.beans.value.WritableBooleanValue) Test(org.testng.annotations.Test)

Aggregations

SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)46 BooleanProperty (javafx.beans.property.BooleanProperty)22 Test (org.junit.Test)7 FXCollections (javafx.collections.FXCollections)6 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)5 FXML (javafx.fxml.FXML)5 UserThread (bisq.common.UserThread)4 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)4 Binding (com.canoo.platform.core.functional.Binding)4 ReadOnlyStringWrapper (javafx.beans.property.ReadOnlyStringWrapper)4 P2PServiceListener (bisq.network.p2p.P2PServiceListener)3 CloseConnectionReason (bisq.network.p2p.network.CloseConnectionReason)3 Connection (bisq.network.p2p.network.Connection)3 ConnectionListener (bisq.network.p2p.network.ConnectionListener)3 Arrays (java.util.Arrays)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 StringProperty (javafx.beans.property.StringProperty)3 ChangeListener (javafx.beans.value.ChangeListener)3 TableColumn (javafx.scene.control.TableColumn)3 Inject (javax.inject.Inject)3