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 PanelSupportedFrameworks implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel, WizardDescriptor.ValidatingPanel { 40 41 private WizardDescriptor wizardDescriptor; 42 private PanelSupportedFrameworksVisual component; 43 44 45 public PanelSupportedFrameworks() { 46 } 47 48 public boolean isFinishPanel() { 49 return true; 50 } 51 52 public Component getComponent() { 53 if (component == null) 54 component = new PanelSupportedFrameworksVisual(this, null, PanelSupportedFrameworksVisual.ALL_FRAMEWORKS, null); 55 56 return component; 57 } 58 59 public HelpCtx getHelp() { 60 HelpCtx helpCtx = null; 61 if (component != null && (helpCtx = component.getHelpCtx())!=null) 62 return helpCtx; 63 return new HelpCtx(PanelSupportedFrameworks.class); 64 } 65 66 public boolean isValid() { 67 getComponent(); 68 return component.valid(wizardDescriptor); 69 } 70 71 private final Set listeners = new HashSet (1); 72 73 public void addChangeListener(ChangeListener l) { 74 synchronized (listeners) { 75 listeners.add(l); 76 } 77 } 78 public void removeChangeListener(ChangeListener l) { 79 synchronized (listeners) { 80 listeners.remove(l); 81 } 82 } 83 protected void fireChangeEvent() { 84 Iterator it; 85 synchronized (listeners) { 86 it = new HashSet (listeners).iterator(); 87 } 88 ChangeEvent ev = new ChangeEvent (this); 89 while (it.hasNext()) { 90 ((ChangeListener )it.next()).stateChanged(ev); 91 } 92 } 93 94 public void readSettings(Object settings) { 95 wizardDescriptor = (WizardDescriptor) settings; 96 component.read (wizardDescriptor); 97 98 Object substitute = ((JComponent ) component).getClientProperty("NewProjectWizard_Title"); if (substitute != null) 102 wizardDescriptor.putProperty("NewProjectWizard_Title", substitute); } 104 105 public void storeSettings(Object settings) { 106 WizardDescriptor d = (WizardDescriptor) settings; 107 component.store(d); 108 ((WizardDescriptor) d).putProperty("NewProjectWizard_Title", null); } 110 111 public void validate() throws WizardValidationException { 112 getComponent (); 113 component.validate (wizardDescriptor); 114 } 115 } 116 | Popular Tags |