Java Code Examples for javafx.beans.binding.Bindings#bindBidirectional()

The following examples show how to use javafx.beans.binding.Bindings#bindBidirectional() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleButton.java    From cute-proxy with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void init() {
    Bindings.bindBidirectional(tooltipText, tooltipProperty(), new StringConverter<Tooltip>() {
        @Override
        public String toString(Tooltip tooltip) {
            if (tooltip == null) {
                return null;
            }
            return tooltip.getText();
        }

        @Override
        public Tooltip fromString(String string) {
            if (string == null) {
                return null;
            }
            return new Tooltip(string);
        }
    });
    iconPath.addListener((observable, oldValue, newValue) ->
            graphicProperty().set(new ImageView(new Image(getClass().getResourceAsStream(newValue)))));
}
 
Example 2
Source File: ExportCOCOController.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
private void bindProperties() {
   ObjectMapper mapper = AppUtils.createJSONMapper();
   try {
      if (!Settings.getToolCOCOJson().isBlank()) {
         coco = mapper.readValue(Settings.getToolCOCOJson(), COCO.class);
      }
      if (coco == null) {
         coco = new COCO();
      }
      // Fields that can only accept numbers
      txtInfoYear.setTextFormatter(AppUtils.createNumberTextFormatter());
      txtLicenseId.setTextFormatter(AppUtils.createNumberTextFormatter());

      // COCO info section
      Bindings.bindBidirectional(txtInfoYear.textProperty(), coco.info.yearProperty, new NumberStringConverter("#"));
      txtInfoVersion.textProperty().bindBidirectional(coco.info.versionProperty);
      txtInfoDescription.textProperty().bindBidirectional(coco.info.descriptionProperty);
      txtInfoContributor.textProperty().bindBidirectional(coco.info.contributorProperty);
      txtInfoUrl.textProperty().bindBidirectional(coco.info.urlProperty);
      datePicker.valueProperty().bindBidirectional(coco.info.dateCreatedProperty);

      // COCO images
      rbUsePathInXml.selectedProperty().bindBidirectional(coco.usePathInXmlProperty);
      rbNameAsId.selectedProperty().bindBidirectional(coco.nameAsIdProperty);
      dirMedia.disableProperty().bindBidirectional(coco.usePathInXmlProperty);

      // COCO license section
      Bindings.bindBidirectional(txtLicenseId.textProperty(), coco.license.idProperty, new NumberStringConverter("#"));
      txtLicenseName.textProperty().bindBidirectional(coco.license.nameProperty);
      txtLicenseUrl.textProperty().bindBidirectional(coco.license.urlProperty);

      // Output
      chkFormatJSON.selectedProperty().bindBidirectional(coco.formatJSONProperty);
      fileOutput.textProperty().bindBidirectional(coco.outputProperty);
   } catch (Exception ex) {
      LOG.log(Level.WARNING, "Unable to initialize COCO info section", ex);
   }
}
 
Example 3
Source File: GraphApp.java    From big-math with MIT License 4 votes vote down vote up
private Node createEditor() {
       GridPane gridPane = new GridPane();
       gridPane.setHgap(4);
       gridPane.setVgap(4);

	int rowIndex = 0;
	
	gridPane.add(new Label("X Start:"), 0, rowIndex);
	TextField xStartTextField = new TextField();
	gridPane.add(xStartTextField, 1, rowIndex);
	Bindings.bindBidirectional(xStartTextField.textProperty(), xStartProperty, BIGDECIMAL_STRING_CONVERTER);
	rowIndex++;

	gridPane.add(new Label("X End:"), 0, rowIndex);
	TextField xEndTextField = new TextField();
	gridPane.add(xEndTextField, 1, rowIndex);
	Bindings.bindBidirectional(xEndTextField.textProperty(), xEndProperty, BIGDECIMAL_STRING_CONVERTER);
	rowIndex++;

	gridPane.add(new Label("Y Start:"), 0, rowIndex);
	TextField yStartTextField = new TextField();
	gridPane.add(yStartTextField, 1, rowIndex);
	Bindings.bindBidirectional(yStartTextField.textProperty(), yStartProperty, BIGDECIMAL_STRING_CONVERTER);
	rowIndex++;

	gridPane.add(new Label("Y End:"), 0, rowIndex);
	TextField yEndTextField = new TextField();
	gridPane.add(yEndTextField, 1, rowIndex);
	Bindings.bindBidirectional(yEndTextField.textProperty(), yEndProperty, BIGDECIMAL_STRING_CONVERTER);
	rowIndex++;

	gridPane.add(new Label("Precision:"), 0, rowIndex);
	TextField precisionTextField = new TextField();
	gridPane.add(precisionTextField, 1, rowIndex);
	Bindings.bindBidirectional(precisionTextField.textProperty(), precisionProperty, INTEGER_FORMAT);
	rowIndex++;

	gridPane.add(new Label("Function 1:"), 0, rowIndex);
	TextField function1TextField = new TextField();
	gridPane.add(function1TextField, 1, rowIndex);
	Bindings.bindBidirectional(function1TextField.textProperty(), function1Property);
	rowIndex++;

	gridPane.add(new Label("Function 2:"), 0, rowIndex);
	TextField function2TextField = new TextField();
	gridPane.add(function2TextField, 1, rowIndex);
	Bindings.bindBidirectional(function2TextField.textProperty(), function2Property);
	rowIndex++;

	gridPane.add(new Label("Function 3:"), 0, rowIndex);
	TextField function3TextField = new TextField();
	gridPane.add(function3TextField, 1, rowIndex);
	Bindings.bindBidirectional(function3TextField.textProperty(), function3Property);
	rowIndex++;

	return gridPane;
}
 
