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