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