1 19 20 package org.netbeans.modules.projectimport.j2seimport.ui; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.beans.PropertyChangeListener ; 24 import javax.swing.event.ChangeEvent ; 25 import javax.swing.event.ChangeListener ; 26 import javax.swing.event.EventListenerList ; 27 import org.openide.WizardDescriptor; 28 import org.openide.util.HelpCtx; 29 import org.openide.util.NbBundle; 30 31 34 public abstract class BasicWizardPanel implements WizardDescriptor.Panel, PropertyChangeListener { 35 36 private boolean valid = true; 37 private WizardDescriptor settings; 38 39 private EventListenerList listeners = new EventListenerList (); 40 41 protected BasicWizardPanel(WizardDescriptor settings) { 42 this.settings = settings; 43 } 44 45 public void setSettings(WizardDescriptor settings) { 46 this.settings = settings; 47 } 48 49 protected WizardDescriptor getSettings() { 50 return settings; 51 } 52 53 public void addChangeListener(ChangeListener l) { 54 listeners.add(ChangeListener .class, l); 55 } 56 57 public void removeChangeListener(ChangeListener l) { 58 listeners.remove(ChangeListener .class, l); 59 } 60 61 protected void fireChange() { 62 ChangeListener [] chListeners = (ChangeListener []) listeners. 63 getListeners(ChangeListener .class); 64 ChangeEvent e = new ChangeEvent (this); 65 for (int i = 0; i < chListeners.length; i++) { 66 chListeners[i].stateChanged(e); 67 } 68 } 69 70 public HelpCtx getHelp() { 71 return null; 72 } 73 74 public void storeSettings(Object settings) {} 75 76 public void readSettings(Object settings) {} 77 78 public boolean isValid() { 79 return valid; 80 } 81 82 87 public void propertyChange(PropertyChangeEvent evt) { 88 if ("valid".equals(evt.getPropertyName())) { boolean nueValid = ((Boolean ) evt.getNewValue()).booleanValue(); 90 if (nueValid != valid) { 91 valid = nueValid; 92 fireChange(); 93 } 94 } 95 } 96 } | Popular Tags |