1 11 package org.eclipse.team.internal.ui; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.jface.util.IPropertyChangeListener; 15 import org.eclipse.jface.util.PropertyChangeEvent; 16 17 20 public class PropertyChangeHandler { 21 22 private ListenerList fListeners = new ListenerList(ListenerList.IDENTITY); 23 24 27 class PropertyNotifier implements ISafeRunnable { 28 29 private IPropertyChangeListener fListener; 30 private PropertyChangeEvent fEvent; 31 32 35 public void handleException(Throwable exception) { 36 TeamUIPlugin.log(IStatus.ERROR, TeamUIMessages.AbstractSynchronizeParticipant_5, exception); 37 } 38 39 42 public void run() throws Exception { 43 fListener.propertyChange(fEvent); 44 } 45 46 52 public void notify(PropertyChangeEvent event) { 53 if (fListeners == null) { 54 return; 55 } 56 fEvent = event; 57 Object [] copiedListeners = fListeners.getListeners(); 58 for (int i = 0; i < copiedListeners.length; i++) { 59 fListener = (IPropertyChangeListener) copiedListeners[i]; 60 SafeRunner.run(this); 61 } 62 fListener = null; 63 } 64 } 65 66 public void addPropertyChangeListener(IPropertyChangeListener listener) { 67 fListeners.add(listener); 68 } 69 70 public void removePropertyChangeListener(IPropertyChangeListener listener) { 71 fListeners.remove(listener); 72 } 73 74 public void firePropertyChange(Object source, String property, Object oldValue, Object newValue) { 75 PropertyNotifier notifier = new PropertyNotifier(); 76 notifier.notify(new PropertyChangeEvent(source, property, oldValue, newValue)); 77 } 78 79 } 80 | Popular Tags |