1 19 20 package org.netbeans.modules.j2ee.ejbcore.ejb.wizard.mdb; 21 22 import java.util.ArrayList ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import javax.swing.event.ChangeEvent ; 27 import javax.swing.event.ChangeListener ; 28 import org.netbeans.api.project.Project; 29 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 30 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider; 31 import org.netbeans.spi.project.ui.templates.support.Templates; 32 import org.openide.WizardDescriptor; 33 import org.openide.util.HelpCtx; 34 import org.openide.util.NbBundle; 35 36 public class MessageEJBWizardPanel implements WizardDescriptor.FinishablePanel { 37 38 private MessageEJBVisualPanel wizardPanel; 39 private final List <ChangeListener > changeListeners = new ArrayList <ChangeListener >(); 40 private final WizardDescriptor wizardDescriptor; 41 44 public MessageEJBWizardPanel(WizardDescriptor wizardDescriptor) { 45 this.wizardDescriptor = wizardDescriptor; 46 } 47 48 public void addChangeListener(ChangeListener changeListener) { 49 changeListeners.add(changeListener); 50 } 51 52 public boolean isValid() { 53 Project project = Templates.getProject(wizardDescriptor); 54 J2eeModuleProvider j2eeModuleProvider = (J2eeModuleProvider) project.getLookup ().lookup (J2eeModuleProvider.class); 55 String j2eeVersion = j2eeModuleProvider.getJ2eeModule().getModuleVersion(); 56 if (!EjbJar.VERSION_3_0.equals(j2eeVersion) && !EjbJar.VERSION_2_1.equals(j2eeVersion)) { 57 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(MessageEJBWizardPanel.class,"MSG_WrongJ2EESpecVersion")); return false; 59 } 60 61 76 return true; 81 } 82 83 public void readSettings(Object settings) { 84 } 85 86 public void removeChangeListener(ChangeListener changeListener) { 87 changeListeners.remove(changeListener); 88 } 89 90 public void storeSettings(Object settings) { 91 92 } 93 94 public boolean isFinishPanel() { 95 return isValid(); 96 } 97 98 protected final void fireChangeEvent() { 99 Iterator <ChangeListener > iterator; 100 synchronized (changeListeners) { 101 iterator = new HashSet <ChangeListener >(changeListeners).iterator(); 102 } 103 ChangeEvent changeEvent = new ChangeEvent (this); 104 while (iterator.hasNext()) { 105 iterator.next().stateChanged(changeEvent); 106 } 107 } 108 109 public org.openide.util.HelpCtx getHelp() { 110 return new HelpCtx(this.getClass()); 111 } 112 113 public java.awt.Component getComponent() { 114 if (wizardPanel == null) { 115 wizardPanel = new MessageEJBVisualPanel(); 116 } 118 return wizardPanel; 119 } 120 121 public boolean isQueue() { 122 return wizardPanel.isQueue(); 123 } 124 125 } 126 127 | Popular Tags |