1 19 20 package org.netbeans.modules.j2ee.ejbjarproject.ui.wizards; 21 22 import java.awt.Component ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 import javax.swing.JComponent ; 27 import javax.swing.event.ChangeEvent ; 28 import javax.swing.event.ChangeListener ; 29 import org.openide.WizardDescriptor; 30 import org.openide.WizardValidationException; 31 import org.openide.util.HelpCtx; 32 33 34 final class ImportLocation implements WizardDescriptor.Panel, WizardDescriptor.ValidatingPanel, WizardDescriptor.FinishablePanel, ChangeListener { 35 36 private WizardDescriptor wizardDescriptor; 37 private ImportLocationVisual component; 38 39 public ImportLocation() { 40 } 41 42 public Component getComponent() { 43 if (component == null) { 44 component = new ImportLocationVisual(this); 45 } 46 return component; 47 } 48 49 public HelpCtx getHelp() { 50 return new HelpCtx(ImportLocation.class); 51 } 52 53 public boolean isValid() { 54 getComponent(); 55 return component.valid( wizardDescriptor ); 56 } 57 58 private final Set listeners = new HashSet (1); 59 public final void addChangeListener(ChangeListener l) { 60 synchronized (listeners) { 61 listeners.add(l); 62 } 63 } 64 public final void removeChangeListener(ChangeListener l) { 65 synchronized (listeners) { 66 listeners.remove(l); 67 } 68 } 69 protected final void fireChangeEvent() { 70 Iterator it; 71 synchronized (listeners) { 72 it = new HashSet (listeners).iterator(); 73 } 74 ChangeEvent ev = new ChangeEvent (this); 75 while (it.hasNext()) { 76 ((ChangeListener )it.next()).stateChanged(ev); 77 } 78 } 79 80 public void readSettings(Object settings) { 81 wizardDescriptor = (WizardDescriptor) settings; 82 component.read (wizardDescriptor); 83 Object substitute = ((JComponent ) component).getClientProperty("NewProjectWizard_Title"); if (substitute != null) 87 wizardDescriptor.putProperty("NewProjectWizard_Title", substitute); } 89 90 public void storeSettings(Object settings) { 91 WizardDescriptor d = (WizardDescriptor)settings; 92 component.store(d); 93 } 94 95 public boolean isFinishPanel() { 96 return false; 97 } 98 99 public void validate() throws WizardValidationException { 100 } 101 102 public void stateChanged(ChangeEvent e) { 103 fireChangeEvent(); 104 } 105 } 106 107 108 | Popular Tags |