1 19 20 24 25 package org.netbeans.modules.j2ee.sun.ws7.serverresources.wizards; 26 27 import java.awt.Component ; 28 import java.util.Set ; 29 import javax.swing.JComponent ; 30 import java.io.InputStream ; 31 import javax.swing.event.ChangeEvent ; 32 import javax.swing.event.ChangeListener ; 33 34 import org.openide.util.NbBundle; 35 import org.openide.WizardDescriptor; 36 import org.netbeans.api.project.Project; 37 import org.openide.filesystems.FileObject; 38 import org.netbeans.spi.project.ui.templates.support.Templates; 39 import org.openide.WizardDescriptor; 40 41 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard; 42 43 import org.netbeans.modules.j2ee.sun.ws7.serverresources.beans.WS70ResourceUtils; 44 45 49 public class CustomResourceWizard extends AbstractResourceWizard{ 50 51 private static final String DATAFILE = "org/netbeans/modules/j2ee/sun/ws7/serverresources/wizards/CustomWizard.xml"; private Wizard wizardInfo; 53 private ResourceConfigHelper helper; 54 55 private transient WizardDescriptor wizard; 56 private transient String [] steps; 58 60 private static Project project; 61 62 63 public static CustomResourceWizard create(){ 64 return new CustomResourceWizard(); 65 } 66 public void initialize(WizardDescriptor wizard){ 67 wizardInfo = getWizardInfo(DATAFILE); 68 this.helper = new ResourceConfigHelperHolder().getCustomResourceHelper(); 69 70 this.wizard = wizard; 71 wizard.putProperty("NewFileWizard_Title", 72 NbBundle.getMessage(CustomResourceWizard.class, "Templates/SunWS70Resources/Custom_Resource")); index = 0; 74 75 project = Templates.getProject(wizard); 76 77 panels = createPanels(); 78 steps = createSteps(); 80 81 try{ 82 FileObject pkgLocation = project.getProjectDirectory(); 83 if (pkgLocation != null) { 84 this.helper.getData().setTargetFileObject(pkgLocation); 85 } 86 }catch (Exception ex){ 87 ex.printStackTrace(); 89 } 90 91 for (int i = 0; i < panels.length; i++) { 92 Component c = panels[i].getComponent(); 93 if (c instanceof JComponent ) { JComponent jc = (JComponent )c; 95 jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (i)); jc.putClientProperty("WizardPanel_contentData", steps); } 100 } 101 } 102 public Set instantiate(){ 103 try{ 104 WS70ResourceUtils.saveCustomResourceDatatoXml(this.helper.getData()); 105 }catch (Exception ex){ 106 System.out.println("Error in instantiate of CustomResourceWizard"); 107 } 108 return java.util.Collections.EMPTY_SET; 109 } 110 public void uninitialize(WizardDescriptor wizard){ 111 112 } 113 private Wizard getWizardInfo(){ 114 try{ 115 InputStream in = this.getClass().getClassLoader().getResourceAsStream(DATAFILE); 116 this.wizardInfo = Wizard.createGraph(in); 117 }catch(Exception ex){ 118 ex.printStackTrace(); 119 } 120 return this.wizardInfo; 121 } 122 123 124 public String name(){ 125 return NbBundle.getMessage(CustomResourceWizard.class, "Templates/SunWS70Resources/Custom_Resource"); } 127 private WizardDescriptor.Panel[] createPanels() { 128 return new WizardDescriptor.Panel[] { 129 new CommonGeneralFinishPanel(helper, wizardInfo, new String [] {"general"}), new CommonPropertyPanel(helper, wizardInfo) 131 }; 132 } 133 134 private String [] createSteps() { 135 return new String [] { 136 WS70WizardConstants.__FirstStepChoose, 137 NbBundle.getMessage(CustomResourceWizard.class, "TITLE_GeneralAttributes_CUSTOM"), NbBundle.getMessage(CustomResourceWizard.class, "TITLE_UserProps_CUSTOM") }; 140 } 141 } 142 | Popular Tags |