KickJava   Java API By Example, From Geeks To Geeks.

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


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

6
7 package SOFA.SOFAnet.Browser;
8
9 import SOFA.SOFAnet.Repository.Contract;
10 import SOFA.SOFAnet.Repository.ContractRule;
11 import SOFA.SOFAnet.Repository.NodeNameFilter;
12 import SOFA.SOFAnet.Repository.NodeNameLicList;
13 import java.util.*;
14 import java.text.DateFormat JavaDoc;
15 import java.text.ParseException JavaDoc;
16 import javax.swing.*;
17 import java.awt.Component JavaDoc;
18 import java.awt.Frame JavaDoc;
19
20 /**
21  *
22  * @author Ladislav Sobr
23  */

24 public class ContractEditDialog extends javax.swing.JDialog JavaDoc
25 {
26   private Contract contract;
27   private NodeNameLicList defaultPushDestinationNodes;
28   private NodeNameFilter defaultPushNodeFilter;
29   private NodeNameFilter defaultPullNodeFilter;
30   private String JavaDoc defaultLicenceText;
31   private DefaultListModel content;
32   private boolean isOK;
33   
34   public class ContractRuleHolder
35   {
36     public ContractRule contractRule;
37
38     /** Creates a new instance of ContractRuleHolder */
39     public ContractRuleHolder(ContractRule contractRule)
40     {
41       this.contractRule = contractRule;
42     }
43
44     public String JavaDoc toString()
45     {
46       if (contractRule.getDescription().length() == 0) return contractRule.getName();
47       else return contractRule.getName() + " (" + contractRule.getDescription() + ")";
48     }
49   }
50   
51   public static boolean showDialog(Component JavaDoc frameComp, Contract contract, String JavaDoc title)
52   {
53     Frame JavaDoc frame = JOptionPane.getFrameForComponent(frameComp);
54     ContractEditDialog dialog = new ContractEditDialog(frame, true, contract, title);
55     dialog.setLocationRelativeTo(frameComp);
56     dialog.setVisible(true);
57     return dialog.isOK();
58   }
59   
60   /** Creates new form ContractEditDialog */
61   public ContractEditDialog(java.awt.Frame JavaDoc parent, boolean modal, Contract contract, String JavaDoc title)
62   {
63     super(parent, modal);
64     this.contract = contract;
65     content = new DefaultListModel();
66     defaultPushDestinationNodes = contract.getDefaultPushDestinationNodes();
67     defaultPushNodeFilter = contract.getDefaultPushNodeFilter();
68     defaultPullNodeFilter = contract.getDefaultPullNodeFilter();
69     defaultLicenceText = contract.getDefaultLicenceText();
70     isOK = false;
71
72     content.ensureCapacity(contract.getRules().size());
73     Iterator it = contract.getRules().values().iterator();
74     while (it.hasNext()) content.addElement(new ContractRuleHolder((ContractRule)((ContractRule)it.next()).clone()));
75     
76     initComponents();
77     setTitle(title);
78     
79     nameTextField.setText(contract.getName());
80     descriptionTextField.setText(contract.getDescription());
81
82     if (defaultPushNodeFilter != null)
83     {
84       defaultPushNodeFilterCheckBox.setSelected(true);
85       defaultPushNodeFilterButton.setEnabled(true);
86     }
87     else
88     {
89       defaultPushNodeFilterCheckBox.setSelected(false);
90       defaultPushNodeFilterButton.setEnabled(false);
91     }
92
93     if (defaultPushDestinationNodes != null)
94     {
95       defaultPushDestinationNodesCheckBox.setSelected(true);
96       defaultPushDestinationNodesButton.setEnabled(true);
97     }
98     else
99     {
100       defaultPushDestinationNodesCheckBox.setSelected(false);
101       defaultPushDestinationNodesButton.setEnabled(false);
102     }
103     
104     if (defaultPullNodeFilter != null)
105     {
106       defaultPullNodeFilterCheckBox.setSelected(true);
107       defaultPullNodeFilterButton.setEnabled(true);
108     }
109     else
110     {
111       defaultPullNodeFilterCheckBox.setSelected(false);
112       defaultPullNodeFilterButton.setEnabled(false);
113     }
114
115     if (defaultLicenceText.length() != 0)
116     {
117       defaultLicenceTextCheckBox.setSelected(true);
118       defaultLicenceTextButton.setEnabled(true);
119     }
120     else
121     {
122       defaultLicenceTextCheckBox.setSelected(false);
123       defaultLicenceTextButton.setEnabled(false);
124     }
125
126     if (defaultPushDestinationNodes != null) defaultPushDestinationNodes = (NodeNameLicList)defaultPushDestinationNodes.clone();
127     else defaultPushDestinationNodes = new NodeNameLicList();
128     if (defaultPushNodeFilter != null) defaultPushNodeFilter = (NodeNameFilter)defaultPushNodeFilter.clone();
129     else defaultPushNodeFilter = new NodeNameFilter();
130     if (defaultPullNodeFilter != null) defaultPullNodeFilter = (NodeNameFilter)defaultPullNodeFilter.clone();
131     else defaultPullNodeFilter = new NodeNameFilter();
132     
133     Date validFrom = contract.getValidFrom();
134     Date validTo = contract.getValidTo();
135     DateFormat JavaDoc dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
136
137     if (validFrom != null) validFromTextField.setText(dateFormat.format(validFrom));
138     else validFromTextField.setText("");
139
140     if (validTo != null) validToTextField.setText(dateFormat.format(validTo));
141     else validToTextField.setText("");
142     
143     autodeleteCheckBox.setSelected(contract.getAutoDelete());
144   }
145   
146   public boolean isOK()
147   {
148     return isOK;
149   }
150   
151   /** This method is called from within the constructor to
152    * initialize the form.
153    * WARNING: Do NOT modify this code. The content of this method is
154    * always regenerated by the Form Editor.
155    */

156   private void initComponents()//GEN-BEGIN:initComponents
157
{
158     nameAndDescriptionPanel = new javax.swing.JPanel JavaDoc();
159     nameLabel = new javax.swing.JLabel JavaDoc();
160     nameTextField = new javax.swing.JTextField JavaDoc();
161     descriptionLabel = new javax.swing.JLabel JavaDoc();
162     descriptionTextField = new javax.swing.JTextField JavaDoc();
163     jPanel7 = new javax.swing.JPanel JavaDoc();
164     jPanel3 = new javax.swing.JPanel JavaDoc();
165     parametersPanel = new javax.swing.JPanel JavaDoc();
166     validFromPanel = new javax.swing.JPanel JavaDoc();
167     validFromLabel = new javax.swing.JLabel JavaDoc();
168     validFromTextField = new javax.swing.JTextField JavaDoc();
169     validToPanel = new javax.swing.JPanel JavaDoc();
170     validToLabel = new javax.swing.JLabel JavaDoc();
171     validToTextField = new javax.swing.JTextField JavaDoc();
172     autodeleteCheckBox = new javax.swing.JCheckBox JavaDoc();
173     defaultsPanel = new javax.swing.JPanel JavaDoc();
174     defaultPushNodeFilterPanel = new javax.swing.JPanel JavaDoc();
175     defaultPushNodeFilterCheckBox = new javax.swing.JCheckBox JavaDoc();
176     defaultPushNodeFilterButton = new javax.swing.JButton JavaDoc();
177     defaultPushDestinationNodesPanel = new javax.swing.JPanel JavaDoc();
178     defaultPushDestinationNodesCheckBox = new javax.swing.JCheckBox JavaDoc();
179     defaultPushDestinationNodesButton = new javax.swing.JButton JavaDoc();
180     defaultPullNodeFilterPanel = new javax.swing.JPanel JavaDoc();
181     defaultPullNodeFilterCheckBox = new javax.swing.JCheckBox JavaDoc();
182     defaultPullNodeFilterButton = new javax.swing.JButton JavaDoc();
183     defaultLicenceTextPanel = new javax.swing.JPanel JavaDoc();
184     defaultLicenceTextCheckBox = new javax.swing.JCheckBox JavaDoc();
185     defaultLicenceTextButton = new javax.swing.JButton JavaDoc();
186     jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
187     rulesList = new javax.swing.JList JavaDoc();
188     jPanel2 = new javax.swing.JPanel JavaDoc();
189     jPanel4 = new javax.swing.JPanel JavaDoc();
190     editButton = new javax.swing.JButton JavaDoc();
191     addButton = new javax.swing.JButton JavaDoc();
192     deleteSelectedButton = new javax.swing.JButton JavaDoc();
193     jPanel6 = new javax.swing.JPanel JavaDoc();
194     OKButton = new javax.swing.JButton JavaDoc();
195     cancelButton = new javax.swing.JButton JavaDoc();
196
197     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
198     nameAndDescriptionPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
199
200     nameAndDescriptionPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Name (ID) and Description of Contract"));
201     nameLabel.setText("Name (Contract ID):");
202     nameAndDescriptionPanel.add(nameLabel);
203
204     nameTextField.setEditable(false);
205     nameAndDescriptionPanel.add(nameTextField);
206
207     descriptionLabel.setText("Description:");
208     nameAndDescriptionPanel.add(descriptionLabel);
209
210     nameAndDescriptionPanel.add(descriptionTextField);
211
212     getContentPane().add(nameAndDescriptionPanel, java.awt.BorderLayout.NORTH);
213
214     jPanel7.setLayout(new java.awt.BorderLayout JavaDoc());
215
216     jPanel3.setLayout(new java.awt.GridLayout JavaDoc(1, 0));
217
218     parametersPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
219
220     parametersPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Parameters"));
221     validFromPanel.setLayout(new javax.swing.BoxLayout JavaDoc(validFromPanel, javax.swing.BoxLayout.X_AXIS));
222
223     validFromLabel.setText("Valid From:");
224     validFromPanel.add(validFromLabel);
225
226     validFromPanel.add(validFromTextField);
227
228     parametersPanel.add(validFromPanel);
229
230     validToPanel.setLayout(new javax.swing.BoxLayout JavaDoc(validToPanel, javax.swing.BoxLayout.X_AXIS));
231
232     validToLabel.setText("Valid To:");
233     validToPanel.add(validToLabel);
234
235     validToPanel.add(validToTextField);
236
237     parametersPanel.add(validToPanel);
238
239     autodeleteCheckBox.setText("Automatically Delete When Expired");
240     parametersPanel.add(autodeleteCheckBox);
241
242     jPanel3.add(parametersPanel);
243
244     defaultsPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
245
246     defaultsPanel.setBorder(new javax.swing.border.TitledBorder JavaDoc("Defaults"));
247     defaultsPanel.setMinimumSize(new java.awt.Dimension JavaDoc(200, 111));
248     defaultsPanel.setPreferredSize(new java.awt.Dimension JavaDoc(200, 111));
249     defaultPushNodeFilterPanel.setLayout(new javax.swing.BoxLayout JavaDoc(defaultPushNodeFilterPanel, javax.swing.BoxLayout.X_AXIS));
250
251     defaultPushNodeFilterCheckBox.setText("Push Node Filter");
252     defaultPushNodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
253     {
254       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
255       {
256         defaultPushNodeFilterCheckBoxActionPerformed(evt);
257       }
258     });
259
260     defaultPushNodeFilterPanel.add(defaultPushNodeFilterCheckBox);
261
262     defaultPushNodeFilterButton.setText("Edit Push Node Filter");
263     defaultPushNodeFilterButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
264     {
265       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
266       {
267         defaultPushNodeFilterButtonActionPerformed(evt);
268       }
269     });
270
271     defaultPushNodeFilterPanel.add(defaultPushNodeFilterButton);
272
273     defaultsPanel.add(defaultPushNodeFilterPanel);
274
275     defaultPushDestinationNodesPanel.setLayout(new javax.swing.BoxLayout JavaDoc(defaultPushDestinationNodesPanel, javax.swing.BoxLayout.X_AXIS));
276
277     defaultPushDestinationNodesCheckBox.setText("Push Destination Nodes");
278     defaultPushDestinationNodesCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
279     {
280       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
281       {
282         defaultPushDestinationNodesCheckBoxActionPerformed(evt);
283       }
284     });
285
286     defaultPushDestinationNodesPanel.add(defaultPushDestinationNodesCheckBox);
287
288     defaultPushDestinationNodesButton.setText("Edit Nodes");
289     defaultPushDestinationNodesButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
290     {
291       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
292       {
293         defaultPushDestinationNodesButtonActionPerformed(evt);
294       }
295     });
296
297     defaultPushDestinationNodesPanel.add(defaultPushDestinationNodesButton);
298
299     defaultsPanel.add(defaultPushDestinationNodesPanel);
300
301     defaultPullNodeFilterPanel.setLayout(new javax.swing.BoxLayout JavaDoc(defaultPullNodeFilterPanel, javax.swing.BoxLayout.X_AXIS));
302
303     defaultPullNodeFilterCheckBox.setText("Pull Node Filter");
304     defaultPullNodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
305     {
306       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
307       {
308         defaultPullNodeFilterCheckBoxActionPerformed(evt);
309       }
310     });
311
312     defaultPullNodeFilterPanel.add(defaultPullNodeFilterCheckBox);
313
314     defaultPullNodeFilterButton.setText("Edit Pull Node Filter");
315     defaultPullNodeFilterButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
316     {
317       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
318       {
319         defaultPullNodeFilterButtonActionPerformed(evt);
320       }
321     });
322
323     defaultPullNodeFilterPanel.add(defaultPullNodeFilterButton);
324
325     defaultsPanel.add(defaultPullNodeFilterPanel);
326
327     defaultLicenceTextPanel.setLayout(new javax.swing.BoxLayout JavaDoc(defaultLicenceTextPanel, javax.swing.BoxLayout.X_AXIS));
328
329     defaultLicenceTextCheckBox.setText("Licence Text");
330     defaultLicenceTextCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
331     {
332       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
333       {
334         defaultLicenceTextCheckBoxActionPerformed(evt);
335       }
336     });
337
338     defaultLicenceTextPanel.add(defaultLicenceTextCheckBox);
339
340     defaultLicenceTextButton.setText("Edit Licence Text");
341     defaultLicenceTextButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
342     {
343       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
344       {
345         defaultLicenceTextButtonActionPerformed(evt);
346       }
347     });
348
349     defaultLicenceTextPanel.add(defaultLicenceTextButton);
350
351     defaultsPanel.add(defaultLicenceTextPanel);
352
353     jPanel3.add(defaultsPanel);
354
355     jPanel7.add(jPanel3, java.awt.BorderLayout.NORTH);
356
357     jScrollPane1.setMinimumSize(new java.awt.Dimension JavaDoc(260, 132));
358     rulesList.setModel(content);
359     rulesList.addMouseListener(new java.awt.event.MouseAdapter JavaDoc()
360     {
361       public void mouseClicked(java.awt.event.MouseEvent JavaDoc evt)
362       {
363         rulesListMouseClicked(evt);
364       }
365     });
366
367     jScrollPane1.setViewportView(rulesList);
368
369     jPanel7.add(jScrollPane1, java.awt.BorderLayout.CENTER);
370
371     jPanel2.setLayout(new java.awt.BorderLayout JavaDoc());
372
373     jPanel4.setLayout(new java.awt.GridLayout JavaDoc(3, 0));
374
375     jPanel4.setBorder(new javax.swing.border.TitledBorder JavaDoc("Contract Rules"));
376     editButton.setText("Edit Rule");
377     editButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
378     {
379       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
380       {
381         editButtonActionPerformed(evt);
382       }
383     });
384
385     jPanel4.add(editButton);
386
387     addButton.setText("Add New Rule");
388     addButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
389     {
390       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
391       {
392         addButtonActionPerformed(evt);
393       }
394     });
395
396     jPanel4.add(addButton);
397
398     deleteSelectedButton.setText("Delete Selected");
399     deleteSelectedButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
400     {
401       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
402       {
403         deleteSelectedButtonActionPerformed(evt);
404       }
405     });
406
407     jPanel4.add(deleteSelectedButton);
408
409     jPanel2.add(jPanel4, java.awt.BorderLayout.NORTH);
410
411     jPanel7.add(jPanel2, java.awt.BorderLayout.EAST);
412
413     getContentPane().add(jPanel7, java.awt.BorderLayout.CENTER);
414
415     jPanel6.setPreferredSize(new java.awt.Dimension JavaDoc(500, 35));
416     OKButton.setText("OK");
417     OKButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
418     {
419       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
420       {
421         OKButtonActionPerformed(evt);
422       }
423     });
424
425     jPanel6.add(OKButton);
426
427     cancelButton.setText("Cancel");
428     cancelButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
429     {
430       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
431       {
432         cancelButtonActionPerformed(evt);
433       }
434     });
435
436     jPanel6.add(cancelButton);
437
438     getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH);
439
440     pack();
441   }//GEN-END:initComponents
442

