1 12 13 package org.eclipse.core.databinding.observable; 14 15 import org.eclipse.core.runtime.Assert; 16 import org.eclipse.core.runtime.AssertionFailedException; 17 18 21 public abstract class AbstractObservable extends ChangeManager implements IObservable { 22 23 26 public AbstractObservable(Realm realm) { 27 super(realm); 28 } 29 30 public synchronized void addChangeListener(IChangeListener listener) { 31 addListener(ChangeEvent.TYPE, listener); 32 } 33 34 public synchronized void removeChangeListener(IChangeListener listener) { 35 removeListener(ChangeEvent.TYPE, listener); 36 } 37 38 public synchronized void addStaleListener(IStaleListener listener) { 39 addListener(StaleEvent.TYPE, listener); 40 } 41 42 public synchronized void removeStaleListener(IStaleListener listener) { 43 removeListener(StaleEvent.TYPE, listener); 44 } 45 46 protected void fireChange() { 47 checkRealm(); 48 fireEvent(new ChangeEvent(this)); 49 } 50 51 protected void fireStale() { 52 checkRealm(); 53 fireEvent(new StaleEvent(this)); 54 } 55 56 59 public synchronized void dispose() { 60 super.dispose(); 61 } 62 63 69 protected void checkRealm() { 70 Assert.isTrue(getRealm().isCurrent()); 71 } 72 } 73 | Popular Tags |