1 19 20 package org.netbeans.modules.project.uiapi; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeSupport ; 24 25 31 public class CategoryChangeSupport { 32 33 public static final CategoryChangeSupport NULL_INSTANCE = new CategoryChangeSupport() { 34 public void firePropertyChange(String pn, Object o, Object n) {} 35 public void removePropertyChangeListener(PropertyChangeListener l) {} 36 void addPropertyChangeListener(PropertyChangeListener l) {} 37 }; 38 39 private PropertyChangeSupport changeSupport; 40 41 42 public static final String VALID_PROPERTY = "isCategoryValid"; 44 45 public static final String ERROR_MESSAGE_PROPERTY = "categoryErrorMessage"; 47 synchronized void addPropertyChangeListener( 48 PropertyChangeListener listener) { 49 if (listener == null) { 50 return; 51 } 52 if (changeSupport == null) { 53 changeSupport = new PropertyChangeSupport (this); 54 } 55 changeSupport.addPropertyChangeListener(listener); 56 } 57 58 public synchronized void removePropertyChangeListener( 59 PropertyChangeListener listener) { 60 if (listener == null || changeSupport == null) { 61 return; 62 } 63 changeSupport.removePropertyChangeListener(listener); 64 } 65 66 67 public void firePropertyChange(String propertyName, 68 Object oldValue, Object newValue) { 69 if (changeSupport == null || 70 (oldValue != null && newValue != null && oldValue.equals(newValue))) { 71 return; 72 } 73 changeSupport.firePropertyChange(propertyName, oldValue, newValue); 74 } 75 76 } 77 | Popular Tags |