443   private void defaultPushNodeFilterButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultPushNodeFilterButtonActionPerformed
444
{//GEN-HEADEREND:event_defaultPushNodeFilterButtonActionPerformed
445
StringListEditDialog.showDialog(this, defaultPushNodeFilter.getPatterns(), "Node Name Pattern", "Default Push Filter Editor");
446   }//GEN-LAST:event_defaultPushNodeFilterButtonActionPerformed
447

448   private void defaultPushNodeFilterCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultPushNodeFilterCheckBoxActionPerformed
449
{//GEN-HEADEREND:event_defaultPushNodeFilterCheckBoxActionPerformed
450
defaultPushNodeFilterButton.setEnabled(defaultPushNodeFilterCheckBox.isSelected());
451   }//GEN-LAST:event_defaultPushNodeFilterCheckBoxActionPerformed
452

453   private void rulesListMouseClicked(java.awt.event.MouseEvent JavaDoc evt)//GEN-FIRST:event_rulesListMouseClicked
454
{//GEN-HEADEREND:event_rulesListMouseClicked
455
if (evt.getClickCount() == 2)
456     {
457       editButton.doClick(); //emulate button click
458
}
459   }//GEN-LAST:event_rulesListMouseClicked
460

461   private void deleteSelectedButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_deleteSelectedButtonActionPerformed
462
{//GEN-HEADEREND:event_deleteSelectedButtonActionPerformed
463
Object JavaDoc[] selected = rulesList.getSelectedValues();
464     for (int i = 0; i < selected.length; i++)
465     {
466       content.removeElement(selected[i]);
467     }
468   }//GEN-LAST:event_deleteSelectedButtonActionPerformed
469

