1 14 package org.wings.plaf; 15 16 import java.beans.PropertyChangeListener ; 17 import java.beans.PropertyChangeSupport ; 18 import java.util.HashMap ; 19 20 24 public class CGDefaults 25 extends HashMap { 26 private PropertyChangeSupport changeSupport; 27 private CGDefaults parent; 28 29 32 public CGDefaults(CGDefaults parent) { 33 this.parent = parent; 34 } 35 36 48 public Object put(Object key, Object value) { 49 Object oldValue = (value == null) ? super.remove(key) : super.put(key, value); 50 if (key instanceof String ) { 51 firePropertyChange((String ) key, oldValue, value); 52 } 53 return oldValue; 54 } 55 56 65 public Object get(Object key, Class type) { 66 Object value = super.get(key); 67 if (value != null) 68 return value; 69 70 if (parent != null) { 71 return parent.get(key, type); 72 } 73 return null; 74 } 75 76 77 87 public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { 88 if (changeSupport == null) { 89 changeSupport = new PropertyChangeSupport (this); 90 } 91 changeSupport.addPropertyChangeListener(listener); 92 } 93 94 95 103 public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { 104 if (changeSupport != null) { 105 changeSupport.removePropertyChangeListener(listener); 106 } 107 } 108 109 110 120 protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 121 if (changeSupport != null) { 122 changeSupport.firePropertyChange(propertyName, oldValue, newValue); 123 } 124 } 125 } 126 127 128 | Popular Tags |