Java Code Examples for javafx.beans.value.ObservableValue#getValue()
The following examples show how to use
javafx.beans.value.ObservableValue#getValue() .
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: RFXCheckBoxTreeCell.java From marathonv5 with Apache License 2.0 | 7 votes |
@Override public String _getValue() { @SuppressWarnings("rawtypes") CheckBoxTreeCell cell = (CheckBoxTreeCell) node; @SuppressWarnings("unchecked") ObservableValue<Boolean> call = (ObservableValue<Boolean>) cell.getSelectedStateCallback().call(cell.getTreeItem()); String cbText; if (call != null) { int selection = call.getValue() ? 2 : 0; cbText = JavaFXCheckBoxElement.states[selection]; } else { Node cb = cell.getGraphic(); RFXComponent comp = getFinder().findRawRComponent(cb, null, null); cbText = comp._getValue(); } return cbText; }
Example 2
Source File: JavaFXCheckBoxTableCellElement.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public String _getValue() { CheckBoxTableCell cell = (CheckBoxTableCell) node; Callback selectedStateCallback = cell.getSelectedStateCallback(); String cbText; if (selectedStateCallback != null) { ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem()); int selection = call.getValue() ? 2 : 0; cbText = JavaFXCheckBoxElement.states[selection]; } else { Node cb = cell.getGraphic(); JavaFXElement comp = (JavaFXElement) JavaFXElementFactory.createElement(cb, driver, window); cbText = comp._getValue(); } String cellText = cell.getText(); if (cellText == null) { cellText = ""; } String text = cellText + ":" + cbText; return text; }
Example 3
Source File: RFXCheckBoxTreeTableCell.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public String _getValue() { CheckBoxTreeTableCell cell = (CheckBoxTreeTableCell) node; Callback selectedStateCallback = cell.getSelectedStateCallback(); String cbText; if (selectedStateCallback != null) { ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem()); int selection = call.getValue() ? 2 : 0; cbText = JavaFXCheckBoxElement.states[selection]; } else { Node cb = cell.getGraphic(); RFXComponent comp = getFinder().findRawRComponent(cb, null, null); cbText = comp._getValue(); } return cbText; }
Example 4
Source File: RFXCheckBoxTableCell.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public String _getValue() { CheckBoxTableCell cell = (CheckBoxTableCell) node; Callback selectedStateCallback = cell.getSelectedStateCallback(); String cbText; if (selectedStateCallback != null) { ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem()); int selection = call.getValue() ? 2 : 0; cbText = JavaFXCheckBoxElement.states[selection]; } else { Node cb = cell.getGraphic(); RFXComponent comp = getFinder().findRawRComponent(cb, null, null); cbText = comp._getValue(); } return cbText; }
Example 5
Source File: RFXCheckBoxListCell.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public String _getValue() { @SuppressWarnings("rawtypes") CheckBoxListCell cell = (CheckBoxListCell) node; ObservableValue<Boolean> call = (ObservableValue<Boolean>) cell.getSelectedStateCallback().call(cell.getItem()); String cbText; if (call != null) { int selection = call.getValue() ? 2 : 0; cbText = JavaFXCheckBoxElement.states[selection]; } else { Node cb = cell.getGraphic(); RFXComponent comp = getFinder().findRawRComponent(cb, null, null); cbText = comp._getValue(); } return cbText; }
Example 6
Source File: JavaFXCheckBoxTreeTableCell.java From marathonv5 with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public String _getValue() { CheckBoxTreeTableCell cell = (CheckBoxTreeTableCell) node; Callback selectedStateCallback = cell.getSelectedStateCallback(); String cbText; if (selectedStateCallback != null) { ObservableValue<Boolean> call = (ObservableValue<Boolean>) selectedStateCallback.call(cell.getItem()); int selection = call.getValue() ? 2 : 0; cbText = JavaFXCheckBoxElement.states[selection]; } else { Node cb = cell.getGraphic(); JavaFXElement comp = (JavaFXElement) JavaFXElementFactory.createElement(cb, driver, window); cbText = comp._getValue(); } String cellText = cell.getText(); if (cellText == null) { cellText = ""; } String text = cellText + ":" + cbText; return text; }
Example 7
Source File: CollectionBindings.java From phoenicis with GNU Lesser General Public License v3.0 | 6 votes |
/** * Maps an {@link ObservableValue<I>} object to an {@link ObservableList} by applying the given converter function * and adding the result to the {@link ObservableList}. * In case the input value is empty, i.e. contains <code>null</code>, the returned {@link ObservableList} is also * empty * * @param property The input value * @param converter The converter function * @param <I> The type of the input value * @param <O> The type of the output value * @return A {@link ObservableList} containing the converted list */ public static <I, O> ObservableList<O> mapToList(ObservableValue<I> property, Function<I, ? extends Collection<O>> converter) { final ObservableList<O> result = FXCollections.observableArrayList(); final InvalidationListener listener = (Observable invalidation) -> { final I input = property.getValue(); if (input != null) { result.setAll(converter.apply(input)); } else { result.clear(); } }; // add the listener to the property property.addListener(listener); // ensure that the result list is initialised correctly listener.invalidated(property); return result; }
Example 8
Source File: CollectionBindings.java From phoenicis with GNU Lesser General Public License v3.0 | 6 votes |
/** * Maps an {@link ObservableValue<I>} object to an {@link ObservableMap} by applying the given converter function * and adding the result to the {@link ObservableMap}. * In case the input value is empty, i.e. contains <code>null</code>, the returned {@link ObservableMap} is also * empty * * @param property The input value * @param converter The converter function * @param <I> The type of the input value * @param <O1> The input type of the result map * @param <O2> The output type of the result map * @return A {@link ObservableMap} containing the converted map */ public static <I, O1, O2> ObservableMap<O1, O2> mapToMap(ObservableValue<I> property, Function<I, Map<O1, O2>> converter) { final ObservableMap<O1, O2> result = FXCollections.observableHashMap(); final InvalidationListener listener = (Observable invalidation) -> { final I input = property.getValue(); result.clear(); if (input != null) { result.putAll(converter.apply(input)); } }; // add the listener to the property property.addListener(listener); // ensure that the result map is initialised correctly listener.invalidated(property); return result; }
Example 9
Source File: ConditionalBinding.java From EasyBind with BSD 2-Clause "Simplified" License | 6 votes |
public ConditionalBinding( Property<T> target, ObservableValue<? extends T> source, ObservableValue<Boolean> condition) { this.target = new WeakReference<>(target); this.source = source; this.condition = condition; // add an empty listener to target just to maintain a strong reference // to this object for the lifetime of target target.addListener(this); condition.addListener((ChangeListener<Boolean>) this); if(condition.getValue()) { target.bind(source); } }
Example 10
Source File: JFXNodeUtils.java From JFoenix with Apache License 2.0 | 5 votes |
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, BiConsumer<T, InvalidationListener> consumer) { Wrapper<T> eventWrapper = new Wrapper<>(); PauseTransition holdTimer = new PauseTransition(delayTime); final InvalidationListener invalidationListener = observable -> { eventWrapper.content = property.getValue(); holdTimer.playFromStart(); }; holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content, invalidationListener)); property.addListener(invalidationListener); return invalidationListener; }
Example 11
Source File: When.java From EasyBind with BSD 2-Clause "Simplified" License | 5 votes |
public ConditionalSubscription( ObservableValue<Boolean> condition, Supplier<? extends Subscription> bindFn) { this.condition = condition; this.bindFn = bindFn; condition.addListener(conditionListener); if(condition.getValue()) { subscription = bindFn.get(); } }
Example 12
Source File: EasyBind.java From EasyBind with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> MonadicBinding<T> orElse(ObservableValue<? extends T> src, T other) { return new PreboundBinding<T>(src) { @Override protected T computeValue() { T val = src.getValue(); return val != null ? val : other; } }; }
Example 13
Source File: EasyBind.java From EasyBind with BSD 2-Clause "Simplified" License | 5 votes |
public static <T, U> MonadicBinding<U> map( ObservableValue<T> src, Function<? super T, ? extends U> f) { return new PreboundBinding<U>(src) { @Override protected U computeValue() { T baseVal = src.getValue(); return baseVal != null ? f.apply(baseVal) : null; } }; }
Example 14
Source File: EasyBind.java From EasyBind with BSD 2-Clause "Simplified" License | 5 votes |
public static <T> MonadicBinding<T> filter( ObservableValue<T> src, Predicate<? super T> p) { return new PreboundBinding<T>(src) { @Override protected T computeValue() { T val = src.getValue(); return (val != null && p.test(val)) ? val : null; } }; }
Example 15
Source File: JFXNodeUtils.java From JFoenix with Apache License 2.0 | 5 votes |
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, Consumer<T> justInTimeConsumer, Consumer<T> delayedConsumer) { Wrapper<T> eventWrapper = new Wrapper<>(); PauseTransition holdTimer = new PauseTransition(delayTime); holdTimer.setOnFinished(event -> delayedConsumer.accept(eventWrapper.content)); final InvalidationListener invalidationListener = observable -> { eventWrapper.content = property.getValue(); justInTimeConsumer.accept(eventWrapper.content); holdTimer.playFromStart(); }; property.addListener(invalidationListener); return invalidationListener; }
Example 16
Source File: JFXNodeUtils.java From JFoenix with Apache License 2.0 | 5 votes |
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, Consumer<T> consumer) { Wrapper<T> eventWrapper = new Wrapper<>(); PauseTransition holdTimer = new PauseTransition(delayTime); holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content)); final InvalidationListener invalidationListener = observable -> { eventWrapper.content = property.getValue(); holdTimer.playFromStart(); }; property.addListener(invalidationListener); return invalidationListener; }
Example 17
Source File: JavaFXCheckBoxTreeCellElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public String _getValue() { @SuppressWarnings("rawtypes") CheckBoxTreeCell cell = (CheckBoxTreeCell) getComponent(); @SuppressWarnings("unchecked") ObservableValue<Boolean> call = (ObservableValue<Boolean>) cell.getSelectedStateCallback().call(cell.getTreeItem()); int selection = call.getValue() ? 2 : 0; String cellText = cell.getText(); if (cellText == null) { cellText = ""; } String text = cellText + ":" + JavaFXCheckBoxElement.states[selection]; return text; }
Example 18
Source File: JavaFXCheckBoxListCellElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public String _getValue() { @SuppressWarnings("rawtypes") CheckBoxListCell cell = (CheckBoxListCell) getComponent(); ObservableValue<Boolean> call = (ObservableValue<Boolean>) cell.getSelectedStateCallback().call(cell.getItem()); int selection = call.getValue() ? 2 : 0; String text = cell.getText() + ":" + JavaFXCheckBoxElement.states[selection]; return text; }