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