Java 类javafx.collections.WeakMapChangeListener 实例源码

项目:StreamSis    文件:AllVariablesController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    // Set style.
    GUIManager.manageWindowStyleOfRootNode(root);
    // Set readOnlyCurrentVarsList to UserVars entry set.
    readOnlyCurrentVarsList.setAll(UserVars.getUserVarsMap().entrySet());
    // Subscribe to UserVars changes.
    UserVars.getUserVarsMap()
            .addListener(new WeakMapChangeListener<String, String>(currentVarsListener));
    // Initialize tables.
    initializeInitialVarsTable();
    initializeCurrentVarsTable();
}
项目:StreamSis    文件:AllVariablesController.java   
public void bindToProject(CuteProject project) {
    this.project = project;
    // Set readOnlyInitialVarsList to project's initial UserVars entry set.
    readOnlyInitialVarsList.setAll(project.getInitialUserVars().entrySet());
    // Subscribe to project initial UserVars changes.
    project.getInitialUserVars()
            .addListener(new WeakMapChangeListener<String, String>(initialVarsListener));
    initialVarsTableView.setItems(readOnlyInitialVarsList);
    currentVarsTableView.disableProperty().bind(project.startedProperty().not());
    initialVarsTableView.disableProperty().bind(project.startedProperty());
}
项目:reta    文件:ObservableMapBuffering.java   
/**
 * @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();
}