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