private IntegerBinding defaultPortProperty(T document, DbmsHandlerComponent dbmsHandlerComponent) { return Bindings.createIntegerBinding(() -> DatabaseUtil.findDbmsType(dbmsHandlerComponent, document).getDefaultPort(), document.typeNameProperty() ); } }
@Override public void initialize(URL location, ResourceBundle resources) { BooleanBinding noSelection = fileListView.getSelectionModel().selectedItemProperty().isNull(); removeFileButton.disableProperty().bind(noSelection); moveItemUpButton.disableProperty().bind(noSelection.or(fileListView.getSelectionModel().selectedIndexProperty().isEqualTo(0))); // we can't just map the val because we need an ObservableNumberValue IntegerBinding lastIndexBinding = Bindings.createIntegerBinding(() -> fileListView.getItems().size() - 1, Val.wrap(fileListView.itemsProperty()).flatMap(LiveList::sizeOf)); moveItemDownButton.disableProperty().bind(noSelection.or(fileListView.getSelectionModel().selectedIndexProperty().isEqualTo(lastIndexBinding))); fileListView.setCellFactory(DesignerUtil.simpleListCellFactory(File::getName, File::getAbsolutePath)); selectFilesButton.setOnAction(e -> onSelectFileClicked()); removeFileButton.setOnAction(e -> onRemoveFileClicked()); moveItemUpButton.setOnAction(e -> moveUp()); moveItemDownButton.setOnAction(e -> moveDown()); }
/** * Converts a integer object observable value into a integer binding. * * @param observable the observable to be converted. * * @return a integer binding. */ @Nonnull public static IntegerBinding mapToInteger(@Nonnull final ObservableObjectValue<Integer> observable) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); return createIntegerBinding(observable::get, observable); }
/** * Creates an integer binding with the first element of an observable set after filtering. * * @param items the observable set of items. * @param defaultValue the value to be returned if there is no value present. * @param filter a non-interfering, stateless predicate to apply to the each element. * * @return an integer binding */ @Nonnull public static IntegerBinding filterThenFindFirstInteger(@Nonnull final ObservableSet<Integer> items, @Nonnull final Integer defaultValue, @Nonnull final Predicate<? super Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.stream().filter(filter).findFirst().orElse(defaultValue), items); }
/** * Creates an integer binding with the first value of an observable map after filtering. * * @param items the observable map of items. * @param defaultValue the value to be returned if there is no value present. * @param filter a non-interfering, stateless predicate to apply to the each value * * @return an integer binding */ @Nonnull public static <K> IntegerBinding filterThenFindFirstInteger(@Nonnull final ObservableMap<K, Integer> items, @Nonnull final Integer defaultValue, @Nonnull final Predicate<? super Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.values().stream().filter(filter).findFirst().orElse(defaultValue), items); }
/** * Creates an integer binding with the first element of an observable list after filtering. * * @param items the observable list of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param filter a non-interfering, stateless predicate to apply to the each element. * * @return an integer binding */ @Nonnull public static IntegerBinding filterThenFindFirstInteger(@Nonnull final ObservableList<Integer> items, @Nonnull final Supplier<Integer> supplier, @Nonnull final Predicate<? super Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.stream().filter(filter).findFirst().orElseGet(supplier), items); }
/** * Creates an integer binding with the first value of an observable map after filtering. * * @param items the observable map of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param filter a non-interfering, stateless predicate to apply to the each value * * @return an integer binding */ @Nonnull public static <K> IntegerBinding filterThenFindFirstInteger(@Nonnull final ObservableMap<K, Integer> items, @Nonnull final Supplier<Integer> supplier, @Nonnull final Predicate<? super Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.values().stream().filter(filter).findFirst().orElseGet(supplier), items); }
/** * Creates an integer binding with the first element of an observable list after filtering. * * @param items the observable list of items. * @param defaultValue the value to be returned if there is no value present. * @param filter a non-interfering, stateless predicate to apply to the each element. * * @return an integer binding */ @Nonnull public static IntegerBinding filterThenFindFirstInteger(@Nonnull final ObservableList<Integer> items, @Nonnull final Integer defaultValue, @Nonnull final Predicate<? super Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.stream().filter(filter).findFirst().orElse(defaultValue), items); }
/** * Returns an integer binding whose value is the reduction of all elements in the list. The mapper function is applied to the reduced value. * * @param items the observable list of elements. * @param defaultValue the value to be returned if there is no value present, may be null. * @param reducer an associative, non-interfering, stateless function for combining two values. * @param mapper a non-interfering, stateless function to apply to the reduced value. * * @return an integer binding */ @Nonnull public static <T> IntegerBinding reduceThenMapToInteger(@Nonnull final ObservableList<T> items, @Nullable final T defaultValue, @Nonnull final BinaryOperator<T> reducer, @Nonnull final Function<? super T, Integer> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(reducer, ERROR_REDUCER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createIntegerBinding(() -> mapper.apply(items.stream().reduce(reducer).orElse(defaultValue)), items); }
/** * Returns an integer binding whose value is the reduction of all values in the map. The mapper function is applied to each value before reduction. * * @param items the observable map. * @param defaultValue the value to be returned if there is no value present, may be null. * @param mapper a non-interfering, stateless function to apply to each value. * @param reducer an associative, non-interfering, stateless function for combining two values. * * @return an integer binding */ @Nonnull public static <K, V> IntegerBinding mapToIntegerThenReduce(@Nonnull final ObservableMap<K, V> items, @Nullable final Integer defaultValue, @Nonnull final Function<? super V, Integer> mapper, @Nonnull final BinaryOperator<Integer> reducer) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(reducer, ERROR_REDUCER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createIntegerBinding(() -> items.values().stream().map(mapper).reduce(reducer).orElse(defaultValue), items); }
/** * Converts an observable into an integer binding. * * @param observable the observable to be converted. * @param mapper a non-interfering, stateless function to apply to the observable value. * * @return an integer binding. * * @since 2.11.0 */ @Nonnull public static <T> IntegerBinding mapAsInteger(@Nonnull final ObservableValue<T> observable, @Nonnull final Function<T, Integer> mapper) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createIntegerBinding(() -> mapper.apply(observable.getValue()), observable); }
/** * Creates an integer binding with the first element of an observable set after filtering. * * @param items the observable set of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param filter a non-interfering, stateless predicate to apply to the each element. * * @return an integer binding */ @Nonnull public static IntegerBinding filterThenFindFirstInteger(@Nonnull final ObservableSet<Integer> items, @Nonnull final Supplier<Integer> supplier, @Nonnull final Predicate<? super Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.stream().filter(filter).findFirst().orElseGet(supplier), items); }
/** * Returns an integer binding whose value is the reduction of all elements in the set. The mapper function is applied to each element before reduction. * * @param items the observable set of elements. * @param defaultValue the value to be returned if there is no value present, may be null. * @param mapper a non-interfering, stateless function to apply to each element. * @param reducer an associative, non-interfering, stateless function for combining two values. * * @return an integer binding */ @Nonnull public static <T> IntegerBinding mapToIntegerThenReduce(@Nonnull final ObservableSet<T> items, @Nullable final Integer defaultValue, @Nonnull final Function<? super T, Integer> mapper, @Nonnull final BinaryOperator<Integer> reducer) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(reducer, ERROR_REDUCER_NULL); return createIntegerBinding(() -> items.stream().map(mapper).reduce(reducer).orElse(defaultValue), items); }
/** * Creates an integer binding with the first value of an observable map after mapping and filtering. * * @param items the observable map of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param mapper a non-interfering, stateless function to apply to the each value before filtering. * @param filter a non-interfering, stateless predicate to apply to the each value after mapping. * * @return an integer binding */ @Nonnull public static <K, V> IntegerBinding mapToIntegerThenFilterThenFindFirst(@Nonnull final ObservableMap<K, V> items, @Nonnull final Supplier<Integer> supplier, @Nonnull final Function<? super V, Integer> mapper, @Nonnull final Predicate<Integer> filter) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); requireNonNull(filter, ERROR_FILTER_NULL); return createIntegerBinding(() -> items.values().stream().map(mapper).filter(filter).findFirst().orElseGet(supplier), items); }
/** * Creates an integer binding with the first element of an observable list after filtering and mapping. * * @param items the observable list of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param filter a non-interfering, stateless predicate to apply to the each element. before mapping. * @param mapper a non-interfering, stateless function to apply to the each element after filtering. * * @return an integer binding */ @Nonnull public static <T> IntegerBinding filterThenMapToIntegerThenFindFirst(@Nonnull final ObservableList<T> items, @Nonnull final Supplier<Integer> supplier, @Nonnull final Predicate<? super T> filter, @Nonnull final Function<? super T, Integer> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); requireNonNull(filter, ERROR_FILTER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createIntegerBinding(() -> items.stream().filter(filter).map(mapper).findFirst().orElseGet(supplier), items); }
/** * Creates an integer binding with the first element of an observable set after filtering and mapping. * * @param items the observable set of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param filter a non-interfering, stateless predicate to apply to the each element. before mapping. * @param mapper a non-interfering, stateless function to apply to the each element after filtering. * * @return an integer binding */ @Nonnull public static <T> IntegerBinding filterThenMapToIntegerThenFindFirst(@Nonnull final ObservableSet<T> items, @Nonnull final Supplier<Integer> supplier, @Nonnull final Predicate<? super T> filter, @Nonnull final Function<? super T, Integer> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); requireNonNull(filter, ERROR_FILTER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createIntegerBinding(() -> items.stream().filter(filter).map(mapper).findFirst().orElseGet(supplier), items); }
/** * Returns an integer binding whose value is the reduction of all values in the map. The mapper function is applied to the reduced value. * * @param items the observable map. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param reducer an associative, non-interfering, stateless function for combining two values. * @param mapper a non-interfering, stateless function to apply to the reduced value. * * @return an integer binding */ @Nonnull public static <K, V> IntegerBinding reduceThenMapToInteger(@Nonnull final ObservableMap<K, V> items, @Nonnull final Supplier<V> supplier, @Nonnull final BinaryOperator<V> reducer, @Nonnull final Function<? super V, Integer> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(reducer, ERROR_REDUCER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); return createIntegerBinding(() -> mapper.apply(items.values().stream().reduce(reducer).orElseGet(supplier)), items); }
/** * Returns an integer binding whose value is the reduction of all elements in the set. The mapper function is applied to the reduced value. * * @param items the observable set of elements. * @param supplier a {@code Supplier} whose result is returned if no value is present. * @param reducer an associative, non-interfering, stateless function for combining two values. * @param mapper a non-interfering, stateless function to apply to the reduced value. * * @return an integer binding */ @Nonnull public static <T> IntegerBinding reduceThenMapToInteger(@Nonnull final ObservableSet<T> items, @Nonnull final Supplier<T> supplier, @Nonnull final BinaryOperator<T> reducer, @Nonnull final Function<? super T, Integer> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(reducer, ERROR_REDUCER_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); return createIntegerBinding(() -> mapper.apply(items.stream().reduce(reducer).orElseGet(supplier)), items); }
private IntegerBinding defaultPortProperty(T document, DbmsHandlerComponent dbmsHandlerComponent) { return Bindings.createIntegerBinding(() -> DatabaseUtil.findDbmsType(dbmsHandlerComponent, document).getDefaultPort(), document.typeNameProperty() ); } }
protected IntegerBinding defaultPortProperty(DbmsHandlerComponent dbmsHandlerComponent) { return Bindings.createIntegerBinding(() -> DatabaseUtil.findDbmsType(dbmsHandlerComponent, this).getDefaultPort(), typeNameProperty() ); }