1 19 20 package org.netbeans.modules.j2ee.ejbcore.ejb.wizard.dd; 21 22 import java.awt.Component ; 23 import java.beans.PropertyChangeEvent ; 24 import java.beans.PropertyChangeListener ; 25 import java.util.HashSet ; 26 import java.util.Iterator ; 27 import java.util.Set ; 28 import javax.swing.event.ChangeEvent ; 29 import javax.swing.event.ChangeListener ; 30 import org.netbeans.api.project.Project; 31 import org.netbeans.spi.project.ui.templates.support.Templates; 32 import org.openide.WizardDescriptor; 33 import org.openide.filesystems.FileObject; 34 import org.openide.util.HelpCtx; 35 import org.openide.util.NbBundle; 36 37 41 public class EjbJarXmlWizardPanel1 implements WizardDescriptor.Panel { 42 43 45 49 private final Set <ChangeListener > listeners = new HashSet <ChangeListener >(1); 50 private final EjbJarXmlVisualPanel1 component = new EjbJarXmlVisualPanel1(); 51 private WizardDescriptor wizardDescriptor; 52 private Project project; 53 54 public EjbJarXmlWizardPanel1() { 55 component.addPropertyChangeListener(new PropertyChangeListener () { 56 public void propertyChange(PropertyChangeEvent evt) { 57 fireChangeEvent(); 58 } 59 }); 60 } 61 62 FileObject getSelectedLocation() { 63 return component.getSelectedLocation(); 64 } 65 66 Project getProject() { 67 return project; 68 } 69 70 public Component getComponent() { 71 return component; 72 } 73 74 public HelpCtx getHelp() { 75 return HelpCtx.DEFAULT_HELP; 76 } 77 78 public boolean isValid() { 79 if (component.getSelectedLocation() == null) { 80 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(EjbJarXmlWizardPanel1.class,"ERR_FileExistsOrNoValidLocation")); return false; 82 } 83 return true; 84 } 85 86 public final void addChangeListener(ChangeListener listener) { 87 synchronized (listeners) { 88 listeners.add(listener); 89 } 90 } 91 92 public final void removeChangeListener(ChangeListener listener) { 93 synchronized (listeners) { 94 listeners.remove(listener); 95 } 96 } 97 98 protected final void fireChangeEvent() { 99 Iterator <ChangeListener > listenersIterator; 100 synchronized (listeners) { 101 listenersIterator = new HashSet <ChangeListener >(listeners).iterator(); 102 } 103 ChangeEvent changeEvent = new ChangeEvent (this); 104 while (listenersIterator.hasNext()) { 105 listenersIterator.next().stateChanged(changeEvent); 106 } 107 } 108 109 public void readSettings(Object settings) { 110 wizardDescriptor = (WizardDescriptor) settings; 111 if (project == null) { 112 project = Templates.getProject(wizardDescriptor); 113 component.setProject(project); 114 } 115 } 116 117 public void storeSettings(Object settings) {} 118 119 } 120 121 | Popular Tags |