1 19 20 package org.netbeans.modules.web.struts.wizards; 21 import javax.swing.event.ListDataEvent ; 22 import javax.swing.event.ListDataListener ; 23 import org.netbeans.api.project.Project; 24 import org.netbeans.modules.web.api.webmodule.WebModule; 25 import org.netbeans.modules.web.struts.StrutsConfigUtilities; 26 import org.openide.WizardDescriptor; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.NbBundle; 29 30 31 public class FormBeanNewPanelVisual extends javax.swing.JPanel implements HelpCtx.Provider, ListDataListener { 32 33 36 public FormBeanNewPanelVisual(Project proj) { 37 initComponents(); 38 39 jComboBoxSuperclass.getModel().addListDataListener(this); 40 WebModule wm = WebModule.getWebModule(proj.getProjectDirectory()); 41 if (wm!=null){ 42 String [] configFiles = StrutsConfigUtilities.getConfigFiles(wm.getDeploymentDescriptor()); 43 jComboBoxConfigFile.setModel(new javax.swing.DefaultComboBoxModel (configFiles)); 44 } 45 46 47 } 49 50 55 private void initComponents() { 57 java.awt.GridBagConstraints gridBagConstraints; 58 59 jLabelSuperclass = new javax.swing.JLabel (); 60 jComboBoxSuperclass = new javax.swing.JComboBox (); 61 jLabelConfigFile = new javax.swing.JLabel (); 62 jComboBoxConfigFile = new javax.swing.JComboBox (); 63 64 setLayout(new java.awt.GridBagLayout ()); 65 66 jLabelSuperclass.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_Superlass_mnem").charAt(0)); 67 jLabelSuperclass.setLabelFor(jComboBoxSuperclass); 68 jLabelSuperclass.setText(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_Superclass")); 69 gridBagConstraints = new java.awt.GridBagConstraints (); 70 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 71 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 12); 72 add(jLabelSuperclass, gridBagConstraints); 73 74 jComboBoxSuperclass.setEditable(true); 75 jComboBoxSuperclass.setModel(new javax.swing.DefaultComboBoxModel (new String [] { "org.apache.struts.action.ActionForm", "org.apache.struts.validator.ValidatorForm", "org.apache.struts.validator.ValidatorActionForm" })); 76 gridBagConstraints = new java.awt.GridBagConstraints (); 77 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 78 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 79 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 80 add(jComboBoxSuperclass, gridBagConstraints); 81 82 jLabelConfigFile.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_ConfigFile_mnem").charAt(0)); 83 jLabelConfigFile.setLabelFor(jComboBoxConfigFile); 84 jLabelConfigFile.setText(org.openide.util.NbBundle.getMessage(FormBeanNewPanelVisual.class, "LBL_ConfigFile")); 85 gridBagConstraints = new java.awt.GridBagConstraints (); 86 gridBagConstraints.gridx = 0; 87 gridBagConstraints.gridy = 1; 88 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 89 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 90 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 12); 91 add(jLabelConfigFile, gridBagConstraints); 92 93 gridBagConstraints = new java.awt.GridBagConstraints (); 94 gridBagConstraints.gridx = 1; 95 gridBagConstraints.gridy = 1; 96 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 97 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 98 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 99 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 100 gridBagConstraints.weightx = 1.0; 101 gridBagConstraints.weighty = 1.0; 102 add(jComboBoxConfigFile, gridBagConstraints); 103 jComboBoxConfigFile.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/wizards/Bundle").getString("ACSD_ConfiguratioFile")); 104 105 } 106 108 private javax.swing.JComboBox jComboBoxConfigFile; 110 private javax.swing.JComboBox jComboBoxSuperclass; 111 private javax.swing.JLabel jLabelConfigFile; 112 private javax.swing.JLabel jLabelSuperclass; 113 115 boolean valid(WizardDescriptor wizardDescriptor) { 116 String superclass = (String ) jComboBoxSuperclass.getEditor().getItem(); 117 String configFile = (String ) jComboBoxConfigFile.getSelectedItem(); 118 119 if (superclass == null || superclass.trim().equals("")){ 120 wizardDescriptor.putProperty("WizardPanel_errorMessage", 121 NbBundle.getMessage(FormBeanNewPanelVisual.class, "MSG_NoSuperClassSelected")); 122 } 123 if (configFile == null || configFile.trim().equals("")){ 124 wizardDescriptor.putProperty("WizardPanel_errorMessage", 126 NbBundle.getMessage(FormBeanNewPanelVisual.class, "MSG_NoConfFileSelectedForBean")); 127 } 128 return true; 129 } 130 131 void read(WizardDescriptor settings) { 132 } 133 134 void store(WizardDescriptor settings) { 135 settings.putProperty(WizardProperties.FORMBEAN_SUPERCLASS, jComboBoxSuperclass.getSelectedItem()); 136 settings.putProperty(WizardProperties.FORMBEAN_CONFIG_FILE, jComboBoxConfigFile.getSelectedItem()); 137 } 138 139 142 public HelpCtx getHelpCtx() { 143 return new HelpCtx(FormBeanNewPanelVisual.class); 144 } 145 146 public void intervalRemoved(ListDataEvent e) { 147 } 148 149 public void intervalAdded(ListDataEvent e) { 150 } 151 152 public void contentsChanged(ListDataEvent e) { 153 } 155 156 } 157 | Popular Tags |