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 TagHandlerSelection implements WizardDescriptor.Panel { 47 48 52 private transient TagHandlerPanel component; 53 private transient TemplateWizard wizard; 54 private transient String j2eeVersion; 55 56 57 public TagHandlerSelection(TemplateWizard wizard) { 58 this.wizard=wizard; 59 } 60 61 public Component getComponent() { 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 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 if (component == null) { 78 component = new TagHandlerPanel(this,j2eeVersion); 79 } 80 return component; 81 } 82 83 public HelpCtx getHelp() { 84 return null; 85 } 87 88 public boolean isValid() { 89 if (!isBodyTagSupport() && WebModule.J2EE_13_LEVEL.equals(j2eeVersion)) { 91 wizard.putProperty("WizardPanel_errorMessage", org.openide.util.NbBundle.getMessage(TagHandlerSelection.class, "NOTE_simpleTag")); 93 } else { 94 wizard.putProperty("WizardPanel_errorMessage", ""); } 96 return true; 97 } 103 104 107 private final Set listeners = new HashSet (1); public final void addChangeListener (ChangeListener l) { 109 synchronized (listeners) { 110 listeners.add (l); 111 } 112 } 113 public final void removeChangeListener (ChangeListener l) { 114 synchronized (listeners) { 115 listeners.remove (l); 116 } 117 } 118 protected final void fireChangeEvent () { 119 Iterator it; 120 synchronized (listeners) { 121 it = new HashSet (listeners).iterator (); 122 } 123 ChangeEvent ev = new ChangeEvent (this); 124 while (it.hasNext ()) { 125 ((ChangeListener ) it.next ()).stateChanged (ev); 126 } 127 } 128 129 130 public void readSettings(Object settings) { 135 } 136 public void storeSettings(Object settings) { 137 WizardDescriptor w = (WizardDescriptor)settings; 138 if (isBodyTagSupport()) 139 w.putProperty("BODY_SUPPORT",Boolean.TRUE); else 141 w.putProperty("BODY_SUPPORT",Boolean.FALSE); } 143 144 boolean isBodyTagSupport() {return component.isBodyTagSupport();} 145 146 } 147 | Popular Tags |