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