Java Code Examples for javafx.beans.value.ObservableStringValue

The following examples show how to use javafx.beans.value.ObservableStringValue. These examples are extracted from open source projects. 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
/**
 * Returns a new observable string which contains either the contents of ifTrue, or ifFalse, depending on the condition
 * @param condition
 * @param ifTrue
 * @param ifFalse
 * @return
 */
public static ObservableStringValue decision(ObservableBooleanValue condition,
                                             ObservableStringValue ifTrue,
                                             ObservableStringValue ifFalse) {
    StringProperty ret = new SimpleStringProperty();
    condition.addListener((obs, ov, nv) -> {
        ret.set(nv ? ifTrue.get() : ifFalse.get());
    });
    ifTrue.addListener((obs, ov, nv) -> {
        if (condition.get()) {
            ret.set(nv);
        }
    });
    ifFalse.addListener((obs, ov, nv) -> {
        if (!condition.get()) {
            ret.set(nv);
        }
    });
    ret.set(condition.get() ? ifTrue.get() : ifFalse.get());

    return ret;
}
 
Example 2
Source Project: VocabHunter   Source File: PositionDescriptionTool.java    License: Apache License 2.0 5 votes vote down vote up
public ObservableStringValue createBinding(final PositionModel position, final ProgressModel progress) {
    return createStringBinding(
        () -> describe(position, progress),
        position.positionIndexProperty(),
        position.sizeProperty(),
        position.analysisModeProperty(),
        position.editableProperty(),
        progress.unseenFilteredProperty());
}
 
Example 3
Source Project: ReactFX   Source File: StringBinding.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @deprecated Use {@link Val#suspendable(javafx.beans.value.ObservableValue)}.
 */
@Deprecated
public static StringBinding wrap(ObservableStringValue source) {
    return new StringBinding() {
        { bind(source); }

        @Override
        protected String computeValue() { return source.get(); }
    };
}
 
Example 4
Source Project: paintera   Source File: MetaPanel.java    License: GNU General Public License v2.0 4 votes vote down vote up
public double[] asArray(final ObservableStringValue... values)
{
	return Arrays.stream(values).map(ObservableValue::getValue).mapToDouble(Double::parseDouble).toArray();
}
 
Example 5
public ObservableStringValue nameProperty()
{
	return name;
}
 
Example 6
Source Project: VocabHunter   Source File: PositionDescriptionToolTest.java    License: Apache License 2.0 4 votes vote down vote up
private void validate(final String s) {
    ObservableStringValue result = target.createBinding(position, progress);

    assertEquals(s, result.getValue());
}
 
Example 7
Source Project: paintera   Source File: BackendDialog.java    License: GNU General Public License v2.0 votes vote down vote up
public ObservableStringValue nameProperty();