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 import org.netbeans.modules.j2ee.sun.ws7.serverresources.beans.WS70ResourceUtils; 42 43 47 public class JDBCResourceWizard extends AbstractResourceWizard{ 48 private static final String DATAFILE = "org/netbeans/modules/j2ee/sun/ws7/serverresources/wizards/JDBCWizard.xml"; private Wizard wizardInfo; 50 private ResourceConfigHelper helper; 51 52 private transient WizardDescriptor wizard; 53 private transient String [] steps; 54 private static Project project; 55 56 public static JDBCResourceWizard create(){ 57 return new JDBCResourceWizard(); 58 } 59 public void initialize(WizardDescriptor wizard){ 60 wizardInfo = getWizardInfo(DATAFILE); 61 this.helper = new ResourceConfigHelperHolder().getJDBCHelper(); 62 63 this.wizard = wizard; 64 wizard.putProperty("NewFileWizard_Title", 65 NbBundle.getMessage(JDBCResourceWizard.class, "Templates/SunWS70Resources/JDBC_Resource")); index = 0; 67 68 project = Templates.getProject(wizard); 69 70 panels = createPanels(); 71 steps = createSteps(); 73 74 try{ 75 FileObject pkgLocation = project.getProjectDirectory(); 76 if (pkgLocation != null) { 77 this.helper.getData().setTargetFileObject(pkgLocation); 78 } 79 }catch (Exception ex){ 80 } 82 83 for (int i = 0; i < panels.length; i++) { 84 Component c = panels[i].getComponent(); 85 if (c instanceof JComponent ) { JComponent jc = (JComponent )c; 87 jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer (i)); jc.putClientProperty("WizardPanel_contentData", steps); } 92 } 93 } 94 public Set instantiate(){ 95 try{ 96 WS70ResourceUtils.saveJDBCResourceDatatoXml(this.helper.getData()); 97 }catch (Exception ex){ 98 ex.printStackTrace(); 99 } 100 return java.util.Collections.EMPTY_SET; 101 102 } 103 public void uninitialize(WizardDescriptor wizard){ 104 105 } 106 private Wizard getWizardInfo(){ 107 try{ 108 InputStream in = this.getClass().getClassLoader().getResourceAsStream(DATAFILE); 109 this.wizardInfo = Wizard.createGraph(in); 110 }catch(Exception ex){ 111 ex.printStackTrace(); 112 } 113 return this.wizardInfo; 114 } 115 116 117 public String name(){ 118 return NbBundle.getMessage(JDBCResourceWizard.class, "Templates/SunWS70Resources/JDBC_Resource"); } 120 private WizardDescriptor.Panel[] createPanels() { 121 return new WizardDescriptor.Panel[] { 122 new CommonGeneralFinishPanel(helper, wizardInfo, new String [] {"general", "connection-setting"}), new CommonPropertyPanel(helper, wizardInfo) 124 125 }; 126 } 127 128 private String [] createSteps() { 129 return new String [] { 130 WS70WizardConstants.__FirstStepChoose, 131 NbBundle.getMessage(JDBCResourceWizard.class, "TITLE_GeneralAttributes_JDBC"), NbBundle.getMessage(JDBCResourceWizard.class, "TITLE_UserProps_JDBC") }; 134 } 135 } 136 | Popular Tags |