1 6 7 package org.netbeans.modules.web.examples; 8 9 import java.io.File ; 10 import java.util.HashSet ; 11 import java.util.NoSuchElementException ; 12 import java.util.Set ; 13 import javax.swing.JComponent ; 14 import org.openide.WizardDescriptor; 15 import org.openide.filesystems.FileObject; 16 import org.openide.loaders.DataObject; 17 import org.openide.loaders.TemplateWizard; 18 import org.openide.util.NbBundle; 19 20 24 public class WebSampleProjectIterator implements TemplateWizard.Iterator { 25 26 private static final long serialVersionUID = 4L; 27 28 int currentIndex; 29 PanelConfigureProject basicPanel; 30 private transient WizardDescriptor wiz; 31 32 static Object create() { 33 return new WebSampleProjectIterator(); 34 } 35 36 public WebSampleProjectIterator () { 37 } 38 39 public void addChangeListener (javax.swing.event.ChangeListener changeListener) { 40 } 41 42 public void removeChangeListener (javax.swing.event.ChangeListener changeListener) { 43 } 44 45 public org.openide.WizardDescriptor.Panel current () { 46 return basicPanel; 47 } 48 49 public boolean hasNext () { 50 return false; 51 } 52 53 public boolean hasPrevious () { 54 return false; 55 } 56 57 public void initialize (org.openide.loaders.TemplateWizard templateWizard) { 58 this.wiz = templateWizard; 59 String name = templateWizard.getTemplate().getNodeDelegate().getDisplayName(); 60 if (name != null) { 61 name = name.replaceAll(" ", ""); } 63 templateWizard.putProperty (WizardProperties.NAME, name); 64 basicPanel = new PanelConfigureProject(); 65 currentIndex = 0; 66 updateStepsList (); 67 } 68 69 public void uninitialize (org.openide.loaders.TemplateWizard templateWizard) { 70 basicPanel = null; 71 this.wiz.putProperty(WizardProperties.PROJECT_DIR,null); 72 this.wiz.putProperty(WizardProperties.NAME,null); 73 currentIndex = -1; 74 } 75 76 public java.util.Set instantiate (org.openide.loaders.TemplateWizard templateWizard) throws java.io.IOException { 77 File projectLocation = (File ) wiz.getProperty(WizardProperties.PROJECT_DIR); 78 String name = (String ) wiz.getProperty(WizardProperties.NAME); 79 80 FileObject prjLoc = null; 81 prjLoc = WebSampleProjectGenerator.createProjectFromTemplate(templateWizard.getTemplate().getPrimaryFile(), projectLocation, name); 82 83 FileObject webRoot = prjLoc.getFileObject("web"); FileObject index = getIndexFile(webRoot); 85 86 Set hset = new HashSet (); 87 hset.add(DataObject.find(prjLoc)); 88 hset.add(DataObject.find(index)); 89 90 return hset; 91 } 92 93 public String name() { 94 return current().getComponent().getName(); 95 } 96 97 public void nextPanel() { 98 throw new NoSuchElementException (); 99 } 100 101 public void previousPanel() { 102 throw new NoSuchElementException (); 103 } 104 105 void updateStepsList() { 106 JComponent component = (JComponent ) current ().getComponent (); 107 if (component == null) { 108 return; 109 } 110 String [] list; 111 list = new String [] { 112 NbBundle.getMessage(PanelConfigureProject.class, "LBL_NWP1_ProjectTitleName"), }; 114 component.putClientProperty ("WizardPanel_contentData", list); component.putClientProperty ("WizardPanel_contentSelectedIndex", new Integer (currentIndex)); } 117 118 private FileObject getIndexFile(FileObject webRoot) { 119 FileObject file = null; 120 file = webRoot.getFileObject("index", "jsp"); 121 if (file == null) { 122 file = webRoot.getFileObject("index", "html"); 123 } 124 return file; 125 } 126 127 128 } 129 | Popular Tags |