1 19 20 package org.netbeans.modules.web.jsf.wizards; 21 22 import javax.swing.event.DocumentListener ; 23 import org.openide.WizardDescriptor; 24 import org.openide.WizardValidationException; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.NbBundle; 27 28 32 public class JSFConfigurationPanelVisual extends javax.swing.JPanel implements HelpCtx.Provider, DocumentListener { 33 34 private JSFConfigurationPanel panel; 35 36 public JSFConfigurationPanelVisual(JSFConfigurationPanel panel, boolean customizer) { 37 initComponents(); 38 this.panel = panel; 39 tURLPattern.getDocument().addDocumentListener(this); 40 cbPackageJars.setVisible(false); 41 if (customizer){ 42 enableComponents(false); 43 } 44 } 45 46 51 private void initComponents() { 53 java.awt.GridBagConstraints gridBagConstraints; 54 55 lServletName = new javax.swing.JLabel (); 56 tServletName = new javax.swing.JTextField (); 57 lURLPattern = new javax.swing.JLabel (); 58 tURLPattern = new javax.swing.JTextField (); 59 cbValidate = new javax.swing.JCheckBox (); 60 cbVerify = new javax.swing.JCheckBox (); 61 cbPackageJars = new javax.swing.JCheckBox (); 62 jPanel1 = new javax.swing.JPanel (); 63 64 setLayout(new java.awt.GridBagLayout ()); 65 66 lServletName.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_lServletName").charAt(0)); 67 lServletName.setLabelFor(tServletName); 68 lServletName.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_Servlet_Name")); 69 gridBagConstraints = new java.awt.GridBagConstraints (); 70 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 71 add(lServletName, gridBagConstraints); 72 73 tServletName.setEditable(false); 74 tServletName.setText("Faces Servlet"); 75 gridBagConstraints = new java.awt.GridBagConstraints (); 76 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 77 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 78 gridBagConstraints.weightx = 1.0; 79 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 0); 80 add(tServletName, gridBagConstraints); 81 tServletName.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_ServletName")); 82 83 lURLPattern.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_lURLPattern").charAt(0)); 84 lURLPattern.setLabelFor(tURLPattern); 85 lURLPattern.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "LBL_URL_Pattern")); 86 gridBagConstraints = new java.awt.GridBagConstraints (); 87 gridBagConstraints.gridx = 0; 88 gridBagConstraints.gridy = 1; 89 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 90 add(lURLPattern, gridBagConstraints); 91 92 tURLPattern.setText("/faces/*"); 93 gridBagConstraints = new java.awt.GridBagConstraints (); 94 gridBagConstraints.gridx = 1; 95 gridBagConstraints.gridy = 1; 96 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 97 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 98 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 0); 99 add(tURLPattern, gridBagConstraints); 100 tURLPattern.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_Mapping")); 101 102 cbValidate.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_cbValidate").charAt(0)); 103 cbValidate.setSelected(true); 104 cbValidate.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "CB_Validate_XML")); 105 cbValidate.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 106 cbValidate.setMargin(new java.awt.Insets (0, 0, 0, 0)); 107 gridBagConstraints = new java.awt.GridBagConstraints (); 108 gridBagConstraints.gridx = 0; 109 gridBagConstraints.gridy = 2; 110 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 111 gridBagConstraints.insets = new java.awt.Insets (12, 0, 5, 0); 112 add(cbValidate, gridBagConstraints); 113 cbValidate.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_ValidateXML")); 114 115 cbVerify.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/jsf/wizards/Bundle").getString("MNE_cbVerify").charAt(0)); 116 cbVerify.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "CB_Verify_Objects")); 117 cbVerify.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 118 cbVerify.setMargin(new java.awt.Insets (0, 0, 0, 0)); 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridx = 1; 121 gridBagConstraints.gridy = 2; 122 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 123 gridBagConstraints.insets = new java.awt.Insets (12, 5, 5, 0); 124 add(cbVerify, gridBagConstraints); 125 cbVerify.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_VerifyObjects")); 126 127 cbPackageJars.setSelected(true); 128 cbPackageJars.setText(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "CB_Package_JARs")); 129 cbPackageJars.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 130 cbPackageJars.setMargin(new java.awt.Insets (0, 0, 0, 0)); 131 gridBagConstraints = new java.awt.GridBagConstraints (); 132 gridBagConstraints.gridx = 0; 133 gridBagConstraints.gridy = 3; 134 gridBagConstraints.gridwidth = 2; 135 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 136 add(cbPackageJars, gridBagConstraints); 137 cbPackageJars.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(JSFConfigurationPanelVisual.class, "ACSD_PackageJarToWar")); 138 139 jPanel1.setEnabled(false); 140 jPanel1.setFocusable(false); 141 jPanel1.setRequestFocusEnabled(false); 142 gridBagConstraints = new java.awt.GridBagConstraints (); 143 gridBagConstraints.gridx = 0; 144 gridBagConstraints.gridy = 4; 145 gridBagConstraints.gridwidth = 2; 146 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 147 gridBagConstraints.weighty = 1.0; 148 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 149 add(jPanel1, gridBagConstraints); 150 151 } 153 154 private javax.swing.JCheckBox cbPackageJars; 156 private javax.swing.JCheckBox cbValidate; 157 private javax.swing.JCheckBox cbVerify; 158 private javax.swing.JPanel jPanel1; 159 private javax.swing.JLabel lServletName; 160 private javax.swing.JLabel lURLPattern; 161 private javax.swing.JTextField tServletName; 162 private javax.swing.JTextField tURLPattern; 163 165 boolean valid(WizardDescriptor wizardDescriptor) { 166 String urlPattern = tURLPattern.getText(); 167 if (urlPattern == null || urlPattern.trim().equals("")){ 168 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JSFConfigurationPanelVisual.class, "MSG_URLPatternIsEmpty")); 170 return false; 171 } 172 if (!isPatternValid(urlPattern)){ 173 wizardDescriptor.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JSFConfigurationPanelVisual.class, "MSG_URLPatternIsNotValid")); 175 return false; 176 } 177 if(wizardDescriptor!=null) 178 wizardDescriptor.putProperty("WizardPanel_errorMessage", null); return true; 180 } 181 182 private boolean isPatternValid(String pattern){ 183 if (pattern.startsWith("*.")){ 184 String p = pattern.substring(2); 185 if (p.indexOf('.') == -1 && p.indexOf('*') == -1 186 && p.indexOf('/') == -1 && !p.trim().equals("")) 187 return true; 188 } 189 if (pattern.endsWith("/*") && pattern.startsWith("/")) 190 return true; 191 return false; 192 } 193 194 void validate (WizardDescriptor d) throws WizardValidationException { 195 } 197 198 void read (WizardDescriptor d) { 199 } 202 203 void store(WizardDescriptor d) { 204 } 207 208 211 public HelpCtx getHelpCtx() { 212 return new HelpCtx(JSFConfigurationPanelVisual.class); 213 } 214 215 public void removeUpdate(javax.swing.event.DocumentEvent e) { 216 panel.fireChangeEvent(); 217 } 218 219 public void insertUpdate(javax.swing.event.DocumentEvent e) { 220 panel.fireChangeEvent(); 221 } 222 223 public void changedUpdate(javax.swing.event.DocumentEvent e) { 224 panel.fireChangeEvent(); 225 } 226 227 public String getServletName(){ 228 return tServletName.getText(); 229 } 230 231 public void setServletName(String name){ 232 tServletName.setText(name); 233 } 234 235 public String getURLPattern(){ 236 return tURLPattern.getText(); 237 } 238 239 public void setURLPattern(String pattern){ 240 tURLPattern.setText(pattern); 241 } 242 243 public boolean validateXML(){ 244 return cbValidate.isSelected(); 245 } 246 247 public void setValidateXML(boolean ver){ 248 cbValidate.setSelected(ver); 249 } 250 251 public boolean verifyObjects(){ 252 return cbVerify.isSelected(); 253 } 254 255 public void setVerifyObjects(boolean val){ 256 cbVerify.setSelected(val); 257 } 258 259 public boolean packageJars(){ 260 return cbPackageJars.isSelected(); 261 } 262 263 public void enableComponents(boolean enable){ 264 cbPackageJars.setEnabled(enable); 265 cbValidate.setEnabled(enable); 266 cbVerify.setEnabled(enable); 267 lServletName.setEnabled(enable); 268 lURLPattern.setEnabled(enable); 269 tServletName.setEnabled(enable); 270 tURLPattern.setEnabled(enable); 271 } 272 } 273 | Popular Tags |