Example usage for javafx.beans.binding Bindings createStringBinding

List of usage examples for javafx.beans.binding Bindings createStringBinding

Introduction

In this page you can find the example usage for javafx.beans.binding Bindings createStringBinding.

Prototype

public static StringBinding createStringBinding(final Callable<String> func, final Observable... dependencies) 

Source Link

Document

Helper function to create a custom StringBinding .

Usage

From source file:jp.co.heppokoact.autocapture.FXMLDocumentController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    // ???//from   w ww.  j ava 2  s  . c o m
    prop = new Properties();
    if (CONFIG_FILE.exists()) {
        try (InputStream in = new FileInputStream(CONFIG_FILE)) {
            prop.loadFromXML(in);
        } catch (IOException e) {
            throw new RuntimeException("????????", e);
        }
    }

    // ????????
    String saveDirectoryPath = prop.getProperty("saveDirectoryPath");
    if (saveDirectoryPath != null) {
        File tempSaveDirectory = new File(saveDirectoryPath);
        if (tempSaveDirectory.exists()) {
            saveDirectory.set(tempSaveDirectory);
        }
    }

    // ???
    saveDirectoryLabel.textProperty().bind(Bindings.createStringBinding(() -> {
        File sd = saveDirectory.get();
        return (sd == null) ? "" : sd.getName();
    }, saveDirectory));
    areaStartXLabel.textProperty().bind(Bindings.convert(areaStartX));
    areaStartYLabel.textProperty().bind(Bindings.convert(areaStartY));
    areaEndXLabel.textProperty().bind(Bindings.convert(areaEndX));
    areaEndYLabel.textProperty().bind(Bindings.convert(areaEndY));
    nextPointXLabel.textProperty().bind(Bindings.convert(nextPointX));
    nextPointYLabel.textProperty().bind(Bindings.convert(nextPointY));
    prevPointXLabel.textProperty().bind(Bindings.convert(prevPointX));
    prevPointYLabel.textProperty().bind(Bindings.convert(prevPointY));

    // ???
    stopButton.setDisable(true);

    // ????
    captureService = new CaptureService();
    captureTimeline = new Timeline(new KeyFrame(new Duration(CAPTURE_INTERVAL), e -> {
        captureService.restart();
    }));
    captureTimeline.setCycleCount(Timeline.INDEFINITE);
    try {
        robot = new Robot();
    } catch (AWTException e) {
        throw new RuntimeException("???????", e);
    }

    // ??
    clip = new AudioClip(ClassLoader.getSystemResource("ayashi.wav").toString());
}

From source file:ambroafb.clients.dialog.ClientDialogController.java

@Override
protected void makeExtraActions(EDITOR_BUTTON_TYPE buttonType) {
    openDate.setDisable(true);/*w w  w.ja v  a  2s  . co  m*/
    boolean editable = true;
    if (buttonType.equals(EDITOR_BUTTON_TYPE.VIEW) || buttonType.equals(EDITOR_BUTTON_TYPE.DELETE)) {
        editable = false;
    }
    Client client = (Client) sceneObj;
    //        if (client != null){
    PhoneComboBox phonesCombobox = new PhoneComboBox(client.getPhones(), editable);
    phonesContainer.getChildren().add(phonesCombobox);
    if (!buttonType.equals(EDITOR_BUTTON_TYPE.ADD)
            && (client.getEmail() == null || client.getEmail().isEmpty())) {
        email.setDisable(true);
    }
    if (client.getIsJur()) {
        changeSceneVisualAsFirm(" ");
    }
    imageGalleryController.setURLData(serviceURLPrefix, client.getRecId() + "/", client.getRecId() + "/all");
    List<String> imageNames = client.getDocuments().stream().map((Client.Document doc) -> doc.path)
            .collect(Collectors.toList());
    imageGalleryController.downloadData(imageNames);
    client.setClientImageGallery(imageGalleryController);

    Consumer<ObservableList<ClientStatus>> setStatusById = (statusList) -> {
        Integer statusId = client.getStatusId();
        Bindings.bindBidirectional(client.statusIdProperty(), statuses.valueProperty(),
                new StatusToIdBiConverter());
        client.statusDescripProperty()
                .bind(Bindings.createStringBinding(
                        () -> (statuses.getValue() == null) ? null : "" + statuses.getValue().getDescrip(),
                        statuses.valueProperty()));
        statusProperty.bind(statuses.valueProperty());
        client.setStatusId(statusId);
    };
    statuses.fillComboBox(setStatusById);

    Consumer<ObservableList<Country>> setCountryById = (countryList) -> {
        Integer countryId = client.getCountryId();
        Bindings.bindBidirectional(client.countryIdProperty(), country.valueProperty(),
                new CountryToIdBiConverter());
        client.countryCodeProperty()
                .bind(Bindings.createStringBinding(
                        () -> (country.getValue() == null) ? null : "" + country.getValue().getCode(),
                        country.valueProperty()));
        client.setCountryId(countryId);
    };
    country.fillComboBoxWithoutALL(setCountryById);
    //        }

}