Example 4
Source File: MultisetProperty.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void bindBidirectional(Property<ObservableMultiset<E>> other) {
	Bindings.bindBidirectional(this, other);
}
 
Example 5
Source File: SetMultimapProperty.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void bindBidirectional(Property<ObservableSetMultimap<K, V>> other) {
	Bindings.bindBidirectional(this, other);
}
 
Example 6
Source File: ConnectViewPresenter.java    From jfxvnc with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {

  ProtocolConfiguration prop = con.getConfiguration();
  historyList.setItems(ctx.getHistory());

  clearBtn.setOnAction(a -> historyList.getItems().clear());
  securityCombo.getItems().addAll(FXCollections.observableArrayList(SecurityType.NONE, SecurityType.VNC_Auth));
  securityCombo.getSelectionModel().selectedItemProperty().addListener((l, a, b) -> {
    prop.securityProperty().set(b != null ? b : SecurityType.UNKNOWN);
  });

  pwdField.disableProperty().bind(Bindings.equal(SecurityType.NONE, securityCombo.getSelectionModel().selectedItemProperty()));

  prop.hostProperty().bindBidirectional(ipField.textProperty());
  StringConverter<Number> converter = new NumberStringConverter("#");
  Bindings.bindBidirectional(portField.textProperty(), prop.portProperty(), converter);

  prop.passwordProperty().bindBidirectional(pwdField.textProperty());
  prop.sslProperty().bindBidirectional(sslCB.selectedProperty());
  prop.sharedProperty().bindBidirectional(sharedCB.selectedProperty());
  forceRfb33CB.setSelected(prop.versionProperty().get() == ProtocolVersion.RFB_3_3);
  forceRfb33CB.selectedProperty().addListener((l, a, b) -> prop.versionProperty().set(b ? ProtocolVersion.RFB_3_3 : ProtocolVersion.RFB_3_8));
  listeningCB.selectedProperty().bindBidirectional(con.listeningModeProperty());
  Bindings.bindBidirectional(listeningPortField.textProperty(), con.listeningPortProperty(), converter);
  listeningPortField.disableProperty().bind(listeningCB.selectedProperty().not());

  prop.rawEncProperty().bindBidirectional(rawCB.selectedProperty());
  prop.copyRectEncProperty().bindBidirectional(copyrectCB.selectedProperty());
  prop.hextileEncProperty().bindBidirectional(hextileCB.selectedProperty());

  prop.clientCursorProperty().bindBidirectional(cursorCB.selectedProperty());
  prop.desktopSizeProperty().bindBidirectional(desktopCB.selectedProperty());
  prop.zlibEncProperty().bindBidirectional(zlibCB.selectedProperty());

  portField.textProperty().addListener((observable, oldValue, newValue) -> {
    if (newValue != null && !newValue.isEmpty() && !newValue.matches("[0-9]+")) {
      if (!oldValue.matches("[0-9]+")) {
        ((StringProperty) observable).setValue("");
        return;
      }
      ((StringProperty) observable).setValue(oldValue);
    }
  });

  con.connectingProperty().addListener((l, a, b) -> Platform.runLater(() -> ipField.getParent().setDisable(b)));

  ctx.bind(ipField.textProperty(), "hostField");
  ctx.bind(portField.textProperty(), "portField");
  ctx.bind(userField.textProperty(), "userField");
  ctx.bind(pwdField.textProperty(), "pwdField");
  ctx.bind(securityCombo, "authType");
  ctx.bind(sslCB.selectedProperty(), "useSSL");
  ctx.bind(sharedCB.selectedProperty(), "useSharedView");
  ctx.bind(forceRfb33CB.selectedProperty(), "forceRfb33");
  ctx.bind(listeningCB.selectedProperty(), "listeningMode");
  ctx.bind(listeningPortField.textProperty(), "listeningPortField");

  ctx.bind(rawCB.selectedProperty(), "useRaw");
  ctx.bind(copyrectCB.selectedProperty(), "useCopyRect");
  ctx.bind(hextileCB.selectedProperty(), "useHextile");
  ctx.bind(cursorCB.selectedProperty(), "useCursor");
  ctx.bind(desktopCB.selectedProperty(), "useDesktopSize");
  ctx.bind(zlibCB.selectedProperty(), "useZlib");

  if (securityCombo.getSelectionModel().getSelectedIndex() < 0) {
    securityCombo.getSelectionModel().select(SecurityType.VNC_Auth);
  }

  historyList.getSelectionModel().selectedItemProperty().addListener((l, a, b) -> updateData(b));
  con.connectInfoProperty().addListener((l, a, b) -> Platform.runLater(() -> addToHistory(b)));

}
 
Example 7
Source File: FlatMap.java    From EasyBind with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void bindBidirectional(Property<U> other) {
    Bindings.bindBidirectional(this, other);
}
 
Example 8
Source File: Var.java    From ReactFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
default void bindBidirectional(Property<T> other) {
    Bindings.bindBidirectional(this, other);
}