Changeset 12181 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-05-15T19:28:35+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/preferences/AbstractProperty.java
r11553 r12181 6 6 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 7 7 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 8 import org.openstreetmap.josm.tools.ListenableWeakReference; 8 9 9 10 /** … … 250 251 */ 251 252 public void addWeakListener(ValueChangeListener<? super T> listener) { 252 addWeakListenerImpl(new PreferenceChangedListenerAdapter(listener)); 253 } 254 255 protected void addWeakListenerImpl(PreferenceChangedListener adapter) { 256 getPreferences().addWeakKeyPreferenceChangeListener(getKey(), adapter); 253 ValueChangeListener<T> weakListener = new WeakPreferenceAdapter(listener); 254 PreferenceChangedListenerAdapter adapter = new PreferenceChangedListenerAdapter(weakListener); 255 addListenerImpl(adapter); 256 } 257 258 private class WeakPreferenceAdapter extends ListenableWeakReference<ValueChangeListener<? super T>> 259 implements ValueChangeListener<T> { 260 public WeakPreferenceAdapter(ValueChangeListener<? super T> referent) { 261 super(referent); 262 } 263 264 @Override 265 public void valueChanged(ValueChangeEvent<? extends T> e) { 266 ValueChangeListener<? super T> r = this.get(); 267 r.valueChanged(e); 268 } 269 270 @Override 271 protected void onDereference() { 272 removeListenerImpl(new PreferenceChangedListenerAdapter(this)); 273 } 274 257 275 } 258 276 -
trunk/src/org/openstreetmap/josm/data/preferences/AbstractToStringProperty.java
r10939 r12181 57 57 super.addListenerImpl(adapter); 58 58 parent.addListenerImpl(adapter); 59 }60 61 @Override62 protected void addWeakListenerImpl(PreferenceChangedListener adapter) {63 super.addWeakListenerImpl(adapter);64 parent.addWeakListenerImpl(adapter);65 }66 67 @Override68 protected void removeListenerImpl(PreferenceChangedListener adapter) {69 super.removeListenerImpl(adapter);70 parent.removeListenerImpl(adapter);71 59 } 72 60
Note:
See TracChangeset
for help on using the changeset viewer.