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