Java Code Examples for java.util.prefs.PreferenceChangeEvent#getNewValue()

The following examples show how to use java.util.prefs.PreferenceChangeEvent#getNewValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Preferences.java    From groovy with Apache License 2.0 6 votes vote down vote up
public void preferenceChange(final PreferenceChangeEvent event) {
    if (event.getKey().equals(VERBOSITY_KEY)) {
        String name = event.getNewValue();

        if (name == null) {
            name = IO.Verbosity.INFO.name;
        }

        try {
            verbosity = IO.Verbosity.forName(name);
        }
        catch (Exception e) {
            event.getNode().put(event.getKey(), verbosity.name);
        }
    }
}
 
Example 2
Source File: InheritedPreferences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    // potential NPE fix; key ought not be null, but guard against it.
    if (evt.getKey() == null) {
        return;
    }
    ignorePut.set(true);
    String k = evt.getKey();
    String v = evt.getNewValue();
    try {
        if (evt.getSource() == stored) {
            // not important, obnly local storage should refire, except clearing of the local value
            if (!isOverriden(k) && v != null) {
                return;
            }
            // try to recover the inherited value
            if (v == null) {
                v = inherited.get(k, null);
            }
        } else if (isOverriden(k)) {
            return;
        }
        // potential NPE, null values should be reported as removals.
        if (v == null) {
            remove(k);
        } else {
            put(k, v);
        }
    } finally {
        ignorePut.set(false);
    }
}
 
Example 3
Source File: ProxyPreferencesImplTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    changeCount++;
    this.key = evt.getKey();
    this.value = evt.getNewValue();
    latch.countDown();
}
 
Example 4
Source File: ProxyPreferencesImplTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent evt) {
    changeCount++;
    this.key = evt.getKey();
    this.value = evt.getNewValue();
    latch.countDown();
}