470   private void addButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_addButtonActionPerformed
471
{//GEN-HEADEREND:event_addButtonActionPerformed
472
String JavaDoc result = JOptionPane.showInputDialog(this, "New Contract Rule:", "");
473     if (result != null)
474     {
475       result = result.trim();
476       if (result.length() != 0)
477       {
478         content.addElement(new ContractRuleHolder(new ContractRule(result, contract)));
479       }
480       else
481       {
482         JOptionPane.showMessageDialog(this, "Empty Rule Name", "Error", JOptionPane.ERROR_MESSAGE);
483       }
484     }
485   }//GEN-LAST:event_addButtonActionPerformed
486

487   private void editButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_editButtonActionPerformed
488
{//GEN-HEADEREND:event_editButtonActionPerformed
489
ContractRuleHolder contractRuleHolder = (ContractRuleHolder)rulesList.getSelectedValue();
490     if (contractRuleHolder == null)
491     {
492       JOptionPane.showMessageDialog(this, "No Contract Rule selected", "Warning", JOptionPane.WARNING_MESSAGE);
493       return;
494     }
495     
496     ContractRuleEditDialog.showDialog(this, contractRuleHolder.contractRule, "Contract Rule Editor");
497   }//GEN-LAST:event_editButtonActionPerformed
498

