1 19 20 package org.netbeans.modules.properties; 21 22 import java.io.Serializable ; 23 import javax.swing.event.EventListenerList ; 24 25 30 public class PropertyBundleSupport implements Serializable { 31 32 33 static final long serialVersionUID = -655481419012858008L; 34 35 36 protected EventListenerList listenerList = new EventListenerList (); 37 38 43 private Object source; 44 45 52 public PropertyBundleSupport(Object source) { 53 if (source == null) { 54 throw new NullPointerException (); 55 } 56 this.source = source; 57 } 58 59 68 public void addPropertyBundleListener(PropertyBundleListener l) { 69 listenerList.add(PropertyBundleListener.class, l); 70 } 71 72 81 public void removePropertyBundleListener(PropertyBundleListener l) { 82 listenerList.remove(PropertyBundleListener.class, l); 83 } 84 85 92 public void fireBundleStructureChanged() { 93 fireBundleChanged(new PropertyBundleEvent( 94 source, 95 PropertyBundleEvent.CHANGE_STRUCT)); 96 } 97 98 105 public void fireBundleDataChanged() { 106 fireBundleChanged(new PropertyBundleEvent( 107 source, 108 PropertyBundleEvent.CHANGE_ALL)); 109 } 110 111 119 public void fireFileChanged(String entryName) { 120 fireBundleChanged(new PropertyBundleEvent(source, entryName)); 121 } 122 123 132 public void fireItemChanged(String entryName, String itemName) { 133 fireBundleChanged(new PropertyBundleEvent(source, entryName, itemName)); 134 } 135 136 144 public void fireBundleChanged(PropertyBundleEvent e) { 145 Object [] listeners = listenerList.getListenerList(); 148 for (int i = listeners.length - 2; i >= 0; i -= 2) { 151 if (listeners[i] == PropertyBundleListener.class) { 152 ((PropertyBundleListener) listeners[i + 1]).bundleChanged(e); 153 } 154 } 155 } 156 157 } | Popular Tags |