1 6 7 package SOFA.SOFAnet.Browser; 8 9 import SOFA.SOFAnet.Repository.ContractRule; 10 import SOFA.SOFAnet.Repository.NodeNameFilter; 11 import SOFA.SOFAnet.Repository.BundleNameFilter; 12 import SOFA.SOFAnet.Repository.NodeNameLicList; 13 import SOFA.SOFAnet.Repository.Licence; 14 import java.util.Date ; 15 import java.text.DateFormat ; 16 import java.text.ParseException ; 17 import javax.swing.*; 18 import java.awt.Component ; 19 import java.awt.Frame ; 20 21 25 public class ContractRuleEditDialog extends javax.swing.JDialog 26 { 27 private ContractRule contractRule; 28 private BundleNameFilter software; 29 private Licence licence; 30 private NodeNameLicList pushDestinationNodes; 31 private NodeNameFilter pushNodeFilter; 32 private NodeNameFilter pullNodeFilter; 33 private boolean isOK; 34 35 public static boolean showDialog(Component frameComp, ContractRule contractRule, String title) 36 { 37 Frame frame = JOptionPane.getFrameForComponent(frameComp); 38 ContractRuleEditDialog dialog = new ContractRuleEditDialog(frame, true, contractRule, title); 39 dialog.setLocationRelativeTo(frameComp); 40 dialog.setVisible(true); 41 return dialog.isOK(); 42 } 43 44 45 public ContractRuleEditDialog(java.awt.Frame parent, boolean modal, ContractRule contractRule, String title) 46 { 47 super(parent, modal); 48 this.contractRule = contractRule; 49 software = (BundleNameFilter)contractRule.getSoftware().clone(); 50 licence = (Licence)contractRule.getLicence().clone(); 51 pushDestinationNodes = contractRule.getPushDestinationNodes(); 52 pushNodeFilter = contractRule.getPushNodeFilter(); 53 pullNodeFilter = contractRule.getPullNodeFilter(); 54 isOK = false; 55 56 initComponents(); 57 setTitle(title); 58 59 nameTextField.setText(contractRule.getName()); 60 descriptionTextField.setText(contractRule.getDescription()); 61 62 Date validFrom = contractRule.getValidFrom(); 63 Date validTo = contractRule.getValidTo(); 64 DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); 65 66 if (validFrom != null) validFromTextField.setText(dateFormat.format(validFrom)); 67 else validFromTextField.setText(""); 68 69 if (validTo != null) validToTextField.setText(dateFormat.format(validTo)); 70 else validToTextField.setText(""); 71 72 autodeleteCheckBox.setSelected(contractRule.getAutoDelete()); 73 74 int pushCounter = contractRule.getPushCounter(); 75 76 if (contractRule.isPush()) 77 { 78 pushCheckBox.setSelected(true); 79 pushOptionsPanel.setEnabled(true); 80 pushCounterCheckBox.setEnabled(true); 81 pushDestinationNodesCheckBox.setEnabled(true); 82 pushNodeFilterCheckBox.setEnabled(true); 83 84 pushCounterTextField.setEnabled(pushCounter != -1); 85 pushDestinationNodesButton.setEnabled(pushDestinationNodes != null); 86 pushNodeFilterButton.setEnabled(pushNodeFilter != null); 87 } 88 else 89 { 90 pushCheckBox.setSelected(false); 91 pushOptionsPanel.setEnabled(false); 92 pushCounterCheckBox.setEnabled(false); 93 pushDestinationNodesCheckBox.setEnabled(false); 94 pushNodeFilterCheckBox.setEnabled(false); 95 96 pushCounterTextField.setEnabled(false); 97 pushDestinationNodesButton.setEnabled(false); 98 pushNodeFilterButton.setEnabled(false); 99 } 100 101 if (pushCounter != -1) 102 { 103 pushCounterCheckBox.setSelected(true); 104 pushCounterTextField.setText(Integer.toString(pushCounter)); 105 } 106 else 107 { 108 pushCounterCheckBox.setSelected(false); 109 pushCounterTextField.setText(""); 110 } 111 112 pushDestinationNodesCheckBox.setSelected(pushDestinationNodes != null); 113 pushNodeFilterCheckBox.setSelected(pushNodeFilter != null); 114 115 int pullCounter = contractRule.getPullCounter(); 116 117 if (contractRule.isPull()) 118 { 119 pullCheckBox.setSelected(true); 120 pullOptionsPanel.setEnabled(true); 121 pullCounterCheckBox.setEnabled(true); 122 pullNodeFilterCheckBox.setEnabled(true); 123 124 pullCounterTextField.setEnabled(pullCounter != -1); 125 pullNodeFilterButton.setEnabled(pullNodeFilter != null); 126 } 127 else 128 { 129 pullCheckBox.setSelected(false); 130 pullOptionsPanel.setEnabled(false); 131 pullCounterCheckBox.setEnabled(false); 132 pullNodeFilterCheckBox.setEnabled(false); 133 134 pullCounterTextField.setEnabled(false); 135 pullNodeFilterButton.setEnabled(false); 136 } 137 138 if (pullCounter != -1) 139 { 140 pullCounterCheckBox.setSelected(true); 141 pullCounterTextField.setText(Integer.toString(pullCounter)); 142 } 143 else 144 { 145 pullCounterCheckBox.setSelected(false); 146 pullCounterTextField.setText(""); 147 } 148 149 pullNodeFilterCheckBox.setSelected(pullNodeFilter != null); 150 151 if (pushDestinationNodes != null) pushDestinationNodes = (NodeNameLicList)pushDestinationNodes.clone(); 152 else pushDestinationNodes = new NodeNameLicList(); 153 if (pushNodeFilter != null) pushNodeFilter = (NodeNameFilter)pushNodeFilter.clone(); 154 else pushNodeFilter = new NodeNameFilter(); 155 if (pullNodeFilter != null) pullNodeFilter = (NodeNameFilter)pullNodeFilter.clone(); 156 else pullNodeFilter = new NodeNameFilter(); 157 } 158 159 public boolean isOK() 160 { 161 return isOK; 162 } 163 164 169 private void initComponents() { 171 nameAndDescriptionPanel = new javax.swing.JPanel (); 172 nameLabel = new javax.swing.JLabel (); 173 nameTextField = new javax.swing.JTextField (); 174 descriptionLabel = new javax.swing.JLabel (); 175 descriptionTextField = new javax.swing.JTextField (); 176 jPanel7 = new javax.swing.JPanel (); 177 softwareAndLicencePanel = new javax.swing.JPanel (); 178 softwareButton = new javax.swing.JButton (); 179 licenceButton = new javax.swing.JButton (); 180 jPanel2 = new javax.swing.JPanel (); 181 jPanel3 = new javax.swing.JPanel (); 182 parametersPanel = new javax.swing.JPanel (); 183 validFromPanel = new javax.swing.JPanel (); 184 validFromLabel = new javax.swing.JLabel (); 185 validFromTextField = new javax.swing.JTextField (); 186 validToPanel = new javax.swing.JPanel (); 187 validToLabel = new javax.swing.JLabel (); 188 validToTextField = new javax.swing.JTextField (); 189 autodeleteCheckBox = new javax.swing.JCheckBox (); 190 actionsPanel = new javax.swing.JPanel (); 191 jPanel5 = new javax.swing.JPanel (); 192 pushCheckBox = new javax.swing.JCheckBox (); 193 pullCheckBox = new javax.swing.JCheckBox (); 194 jPanel4 = new javax.swing.JPanel (); 195 jPanel9 = new javax.swing.JPanel (); 196 pushOptionsPanel = new javax.swing.JPanel (); 197 pushCounterPanel = new javax.swing.JPanel (); 198 pushCounterCheckBox = new javax.swing.JCheckBox (); 199 pushCounterTextField = new javax.swing.JTextField (); 200 pushNodeFilterPanel = new javax.swing.JPanel (); 201 pushNodeFilterCheckBox = new javax.swing.JCheckBox (); 202 pushNodeFilterButton = new javax.swing.JButton (); 203 pushDestinationNodesPanel = new javax.swing.JPanel (); 204 pushDestinationNodesCheckBox = new javax.swing.JCheckBox (); 205 pushDestinationNodesButton = new javax.swing.JButton (); 206 pullOptionsPanel = new javax.swing.JPanel (); 207 pullCounterPanel = new javax.swing.JPanel (); 208 pullCounterCheckBox = new javax.swing.JCheckBox (); 209 pullCounterTextField = new javax.swing.JTextField (); 210 pullNodeFilterPanel = new javax.swing.JPanel (); 211 pullNodeFilterCheckBox = new javax.swing.JCheckBox (); 212 pullNodeFilterButton = new javax.swing.JButton (); 213 jPanel6 = new javax.swing.JPanel (); 214 OKButton = new javax.swing.JButton (); 215 cancelButton = new javax.swing.JButton (); 216 217 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 218 setTitle("Contract Rule Editor"); 219 nameAndDescriptionPanel.setLayout(new java.awt.GridLayout (4, 0)); 220 221 nameAndDescriptionPanel.setBorder(new javax.swing.border.TitledBorder ("Name and Description of Contract Rule")); 222 nameLabel.setText("Name:"); 223 nameAndDescriptionPanel.add(nameLabel); 224 225 nameTextField.setEditable(false); 226 nameAndDescriptionPanel.add(nameTextField); 227 228 descriptionLabel.setText("Description:"); 229 nameAndDescriptionPanel.add(descriptionLabel); 230 231 nameAndDescriptionPanel.add(descriptionTextField); 232 233 getContentPane().add(nameAndDescriptionPanel, java.awt.BorderLayout.NORTH); 234 235 jPanel7.setLayout(new java.awt.BorderLayout ()); 236 237 softwareAndLicencePanel.setBorder(new javax.swing.border.TitledBorder ("Covered Software And Licence")); 238 softwareButton.setText("Edit Software (Bundle Filter)"); 239 softwareButton.addActionListener(new java.awt.event.ActionListener () 240 { 241 public void actionPerformed(java.awt.event.ActionEvent evt) 242 { 243 softwareButtonActionPerformed(evt); 244 } 245 }); 246 247 softwareAndLicencePanel.add(softwareButton); 248 249 licenceButton.setText("Edit Licence"); 250 licenceButton.addActionListener(new java.awt.event.ActionListener () 251 { 252 public void actionPerformed(java.awt.event.ActionEvent evt) 253 { 254 licenceButtonActionPerformed(evt); 255 } 256 }); 257 258 softwareAndLicencePanel.add(licenceButton); 259 260 jPanel7.add(softwareAndLicencePanel, java.awt.BorderLayout.NORTH); 261 262 jPanel2.setLayout(new java.awt.BorderLayout ()); 263 264 jPanel3.setLayout(new java.awt.GridLayout (1, 0)); 265 266 parametersPanel.setLayout(new java.awt.GridLayout (3, 0)); 267 268 parametersPanel.setBorder(new javax.swing.border.TitledBorder ("Parameters")); 269 validFromPanel.setLayout(new javax.swing.BoxLayout (validFromPanel, javax.swing.BoxLayout.X_AXIS)); 270 271 validFromLabel.setText("Valid From:"); 272 validFromPanel.add(validFromLabel); 273 274 validFromPanel.add(validFromTextField); 275 276 parametersPanel.add(validFromPanel); 277 278 validToPanel.setLayout(new javax.swing.BoxLayout (validToPanel, javax.swing.BoxLayout.X_AXIS)); 279 280 validToLabel.setText("Valid To:"); 281 validToPanel.add(validToLabel); 282 283 validToPanel.add(validToTextField); 284 285 parametersPanel.add(validToPanel); 286 287 autodeleteCheckBox.setText("Automatically Delete When Expired"); 288 parametersPanel.add(autodeleteCheckBox); 289 290 jPanel3.add(parametersPanel); 291 292 actionsPanel.setLayout(new java.awt.BorderLayout ()); 293 294 actionsPanel.setBorder(new javax.swing.border.TitledBorder ("Covered Actions")); 295 actionsPanel.setMinimumSize(new java.awt.Dimension (200, 111)); 296 actionsPanel.setPreferredSize(new java.awt.Dimension (200, 111)); 297 jPanel5.setLayout(new java.awt.GridLayout (2, 0)); 298 299 pushCheckBox.setText("Push"); 300 pushCheckBox.addActionListener(new java.awt.event.ActionListener () 301 { 302 public void actionPerformed(java.awt.event.ActionEvent evt) 303 { 304 pushCheckBoxActionPerformed(evt); 305 } 306 }); 307 308 jPanel5.add(pushCheckBox); 309 310 pullCheckBox.setText("Pull"); 311 pullCheckBox.addActionListener(new java.awt.event.ActionListener () 312 { 313 public void actionPerformed(java.awt.event.ActionEvent evt) 314 { 315 pullCheckBoxActionPerformed(evt); 316 } 317 }); 318 319 jPanel5.add(pullCheckBox); 320 321 actionsPanel.add(jPanel5, java.awt.BorderLayout.NORTH); 322 323 jPanel3.add(actionsPanel); 324 325 jPanel2.add(jPanel3, java.awt.BorderLayout.NORTH); 326 327 jPanel4.setLayout(new java.awt.BorderLayout ()); 328 329 jPanel9.setLayout(new java.awt.GridLayout (1, 0)); 330 331 pushOptionsPanel.setLayout(new java.awt.GridLayout (3, 0)); 332 333 pushOptionsPanel.setBorder(new javax.swing.border.TitledBorder ("Push Options")); 334 pushCounterPanel.setLayout(new javax.swing.BoxLayout (pushCounterPanel, javax.swing.BoxLayout.X_AXIS)); 335 336 pushCounterCheckBox.setText("Push Counter"); 337 pushCounterCheckBox.addActionListener(new java.awt.event.ActionListener () 338 { 339 public void actionPerformed(java.awt.event.ActionEvent evt) 340 { 341 pushCounterCheckBoxActionPerformed(evt); 342 } 343 }); 344 345 pushCounterPanel.add(pushCounterCheckBox); 346 347 pushCounterPanel.add(pushCounterTextField); 348 349 pushOptionsPanel.add(pushCounterPanel); 350 351 pushNodeFilterPanel.setLayout(new javax.swing.BoxLayout (pushNodeFilterPanel, javax.swing.BoxLayout.X_AXIS)); 352 353 pushNodeFilterCheckBox.setText("Push Node Filter"); 354 pushNodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener () 355 { 356 public void actionPerformed(java.awt.event.ActionEvent evt) 357 { 358 pushNodeFilterCheckBoxActionPerformed(evt); 359 } 360 }); 361 362 pushNodeFilterPanel.add(pushNodeFilterCheckBox); 363 364 pushNodeFilterButton.setText("Edit Push Node Filter"); 365 pushNodeFilterButton.addActionListener(new java.awt.event.ActionListener () 366 { 367 public void actionPerformed(java.awt.event.ActionEvent evt) 368 { 369 pushNodeFilterButtonActionPerformed(evt); 370 } 371 }); 372 373 pushNodeFilterPanel.add(pushNodeFilterButton); 374 375 pushOptionsPanel.add(pushNodeFilterPanel); 376 377 pushDestinationNodesPanel.setLayout(new javax.swing.BoxLayout (pushDestinationNodesPanel, javax.swing.BoxLayout.X_AXIS)); 378 379 pushDestinationNodesCheckBox.setText("Push Destination Nodes"); 380 pushDestinationNodesCheckBox.addActionListener(new java.awt.event.ActionListener () 381 { 382 public void actionPerformed(java.awt.event.ActionEvent evt) 383 { 384 pushDestinationNodesCheckBoxActionPerformed(evt); 385 } 386 }); 387 388 pushDestinationNodesPanel.add(pushDestinationNodesCheckBox); 389 390 pushDestinationNodesButton.setText("Edit Nodes"); 391 pushDestinationNodesButton.addActionListener(new java.awt.event.ActionListener () 392 { 393 public void actionPerformed(java.awt.event.ActionEvent evt) 394 { 395 pushDestinationNodesButtonActionPerformed(evt); 396 } 397 }); 398 399 pushDestinationNodesPanel.add(pushDestinationNodesButton); 400 401 pushOptionsPanel.add(pushDestinationNodesPanel); 402 403 jPanel9.add(pushOptionsPanel); 404 405 pullOptionsPanel.setLayout(new java.awt.GridLayout (3, 0)); 406 407 pullOptionsPanel.setBorder(new javax.swing.border.TitledBorder ("Pull Options")); 408 pullCounterPanel.setLayout(new javax.swing.BoxLayout (pullCounterPanel, javax.swing.BoxLayout.X_AXIS)); 409 410 pullCounterCheckBox.setText("Pull Counter"); 411 pullCounterCheckBox.addActionListener(new java.awt.event.ActionListener () 412 { 413 public void actionPerformed(java.awt.event.ActionEvent evt) 414 { 415 pullCounterCheckBoxActionPerformed(evt); 416 } 417 }); 418 419 pullCounterPanel.add(pullCounterCheckBox); 420 421 pullCounterPanel.add(pullCounterTextField); 422 423 pullOptionsPanel.add(pullCounterPanel); 424 425 pullNodeFilterPanel.setLayout(new javax.swing.BoxLayout (pullNodeFilterPanel, javax.swing.BoxLayout.X_AXIS)); 426 427 pullNodeFilterCheckBox.setText("Pull Node Filter"); 428 pullNodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener () 429 { 430 public void actionPerformed(java.awt.event.ActionEvent evt) 431 { 432 pullNodeFilterCheckBoxActionPerformed(evt); 433 } 434 }); 435 436 pullNodeFilterPanel.add(pullNodeFilterCheckBox); 437 438 pullNodeFilterButton.setText("Edit Pull Node Filter"); 439 pullNodeFilterButton.addActionListener(new java.awt.event.ActionListener () 440 { 441 public void actionPerformed(java.awt.event.ActionEvent evt) 442 { 443 pullNodeFilterButtonActionPerformed(evt); 444 } 445 }); 446 447 pullNodeFilterPanel.add(pullNodeFilterButton); 448 449 pullOptionsPanel.add(pullNodeFilterPanel); 450 451 jPanel9.add(pullOptionsPanel); 452 453 jPanel4.add(jPanel9, java.awt.BorderLayout.NORTH); 454 455 jPanel2.add(jPanel4, java.awt.BorderLayout.CENTER); 456 457 jPanel7.add(jPanel2, java.awt.BorderLayout.CENTER); 458 459 getContentPane().add(jPanel7, java.awt.BorderLayout.CENTER); 460 461 OKButton.setText("OK"); 462 OKButton.addActionListener(new java.awt.event.ActionListener () 463 { 464 public void actionPerformed(java.awt.event.ActionEvent evt) 465 { 466 OKButtonActionPerformed(evt); 467 } 468 }); 469 470 jPanel6.add(OKButton); 471 472 cancelButton.setText("Cancel"); 473 cancelButton.addActionListener(new java.awt.event.ActionListener () 474 { 475 public void actionPerformed(java.awt.event.ActionEvent evt) 476 { 477 cancelButtonActionPerformed(evt); 478 } 479 }); 480 481 jPanel6.add(cancelButton); 482 483 getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH); 484 485 pack(); 486 } 488 private void pushNodeFilterButtonActionPerformed(java.awt.event.ActionEvent evt) { StringListEditDialog.showDialog(this, pushNodeFilter.getPatterns(), "Node Name Pattern", "Push Node Filter Editor"); 491 } 493 private void pushNodeFilterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { pushNodeFilterButton.setEnabled(pushNodeFilterCheckBox.isSelected()); 496 } 498 private void pullNodeFilterButtonActionPerformed(java.awt.event.ActionEvent evt) { StringListEditDialog.showDialog(this, pullNodeFilter.getPatterns(), "Node Name Pattern", "Pull Node Filter Editor"); 501 } 503 private void pullNodeFilterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { pullNodeFilterButton.setEnabled(pullNodeFilterCheckBox.isSelected()); 506 } 508 private void pullCounterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { pullCounterTextField.setEnabled(pullCounterCheckBox.isSelected()); 511 } 513 private void pushDestinationNodesButtonActionPerformed(java.awt.event.ActionEvent evt) { NodeNameLicListEditDialog.showDialog(this, pushDestinationNodes, "Push Destination Nodes Editor"); 516 } 518 private void pushDestinationNodesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { pushDestinationNodesButton.setEnabled(pushDestinationNodesCheckBox.isSelected()); 521 } 523 private void pushCounterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { pushCounterTextField.setEnabled(pushCounterCheckBox.isSelected()); 526 } 528 private void pullCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { if (pullCheckBox.isSelected()) 531 { 532 pullOptionsPanel.setEnabled(true); 533 pullCounterCheckBox.setEnabled(true); 534 pullNodeFilterCheckBox.setEnabled(true); 535 536 pullCounterTextField.setEnabled(pullCounterCheckBox.isSelected()); 537 pullNodeFilterButton.setEnabled(pullNodeFilterCheckBox.isSelected()); 538 } 539 else 540 { 541 pullOptionsPanel.setEnabled(false); 542 pullCounterCheckBox.setEnabled(false); 543 pullNodeFilterCheckBox.setEnabled(false); 544 545 pullCounterTextField.setEnabled(false); 546 pullNodeFilterButton.setEnabled(false); 547 } 548 } 550 private void pushCheckBoxActionPerformed(java.awt.event.ActionEvent evt) { if (pushCheckBox.isSelected()) 553 { 554 pushOptionsPanel.setEnabled(true); 555 pushCounterCheckBox.setEnabled(true); 556 pushDestinationNodesCheckBox.setEnabled(true); 557 pushNodeFilterCheckBox.setEnabled(true); 558 559 pushCounterTextField.setEnabled(pushCounterCheckBox.isSelected()); 560 pushDestinationNodesButton.setEnabled(pushDestinationNodesCheckBox.isSelected()); 561 pushNodeFilterButton.setEnabled(pushNodeFilterCheckBox.isSelected()); 562 } 563 else 564 { 565 pushOptionsPanel.setEnabled(false); 566 pushCounterCheckBox.setEnabled(false); 567 pushDestinationNodesCheckBox.setEnabled(false); 568 pushNodeFilterCheckBox.setEnabled(false); 569 570 pushCounterTextField.setEnabled(false); 571 pushDestinationNodesButton.setEnabled(false); 572 pushNodeFilterButton.setEnabled(false); 573 } 574 } 576 private void licenceButtonActionPerformed(java.awt.event.ActionEvent evt) { LicenceEditDialog.showDialog(this, licence, true, "Licence of Contract Rule"); 579 } 581 private void softwareButtonActionPerformed(java.awt.event.ActionEvent evt) { StringListEditDialog.showDialog(this, software.getPatterns(), "Bundle Name Pattern", "Software covered by Contract Rule - Bundle Filter Editor"); 584 } 586 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 589 } 591 private void OKButtonActionPerformed(java.awt.event.ActionEvent evt) { Date validFrom = null; 594 Date validTo = null; 595 try 596 { 597 DateFormat dateFormat = DateFormat.getInstance(); 598 String validFromText = validFromTextField.getText().trim().toLowerCase(); 599 if (validFromText.length() != 0 && validFromText.compareTo("no limitation") != 0) validFrom = dateFormat.parse(validFromText); 600 601 String validToText = validToTextField.getText().trim().toLowerCase(); 602 if (validToText.length() != 0 && validToText.compareTo("no limitation") != 0) validTo = dateFormat.parse(validToText); 603 } 604 catch (ParseException e) 605 { 606 JOptionPane.showMessageDialog(this, "Error occured while parsing 'Valid From' or 'Valid To':\n" + e, "Error", JOptionPane.ERROR_MESSAGE); 607 return; 608 } 609 610 boolean isPush = pushCheckBox.isSelected(); 611 boolean isPull = pullCheckBox.isSelected(); 612 613 int pushCounter = -1; 614 int pullCounter = -1; 615 616 String pushCounterText = pushCounterTextField.getText().trim(); 617 String pullCounterText = pullCounterTextField.getText().trim(); 618 619 if (isPush && pushCounterCheckBox.isSelected() && pushCounterText.length() != 0) 620 { 621 try 622 { 623 pushCounter = Integer.parseInt(pushCounterText); 624 if (pushCounter < 0) throw new NumberFormatException ("Negative 'Push Counter' is not allowed"); 625 } 626 catch (NumberFormatException e) 627 { 628 JOptionPane.showMessageDialog(this, "Error occured while parsing 'Push Counter':\n" + e, "Error", JOptionPane.ERROR_MESSAGE); 629 return; 630 } 631 } 632 633 if (isPull && pullCounterCheckBox.isSelected() && pullCounterText.length() != 0) 634 { 635 try 636 { 637 pullCounter = Integer.parseInt(pullCounterText); 638 if (pullCounter < 0) throw new NumberFormatException ("Negative 'Pull Counter' is not allowed"); 639 } 640 catch (NumberFormatException e) 641 { 642 JOptionPane.showMessageDialog(this, "Error occured while parsing 'Pull Counter':\n" + e, "Error", JOptionPane.ERROR_MESSAGE); 643 return; 644 } 645 } 646 647 if (!pushDestinationNodesCheckBox.isSelected()) pushDestinationNodes = null; 648 if (!pushNodeFilterCheckBox.isSelected()) pushNodeFilter = null; 649 if (!pullNodeFilterCheckBox.isSelected()) pullNodeFilter = null; 650 651 contractRule.setDescription(descriptionTextField.getText()); 652 contractRule.setSoftware(software); 653 contractRule.setLicence(licence); 654 contractRule.setValidFrom(validFrom); 655 contractRule.setValidTo(validTo); 656 contractRule.setAutoDelete(autodeleteCheckBox.isSelected()); 657 658 if (isPush) 659 { 660 contractRule.setPush(true); 661 contractRule.setPushDestinationNodes(pushDestinationNodes); 662 contractRule.setPushNodeFilter(pushNodeFilter); 663 contractRule.setPushCounter(pushCounter); 664 } 665 else 666 { 667 contractRule.setPush(false); 668 contractRule.setPushDestinationNodes(null); 669 contractRule.setPushNodeFilter(null); 670 contractRule.setPushCounter(-1); 671 } 672 673 if (isPull) 674 { 675 contractRule.setPull(true); 676 contractRule.setPullNodeFilter(pullNodeFilter); 677 contractRule.setPullCounter(pullCounter); 678 } 679 else 680 { 681 contractRule.setPull(false); 682 contractRule.setPullNodeFilter(null); 683 contractRule.setPullCounter(-1); 684 } 685 686 isOK = true; 687 dispose(); 688 } 690 private javax.swing.JButton OKButton; 692 private javax.swing.JPanel actionsPanel; 693 private javax.swing.JCheckBox autodeleteCheckBox; 694 private javax.swing.JButton cancelButton; 695 private javax.swing.JLabel descriptionLabel; 696 private javax.swing.JTextField descriptionTextField; 697 private javax.swing.JPanel jPanel2; 698 private javax.swing.JPanel jPanel3; 699 private javax.swing.JPanel jPanel4; 700 private javax.swing.JPanel jPanel5; 701 private javax.swing.JPanel jPanel6; 702 private javax.swing.JPanel jPanel7; 703 private javax.swing.JPanel jPanel9; 704 private javax.swing.JButton licenceButton; 705 private javax.swing.JPanel nameAndDescriptionPanel; 706 private javax.swing.JLabel nameLabel; 707 private javax.swing.JTextField nameTextField; 708 private javax.swing.JPanel parametersPanel; 709 private javax.swing.JCheckBox pullCheckBox; 710 private javax.swing.JCheckBox pullCounterCheckBox; 711 private javax.swing.JPanel pullCounterPanel; 712 private javax.swing.JTextField pullCounterTextField; 713 private javax.swing.JButton pullNodeFilterButton; 714 private javax.swing.JCheckBox pullNodeFilterCheckBox; 715 private javax.swing.JPanel pullNodeFilterPanel; 716 private javax.swing.JPanel pullOptionsPanel; 717 private javax.swing.JCheckBox pushCheckBox; 718 private javax.swing.JCheckBox pushCounterCheckBox; 719 private javax.swing.JPanel pushCounterPanel; 720 private javax.swing.JTextField pushCounterTextField; 721 private javax.swing.JButton pushDestinationNodesButton; 722 private javax.swing.JCheckBox pushDestinationNodesCheckBox; 723 private javax.swing.JPanel pushDestinationNodesPanel; 724 private javax.swing.JButton pushNodeFilterButton; 725 private javax.swing.JCheckBox pushNodeFilterCheckBox; 726 private javax.swing.JPanel pushNodeFilterPanel; 727 private javax.swing.JPanel pushOptionsPanel; 728 private javax.swing.JPanel softwareAndLicencePanel; 729 private javax.swing.JButton softwareButton; 730 private javax.swing.JLabel validFromLabel; 731 private javax.swing.JPanel validFromPanel; 732 private javax.swing.JTextField validFromTextField; 733 private javax.swing.JLabel validToLabel; 734 private javax.swing.JPanel validToPanel; 735 private javax.swing.JTextField validToTextField; 736 738 } 739 | Popular Tags |