1 19 20 package org.netbeans.modules.web.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.event.ChangeEvent ; 27 import javax.swing.event.ChangeListener ; 28 import org.netbeans.api.project.ProjectUtils; 29 30 import org.openide.WizardDescriptor; 31 import org.openide.util.HelpCtx; 32 import org.openide.loaders.TemplateWizard; 33 34 import org.netbeans.api.project.Project; 35 import org.netbeans.api.project.Sources; 36 import org.netbeans.api.project.SourceGroup; 37 import org.netbeans.api.java.project.JavaProjectConstants; 38 import org.netbeans.spi.project.ui.templates.support.Templates; 39 import org.netbeans.modules.web.api.webmodule.WebModule; 40 41 46 public class ListenerPanel implements WizardDescriptor.Panel { 47 48 52 private ListenerVisualPanel component; 53 private transient TemplateWizard wizard; 54 55 56 public ListenerPanel(TemplateWizard wizard) { 57 this.wizard=wizard; 58 } 59 60 public Component getComponent() { 65 if (component == null) { 66 Project project = Templates.getProject( wizard ); 67 Sources sources = ProjectUtils.getSources(project); 68 SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); 69 WebModule wm=null; 70 String j2eeVersion = WebModule.J2EE_14_LEVEL; 71 if (groups!=null && groups.length>0) { 72 wm = WebModule.getWebModule(groups[0].getRootFolder());; 73 } 74 if (wm!=null) { 75 j2eeVersion=wm.getJ2eePlatformVersion(); 76 } 77 component = new ListenerVisualPanel(this,j2eeVersion); 78 } 79 return component; 80 } 81 82 public HelpCtx getHelp() { 83 return HelpCtx.DEFAULT_HELP; 85 } 86 97 public boolean isValid() { 98 if(isListenerSelected()) { 99 wizard.putProperty("WizardPanel_errorMessage", ""); return true; 101 } 102 wizard.putProperty("WizardPanel_errorMessage", org.openide.util.NbBundle.getMessage(ListenerPanel.class,"MSG_noListenerSelected")); 104 return false; 105 } 106 107 110 private final Set listeners = new HashSet (1); public final void addChangeListener (ChangeListener l) { 112 synchronized (listeners) { 113 listeners.add (l); 114 } 115 } 116 public final void removeChangeListener (ChangeListener l) { 117 synchronized (listeners) { 118 listeners.remove (l); 119 } 120 } 121 protected final void fireChangeEvent () { 122 Iterator it; 123 synchronized (listeners) { 124 it = new HashSet (listeners).iterator (); 125 } 126 ChangeEvent ev = new ChangeEvent (this); 127 while (it.hasNext ()) { 128 ((ChangeListener ) it.next ()).stateChanged (ev); 129 } 130 } 131 132 133 public void readSettings(Object settings) { 138 } 139 public void storeSettings(Object settings) { 140 } 141 boolean createElementInDD (){ 142 return component.createElementInDD(); 143 } 144 145 boolean isContextListener() {return component.isContextListener();} 146 147 boolean isContextAttrListener() {return component.isContextAttrListener();} 148 149 boolean isSessionListener() {return component.isSessionListener();} 150 151 boolean isSessionAttrListener() {return component.isSessionAttrListener();} 152 153 boolean isRequestListener() {return component.isRequestListener();} 154 155 boolean isRequestAttrListener() {return component.isRequestAttrListener();} 156 157 boolean isListenerSelected() { 158 return isContextListener() || isContextAttrListener() || 159 isSessionListener() || isSessionAttrListener() || 160 isRequestListener() || isRequestAttrListener(); 161 } 162 } 163 | Popular Tags |