499   private void defaultLicenceTextCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultLicenceTextCheckBoxActionPerformed
500
{//GEN-HEADEREND:event_defaultLicenceTextCheckBoxActionPerformed
501
defaultLicenceTextButton.setEnabled(defaultLicenceTextCheckBox.isSelected());
502   }//GEN-LAST:event_defaultLicenceTextCheckBoxActionPerformed
503

504   private void defaultLicenceTextButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultLicenceTextButtonActionPerformed
505
{//GEN-HEADEREND:event_defaultLicenceTextButtonActionPerformed
506
String JavaDoc result = MemoEditDialog.showDialog(this, defaultLicenceText, "Default Licence Text", "Default Licence Text");
507     if (result != null) defaultLicenceText = result;
508   }//GEN-LAST:event_defaultLicenceTextButtonActionPerformed
509

510   private void cancelButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_cancelButtonActionPerformed
511
{//GEN-HEADEREND:event_cancelButtonActionPerformed
512
dispose();
513   }//GEN-LAST:event_cancelButtonActionPerformed
514

515   private void OKButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_OKButtonActionPerformed
516
{//GEN-HEADEREND:event_OKButtonActionPerformed
517
Date validFrom = null;
518     Date validTo = null;
519     try
520     {
521       DateFormat JavaDoc dateFormat = DateFormat.getInstance();
522       String JavaDoc validFromText = validFromTextField.getText().trim().toLowerCase();
523       if (validFromText.length() != 0 && validFromText.compareTo("no limitation") != 0) validFrom = dateFormat.parse(validFromText);
524
525       String JavaDoc validToText = validToTextField.getText().trim().toLowerCase();
526       if (validToText.length() != 0 && validToText.compareTo("no limitation") != 0) validTo = dateFormat.parse(validToText);
527     }
528     catch (ParseException JavaDoc e)
529     {
530       JOptionPane.showMessageDialog(this, "Error occured while parsing 'Valid From' or 'Valid To':\n" + e, "Error", JOptionPane.ERROR_MESSAGE);
531       return;
532     }
533     
534     
535     contract.setDescription(descriptionTextField.getText());
536     
537
538     if (!defaultPushDestinationNodesCheckBox.isSelected()) defaultPushDestinationNodes = null;
539     if (!defaultPushNodeFilterCheckBox.isSelected()) defaultPushNodeFilter = null;
540     if (!defaultPullNodeFilterCheckBox.isSelected()) defaultPullNodeFilter = null;
541     if (!defaultLicenceTextCheckBox.isSelected()) defaultLicenceText = "";
542     
543     contract.setDefaultPushDestinationNodes(defaultPushDestinationNodes);
544     contract.setDefaultPushNodeFilter(defaultPushNodeFilter);
545     contract.setDefaultPullNodeFilter(defaultPullNodeFilter);
546     contract.setDefaultLicenceText(defaultLicenceText);
547     contract.setValidFrom(validFrom);
548     contract.setValidTo(validTo);
549     contract.setAutoDelete(autodeleteCheckBox.isSelected());
550     
551     Map rules = contract.getRules();
552     rules.clear();
553     Enumeration en = content.elements();
554     while (en.hasMoreElements())
555     {
556       ContractRule contractRule = ((ContractRuleHolder)en.nextElement()).contractRule;
557       rules.put(contractRule.getName(), contractRule);
558     }
559     
560     isOK = true;
561     dispose();
562   }//GEN-LAST:event_OKButtonActionPerformed
563

