KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnet > Browser > ContractRuleEditDialog


1 /*
2  * ContractRuleEditDialog.java
3  *
4  * Created on 17. květen 2004, 22:47
5  */

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 JavaDoc;
15 import java.text.DateFormat JavaDoc;
16 import java.text.ParseException JavaDoc;
17 import javax.swing.*;
18 import java.awt.Component JavaDoc;
19 import java.awt.Frame JavaDoc;
20
21 /**
22  *
23  * @author Ladislav Sobr
24  */

25 public class ContractRuleEditDialog extends javax.swing.JDialog JavaDoc
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 JavaDoc frameComp, ContractRule contractRule, String JavaDoc title)
36   {
37     Frame JavaDoc 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   /** Creates new form ContractRuleEditDialog */
45   public ContractRuleEditDialog(java.awt.Frame JavaDoc parent, boolean modal, ContractRule contractRule, String JavaDoc 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 JavaDoc validFrom = contractRule.getValidFrom();
63     Date JavaDoc validTo = contractRule.getValidTo();
64     DateFormat JavaDoc 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   /** This method is called from within the constructor to
165    * initialize the form.
166    * WARNING: Do NOT modify this code. The content of this method is
167    * always regenerated by the Form Editor.
168    */

169   private void initComponents()//GEN-BEGIN:initComponents
170
{
171     nameAndDescriptionPanel = new javax.swing.JPanel JavaDoc();
172     nameLabel = new javax.swing.JLabel JavaDoc();
173     nameTextField = new javax.swing.JTextField JavaDoc();
174     descriptionLabel = new javax.swing.JLabel JavaDoc();
175     descriptionTextField = new javax.swing.JTextField JavaDoc();
176     jPanel7 = new javax.swing.JPanel JavaDoc();
177     softwareAndLicencePanel = new javax.swing.JPanel JavaDoc();
178     softwareButton = new javax.swing.JButton JavaDoc();
179     licenceButton = new javax.swing.JButton JavaDoc();
180     jPanel2 = new javax.swing.JPanel JavaDoc();
181     jPanel3 = new javax.swing.JPanel JavaDoc();
182     parametersPanel = new javax.swing.JPanel JavaDoc();
183     validFromPanel = new javax.swing.JPanel JavaDoc();
184     validFromLabel = new javax.swing.JLabel JavaDoc();
185     validFromTextField = new javax.swing.JTextField JavaDoc();
186     validToPanel = new javax.swing.JPanel JavaDoc();
187     validToLabel = new javax.swing.JLabel JavaDoc();
188     validToTextField = new javax.swing.JTextField JavaDoc();
189     autodeleteCheckBox = new javax.swing.JCheckBox JavaDoc();
190     actionsPanel = new javax.swing.JPanel JavaDoc();
191     jPanel5 = new javax.swing.JPanel JavaDoc();
192     pushCheckBox = new javax.swing.JCheckBox JavaDoc();
193     pullCheckBox = new javax.swing.JCheckBox JavaDoc();
194     jPanel4 = new javax.swing.JPanel JavaDoc();
195     jPanel9 = new javax.swing.JPanel JavaDoc();
196     pushOptionsPanel = new javax.swing.JPanel JavaDoc();
197     pushCounterPanel = new javax.swing.JPanel JavaDoc();
198     pushCounterCheckBox = new javax.swing.JCheckBox JavaDoc();
199     pushCounterTextField = new javax.swing.JTextField JavaDoc();
200     pushNodeFilterPanel = new javax.swing.JPanel JavaDoc();
201     pushNodeFilterCheckBox = new javax.swing.JCheckBox JavaDoc();
202     pushNodeFilterButton = new javax.swing.JButton JavaDoc();
203     pushDestinationNodesPanel = new javax.swing.JPanel JavaDoc();
204     pushDestinationNodesCheckBox = new javax.swing.JCheckBox JavaDoc();
205     pushDestinationNodesButton = new javax.swing.JButton JavaDoc();
206     pullOptionsPanel = new javax.swing.JPanel JavaDoc();
207     pullCounterPanel = new javax.swing.JPanel JavaDoc();
208     pullCounterCheckBox = new javax.swing.JCheckBox JavaDoc();
209     pullCounterTextField = new javax.swing.JTextField JavaDoc();
210     pullNodeFilterPanel = new javax.swing.JPanel JavaDoc();
211     pullNodeFilterCheckBox = new javax.swing.JCheckBox JavaDoc();
212     pullNodeFilterButton = new javax.swing.JButton JavaDoc();
213     jPanel6 = new javax.swing.JPanel JavaDoc();
214     OKButton = new javax.swing.JButton JavaDoc();
215     cancelButton = new javax.swing.JButton JavaDoc();
216
217     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
218     setTitle("Contract Rule Editor");
219     nameAndDescriptionPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
220
221     nameAndDescriptionPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("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 JavaDoc());
236
237     softwareAndLicencePanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Covered Software And Licence"));
238     softwareButton.setText("Edit Software (Bundle Filter)");
239     softwareButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
240     {
241       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
251     {
252       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc());
263
264     jPanel3.setLayout(new java.awt.GridLayout JavaDoc(1, 0));
265
266     parametersPanel.setLayout(new java.awt.GridLayout JavaDoc(3, 0));
267
268     parametersPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Parameters"));
269     validFromPanel.setLayout(new javax.swing.BoxLayout JavaDoc(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 JavaDoc(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 JavaDoc());
293
294     actionsPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Covered Actions"));
295     actionsPanel.setMinimumSize(new java.awt.Dimension JavaDoc(200, 111));
296     actionsPanel.setPreferredSize(new java.awt.Dimension JavaDoc(200, 111));
297     jPanel5.setLayout(new java.awt.GridLayout JavaDoc(2, 0));
298
299     pushCheckBox.setText("Push");
300     pushCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
301     {
302       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
312     {
313       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc());
328
329     jPanel9.setLayout(new java.awt.GridLayout JavaDoc(1, 0));
330
331     pushOptionsPanel.setLayout(new java.awt.GridLayout JavaDoc(3, 0));
332
333     pushOptionsPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Push Options"));
334     pushCounterPanel.setLayout(new javax.swing.BoxLayout JavaDoc(pushCounterPanel, javax.swing.BoxLayout.X_AXIS));
335
336     pushCounterCheckBox.setText("Push Counter");
337     pushCounterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
338     {
339       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc(pushNodeFilterPanel, javax.swing.BoxLayout.X_AXIS));
352
353     pushNodeFilterCheckBox.setText("Push Node Filter");
354     pushNodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
355     {
356       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
366     {
367       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc(pushDestinationNodesPanel, javax.swing.BoxLayout.X_AXIS));
378
379     pushDestinationNodesCheckBox.setText("Push Destination Nodes");
380     pushDestinationNodesCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
381     {
382       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
392     {
393       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc(3, 0));
406
407     pullOptionsPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Pull Options"));
408     pullCounterPanel.setLayout(new javax.swing.BoxLayout JavaDoc(pullCounterPanel, javax.swing.BoxLayout.X_AXIS));
409
410     pullCounterCheckBox.setText("Pull Counter");
411     pullCounterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
412     {
413       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc(pullNodeFilterPanel, javax.swing.BoxLayout.X_AXIS));
426
427     pullNodeFilterCheckBox.setText("Pull Node Filter");
428     pullNodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
429     {
430       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
440     {
441       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
463     {
464       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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 JavaDoc()
474     {
475       public void actionPerformed(java.awt.event.ActionEvent JavaDoc 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   }//GEN-END:initComponents
487

488   private void pushNodeFilterButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pushNodeFilterButtonActionPerformed
489
{//GEN-HEADEREND:event_pushNodeFilterButtonActionPerformed
490
StringListEditDialog.showDialog(this, pushNodeFilter.getPatterns(), "Node Name Pattern", "Push Node Filter Editor");
491   }//GEN-LAST:event_pushNodeFilterButtonActionPerformed
492

493   private void pushNodeFilterCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pushNodeFilterCheckBoxActionPerformed
494
{//GEN-HEADEREND:event_pushNodeFilterCheckBoxActionPerformed
495
pushNodeFilterButton.setEnabled(pushNodeFilterCheckBox.isSelected());
496   }//GEN-LAST:event_pushNodeFilterCheckBoxActionPerformed
497

498   private void pullNodeFilterButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pullNodeFilterButtonActionPerformed
499
{//GEN-HEADEREND:event_pullNodeFilterButtonActionPerformed
500
StringListEditDialog.showDialog(this, pullNodeFilter.getPatterns(), "Node Name Pattern", "Pull Node Filter Editor");
501   }//GEN-LAST:event_pullNodeFilterButtonActionPerformed
502

503   private void pullNodeFilterCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pullNodeFilterCheckBoxActionPerformed
504
{//GEN-HEADEREND:event_pullNodeFilterCheckBoxActionPerformed
505
pullNodeFilterButton.setEnabled(pullNodeFilterCheckBox.isSelected());
506   }//GEN-LAST:event_pullNodeFilterCheckBoxActionPerformed
507

508   private void pullCounterCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pullCounterCheckBoxActionPerformed
509
{//GEN-HEADEREND:event_pullCounterCheckBoxActionPerformed
510
pullCounterTextField.setEnabled(pullCounterCheckBox.isSelected());
511   }//GEN-LAST:event_pullCounterCheckBoxActionPerformed
512

513   private void pushDestinationNodesButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pushDestinationNodesButtonActionPerformed
514
{//GEN-HEADEREND:event_pushDestinationNodesButtonActionPerformed
515
NodeNameLicListEditDialog.showDialog(this, pushDestinationNodes, "Push Destination Nodes Editor");
516   }//GEN-LAST:event_pushDestinationNodesButtonActionPerformed
517

518   private void pushDestinationNodesCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pushDestinationNodesCheckBoxActionPerformed
519
{//GEN-HEADEREND:event_pushDestinationNodesCheckBoxActionPerformed
520
pushDestinationNodesButton.setEnabled(pushDestinationNodesCheckBox.isSelected());
521   }//GEN-LAST:event_pushDestinationNodesCheckBoxActionPerformed
522

523   private void pushCounterCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pushCounterCheckBoxActionPerformed
524
{//GEN-HEADEREND:event_pushCounterCheckBoxActionPerformed
525
pushCounterTextField.setEnabled(pushCounterCheckBox.isSelected());
526   }//GEN-LAST:event_pushCounterCheckBoxActionPerformed
527

528   private void pullCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pullCheckBoxActionPerformed
529
{//GEN-HEADEREND:event_pullCheckBoxActionPerformed
530
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   }//GEN-LAST:event_pullCheckBoxActionPerformed
549

550   private void pushCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_pushCheckBoxActionPerformed
551
{//GEN-HEADEREND:event_pushCheckBoxActionPerformed
552
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   }//GEN-LAST:event_pushCheckBoxActionPerformed
575

576   private void licenceButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_licenceButtonActionPerformed
577
{//GEN-HEADEREND:event_licenceButtonActionPerformed
578
LicenceEditDialog.showDialog(this, licence, true, "Licence of Contract Rule");
579   }//GEN-LAST:event_licenceButtonActionPerformed
580

581   private void softwareButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_softwareButtonActionPerformed
582
{//GEN-HEADEREND:event_softwareButtonActionPerformed
583
StringListEditDialog.showDialog(this, software.getPatterns(), "Bundle Name Pattern", "Software covered by Contract Rule - Bundle Filter Editor");
584   }//GEN-LAST:event_softwareButtonActionPerformed
585

586   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
587
{//GEN-HEADEREND:event_cancelButtonActionPerformed
588
dispose();
589   }//GEN-LAST:event_cancelButtonActionPerformed
590

591   private void OKButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_OKButtonActionPerformed
592
{//GEN-HEADEREND:event_OKButtonActionPerformed
593
Date JavaDoc validFrom = null;
594     Date JavaDoc validTo = null;
595     try
596     {
597       DateFormat JavaDoc dateFormat = DateFormat.getInstance();
598       String JavaDoc validFromText = validFromTextField.getText().trim().toLowerCase();
599       if (validFromText.length() != 0 && validFromText.compareTo("no limitation") != 0) validFrom = dateFormat.parse(validFromText);
600
601       String JavaDoc validToText = validToTextField.getText().trim().toLowerCase();
602       if (validToText.length() != 0 && validToText.compareTo("no limitation") != 0) validTo = dateFormat.parse(validToText);
603     }
604     catch (ParseException JavaDoc 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 JavaDoc pushCounterText = pushCounterTextField.getText().trim();
617     String JavaDoc 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 JavaDoc("Negative 'Push Counter' is not allowed");
625       }
626       catch (NumberFormatException JavaDoc 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 JavaDoc("Negative 'Pull Counter' is not allowed");
639       }
640       catch (NumberFormatException JavaDoc 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   }//GEN-LAST:event_OKButtonActionPerformed
689

690   // Variables declaration - do not modify//GEN-BEGIN:variables
691
private javax.swing.JButton JavaDoc OKButton;
692   private javax.swing.JPanel JavaDoc actionsPanel;
693   private javax.swing.JCheckBox JavaDoc autodeleteCheckBox;
694   private javax.swing.JButton JavaDoc cancelButton;
695   private javax.swing.JLabel JavaDoc descriptionLabel;
696   private javax.swing.JTextField JavaDoc descriptionTextField;
697   private javax.swing.JPanel JavaDoc jPanel2;
698   private javax.swing.JPanel JavaDoc jPanel3;
699   private javax.swing.JPanel JavaDoc jPanel4;
700   private javax.swing.JPanel JavaDoc jPanel5;
701   private javax.swing.JPanel JavaDoc jPanel6;
702   private javax.swing.JPanel JavaDoc jPanel7;
703   private javax.swing.JPanel JavaDoc jPanel9;
704   private javax.swing.JButton JavaDoc licenceButton;
705   private javax.swing.JPanel JavaDoc nameAndDescriptionPanel;
706   private javax.swing.JLabel JavaDoc nameLabel;
707   private javax.swing.JTextField JavaDoc nameTextField;
708   private javax.swing.JPanel JavaDoc parametersPanel;
709   private javax.swing.JCheckBox JavaDoc pullCheckBox;
710   private javax.swing.JCheckBox JavaDoc pullCounterCheckBox;
711   private javax.swing.JPanel JavaDoc pullCounterPanel;
712   private javax.swing.JTextField JavaDoc pullCounterTextField;
713   private javax.swing.JButton JavaDoc pullNodeFilterButton;
714   private javax.swing.JCheckBox JavaDoc pullNodeFilterCheckBox;
715   private javax.swing.JPanel JavaDoc pullNodeFilterPanel;
716   private javax.swing.JPanel JavaDoc pullOptionsPanel;
717   private javax.swing.JCheckBox JavaDoc pushCheckBox;
718   private javax.swing.JCheckBox JavaDoc pushCounterCheckBox;
719   private javax.swing.JPanel JavaDoc pushCounterPanel;
720   private javax.swing.JTextField JavaDoc pushCounterTextField;
721   private javax.swing.JButton JavaDoc pushDestinationNodesButton;
722   private javax.swing.JCheckBox JavaDoc pushDestinationNodesCheckBox;
723   private javax.swing.JPanel JavaDoc pushDestinationNodesPanel;
724   private javax.swing.JButton JavaDoc pushNodeFilterButton;
725   private javax.swing.JCheckBox JavaDoc pushNodeFilterCheckBox;
726   private javax.swing.JPanel JavaDoc pushNodeFilterPanel;
727   private javax.swing.JPanel JavaDoc pushOptionsPanel;
728   private javax.swing.JPanel JavaDoc softwareAndLicencePanel;
729   private javax.swing.JButton JavaDoc softwareButton;
730   private javax.swing.JLabel JavaDoc validFromLabel;
731   private javax.swing.JPanel JavaDoc validFromPanel;
732   private javax.swing.JTextField JavaDoc validFromTextField;
733   private javax.swing.JLabel JavaDoc validToLabel;
734   private javax.swing.JPanel JavaDoc validToPanel;
735   private javax.swing.JTextField JavaDoc validToTextField;
736   // End of variables declaration//GEN-END:variables
737

738 }
739
Popular Tags