public <ValueType> PropertyValueListener(String labelDescription, ReadOnlyProperty listenedProperty, String textFieldId, Object owningObject, Boolean showCounters) { this.owningObject = owningObject; receivedValueTF.setId(textFieldId); receivedValueTF.setTooltip(new Tooltip()); if (listenedProperty.getName().contains("BOUNDS")) { //Make text field width, because bounds - big. receivedValueTF.setMinWidth(500); } this.listenedProperty = listenedProperty; counter = new PropertyValueCounter(listenedProperty); getChildren().add(LabelBuilder.create().text(labelDescription).prefWidth(100).build()); if (showCounters) { getChildren().add(counter.getVisualRepresentation()); } getChildren().add(receivedValueTF); listenedProperty.addListener(new ChangeListener() { public void changed(ObservableValue ov, Object t, Object t1) { processNewValue(t1); } }); processNewValue(listenedProperty.getValue()); }
@Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty property, Object value) { final Object bean = property.getBean(); if (bean instanceof Stage) { final Stage stage = (Stage) bean; if (stage.isShowing()) { stage.hide(); stage.initModality((Modality) value); stage.show(); } else { stage.initModality((Modality) value); } } else { LOG.warn("Unsupported Dialog-type encountered: {}", bean.getClass()); } }
@Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (!selectionChanging) { selectionChanging = true; ReadOnlyProperty<? extends Boolean> property = (ReadOnlyProperty<? extends Boolean>) observable; MapItem mapItem = (MapItem) property.getBean(); T item = (T) mapItem.getItem(); if (item == null) { item = (T) mapItem; } if (newValue) { addSelectedItem(item); } else { removeSelectedItem(item); } selectionChanging = false; } }
public LineThicknessMenuButton(TimeGraphWidget widget, ConfigOption<LineThickness> option, ReadOnlyProperty<? extends Paint> colorSource) { fOption = option; fColorSource = colorSource; ToggleGroup tg = new ToggleGroup(); List<LineThicknessMenuButtonItem> items = Arrays.stream(LineThickness.values()) .map(lt -> { LineThicknessMenuButtonItem rmi = new LineThicknessMenuButtonItem(lt); rmi.setGraphic(getRectangleForThickness(lt)); rmi.setToggleGroup(tg); LineThickness currentThickness = option.get(); rmi.setSelected(lt == currentThickness); rmi.setOnAction(e -> { option.set(lt); LineThicknessMenuButton.this.setGraphic(getRectangleForThickness(lt)); repaintAllRectangles(widget); }); return rmi; }) .collect(Collectors.toList()); /* Initial value shown in the button */ setGraphic(getRectangleForThickness(option.get())); getItems().addAll(items); }
@Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty property, Object value) { final Stage stage = (Stage) property.getBean(); if (Boolean.TRUE.equals(value)) { stage.show(); } else { stage.hide(); } }
@SuppressWarnings("unchecked") @Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty readOnlyProperty, Object value) { final Property property = (Property) readOnlyProperty; if (property.getValue() == null? value != null : ! property.getValue().equals(value)) { property.setValue(value); } }
@SuppressWarnings("unchecked") protected void clearListeners(Object node, ReadOnlyProperty property) { final ChangeListener changeListener = (ChangeListener) getProperties(node).get(property.getName() + ".change"); if (changeListener != null) { property.removeListener(changeListener); } final InvalidationListener invalidationListener = (InvalidationListener) getProperties(node).get(property.getName() + ".invalidation"); if (invalidationListener != null) { property.removeListener(invalidationListener); } }
@SuppressWarnings("unchecked") protected void setChangeListener(Consumer<Object> dispatcher, Object node, ReadOnlyProperty property, VChangeListener listener) { final ChangeListener newListener = (source, oldValue, newValue) -> { final Object action = listener.onChange(fxToV(oldValue), fxToV(newValue)); if (action != null) { dispatcher.accept(action); } }; property.addListener(newListener); getProperties(node).put(property.getName() + ".change", newListener); }
protected void setInvalidationListener(Consumer<Object> dispatcher, Object node, ReadOnlyProperty property, VInvalidationListener listener) { final InvalidationListener newListener = source -> { final Object action = listener.onInvalidation(); if (action != null) { dispatcher.accept(action); } }; property.addListener(newListener); getProperties(node).put(property.getName() + ".invalidation", newListener); }
@SuppressWarnings("unchecked") @Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty property, Object value) { if (value instanceof ToggleGroup) { ((Property) property).setValue(value); return; } throw new IllegalStateException(String.format("Unable to set the value %s of property %s in class %s", value, property.getName(), property.getBean().getClass())); }
/** * 取得屬性本身 * * @param bean 要取得屬性本身的物件 * @return 屬性本身 * @throws IllegalStateException 屬性不提供{@link ReadOnlyProperty} */ @SuppressWarnings("unchecked") public ReadOnlyProperty<T> getProperty(Object bean) { if (!this.hasProperty()) throw new IllegalStateException("Cannot get property " + this.name); return (ReadOnlyProperty<T>) this.reflectedInfo.getProperty.apply(bean); }
public final ReadOnlyProperty<ConnectionStatus> connectionStatusProperty() { return connectionStatus; }
public static ReadOnlyProperty<Playback> currentPlaybackProperty() { return currentPlayback; }
public ReadOnlyProperty getObservedProperty() { return observedProperty; }
@Override public void addSimpleListener(ReadOnlyProperty<? extends Object> bindableProperty, Object owningObject) { AbstractPropertyValueListener listener = new PropertyValueListener(bindableProperty, owningObject); readonlyPropertyListeners.put(bindableProperty.getName().toUpperCase(), listener); listenersFlowPane.getChildren().add(listener.getVisualRepresentation()); }
public <ValueType> PropertyValueListener(ReadOnlyProperty bindableProperty, Object owningObject) { this(bindableProperty, owningObject, true); }
public <ValueType> PropertyValueListener(ReadOnlyProperty bindableProperty, Object owningObject, Boolean showCounters) { this(bindableProperty.getName().toLowerCase() + " : ", bindableProperty, bindableProperty.getName().toUpperCase() + LISTENER_SUFFIX, owningObject, showCounters); }
public <ValueType> PropertyValueListener(String labelDescription, ReadOnlyProperty listenedProperty, String textFieldId, Object owningObject) { this(labelDescription, listenedProperty, textFieldId, owningObject, true); }
public synchronized <T> void addPropertyListener(ReadOnlyProperty<T> property, ChangeListener<? super T> listener) { addPropertyListener(property.getName(), listener); }
public synchronized <T> void removePropertyListener(ReadOnlyProperty<T> property, ChangeListener<? super T> listener) { removePropertyListener(property.getName(), listener); }
@Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty property, Object value) { LOG.warn("Tried to set read-only property {} to {}", property, value); }
@Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty property, Object value) { if (Boolean.TRUE.equals(value)) { ((Node) property.getBean()).requestFocus(); } }
@SuppressWarnings("unchecked") @Override protected void setValue(Consumer<Object> dispatcher, ReadOnlyProperty property, Object value) { ((ObservableList) property.getValue()).setAll(value == null? Collections.emptyList() : ((Seq) value).toJavaList()); }
public final ReadOnlyProperty<Node> dockParentProperty() { return parent.getReadOnlyProperty(); }
public ReadOnlyProperty<String> nameProperty() { return mName; }
/** * @return the viewCoordinatePath */ public ReadOnlyProperty<UUID> getViewCoordinatePath() { return viewCoordinatePath.getReadOnlyProperty(); }
/** * @return the editCoordinatePath */ public ReadOnlyProperty<UUID> getEditCoordinatePath() { return editCoordinatePath.getReadOnlyProperty(); }
/** * @param newBeanType * bean type * @param newPropertyName * bean property name * @param newSubject * property value */ public ObservableSetBuffering(final Class<?> newBeanType, final String newPropertyName, final ObservableSet<E> newSubject) { super(FXCollections.observableSet(new HashSet<>(newSubject != null ? newSubject.size() : 0))); if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>)) { beanType = newBeanType; } else { final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean(); beanType = (bean != null ? bean.getClass() : null); } if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>)) { propertyName = newPropertyName; } else { propertyName = ((ReadOnlyProperty<?>) newSubject).getName(); } subject = Objects.requireNonNull(newSubject); addAll(subject); thisListener = c -> { if (equalsBuffering) { buffering.setValue(!equalsSubject()); } else { buffering.setValue(true); } validate(); }; subjectListener = c -> { if (!buffering.getValue()) { revert(); } }; addListener(thisListener); weakSubjectListener = new WeakSetChangeListener<E>(subjectListener); subject.addListener(weakSubjectListener); validate(); }
/** * @param newBeanType * bean type * @param newPropertyName * bean property name * @param newSubject * property value */ public ObservableListBuffering(final Class<?> newBeanType, final String newPropertyName, final ObservableList<E> newSubject) { super(FXCollections.observableArrayList()); if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>)) { beanType = newBeanType; } else { final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean(); beanType = (bean != null ? bean.getClass() : null); } if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>)) { propertyName = newPropertyName; } else { propertyName = ((ReadOnlyProperty<?>) newSubject).getName(); } subject = Objects.requireNonNull(newSubject); addAll(subject); thisListener = c -> { if (equalsBuffering) { buffering.setValue(!equalsSubject()); } else { buffering.setValue(true); } validate(); }; subjectListener = c -> { if (!buffering.getValue()) { revert(); } }; addListener(thisListener); weakSubjectListener = new WeakListChangeListener<E>(subjectListener); subject.addListener(weakSubjectListener); validate(); }
/** * @param newBeanType * bean type * @param newPropertyName * bean property name * @param newSubject * property value */ public SimpleObjectPropertyBuffering(final Class<?> newBeanType, final String newPropertyName, final Property<T> newSubject) { if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>)) { beanType = newBeanType; } else { final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean(); beanType = (bean != null ? bean.getClass() : null); } if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>)) { propertyName = newPropertyName; } else { propertyName = ((ReadOnlyProperty<?>) newSubject).getName(); } subject = java.util.Objects.requireNonNull(newSubject); setValue(subject.getValue()); thisListener = (observable, oldValue, value) -> { if (equalsBuffering) { buffering.setValue(!Objects.equals(getValue(), subject.getValue())); } else { buffering.setValue(true); } validate(); }; subjectListener = (observable, oldValue, value) -> { if (!buffering.getValue()) { revert(); } }; addListener(thisListener); weakSubjectListener = new WeakChangeListener<T>(subjectListener); subject.addListener(weakSubjectListener); validate(); }
/** * @param newBeanType * bean type * @param newPropertyName * bean property name * @param newSubject * property value */ public ObservableMapBuffering(final Class<?> newBeanType, final String newPropertyName, final ObservableMap<K, E> newSubject) { super(FXCollections.observableHashMap()); if (newBeanType != null || !(newSubject instanceof ReadOnlyProperty<?>)) { beanType = newBeanType; } else { final Object bean = ((ReadOnlyProperty<?>) newSubject).getBean(); beanType = (bean != null ? bean.getClass() : null); } if (newPropertyName != null || !(newSubject instanceof ReadOnlyProperty<?>)) { propertyName = newPropertyName; } else { propertyName = ((ReadOnlyProperty<?>) newSubject).getName(); } subject = Objects.requireNonNull(newSubject); putAll(subject); thisListener = c -> { // TODO: Workaround for https://bugs.openjdk.java.net/browse/JDK-8136465 if (!reverting) { if (equalsBuffering) { buffering.setValue(!equalsSubject()); } else { buffering.setValue(true); } validate(); } }; subjectListener = c -> { // TODO: Workaround for https://bugs.openjdk.java.net/browse/JDK-8136465 if (!committing) { if (!buffering.getValue()) { revert(); } } }; addListener(thisListener); weakSubjectListener = new WeakMapChangeListener<K, E>(subjectListener); subject.addListener(weakSubjectListener); validate(); }
/** * @return key property */ public ReadOnlyProperty<K> keyProperty() { return key; }
public ReadOnlyProperty<String> titleProperty() { return titleProperty; }
public ReadOnlyProperty<String> titleDescProperty() { return titleDescProperty; }
public ReadOnlyProperty<String> artistProperty() { return artistProperty; }
public ReadOnlyProperty<String> albumProperty() { return albumProperty; }
public ReadOnlyProperty<String> infoProperty() { return infoProperty; }