564   private void defaultPullNodeFilterButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultPullNodeFilterButtonActionPerformed
565
{//GEN-HEADEREND:event_defaultPullNodeFilterButtonActionPerformed
566
StringListEditDialog.showDialog(this, defaultPullNodeFilter.getPatterns(), "Node Name Pattern", "Default Pull Filter Editor");
567   }//GEN-LAST:event_defaultPullNodeFilterButtonActionPerformed
568

569   private void defaultPullNodeFilterCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultPullNodeFilterCheckBoxActionPerformed
570
{//GEN-HEADEREND:event_defaultPullNodeFilterCheckBoxActionPerformed
571
defaultPullNodeFilterButton.setEnabled(defaultPullNodeFilterCheckBox.isSelected());
572   }//GEN-LAST:event_defaultPullNodeFilterCheckBoxActionPerformed
573

574   private void defaultPushDestinationNodesButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultPushDestinationNodesButtonActionPerformed
575
{//GEN-HEADEREND:event_defaultPushDestinationNodesButtonActionPerformed
576
NodeNameLicListEditDialog.showDialog(this, defaultPushDestinationNodes, "Default Push Destination Nodes Editor");
577   }//GEN-LAST:event_defaultPushDestinationNodesButtonActionPerformed
578

579   private void defaultPushDestinationNodesCheckBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_defaultPushDestinationNodesCheckBoxActionPerformed
580
{//GEN-HEADEREND:event_defaultPushDestinationNodesCheckBoxActionPerformed
581
defaultPushDestinationNodesButton.setEnabled(defaultPushDestinationNodesCheckBox.isSelected());
582   }//GEN-LAST:event_defaultPushDestinationNodesCheckBoxActionPerformed
583

