Java Code Examples for org.reactfx.value.Val#wrap()

The following examples show how to use org.reactfx.value.Val#wrap() . 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: NodeEditionCodeArea.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public IntFunction<javafx.scene.Node> defaultLineNumberFactory() {
    IntFunction<javafx.scene.Node> base = LineNumberFactory.get(this);
    Val<Integer> activePar = Val.wrap(currentParagraphProperty());

    return idx -> {

        javafx.scene.Node label = base.apply(idx);

        activePar.conditionOnShowing(label)
                 .values()
                 .subscribe(p -> label.pseudoClassStateChanged(PseudoClass.getPseudoClass("has-caret"), idx == p));

        // adds a pseudo class if part of the focus node appears on this line
        currentFocusNode.conditionOnShowing(label)
                        .values()
                        .subscribe(n -> label.pseudoClassStateChanged(PseudoClass.getPseudoClass("is-focus-node"),
                                                                      n != null && idx + 1 <= n.getEndLine() && idx + 1 >= n.getBeginLine()));

        return label;
    };
}
 
Example 2
Source File: MutableTabPane.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/** Makes the title unique w.r.t. already present tabs. */
private Val<String> uniqueNameBinding(Val<String> titleProperty, int tabIdx) {
    Binding<String> uniqueBinding = Bindings.createStringBinding(
        () -> {
            String title = titleProperty.getOrElse("Unnamed");
            int sameName = 0;
            LiveList<T> controllers = getControllers();
            for (int i = 0; i < controllers.size() && i < tabIdx; i++) {
                if (title.equals(controllers.get(i).titleProperty().getOrElse("Unnamed"))) {
                    sameName++;
                }

            }
            return sameName == 0 ? title : title + " (" + sameName + ")";
        },
        titleProperty,
        getTabs()
    );
    return Val.wrap(uniqueBinding);
}
 
Example 3
Source File: SourceEditorController.java    From pmd-designer with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Val<String> textProperty() {
    return Val.wrap(nodeEditionCodeArea.textProperty());
}
 
Example 4
Source File: ViolationCollectionView.java    From pmd-designer with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Val<ObservableList<LiveViolationRecord>> itemsProperty() {
    return Val.wrap(view.itemsProperty());
}
 
Example 5
Source File: PropertyCollectionView.java    From pmd-designer with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Val<ObservableList<PropertyDescriptorSpec>> itemsProperty() {
    return Val.wrap(view.itemsProperty());
}
 
Example 6
Source File: MappedList.java    From ReactFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DynamicallyMappedList(
        ObservableList<? extends E> source,
        ObservableValue<? extends Function<? super E, ? extends F>> mapper) {
    this.source = source;
    this.mapper = Val.wrap(mapper);
}
 
Example 7
Source File: Toggle.java    From ReactFX with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Creates a {@linkplain Toggle} view of an observable boolean and a
 * {@linkplain Suspendable} whose suspension causes the boolean value
 * to switch.
 * @param obs boolean value that indicates suspension of {@code suspender}.
 * @param suspender Assumed to switch the value of {@code obs} when
 * suspended and switch back when resumed, unless there are other suspenders
 * keeping it in the value corresponding to the suspended state.
 */
static Toggle from(ObservableValue<Boolean> obs, Suspendable suspender) {
    return new ToggleFromVal(Val.wrap(obs), suspender);
}