1 19 20 package org.netbeans.modules.web.struts.dialogs; 21 22 import java.util.Iterator ; 23 import java.util.List ; 24 import javax.swing.DefaultComboBoxModel ; 25 import javax.swing.SwingUtilities ; 26 import org.netbeans.modules.web.struts.StrutsConfigDataObject; 28 import org.netbeans.modules.web.struts.StrutsConfigUtilities; 29 import org.netbeans.modules.web.struts.config.model.Action; 30 import org.netbeans.modules.web.struts.config.model.FormBean; 31 import org.openide.util.NbBundle; 32 33 37 public class AddActionPanel extends javax.swing.JPanel implements ValidatingPanel { 38 39 StrutsConfigDataObject config; 40 public AddActionPanel(StrutsConfigDataObject dObject) { 41 config=dObject; 42 initComponents(); 43 List actions = StrutsConfigUtilities.getAllActionsInModule(dObject); 44 DefaultComboBoxModel model = (DefaultComboBoxModel )CBInputAction.getModel(); 45 Iterator iter = actions.iterator(); 46 while (iter.hasNext()) 47 model.addElement(((Action)iter.next()).getAttributeValue("path")); 49 List formBeans = StrutsConfigUtilities.getAllFormBeansInModule(dObject); 50 model = (DefaultComboBoxModel )CBFormName.getModel(); 51 iter = formBeans.iterator(); 52 while (iter.hasNext()) 53 model.addElement(((FormBean)iter.next()).getAttributeValue("name")); } 55 56 public String validatePanel() { 57 if (TFActionClass.getText().trim().length()==0) 58 return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyActionClass"); 59 String actionPath = TFActionPath.getText().trim(); 60 if (actionPath.length()==0 || actionPath.equals("/")) return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyActionPath"); 62 if (!actionPath.startsWith("/") ) return NbBundle.getMessage(AddActionPanel.class,"MSG_IncorrectActionPath", actionPath); 64 if (containsActionPath(actionPath)) return NbBundle.getMessage(AddActionPanel.class,"MSG_DupliciteActionPath",actionPath); 66 if (CHBUseFormBean.isSelected()) { 67 if (CBFormName.getSelectedItem()==null) 68 NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyFormName"); 69 if (RBInputResource.isSelected()) { 70 String inputResource = TFInputResource.getText().trim(); 71 if (inputResource.length()==0 || inputResource.equals("/")) return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyInputResource"); 73 } else if (CBInputAction.getSelectedItem()==null) { 74 return NbBundle.getMessage(AddActionPanel.class,"MSG_EmptyAction"); 75 } 76 } 77 return null; 78 } 79 80 public javax.swing.AbstractButton [] getStateChangeComponents() { 81 return new javax.swing.AbstractButton []{ CHBUseFormBean, RBInputResource, RBInputAction }; 82 } 83 84 public javax.swing.text.JTextComponent [] getDocumentChangeComponents() { 85 return new javax.swing.text.JTextComponent []{TFActionClass, TFActionPath, TFInputResource}; 86 } 87 88 93 private void initComponents() { 95 java.awt.GridBagConstraints gridBagConstraints; 96 97 buttonGroup1 = new javax.swing.ButtonGroup (); 98 buttonGroup2 = new javax.swing.ButtonGroup (); 99 jLabelFormName = new javax.swing.JLabel (); 100 CBFormName = new javax.swing.JComboBox (); 101 CBInputAction = new javax.swing.JComboBox (); 102 TFInputResource = new javax.swing.JTextField (); 103 CHBUseFormBean = new javax.swing.JCheckBox (); 104 jButtonBrowse = new javax.swing.JButton (); 105 jLabelScope = new javax.swing.JLabel (); 106 jLabelAttribute = new javax.swing.JLabel (); 107 TFAttribute = new javax.swing.JTextField (); 108 CHBValidate = new javax.swing.JCheckBox (); 109 jLabelParameter = new javax.swing.JLabel (); 110 TFParameter = new javax.swing.JTextField (); 111 RBInputResource = new javax.swing.JRadioButton (); 112 RBInputAction = new javax.swing.JRadioButton (); 113 jPanel1 = new javax.swing.JPanel (); 114 RBSession = new javax.swing.JRadioButton (); 115 RBRequest = new javax.swing.JRadioButton (); 116 jLabelActionClass = new javax.swing.JLabel (); 117 TFActionClass = new javax.swing.JTextField (); 118 jButtonBrowseClass = new javax.swing.JButton (); 119 jLabelActionPath = new javax.swing.JLabel (); 120 TFActionPath = new javax.swing.JTextField (); 121 122 setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 11, 11)); 123 setLayout(new java.awt.GridBagLayout ()); 124 125 jLabelFormName.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_FormName_mnem").charAt(0)); 126 jLabelFormName.setLabelFor(CBFormName); 127 jLabelFormName.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_FormName")); gridBagConstraints = new java.awt.GridBagConstraints (); 129 gridBagConstraints.gridx = 0; 130 gridBagConstraints.gridy = 3; 131 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 132 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 133 add(jLabelFormName, gridBagConstraints); 134 gridBagConstraints = new java.awt.GridBagConstraints (); 135 gridBagConstraints.gridx = 1; 136 gridBagConstraints.gridy = 3; 137 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 138 gridBagConstraints.weightx = 1.0; 139 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 140 add(CBFormName, gridBagConstraints); 141 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/web/struts/dialogs/Bundle"); CBFormName.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CBFormName")); 144 CBInputAction.setEnabled(false); 145 gridBagConstraints = new java.awt.GridBagConstraints (); 146 gridBagConstraints.gridx = 1; 147 gridBagConstraints.gridy = 5; 148 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 149 gridBagConstraints.weightx = 1.0; 150 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 151 add(CBInputAction, gridBagConstraints); 152 CBInputAction.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CBInputAction")); 154 TFInputResource.setText("/"); 155 gridBagConstraints = new java.awt.GridBagConstraints (); 156 gridBagConstraints.gridx = 1; 157 gridBagConstraints.gridy = 4; 158 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 159 gridBagConstraints.weightx = 1.0; 160 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 161 add(TFInputResource, gridBagConstraints); 162 TFInputResource.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_TFInputResource")); TFInputResource.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFinputResource")); 165 CHBUseFormBean.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_UseFormBean_mnem").charAt(0)); 166 CHBUseFormBean.setSelected(true); 167 CHBUseFormBean.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "CB_UseFormBean")); CHBUseFormBean.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 169 CHBUseFormBean.setMargin(new java.awt.Insets (0, 0, 0, 0)); 170 CHBUseFormBean.addItemListener(new java.awt.event.ItemListener () { 171 public void itemStateChanged(java.awt.event.ItemEvent evt) { 172 CHBUseFormBeanItemStateChanged(evt); 173 } 174 }); 175 gridBagConstraints = new java.awt.GridBagConstraints (); 176 gridBagConstraints.gridx = 0; 177 gridBagConstraints.gridy = 2; 178 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 179 gridBagConstraints.insets = new java.awt.Insets (20, 0, 0, 0); 180 add(CHBUseFormBean, gridBagConstraints); 181 CHBUseFormBean.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CHBUseFormBean")); 183 jButtonBrowse.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_BrowseButton_mnem").charAt(0)); 184 jButtonBrowse.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_BrowseButton")); jButtonBrowse.addActionListener(new java.awt.event.ActionListener () { 186 public void actionPerformed(java.awt.event.ActionEvent evt) { 187 jButtonBrowseActionPerformed(evt); 188 } 189 }); 190 gridBagConstraints = new java.awt.GridBagConstraints (); 191 gridBagConstraints.gridx = 2; 192 gridBagConstraints.gridy = 4; 193 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 0); 194 add(jButtonBrowse, gridBagConstraints); 195 jButtonBrowse.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_jButtonBrowse")); 197 jLabelScope.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Scope")); gridBagConstraints = new java.awt.GridBagConstraints (); 199 gridBagConstraints.gridx = 0; 200 gridBagConstraints.gridy = 6; 201 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 202 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 203 add(jLabelScope, gridBagConstraints); 204 205 jLabelAttribute.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Attribute_mnem").charAt(0)); 206 jLabelAttribute.setLabelFor(TFAttribute); 207 jLabelAttribute.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Attribute")); gridBagConstraints = new java.awt.GridBagConstraints (); 209 gridBagConstraints.gridx = 0; 210 gridBagConstraints.gridy = 7; 211 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 212 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 213 add(jLabelAttribute, gridBagConstraints); 214 gridBagConstraints = new java.awt.GridBagConstraints (); 215 gridBagConstraints.gridx = 1; 216 gridBagConstraints.gridy = 7; 217 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 218 gridBagConstraints.weightx = 1.0; 219 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 220 add(TFAttribute, gridBagConstraints); 221 TFAttribute.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFAttribute")); 223 CHBValidate.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "CB_Validate_mnem").charAt(0)); 224 CHBValidate.setSelected(true); 225 CHBValidate.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "CB_Validate")); CHBValidate.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 227 CHBValidate.setMargin(new java.awt.Insets (0, 0, 0, 0)); 228 gridBagConstraints = new java.awt.GridBagConstraints (); 229 gridBagConstraints.gridx = 0; 230 gridBagConstraints.gridy = 8; 231 gridBagConstraints.gridwidth = 2; 232 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 233 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 234 add(CHBValidate, gridBagConstraints); 235 CHBValidate.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_CHBValidate")); 237 jLabelParameter.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Parameter_mnem").charAt(0)); 238 jLabelParameter.setLabelFor(TFParameter); 239 jLabelParameter.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Parameter")); gridBagConstraints = new java.awt.GridBagConstraints (); 241 gridBagConstraints.gridx = 0; 242 gridBagConstraints.gridy = 9; 243 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 244 gridBagConstraints.insets = new java.awt.Insets (20, 0, 0, 0); 245 add(jLabelParameter, gridBagConstraints); 246 gridBagConstraints = new java.awt.GridBagConstraints (); 247 gridBagConstraints.gridx = 1; 248 gridBagConstraints.gridy = 9; 249 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 250 gridBagConstraints.weightx = 1.0; 251 gridBagConstraints.insets = new java.awt.Insets (20, 12, 0, 0); 252 add(TFParameter, gridBagConstraints); 253 TFParameter.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFParameter")); 255 buttonGroup1.add(RBInputResource); 256 RBInputResource.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputResource_mnem").charAt(0)); 257 RBInputResource.setSelected(true); 258 RBInputResource.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputResource")); RBInputResource.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 260 RBInputResource.setMargin(new java.awt.Insets (0, 0, 0, 0)); 261 RBInputResource.addItemListener(new java.awt.event.ItemListener () { 262 public void itemStateChanged(java.awt.event.ItemEvent evt) { 263 RBInputResourceItemStateChanged(evt); 264 } 265 }); 266 gridBagConstraints = new java.awt.GridBagConstraints (); 267 gridBagConstraints.gridx = 0; 268 gridBagConstraints.gridy = 4; 269 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 270 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 271 add(RBInputResource, gridBagConstraints); 272 RBInputResource.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBInputResources")); 274 buttonGroup1.add(RBInputAction); 275 RBInputAction.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputAction_mnem").charAt(0)); 276 RBInputAction.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_InputAction")); RBInputAction.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 278 RBInputAction.setMargin(new java.awt.Insets (0, 0, 0, 0)); 279 RBInputAction.addItemListener(new java.awt.event.ItemListener () { 280 public void itemStateChanged(java.awt.event.ItemEvent evt) { 281 RBInputActionItemStateChanged(evt); 282 } 283 }); 284 gridBagConstraints = new java.awt.GridBagConstraints (); 285 gridBagConstraints.gridx = 0; 286 gridBagConstraints.gridy = 5; 287 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 288 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 0); 289 add(RBInputAction, gridBagConstraints); 290 RBInputAction.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBInputAction")); 292 buttonGroup2.add(RBSession); 293 RBSession.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Session_mnem").charAt(0)); 294 RBSession.setSelected(true); 295 RBSession.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Sesson")); RBSession.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 297 RBSession.setMargin(new java.awt.Insets (0, 0, 0, 0)); 298 jPanel1.add(RBSession); 299 RBSession.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBSession")); 301 buttonGroup2.add(RBRequest); 302 RBRequest.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Request_mnem").charAt(0)); 303 RBRequest.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "RB_Request")); RBRequest.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 305 RBRequest.setMargin(new java.awt.Insets (0, 0, 0, 0)); 306 jPanel1.add(RBRequest); 307 RBRequest.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_RBRequest")); 309 gridBagConstraints = new java.awt.GridBagConstraints (); 310 gridBagConstraints.gridx = 1; 311 gridBagConstraints.gridy = 6; 312 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 313 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 314 add(jPanel1, gridBagConstraints); 315 jPanel1.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_Scope")); 317 jLabelActionClass.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionClass_mnem").charAt(0)); 318 jLabelActionClass.setLabelFor(TFActionClass); 319 jLabelActionClass.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionClass")); gridBagConstraints = new java.awt.GridBagConstraints (); 321 gridBagConstraints.gridx = 0; 322 gridBagConstraints.gridy = 0; 323 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 324 add(jLabelActionClass, gridBagConstraints); 325 326 TFActionClass.setColumns(30); 327 gridBagConstraints = new java.awt.GridBagConstraints (); 328 gridBagConstraints.gridx = 1; 329 gridBagConstraints.gridy = 0; 330 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 331 gridBagConstraints.weightx = 1.0; 332 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 333 add(TFActionClass, gridBagConstraints); 334 TFActionClass.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFActionClass")); 336 jButtonBrowseClass.setMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_Browse_mnem").charAt(0)); 337 jButtonBrowseClass.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_BrowseButton")); jButtonBrowseClass.setEnabled(false); 339 jButtonBrowseClass.addActionListener(new java.awt.event.ActionListener () { 340 public void actionPerformed(java.awt.event.ActionEvent evt) { 341 jButtonBrowseClassActionPerformed(evt); 342 } 343 }); 344 gridBagConstraints = new java.awt.GridBagConstraints (); 345 gridBagConstraints.gridx = 2; 346 gridBagConstraints.gridy = 0; 347 gridBagConstraints.insets = new java.awt.Insets (0, 5, 0, 0); 348 add(jButtonBrowseClass, gridBagConstraints); 349 jButtonBrowseClass.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_jButtonBrowseClass")); 351 jLabelActionPath.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionPath_mnem").charAt(0)); 352 jLabelActionPath.setLabelFor(TFActionPath); 353 jLabelActionPath.setText(org.openide.util.NbBundle.getMessage(AddActionPanel.class, "LBL_ActionPath")); gridBagConstraints = new java.awt.GridBagConstraints (); 355 gridBagConstraints.gridx = 0; 356 gridBagConstraints.gridy = 1; 357 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 358 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 359 add(jLabelActionPath, gridBagConstraints); 360 361 TFActionPath.setText("/"); 362 gridBagConstraints = new java.awt.GridBagConstraints (); 363 gridBagConstraints.gridx = 1; 364 gridBagConstraints.gridy = 1; 365 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 366 gridBagConstraints.weightx = 1.0; 367 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 368 add(TFActionPath, gridBagConstraints); 369 TFActionPath.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TFActionPath")); 371 getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_AddActionDialog")); } 374 private void jButtonBrowseClassActionPerformed(java.awt.event.ActionEvent evt) { SwingUtilities.invokeLater(new Runnable () { 376 public void run() { 377 } 380 }); 381 382 } 384 private void jButtonBrowseActionPerformed(java.awt.event.ActionEvent evt) { try{ 387 org.netbeans.api.project.SourceGroup[] groups = StrutsConfigUtilities.getDocBaseGroups(config.getPrimaryFile()); 388 org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups); 389 if (fo!=null) { 390 String res = "/"+StrutsConfigUtilities.getResourcePath(groups,fo,'/',true); 391 TFInputResource.setText(res); 392 } 393 } catch (java.io.IOException ex) {} 394 } 396 private void RBInputActionItemStateChanged(java.awt.event.ItemEvent evt) { boolean selected = RBInputAction.isSelected(); 399 TFInputResource.setEditable(!selected); 400 jButtonBrowse.setEnabled(!selected); 401 CBInputAction.setEnabled(selected); 402 } 404 private void RBInputResourceItemStateChanged(java.awt.event.ItemEvent evt) { boolean selected = RBInputResource.isSelected(); 407 TFInputResource.setEditable(selected); 408 jButtonBrowse.setEnabled(selected); 409 CBInputAction.setEnabled(!selected); 410 } 412 private void CHBUseFormBeanItemStateChanged(java.awt.event.ItemEvent evt) { boolean selected = CHBUseFormBean.isSelected(); 415 CBFormName.setEnabled(selected); 416 RBInputResource.setEnabled(selected); 417 RBInputAction.setEnabled(selected); 418 if (selected) { 419 if (RBInputResource.isSelected()) { 420 TFInputResource.setEditable(true); 421 jButtonBrowse.setEnabled(true); 422 } else { 423 CBInputAction.setEnabled(true); 424 } 425 } else { 426 TFInputResource.setEditable(false); 427 jButtonBrowse.setEnabled(false); 428 CBInputAction.setEnabled(false); 429 } 430 431 RBSession.setEnabled(selected); 432 RBRequest.setEnabled(selected); 433 TFAttribute.setEditable(selected); 434 CHBValidate.setEnabled(selected); 435 } 437 438 private javax.swing.JComboBox CBFormName; 440 private javax.swing.JComboBox CBInputAction; 441 private javax.swing.JCheckBox CHBUseFormBean; 442 private javax.swing.JCheckBox CHBValidate; 443 private javax.swing.JRadioButton RBInputAction; 444 private javax.swing.JRadioButton RBInputResource; 445 private javax.swing.JRadioButton RBRequest; 446 private javax.swing.JRadioButton RBSession; 447 private javax.swing.JTextField TFActionClass; 448 private javax.swing.JTextField TFActionPath; 449 private javax.swing.JTextField TFAttribute; 450 private javax.swing.JTextField TFInputResource; 451 private javax.swing.JTextField TFParameter; 452 private javax.swing.ButtonGroup buttonGroup1; 453 private javax.swing.ButtonGroup buttonGroup2; 454 private javax.swing.JButton jButtonBrowse; 455 private javax.swing.JButton jButtonBrowseClass; 456 private javax.swing.JLabel jLabelActionClass; 457 private javax.swing.JLabel jLabelActionPath; 458 private javax.swing.JLabel jLabelAttribute; 459 private javax.swing.JLabel jLabelFormName; 460 private javax.swing.JLabel jLabelParameter; 461 private javax.swing.JLabel jLabelScope; 462 private javax.swing.JPanel jPanel1; 463 465 public String getActionClass() { 466 return TFActionClass.getText().trim(); 467 } 468 469 public String getActionPath() { 470 return TFActionPath.getText().trim(); 471 } 472 473 public String getFormName() { 474 return (String )CBFormName.getSelectedItem(); 475 } 476 477 public String getInput() { 478 if (!CHBUseFormBean.isSelected()) return null; 479 if (RBInputResource.isSelected()) { 480 String input=TFInputResource.getText().trim(); 481 return input.length()==0?null:input; 482 } else { 483 return (String )CBInputAction.getSelectedItem(); 484 } 485 } 486 487 public String getScope() { 488 if (!CHBUseFormBean.isSelected()) return null; 489 if (RBSession.isSelected()) { 490 return "session"; } else { 492 return "request"; } 494 } 495 496 public String getValidate() { 497 if (!CHBUseFormBean.isSelected()) return null; 498 if (CHBValidate.isSelected()) return null; 499 return "false"; } 501 502 public String getAttribute() { 503 if (!CHBUseFormBean.isSelected()) return null; 504 String attr=TFAttribute.getText().trim(); 505 return attr.length()==0?null:attr; 506 } 507 508 public String getParameter() { 509 String param=TFParameter.getText().trim(); 510 return param.length()==0?null:param; 511 } 512 513 public boolean isActionFormUsed(){ 514 return CHBUseFormBean.isSelected(); 515 } 516 517 private boolean containsActionPath(String path) { 518 DefaultComboBoxModel model = (DefaultComboBoxModel )CBInputAction.getModel(); 519 for (int i=0; i<model.getSize(); i++) { 520 if (path.equals(model.getElementAt(i))) return true; 521 } 522 return false; 523 } 524 } 525 | Popular Tags |