private static Object getConstraint(Node node, Object key) { if (node.hasProperties()) { Object value = node.getProperties().get(key); if (value != null) { return value; } } return null; }
doc.childrenProperty().addListener( (MapChangeListener.Change< ? extends String, .values() .forEach(list -> list.addListener(onListChange));
tab.getStyleClass().addListener(weakStyleClassListener); getProperties().put(Tab.class, tab);
private static Stack<InputMap<?>> getStack(Node node) { ObservableMap<Object, Object> nodeProperties = getProperties(node); if (nodeProperties.get(P_STACK) == null) { Stack<InputMap<?>> stackedInputMaps = new Stack<>(); nodeProperties.put(P_STACK, stackedInputMaps); return stackedInputMaps; } return (Stack<InputMap<?>>) nodeProperties.get(P_STACK); }
private static void updateManagedProperty(Node n, DeviceType type) { // first time we've set this invisible => store the preset if (!n.getProperties().containsKey(PROP_MANAGED_STATE)) { n.getProperties().put(PROP_MANAGED_STATE, n.isManaged()); } // don't track changes through this n.managedProperty().removeListener(MANAGED_LISTENER); // If it's visible we use the stored value for "managed" property n.setManaged(n.isVisible() ? (Boolean) n.getProperties().get(PROP_MANAGED_STATE) : false); // need to track changes through API n.managedProperty().addListener(MANAGED_LISTENER); }
public static <K,T> Observable<ObservableMap<K,T>> fromObservableMap(final ObservableMap<K,T> source) { return Observable.create((ObservableOnSubscribe<ObservableMap<K,T>>) subscriber -> { MapChangeListener<K,T> listener = c -> subscriber.onNext(source); source.addListener(listener); subscriber.setDisposable(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeListener(listener))); }).startWith(source).subscribeOn(JavaFxScheduler.platform()); }
@Override public void executeOnCloseButtonClicked() { for (IWare ware : availableMap.keySet()) { IntegerProperty amount = availableMap.get(ware); office.move(ware, amount.intValue(), 0); } availableMap.clear(); ViewChangeCityPlayerProxyJFX proxy = new ViewChangeCityPlayerProxyJFX(viewState.getCurrentCityProxy().get(), EViewChangeEvent.MAIN_VIEW_CHURCH); clientEventBus.post(new NoticeBoardUpdate(proxy)); super.executeOnCloseButtonClicked(); } @VisibleForTesting
/** * {@inheritDoc} */ @Override public Collection<ServiceTask<?>> getPendingTaskList() { return this.pendingTasks.values(); }
/** * Registers a {@code MapChangeListener} that always handles notifications inside the UI thread. * * @param observable the observable on which the listener will be registered. * @param runnable the code to be executed when the listener is notified. * * @return a {@code MapChangeListener}. */ public static <K, V> MapChangeListener<K, V> uiThreadAwareMapChangeListener(@Nonnull final ObservableMap<K, V> observable, @Nonnull final Runnable runnable) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); MapChangeListener<K, V> listener = uiThreadAwareMapChangeListener(runnable); observable.addListener(listener); return listener; }
/** * {@inheritDoc} */ @Override public void removePendingTask(final String taskKey) { this.pendingTasks.remove(taskKey); }
@Override public Set<K> keySet() { return getDelegate().keySet(); }
public void addDirectMessage(final DirectMessage directMessageEvent) { final long otherId = getOtherId(directMessageEvent); final User other = messageEvents.keySet() .stream() .filter(user -> user.getId() == otherId) .findAny() .orElseGet(() -> showUser(otherId)); final ObservableList<DirectMessage> messagesWithOther = messageEvents.computeIfAbsent( other, k -> FXCollections.observableArrayList() ); messagesWithOther.add(directMessageEvent); messagesWithOther.sort(Comparator.comparingLong(DirectMessage::getId)); }
/** * Convenience method for deviceSizes.put(device, size) */ public void setDeviceSize(String device, Size size) { deviceSizes.put(device, size); }
private EventHandler<MouseEvent> createNextAction(EWare ware) { return evt -> { try { office.move(ware, -1); IntegerProperty donated = availableMap.get(ware); availableMap.put(ware, new SimpleIntegerProperty(donated.add(1).intValue())); } catch (RuntimeException e) { logger.error("Failed to move wares", e); } }; }
public static <K,T> Observable<ObservableMap<K,T>> fromObservableMap(final ObservableMap<K,T> source) { return Observable.create((ObservableOnSubscribe<ObservableMap<K,T>>) subscriber -> { MapChangeListener<K,T> listener = c -> subscriber.onNext(source); source.addListener(listener); subscriber.setDisposable(JavaFxSubscriptions.unsubscribeInEventDispatchThread(() -> source.removeListener(listener))); }).startWith(source).subscribeOn(JavaFxScheduler.platform()); }
private void updateAllSelectionShapes() { selections.values().forEach(this::updateSingleSelection); }
/** * Registers a {@code MapChangeListener} that always handles notifications inside the UI thread. * * @param observable the observable on which the listener will be registered. * @param listener the wrapped map change listener. * * @return a {@code MapChangeListener}. */ public static <K, V> MapChangeListener<K, V> uiThreadAwareMapChangeListener(@Nonnull final ObservableMap<K, V> observable, @Nonnull MapChangeListener<K, V> listener) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); MapChangeListener<K, V> uiListener = uiThreadAwareMapChangeListener(listener); observable.addListener(uiListener); return listener; }
private void removeLocation(WorldMapView.Location location) { locationMap.remove(location); }