584   // Variables declaration - do not modify//GEN-BEGIN:variables
585
private javax.swing.JButton JavaDoc OKButton;
586   private javax.swing.JButton JavaDoc addButton;
587   private javax.swing.JCheckBox JavaDoc autodeleteCheckBox;
588   private javax.swing.JButton JavaDoc cancelButton;
589   private javax.swing.JButton JavaDoc defaultLicenceTextButton;
590   private javax.swing.JCheckBox JavaDoc defaultLicenceTextCheckBox;
591   private javax.swing.JPanel JavaDoc defaultLicenceTextPanel;
592   private javax.swing.JButton JavaDoc defaultPullNodeFilterButton;
593   private javax.swing.JCheckBox JavaDoc defaultPullNodeFilterCheckBox;
594   private javax.swing.JPanel JavaDoc defaultPullNodeFilterPanel;
595   private javax.swing.JButton JavaDoc defaultPushDestinationNodesButton;
596   private javax.swing.JCheckBox JavaDoc defaultPushDestinationNodesCheckBox;
597   private javax.swing.JPanel JavaDoc defaultPushDestinationNodesPanel;
598   private javax.swing.JButton JavaDoc defaultPushNodeFilterButton;
599   private javax.swing.JCheckBox JavaDoc defaultPushNodeFilterCheckBox;
600   private javax.swing.JPanel JavaDoc defaultPushNodeFilterPanel;
601   private javax.swing.JPanel JavaDoc defaultsPanel;
602   private javax.swing.JButton JavaDoc deleteSelectedButton;
603   private javax.swing.JLabel JavaDoc descriptionLabel;
604   private javax.swing.JTextField JavaDoc descriptionTextField;
605   private javax.swing.JButton JavaDoc editButton;
606   private javax.swing.JPanel JavaDoc jPanel2;
607   private javax.swing.JPanel JavaDoc jPanel3;
608   private javax.swing.JPanel JavaDoc jPanel4;
609   private javax.swing.JPanel JavaDoc jPanel6;
610   private javax.swing.JPanel JavaDoc jPanel7;
611   private javax.swing.JScrollPane JavaDoc jScrollPane1;
612   private javax.swing.JPanel JavaDoc nameAndDescriptionPanel;
613   private javax.swing.JLabel JavaDoc nameLabel;
614   private javax.swing.JTextField JavaDoc nameTextField;
615   private javax.swing.JPanel JavaDoc parametersPanel;
616   private javax.swing.JList JavaDoc rulesList;
617   private javax.swing.JLabel JavaDoc validFromLabel;
618   private javax.swing.JPanel JavaDoc validFromPanel;
619   private javax.swing.JTextField JavaDoc validFromTextField;
620   private javax.swing.JLabel JavaDoc validToLabel;
621   private javax.swing.JPanel JavaDoc validToPanel;
622   private javax.swing.JTextField JavaDoc validToTextField;
623   // End of variables declaration//GEN-END:variables
624

625 }
626
Popular Tags