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 37 final class PersistenceClientSetupPanel implements WizardDescriptor.Panel, WizardDescriptor.FinishablePanel, ChangeListener { 38 39 private WizardDescriptor wizardDescriptor; 40 private PersistenceClientSetupPanelVisual component; 41 42 private Project project; 43 44 public PersistenceClientSetupPanel(Project project, WizardDescriptor wizardDescriptor) { 45 this.project = project; 46 this.wizardDescriptor = wizardDescriptor; 47 } 48 49 public boolean isFinishPanel() { 50 return true; 51 } 52 53 public Component getComponent() { 54 if (component == null) { 55 component = new PersistenceClientSetupPanelVisual(wizardDescriptor); 56 component.addChangeListener(this); 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 protected final void fireChangeEvent(ChangeEvent ev) { 112 Iterator it; 113 synchronized (listeners) { 114 it = new HashSet (listeners).iterator(); 115 } 116 while (it.hasNext()) { 117 ((ChangeListener )it.next()).stateChanged(ev); 118 } 119 } 120 121 public void stateChanged(ChangeEvent e) { 122 fireChangeEvent(e); 123 } 124 } 125 | Popular Tags |