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