1 19 20 package org.netbeans.modules.j2ee.ddloaders.web.multiview; 21 22 import javax.swing.JComboBox ; 23 import javax.swing.JLabel ; 24 import org.netbeans.modules.j2ee.dd.api.web.FilterMapping; 25 import org.netbeans.modules.j2ee.dd.api.web.Servlet; 26 import org.netbeans.modules.j2ee.dd.api.web.ServletMapping; 27 import org.netbeans.modules.j2ee.ddloaders.web.*; 28 import org.netbeans.modules.xml.multiview.ui.*; 29 import org.netbeans.modules.xml.multiview.Utils; 30 import org.netbeans.modules.xml.multiview.Error; 31 import org.netbeans.api.project.SourceGroup; 32 import org.netbeans.modules.j2ee.dd.api.common.RunAs; 33 import org.openide.util.NbBundle; 34 35 38 public class ServletPanel extends SectionInnerPanel implements java.awt.event.ActionListener { 39 private DDDataObject dObj; 40 private Servlet servlet; 41 private javax.swing.JButton linkServletClass, linkJspFile; 42 private InitParamsPanel initParamsPanel; 43 private JComboBox runAsCB; 44 45 46 public ServletPanel(SectionView sectionView, DDDataObject dObj,Servlet servlet) { 47 super(sectionView); 48 this.dObj=dObj; 49 this.servlet=servlet; 50 initComponents(); 51 servletNameTF.setText(servlet.getServletName()); 53 addValidatee(servletNameTF); 54 55 Utils.makeTextAreaLikeTextField(descriptionTA,servletNameTF); 57 descriptionTA.setText(servlet.getDefaultDescription()); 58 addModifier(descriptionTA); 59 60 java.math.BigInteger los = servlet.getLoadOnStartup(); 62 orderTF.setText(los==null?"":los.toString()); 63 addValidatee(orderTF); 64 65 String jspFile = servlet.getJspFile(); 67 if (jspFile!=null) { 68 jspFileRB.setSelected(true); 69 servletClassTF.setEnabled(false); 70 browseButton.setEnabled(false); 71 jspFileTF.setText(jspFile); 72 } else { 73 servletClassRB.setSelected(true); 74 jspFileTF.setEnabled(false); 75 browseButton1.setEnabled(false); 76 servletClassTF.setText(servlet.getServletClass()); 77 } 78 servletClassRB.addActionListener(this); 79 jspFileRB.addActionListener(this); 80 addValidatee(servletClassTF); 81 addValidatee(jspFileTF); 82 83 84 String [] urlPatterns = DDUtils.getUrlPatterns(dObj.getWebApp(),servlet); 86 servletMappingsTF.setText(DDUtils.urlPatternList(urlPatterns)); 87 addValidatee(servletMappingsTF); 88 89 InitParamTableModel model = new InitParamTableModel(); 91 initParamsPanel = new InitParamsPanel(dObj, model); 92 initParamsPanel.setModel(servlet,servlet.getInitParam()); 93 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 94 gridBagConstraints.gridx = 0; 95 gridBagConstraints.gridy = 7; 96 gridBagConstraints.gridwidth = 5; 97 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 98 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 99 gridBagConstraints.insets = new java.awt.Insets (2, 10, 0, 0); 100 add(initParamsPanel, gridBagConstraints); 103 104 JLabel securityRoleRefsLabel = new JLabel (); 105 securityRoleRefsLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_securityRoleRefs_mnem").charAt(0)); 106 securityRoleRefsLabel.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_SecurityRoleRefs")); 107 gridBagConstraints = new java.awt.GridBagConstraints (); 108 gridBagConstraints.gridx = 0; 109 gridBagConstraints.gridy = 8; 110 gridBagConstraints.gridwidth = 5; 111 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 112 gridBagConstraints.insets = new java.awt.Insets (15, 10, 0, 0); 113 add(securityRoleRefsLabel, gridBagConstraints); 114 115 SecurityRoleRefTableModel roleRefModel = new SecurityRoleRefTableModel(); 117 SecurityRoleRefTablePanel roleRefPanel = new SecurityRoleRefTablePanel(dObj, roleRefModel); 118 roleRefPanel.setModel(dObj.getWebApp(), servlet, servlet.getSecurityRoleRef()); 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridx = 0; 121 gridBagConstraints.gridy = 9; 122 gridBagConstraints.gridwidth = 5; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 124 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 125 gridBagConstraints.insets = new java.awt.Insets (2, 10, 0, 0); 126 add(roleRefPanel, gridBagConstraints); 127 128 RunAsPanel runAsPanel = new RunAsPanel(dObj.getWebApp()); 129 gridBagConstraints = new java.awt.GridBagConstraints (); 130 gridBagConstraints.gridx = 0; 131 gridBagConstraints.gridy = 10; 132 gridBagConstraints.gridwidth = 5; 133 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 134 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 135 gridBagConstraints.insets = new java.awt.Insets (2, 10, 0, 0); 136 add(runAsPanel, gridBagConstraints); 137 runAsCB = runAsPanel.getRunAsCB(); 138 139 RunAs runAs = servlet.getRunAs(); 140 if (runAs == null) { 141 runAsCB.setSelectedItem(""); } else { 143 runAsCB.setSelectedItem(runAs.getRoleName()); 144 } 145 addModifier(runAsCB); 146 147 linkServletClass = new LinkButton(this, servlet, "ClassName"); gridBagConstraints = new java.awt.GridBagConstraints (); 149 gridBagConstraints.gridx = 3; 150 gridBagConstraints.gridy = 2; 151 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 152 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 153 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 154 linkServletClass.setText(NbBundle.getMessage(ServletPanel.class, "LBL_goToSource")); 155 add(linkServletClass, gridBagConstraints); 156 157 linkJspFile = new LinkButton(this, servlet, "JspFile"); gridBagConstraints = new java.awt.GridBagConstraints (); 159 gridBagConstraints.gridx = 3; 160 gridBagConstraints.gridy = 3; 161 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 162 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 163 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 164 linkJspFile.setText(NbBundle.getMessage(ServletPanel.class, "LBL_goToSource")); 165 add(linkJspFile, gridBagConstraints); 166 167 setAccessibility(); 168 } 169 170 private void setAccessibility() { 171 linkServletClass.setMnemonic(NbBundle.getMessage(ServletPanel.class, "LBL_goToSource_mnem").charAt(0)); 172 linkJspFile.setMnemonic(NbBundle.getMessage(ServletPanel.class, "LBL_goToSource_mnem2").charAt(0)); 173 initParamsLabel.setLabelFor(initParamsPanel.getTable()); 174 } 175 176 public void linkButtonPressed(Object ddBean, String property) { 177 if ("ClassName".equals(property)) { DDUtils.openEditorFor(dObj,((Servlet)ddBean).getServletClass()); 179 } else if ("JspFile".equals(property)) { DDUtils.openEditorForSingleFile(dObj,((Servlet)ddBean).getJspFile()); 181 } 182 } 183 184 189 private void initComponents() { 191 java.awt.GridBagConstraints gridBagConstraints; 192 193 buttonGroup1 = new javax.swing.ButtonGroup (); 194 servletNameLabel = new javax.swing.JLabel (); 195 servletNameTF = new javax.swing.JTextField (); 196 orderLabel = new javax.swing.JLabel (); 197 orderTF = new javax.swing.JTextField (); 198 descriptionLabel = new javax.swing.JLabel (); 199 descriptionTA = new javax.swing.JTextArea (); 200 servletClassRB = new javax.swing.JRadioButton (); 201 servletClassTF = new javax.swing.JTextField (); 202 browseButton = new javax.swing.JButton (); 203 jspFileRB = new javax.swing.JRadioButton (); 204 jspFileTF = new javax.swing.JTextField (); 205 browseButton1 = new javax.swing.JButton (); 206 servletMappingLabel = new javax.swing.JLabel (); 207 servletMappingsTF = new javax.swing.JTextField (); 208 jLabel1 = new javax.swing.JLabel (); 209 initParamsLabel = new javax.swing.JLabel (); 210 filler = new javax.swing.JPanel (); 211 212 setLayout(new java.awt.GridBagLayout ()); 213 214 servletNameLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_servletName_mnem").charAt(0)); 215 servletNameLabel.setLabelFor(servletNameTF); 216 servletNameLabel.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_servletName")); 217 gridBagConstraints = new java.awt.GridBagConstraints (); 218 gridBagConstraints.gridx = 0; 219 gridBagConstraints.gridy = 0; 220 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 221 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 10); 222 add(servletNameLabel, gridBagConstraints); 223 224 servletNameTF.setColumns(20); 225 gridBagConstraints = new java.awt.GridBagConstraints (); 226 gridBagConstraints.gridx = 1; 227 gridBagConstraints.gridy = 0; 228 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 229 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 230 add(servletNameTF, gridBagConstraints); 231 232 orderLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_order_mnem").charAt(0)); 233 orderLabel.setLabelFor(orderTF); 234 orderLabel.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_order")); 235 gridBagConstraints = new java.awt.GridBagConstraints (); 236 gridBagConstraints.gridx = 3; 237 gridBagConstraints.gridy = 0; 238 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 239 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 10); 240 add(orderLabel, gridBagConstraints); 241 242 orderTF.setColumns(2); 243 gridBagConstraints = new java.awt.GridBagConstraints (); 244 gridBagConstraints.gridx = 4; 245 gridBagConstraints.gridy = 0; 246 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 247 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 248 add(orderTF, gridBagConstraints); 249 250 descriptionLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_description_mnem").charAt(0)); 251 descriptionLabel.setLabelFor(descriptionTA); 252 descriptionLabel.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_description")); 253 gridBagConstraints = new java.awt.GridBagConstraints (); 254 gridBagConstraints.gridx = 0; 255 gridBagConstraints.gridy = 1; 256 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 257 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 10); 258 add(descriptionLabel, gridBagConstraints); 259 260 descriptionTA.setRows(3); 261 gridBagConstraints = new java.awt.GridBagConstraints (); 262 gridBagConstraints.gridx = 1; 263 gridBagConstraints.gridy = 1; 264 gridBagConstraints.gridwidth = 4; 265 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 266 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 267 add(descriptionTA, gridBagConstraints); 268 269 buttonGroup1.add(servletClassRB); 270 servletClassRB.setMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_servletClass_mnem").charAt(0)); 271 servletClassRB.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_servletClass")); 272 servletClassRB.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); 273 servletClassRB.setOpaque(false); 274 gridBagConstraints = new java.awt.GridBagConstraints (); 275 gridBagConstraints.gridx = 0; 276 gridBagConstraints.gridy = 2; 277 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 278 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 10); 279 add(servletClassRB, gridBagConstraints); 280 281 gridBagConstraints = new java.awt.GridBagConstraints (); 282 gridBagConstraints.gridx = 1; 283 gridBagConstraints.gridy = 2; 284 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 285 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 286 add(servletClassTF, gridBagConstraints); 287 288 browseButton.setMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_browse_mnem").charAt(0)); 289 browseButton.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_browse")); 290 browseButton.setMargin(new java.awt.Insets (0, 14, 0, 14)); 291 browseButton.addActionListener(new java.awt.event.ActionListener () { 292 public void actionPerformed(java.awt.event.ActionEvent evt) { 293 browseButtonActionPerformed(evt); 294 } 295 }); 296 297 gridBagConstraints = new java.awt.GridBagConstraints (); 298 gridBagConstraints.gridx = 2; 299 gridBagConstraints.gridy = 2; 300 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 301 gridBagConstraints.insets = new java.awt.Insets (3, 10, 0, 0); 302 add(browseButton, gridBagConstraints); 303 304 buttonGroup1.add(jspFileRB); 305 jspFileRB.setMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_jspFile_mnem").charAt(0)); 306 jspFileRB.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_jspFile")); 307 jspFileRB.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); 308 jspFileRB.setOpaque(false); 309 gridBagConstraints = new java.awt.GridBagConstraints (); 310 gridBagConstraints.gridx = 0; 311 gridBagConstraints.gridy = 3; 312 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 313 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 10); 314 add(jspFileRB, gridBagConstraints); 315 316 gridBagConstraints = new java.awt.GridBagConstraints (); 317 gridBagConstraints.gridx = 1; 318 gridBagConstraints.gridy = 3; 319 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 320 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 321 add(jspFileTF, gridBagConstraints); 322 323 browseButton1.setMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_browse_mnem2").charAt(0)); 324 browseButton1.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_browse")); 325 browseButton1.setMargin(new java.awt.Insets (0, 14, 0, 14)); 326 browseButton1.addActionListener(new java.awt.event.ActionListener () { 327 public void actionPerformed(java.awt.event.ActionEvent evt) { 328 browseButton1ActionPerformed(evt); 329 } 330 }); 331 332 gridBagConstraints = new java.awt.GridBagConstraints (); 333 gridBagConstraints.gridx = 2; 334 gridBagConstraints.gridy = 3; 335 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 336 gridBagConstraints.insets = new java.awt.Insets (3, 10, 0, 0); 337 add(browseButton1, gridBagConstraints); 338 339 servletMappingLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_urlPatterns_mnem").charAt(0)); 340 servletMappingLabel.setLabelFor(servletMappingsTF); 341 servletMappingLabel.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_urlPatterns")); 342 gridBagConstraints = new java.awt.GridBagConstraints (); 343 gridBagConstraints.gridx = 0; 344 gridBagConstraints.gridy = 4; 345 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 346 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 10); 347 add(servletMappingLabel, gridBagConstraints); 348 349 servletMappingsTF.setColumns(30); 350 gridBagConstraints = new java.awt.GridBagConstraints (); 351 gridBagConstraints.gridx = 1; 352 gridBagConstraints.gridy = 4; 353 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 354 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 355 add(servletMappingsTF, gridBagConstraints); 356 357 jLabel1.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "HINT_urlPatterns")); 358 gridBagConstraints = new java.awt.GridBagConstraints (); 359 gridBagConstraints.gridx = 1; 360 gridBagConstraints.gridy = 5; 361 gridBagConstraints.gridwidth = 4; 362 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 363 add(jLabel1, gridBagConstraints); 364 365 initParamsLabel.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_initParams_mnem").charAt(0)); 366 initParamsLabel.setText(org.openide.util.NbBundle.getMessage(ServletPanel.class, "LBL_initParams")); 367 gridBagConstraints = new java.awt.GridBagConstraints (); 368 gridBagConstraints.gridx = 0; 369 gridBagConstraints.gridy = 6; 370 gridBagConstraints.gridwidth = 5; 371 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 372 gridBagConstraints.insets = new java.awt.Insets (15, 10, 0, 0); 373 add(initParamsLabel, gridBagConstraints); 374 375 filler.setBackground(new java.awt.Color (255, 255, 255)); 376 filler.setOpaque(false); 377 gridBagConstraints = new java.awt.GridBagConstraints (); 378 gridBagConstraints.gridx = 5; 379 gridBagConstraints.gridy = 0; 380 gridBagConstraints.gridheight = 6; 381 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 382 gridBagConstraints.weightx = 1.0; 383 add(filler, gridBagConstraints); 384 385 } 386 388 private void browseButton1ActionPerformed(java.awt.event.ActionEvent evt) { try { 391 org.netbeans.api.project.SourceGroup[] groups = DDUtils.getDocBaseGroups(dObj); 392 org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups); 393 if (fo!=null) { 394 String res = "/"+DDUtils.getResourcePath(groups,fo,'/',true); 395 if (!res.equals(jspFileTF.getText())) { 396 dObj.modelUpdatedFromUI(); 397 jspFileTF.setText(res); 398 dObj.setChangedFromUI(true); 399 servlet.setJspFile(res); 400 dObj.setChangedFromUI(false); 401 getSectionView().checkValidity(); 402 } 403 } 404 } catch (java.io.IOException ex) {} 405 } 407 private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) { try { 410 SourceGroup[] groups = DDUtils.getJavaSourceGroups(dObj); 411 org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups); 412 if (fo!=null) { 413 String className = DDUtils.getResourcePath(groups,fo); 414 if (className.length()>0 && !className.equals(servletClassTF.getText())) { 415 dObj.modelUpdatedFromUI(); 416 servletClassTF.setText(className); 417 dObj.setChangedFromUI(true); 418 servlet.setServletClass(className); 419 dObj.setChangedFromUI(false); 420 getSectionView().checkValidity(); 421 } 422 } 423 } catch (java.io.IOException ex) {} 424 } 426 427 private javax.swing.JButton browseButton; 429 private javax.swing.JButton browseButton1; 430 private javax.swing.ButtonGroup buttonGroup1; 431 private javax.swing.JLabel descriptionLabel; 432 private javax.swing.JTextArea descriptionTA; 433 private javax.swing.JPanel filler; 434 private javax.swing.JLabel initParamsLabel; 435 private javax.swing.JLabel jLabel1; 436 private javax.swing.JRadioButton jspFileRB; 437 private javax.swing.JTextField jspFileTF; 438 private javax.swing.JLabel orderLabel; 439 private javax.swing.JTextField orderTF; 440 private javax.swing.JRadioButton servletClassRB; 441 private javax.swing.JTextField servletClassTF; 442 private javax.swing.JLabel servletMappingLabel; 443 private javax.swing.JTextField servletMappingsTF; 444 private javax.swing.JLabel servletNameLabel; 445 private javax.swing.JTextField servletNameTF; 446 448 public void actionPerformed(java.awt.event.ActionEvent evt) { 449 if (servletClassRB.isSelected()) { 450 servletClassTF.setEnabled(true); 451 jspFileTF.setEnabled(false); 452 browseButton.setEnabled(true); 453 browseButton1.setEnabled(false); 454 String servletClass = servletClassTF.getText().trim(); 455 if (servletClass.length()>0 && !servletClass.equals(servlet.getServletClass())) { 456 dObj.modelUpdatedFromUI(); 457 dObj.setChangedFromUI(true); 458 servlet.setServletClass(servletClass); 459 dObj.setChangedFromUI(false); 460 getSectionView().checkValidity(); 461 } 462 } else { 463 servletClassTF.setEnabled(false); 464 jspFileTF.setEnabled(true); 465 browseButton.setEnabled(false); 466 browseButton1.setEnabled(true); 467 String jspFile = jspFileTF.getText().trim(); 468 if (jspFile.length()>0 && !jspFile.equals(servlet.getJspFile())) { 469 dObj.modelUpdatedFromUI(); 470 dObj.setChangedFromUI(true); 471 servlet.setJspFile(jspFile); 472 dObj.setChangedFromUI(false); 473 getSectionView().checkValidity(); 474 } 475 } 476 } 477 public javax.swing.JComponent getErrorComponent(String name) { 478 if ("ServletName".equals(name)) return servletNameTF; else if ("ServletClass".equals(name)) return servletClassTF; else if ("JspFile".equals(name)) return jspFileTF; else if ("ServletMapping".equals(name)) return servletMappingsTF; return null; 483 } 484 485 public void documentChanged(javax.swing.text.JTextComponent comp, String value) { 486 if (comp==servletNameTF) { 487 String val = (String )value; 488 if (val.length()==0) { 489 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "Servlet Name",servletNameTF)); 490 return; 491 } 492 Servlet[] servlets = dObj.getWebApp().getServlet(); 493 for (int i=0;i<servlets.length;i++) { 494 if (servlet!=servlets[i] && val.equals(servlets[i].getServletName())) { 495 getSectionView().getErrorPanel().setError(new Error (Error.TYPE_FATAL, Error.DUPLICATE_VALUE_MESSAGE, val, servletNameTF)); 496 return; 497 } 498 } 499 getSectionView().getErrorPanel().clearError(); 500 } else if (comp==servletClassTF) { 501 String text = (String )value; 502 if (text.length()==0) { 503 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "Servlet Class",servletClassTF)); 504 return; 505 } 506 getSectionView().getErrorPanel().clearError(); 507 } else if (comp==jspFileTF) { 508 String text = (String )value; 509 if (text.length()==0) { 510 getSectionView().getErrorPanel().setError(new Error (Error.MISSING_VALUE_MESSAGE, "Jsp File",jspFileTF)); 511 return; 512 } 513 getSectionView().getErrorPanel().clearError(); 514 } else if (comp==servletMappingsTF) { 515 String text = (String )value; 516 String [] patterns = DDUtils.getStringArray(text); 517 for (int i=0;i<patterns.length;i++) { 518 String errorMessage = DDUtils.checkServletMappig(patterns[i]); 519 if (errorMessage!=null) { 520 getSectionView().getErrorPanel().setError(new Error (Error.ERROR_MESSAGE, errorMessage, servletMappingsTF)); 521 return; 522 } 523 if (DDUtils.isServletMapping(dObj.getWebApp(),servlet,patterns[i])) { 524 getSectionView().getErrorPanel().setError(new Error (Error.DUPLICATE_VALUE_MESSAGE, patterns[i], servletMappingsTF)); 525 return; 526 } 527 } 528 getSectionView().getErrorPanel().clearError(); 529 } else if (comp==orderTF) { 530 String text = (String )value; 531 java.math.BigInteger los=null; 532 try { 533 los = new java.math.BigInteger (text); 534 } catch (NumberFormatException ex) {} 535 if (los==null) { 536 getSectionView().getErrorPanel().setError(new Error (Error.TYPE_FATAL, Error.ERROR_MESSAGE, "Invalid Value : "+text, orderTF)); 537 return; 538 } 539 getSectionView().getErrorPanel().clearError(); 540 } 541 } 542 543 public void setValue(javax.swing.JComponent source, Object value) { 544 if (source==servletNameTF) { 545 String text = (String )value; 546 ServletMapping[] maps = DDUtils.getServletMappings(dObj.getWebApp(), servlet); 548 for (int i=0;i<maps.length;i++) { 549 maps[i].setServletName(text); 550 } 551 FilterMapping[] filterMappings = DDUtils.getFilterMappings(dObj.getWebApp(), servlet); 553 for (int i = 0; i < filterMappings.length; i++) { 554 filterMappings[i].setServletName(text); 555 } 556 servlet.setServletName(text); 558 SectionPanel enclosingPanel = getSectionView().findSectionPanel(servlet); 560 enclosingPanel.setTitle(((ServletsMultiViewElement.ServletsView)getSectionView()).getServletTitle(servlet)); 561 enclosingPanel.getNode().setDisplayName(text); 562 } else if (source==servletClassTF) { 563 String text = (String )value; 564 servlet.setServletClass(text.length()==0?null:text); 565 } else if (source==jspFileTF) { 566 String text = (String )value; 567 servlet.setJspFile(text.length()==0?null:text); 568 } else if (source==descriptionTA) { 569 String text = (String )value; 570 servlet.setDescription(text.length()==0?null:text); 571 } else if (source==servletMappingsTF) { 572 DDUtils.setServletMappings(dObj.getWebApp(),servlet,DDUtils.getStringArray((String )value)); 573 SectionPanel enclosingPanel = getSectionView().findSectionPanel(servlet); 574 enclosingPanel.setTitle(((ServletsMultiViewElement.ServletsView)getSectionView()).getServletTitle(servlet)); 575 } else if (source==orderTF) { 576 String text = (String )value; 577 servlet.setLoadOnStartup(text.length()==0?null:new java.math.BigInteger (text)); 578 } else if (source == runAsCB) { 579 String text = (String ) runAsCB.getSelectedItem(); 580 581 if (text.length() == 0) { 582 servlet.setRunAs(null); 583 } else { 584 try { 585 RunAs runAs = (RunAs) dObj.getWebApp().createBean("RunAs"); runAs.setRoleName(text); 587 servlet.setRunAs(runAs); 588 } catch (ClassNotFoundException ex) { 589 ex.printStackTrace(); 590 } 592 } 593 } 594 } 595 596 public void rollbackValue(javax.swing.text.JTextComponent source) { 597 if (source==servletNameTF) { 598 servletNameTF.setText(servlet.getServletName()); 599 } else if (source==servletClassTF) { 600 servletClassTF.setText(servlet.getServletClass()); 601 } else if (source==jspFileTF) { 602 jspFileTF.setText(servlet.getJspFile()); 603 } else if (source==servletMappingsTF) { 604 String [] urlPatterns = DDUtils.getUrlPatterns(dObj.getWebApp(),servlet); 605 servletMappingsTF.setText(DDUtils.urlPatternList(urlPatterns)); 606 } else if (source==orderTF) { 607 java.math.BigInteger los = servlet.getLoadOnStartup(); 608 orderTF.setText(los==null?"":los.toString()); 609 } 610 } 611 612 614 protected void startUIChange() { 615 dObj.setChangedFromUI(true); 616 } 617 618 620 protected void endUIChange() { 621 dObj.modelUpdatedFromUI(); 622 dObj.setChangedFromUI(false); 623 } 624 625 626 } 627 | Popular Tags |