1 19 20 package org.netbeans.modules.web.jsf.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.netbeans.api.project.Project; 30 31 import org.openide.WizardDescriptor; 32 import org.openide.util.HelpCtx; 33 34 38 final class ManagedBeanPanel implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel { 39 40 private WizardDescriptor wizardDescriptor; 41 private ManagedBeanPanelVisual component; 42 43 private Project project; 44 45 public ManagedBeanPanel(Project project, WizardDescriptor wizardDescriptor) { 46 this.project = project; 47 this.wizardDescriptor = wizardDescriptor; 48 } 49 50 public boolean isFinishPanel() { 51 return true; 52 } 53 54 public Component getComponent() { 55 if (component == null) 56 component = new ManagedBeanPanelVisual(project); 57 58 return component; 59 } 60 61 public HelpCtx getHelp() { 62 return new HelpCtx(ManagedBeanPanel.class); 63 } 64 65 public boolean isValid() { 66 getComponent(); 67 return component.valid(wizardDescriptor); 68 } 69 70 private final Set listeners = new HashSet (1); 71 72 public final void addChangeListener(ChangeListener l) { 73 synchronized (listeners) { 74 listeners.add(l); 75 } 76 } 77 public final void removeChangeListener(ChangeListener l) { 78 synchronized (listeners) { 79 listeners.remove(l); 80 } 81 } 82 protected final void fireChangeEvent() { 83 Iterator it; 84 synchronized (listeners) { 85 it = new HashSet (listeners).iterator(); 86 } 87 ChangeEvent ev = new ChangeEvent (this); 88 while (it.hasNext()) { 89 ((ChangeListener )it.next()).stateChanged(ev); 90 } 91 } 92 93 public void readSettings(Object settings) { 94 wizardDescriptor = (WizardDescriptor) settings; 95 component.read(wizardDescriptor); 96 97 Object substitute = ((JComponent ) component).getClientProperty("NewProjectWizard_Title"); if (substitute != null) 101 wizardDescriptor.putProperty("NewProjectWizard_Title", substitute); } 103 104 public void storeSettings(Object settings) { 105 WizardDescriptor d = (WizardDescriptor) settings; 106 component.store(d); 107 108 ((WizardDescriptor) d).putProperty("NewProjectWizard_Title", null); } 110 111 } 112 | Popular Tags |