1 19 package org.openide.options; 20 21 import java.beans.PropertyChangeEvent ; 22 import java.beans.PropertyVetoException ; 23 import java.beans.VetoableChangeListener ; 24 25 import java.util.*; 26 27 28 34 public abstract class VetoSystemOption extends SystemOption { 35 36 static final long serialVersionUID = -614731095908156413L; 37 38 39 private static final String PROP_VETO_SUPPORT = "vetoSupport"; 41 42 public VetoSystemOption() { 43 } 44 45 48 private HashSet getVeto() { 49 HashSet set = (HashSet) getProperty(PROP_VETO_SUPPORT); 50 51 if (set == null) { 52 set = new HashSet(); 53 putProperty(PROP_VETO_SUPPORT, set); 54 } 55 56 return set; 57 } 58 59 62 public final void addVetoableChangeListener(VetoableChangeListener list) { 63 synchronized (getLock()) { 64 getVeto().add(list); 65 } 66 } 67 68 71 public final void removeVetoableChangeListener(VetoableChangeListener list) { 72 synchronized (getLock()) { 73 getVeto().remove(list); 74 } 75 } 76 77 83 public final void fireVetoableChange(String name, Object oldValue, Object newValue) 84 throws PropertyVetoException { 85 PropertyChangeEvent ev = new PropertyChangeEvent (this, name, oldValue, newValue); 86 87 Iterator en; 88 89 synchronized (getLock()) { 90 en = ((HashSet) getVeto().clone()).iterator(); 91 } 92 93 while (en.hasNext()) { 94 ((VetoableChangeListener ) en.next()).vetoableChange(ev); 95 } 96 } 97 } 98 | Popular Tags |