/** Gets the index of the currently focused item. */ private int getFocusIdx() { if (!autoCompletePopup.isShowing()) { return -1; } List<ObservableSet<PseudoClass>> collect = autoCompletePopup.getItems() .stream() .map(this::getStyleableNode) .filter(Objects::nonNull) .map(Node::getPseudoClassStates) .collect(Collectors.toList()); for (int i = 0; i < collect.size(); i++) { if (collect.get(i).contains(PseudoClass.getPseudoClass("focused"))) { return i; } } return -1; }
/** * Redisplay current datas, do not make remote server call */ public void redisplayCurrentDatas() { selections.clear(); }
/** * @param root * The "checked" state of all the descendants, including the root * itself, will be monitored */ public CheckedTreeItemCollector(CheckBoxTreeItem<T> root) { this.root = root; root.addEventHandler(TreeModificationEvent.ANY, event -> { @SuppressWarnings("unchecked") TreeModificationEvent<T> mod = (TreeModificationEvent<T>) event; T value = mod.getTreeItem().getValue(); boolean checked = mod.getTreeItem().isSelected(); synchronized (this.checkedItems) { if (checked && !this.checkedItems.contains(value)) { this.checkedItems.add(value); } else if (!checked && this.checkedItems.contains(value)) { this.checkedItems.remove(value); } } }); this.checkedItems.addListener((SetChangeListener<T>) change -> { if (change.getElementAdded() != null) { setCheckedStateForValue(root, change.getElementAdded(), true); } if (change.getElementRemoved() != null) { setCheckedStateForValue(root, change.getElementRemoved(), false); } }); }
public static <T> Observable<ObservableSet<T>> fromObservableSet(final ObservableSet<T> source) { return Observable.create((ObservableOnSubscribe<ObservableSet<T>>) subscriber -> { SetChangeListener<T> listener = c -> subscriber.onNext(source); source.addListener(listener); subscriber.setDisposable(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeListener(listener))); }).startWith(source).subscribeOn(JavaFxScheduler.platform()); }
/** * Registers a {@code SetChangeListener} that always handles notifications inside the UI thread. * * @param observable the observable on which the listener will be registered. * @param consumer the consumer of the {@code newValue} argument. * * @return a {@code SetChangeListener}. */ public static <E> SetChangeListener<E> uiThreadAwareSetChangeListener(@Nonnull final ObservableSet<E> observable, @Nonnull final Consumer<SetChangeListener.Change<? extends E>> consumer) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); SetChangeListener<E> listener = uiThreadAwareSetChangeListener(consumer); observable.addListener(listener); return listener; }
@Override protected void updateItem(Object item, boolean empty) { super.updateItem(item, empty); setGraphic(null); if (!empty && item != null) { final IBuildable flowItem = (IBuildable) Services.getBean(getFlowItemId()); ((MultiPresenterFactory) flowItem).setForData((OperationData) item); flowItem.buildFrom(controller, contentConfiguration); factories.add((MultiPresenterFactory) flowItem); if (((MultiPresenterFactory) flowItem).getSelectionPaneWrapper() != null) { ((MultiPresenterFactory) flowItem).getSelectionPaneWrapper().visibleProperty().bind(modifying); } ((MultiPresenterFactory) flowItem).getSelection().selectedProperty().addListener((ChangeListener<Boolean>) (observable, oldValue, newValue) -> { if (newValue.booleanValue()) { selections.add((OperationData) item); } else { selections.remove(item); } }); final Node display = flowItem.getDisplay(); NodeHelper.setHgrow(display); setGraphic(display); } } }
public DockingPaneSkin(DockingPane control) { this.control = control; pane.setCenter(rootSplitPane); this.control.getDockingAreaDescriptors().addListener(dockingAreaDescriptorSetChangeListener); this.control.getDockables().addListener(dockableEntrySetChangeListener); this.control.getDockingAreaDescriptors().forEach(dockingAreaDescriptor -> addDockingArea(dockingAreaDescriptor)); this.control.getDockables().forEach(dockableEntry -> addDockable(dockableEntry)); this.control.sceneProperty().addListener((ov, oldValue, newValue) -> { if (oldValue != null) { oldValue.focusOwnerProperty().removeListener(focusOwnerChangeListener); } if (newValue != null) { newValue.focusOwnerProperty().addListener(focusOwnerChangeListener); } }); this.control.getScene().focusOwnerProperty().addListener(focusOwnerChangeListener); }
private void removeDockable(FXDockableEntry dockableEntry) { dockables.remove(dockableEntry); }
@Override protected InputDeviceRegistry createInputDeviceRegistry() { InputDeviceRegistry registry = new InputDeviceRegistry() { { // Register a pointing device so that the virtual keyboard will // be used devices.add(new InputDevice() { @Override public boolean isTouch() { return true; } @Override public boolean isMultiTouch() { return false; } @Override public boolean isRelative() { return false; } @Override public boolean is5Way() { return false; } @Override public boolean isFullKeyboard() { return false; } }); } }; return registry; }
private void updateAllCaretShapes() { carets.forEach(this::updateSingleCaret); }
@Override public void dispose() { control.getDockables().removeListener(dockableEntrySetChangeListener); control.getDockingAreaDescriptors().removeListener(dockingAreaDescriptorSetChangeListener); control.getScene().focusOwnerProperty().removeListener(focusOwnerChangeListener); control = null; pane = null; rootSplitPane = null; }
/** * @param root * The "checked" state of all the descendants, including the root * itself, will be monitored */ public CheckedTreeItemCollector(CheckBoxTreeItem<T> root) { this.root = root; root.addEventHandler(TreeModificationEvent.ANY, event -> { @SuppressWarnings("unchecked") TreeModificationEvent<T> mod = (TreeModificationEvent<T>) event; T value = mod.getTreeItem().getValue(); boolean checked = mod.getTreeItem().isSelected(); synchronized (this.checkedItems) { if (checked && !this.checkedItems.contains(value)) { this.checkedItems.add(value); } else if (!checked && this.checkedItems.contains(value)) { this.checkedItems.remove(value); } } }); this.checkedItems.addListener((SetChangeListener<T>) change -> { if (change.getElementAdded() != null) { setCheckedStateForValue(root, change.getElementAdded(), true); } if (change.getElementRemoved() != null) { setCheckedStateForValue(root, change.getElementRemoved(), false); } }); }
public static <T> Observable<ObservableSet<T>> fromObservableSet(final ObservableSet<T> source) { return Observable.create((ObservableOnSubscribe<ObservableSet<T>>) subscriber -> { SetChangeListener<T> listener = c -> subscriber.onNext(source); source.addListener(listener); subscriber.setDisposable(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeListener(listener))); }).startWith(source).subscribeOn(JavaFxScheduler.platform()); }
/** * Registers a {@code SetChangeListener} that always handles notifications inside the UI thread. * * @param observable the observable on which the listener will be registered. * @param listener the wrapped set change listener. * * @return a {@code SetChangeListener}. */ public static <E> SetChangeListener<E> uiThreadAwareSetChangeListener(@Nonnull final ObservableSet<E> observable, @Nonnull SetChangeListener<E> listener) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); SetChangeListener<E> uiListener = uiThreadAwareSetChangeListener(listener); observable.addListener(uiListener); return listener; }
public DockingPaneSkin(DockingPane control) { this.control = control; pane.setCenter(rootSplitPane); this.control.getDockingAreaDescriptors().addListener(dockingAreaDescriptorSetChangeListener); this.control.getDockables().addListener(dockableEntrySetChangeListener); this.control.getDockingAreaDescriptors().forEach(dockingAreaDescriptor -> addDockingArea(dockingAreaDescriptor)); this.control.getDockables().forEach(this::addDockable);
private void removeDockable(FXDockableEntry dockableEntry) { dockables.remove(dockableEntry); }
@Override public boolean add(E e) { return getDelegate().add(e); }
@Override public void extractValues(ReadOnlySetProperty<?> originalValue, ValueExtractor.ValueReceiver receiver) { Optional.ofNullable(originalValue.getValue()) .ifPresent(s -> s.forEach(e -> receiver.iterableValue("<iterable element>", e))); } }