KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * LocalInfoDialog.java
3  *
4  * Created on 17. květen 2004, 15:19
5  */

6
7 package SOFA.SOFAnet.Browser;
8
9 import javax.swing.*;
10 import SOFA.SOFAnet.Repository.LocalInfo;
11 import SOFA.SOFAnet.Repository.BundleContent;
12 import SOFA.SOFAnet.Repository.Licence;
13 import SOFA.SOFAnet.Repository.NodeNameFilter;
14 import SOFA.SOFAnet.Repository.ShareGroups;
15 import SOFA.SOFAnet.Repository.NodeNameList;
16 import java.util.List JavaDoc;
17 import java.awt.Component JavaDoc;
18 import java.awt.Frame JavaDoc;
19
20 /**
21  *
22  * @author Ladislav Sobr
23  */

24 public class LocalInfoDialog extends javax.swing.JDialog JavaDoc
25 {
26   private LocalInfo localInfo;
27   private BundleContent bundleContent;
28   
29   public static void showDialog(Component JavaDoc frameComp, LocalInfo localInfo, BundleContent bundleContent)
30   {
31     Frame JavaDoc frame = JOptionPane.getFrameForComponent(frameComp);
32     LocalInfoDialog dialog = new LocalInfoDialog(frame, true, localInfo, bundleContent);
33     dialog.setLocationRelativeTo(frameComp);
34     dialog.setVisible(true);
35   }
36   
37   /** Creates new form LocalInfoDialog */
38   public LocalInfoDialog(java.awt.Frame JavaDoc parent, boolean modal, LocalInfo localInfo, BundleContent bundleContent)
39   {
40     super(parent, modal);
41     this.localInfo = localInfo;
42     this.bundleContent = bundleContent;
43     initComponents();
44     
45     Licence licence = localInfo.getLicence();
46     
47     if (localInfo.isInstalled())
48     {
49       installedPanel.setEnabled(true);
50       inMemoryCheckBox.setEnabled(true);
51       inMemoryCounterLabel.setEnabled(true);
52       inMemoryCounterTextField.setEnabled(true);
53       
54       installedCheckBox.setSelected(true);
55       inMemoryCheckBox.setSelected(localInfo.isInMemory());
56       inMemoryCounterTextField.setText(Integer.toString(localInfo.getInMemoryCounter()));
57     }
58     else
59     {
60       installedPanel.setEnabled(false);
61       inMemoryCheckBox.setEnabled(false);
62       inMemoryCounterLabel.setEnabled(false);
63       inMemoryCounterTextField.setEnabled(false);
64       
65       installedCheckBox.setSelected(false);
66       inMemoryCheckBox.setSelected(false);
67       inMemoryCounterTextField.setText("");
68     }
69     
70     if (localInfo.isShareManager())
71     {
72       shareManagerPanel.setEnabled(true);
73       nodeFilterCheckBox.setEnabled(true);
74       nodeFilterButton.setEnabled(localInfo.getSMNodeFilter() != null);
75       shareGroupsCheckBox.setEnabled(true);
76       shareGroupsButton.setEnabled(localInfo.getSMShareGroups() != null);
77       clientsCheckBox.setEnabled(true);
78       clientsButton.setEnabled(licence.withCopies());
79       equalityCheckBox.setEnabled(true);
80       
81       shareManagerCheckBox.setSelected(true);
82       nodeFilterCheckBox.setSelected(localInfo.getSMNodeFilter() != null);
83       shareGroupsCheckBox.setSelected(localInfo.getSMShareGroups() != null);
84       clientsCheckBox.setSelected(licence.withCopies());
85       equalityCheckBox.setSelected(localInfo.isSMEquality());
86     }
87     else
88     {
89       shareManagerPanel.setEnabled(false);
90       nodeFilterCheckBox.setEnabled(false);
91       nodeFilterButton.setEnabled(false);
92       shareGroupsCheckBox.setEnabled(false);
93       shareGroupsButton.setEnabled(false);
94       clientsCheckBox.setEnabled(false);
95       clientsButton.setEnabled(false);
96       equalityCheckBox.setEnabled(false);
97       
98       shareManagerCheckBox.setSelected(false);
99       nodeFilterCheckBox.setSelected(false);
100       shareGroupsCheckBox.setSelected(false);
101       clientsCheckBox.setSelected(false);
102       equalityCheckBox.setSelected(false);
103     }
104     
105     if (localInfo.isShareClient())
106     {
107       shareClientPanel.setEnabled(true);
108       managerLabel.setEnabled(true);
109       managerTextField.setEnabled(true);
110       
111       shareClientCheckBox.setSelected(true);
112       managerTextField.setText(localInfo.getSCManager());
113     }
114     else
115     {
116       shareClientPanel.setEnabled(false);
117       managerLabel.setEnabled(false);
118       managerTextField.setEnabled(false);
119       
120       shareClientCheckBox.setSelected(false);
121       managerTextField.setText("");
122     }
123     
124     if (bundleContent == null) showBundleContentButton.setVisible(false);
125     
126     setTitle("Local Info of '" + localInfo.getName() + "'");
127   }
128   
129   /** This method is called from within the constructor to
130    * initialize the form.
131    * WARNING: Do NOT modify this code. The content of this method is
132    * always regenerated by the Form Editor.
133    */

134   private void initComponents()//GEN-BEGIN:initComponents
135
{
136     jPanel12 = new javax.swing.JPanel JavaDoc();
137     installedCheckBox = new javax.swing.JCheckBox JavaDoc();
138     installedPanel = new javax.swing.JPanel JavaDoc();
139     inMemoryCheckBox = new javax.swing.JCheckBox JavaDoc();
140     inMemoryCounterLabel = new javax.swing.JLabel JavaDoc();
141     inMemoryCounterTextField = new javax.swing.JTextField JavaDoc();
142     shareManagerCheckBox = new javax.swing.JCheckBox JavaDoc();
143     shareManagerPanel = new javax.swing.JPanel JavaDoc();
144     jPanel6 = new javax.swing.JPanel JavaDoc();
145     nodeFilterCheckBox = new javax.swing.JCheckBox JavaDoc();
146     nodeFilterButton = new javax.swing.JButton JavaDoc();
147     jPanel7 = new javax.swing.JPanel JavaDoc();
148     shareGroupsCheckBox = new javax.swing.JCheckBox JavaDoc();
149     shareGroupsButton = new javax.swing.JButton JavaDoc();
150     jPanel8 = new javax.swing.JPanel JavaDoc();
151     clientsCheckBox = new javax.swing.JCheckBox JavaDoc();
152     clientsButton = new javax.swing.JButton JavaDoc();
153     equalityCheckBox = new javax.swing.JCheckBox JavaDoc();
154     shareClientCheckBox = new javax.swing.JCheckBox JavaDoc();
155     shareClientPanel = new javax.swing.JPanel JavaDoc();
156     managerLabel = new javax.swing.JLabel JavaDoc();
157     managerTextField = new javax.swing.JTextField JavaDoc();
158     licencePanel = new javax.swing.JPanel JavaDoc();
159     licenceButton = new javax.swing.JButton JavaDoc();
160     showBundleContentButton = new javax.swing.JButton JavaDoc();
161     jPanel5 = new javax.swing.JPanel JavaDoc();
162     closeButton = new javax.swing.JButton JavaDoc();
163
164     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
165     jPanel12.setLayout(new java.awt.GridLayout JavaDoc(4, 0, 0, 5));
166
167     jPanel12.setBorder(new javax.swing.border.EtchedBorder JavaDoc());
168     installedCheckBox.setText("Installed");
169     installedCheckBox.setBorderPaintedFlat(true);
170     installedCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
171     {
172       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
173       {
174         CheckBoxNoChangeAction(evt);
175       }
176     });
177
178     jPanel12.add(installedCheckBox);
179
180     installedPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
181
182     installedPanel.setBorder(new javax.swing.border.EtchedBorder JavaDoc());
183     inMemoryCheckBox.setText("In Memory");
184     inMemoryCheckBox.setBorderPaintedFlat(true);
185     inMemoryCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
186     {
187       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
188       {
189         CheckBoxNoChangeAction(evt);
190       }
191     });
192
193     installedPanel.add(inMemoryCheckBox);
194
195     inMemoryCounterLabel.setText(" In Memory Counter:");
196     installedPanel.add(inMemoryCounterLabel);
197
198     inMemoryCounterTextField.setEditable(false);
199     installedPanel.add(inMemoryCounterTextField);
200
201     jPanel12.add(installedPanel);
202
203     shareManagerCheckBox.setText("Share Manager");
204     shareManagerCheckBox.setBorderPaintedFlat(true);
205     shareManagerCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
206     {
207       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
208       {
209         CheckBoxNoChangeAction(evt);
210       }
211     });
212
213     jPanel12.add(shareManagerCheckBox);
214
215     shareManagerPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
216
217     shareManagerPanel.setBorder(new javax.swing.border.EtchedBorder JavaDoc());
218     jPanel6.setLayout(new javax.swing.BoxLayout JavaDoc(jPanel6, javax.swing.BoxLayout.X_AXIS));
219
220     nodeFilterCheckBox.setText("Node Filter");
221     nodeFilterCheckBox.setBorderPaintedFlat(true);
222     nodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
223     {
224       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
225       {
226         CheckBoxNoChangeAction(evt);
227       }
228     });
229
230     jPanel6.add(nodeFilterCheckBox);
231
232     nodeFilterButton.setText("Show Node Filter");
233     nodeFilterButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
234     {
235       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
236       {
237         nodeFilterButtonActionPerformed(evt);
238       }
239     });
240
241     jPanel6.add(nodeFilterButton);
242
243     shareManagerPanel.add(jPanel6);
244
245     jPanel7.setLayout(new javax.swing.BoxLayout JavaDoc(jPanel7, javax.swing.BoxLayout.X_AXIS));
246
247     shareGroupsCheckBox.setText("Share Groups");
248     shareGroupsCheckBox.setBorderPaintedFlat(true);
249     shareGroupsCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
250     {
251       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
252       {
253         CheckBoxNoChangeAction(evt);
254       }
255     });
256
257     jPanel7.add(shareGroupsCheckBox);
258
259     shareGroupsButton.setText("Show Share Groups");
260     shareGroupsButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
261     {
262       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
263       {
264         shareGroupsButtonActionPerformed(evt);
265       }
266     });
267
268     jPanel7.add(shareGroupsButton);
269
270     shareManagerPanel.add(jPanel7);
271
272     jPanel8.setLayout(new javax.swing.BoxLayout JavaDoc(jPanel8, javax.swing.BoxLayout.X_AXIS));
273
274     clientsCheckBox.setText("Clients");
275     clientsCheckBox.setBorderPaintedFlat(true);
276     clientsCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
277     {
278       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
279       {
280         CheckBoxNoChangeAction(evt);
281       }
282     });
283
284     jPanel8.add(clientsCheckBox);
285
286     clientsButton.setText("Show Clients");
287     clientsButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
288     {
289       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
290       {
291         clientsButtonActionPerformed(evt);
292       }
293     });
294
295     jPanel8.add(clientsButton);
296
297     shareManagerPanel.add(jPanel8);
298
299     equalityCheckBox.setText("Equality");
300     equalityCheckBox.setBorderPaintedFlat(true);
301     equalityCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
302     {
303       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
304       {
305         CheckBoxNoChangeAction(evt);
306       }
307     });
308
309     shareManagerPanel.add(equalityCheckBox);
310
311     jPanel12.add(shareManagerPanel);
312
313     shareClientCheckBox.setText("Share Client");
314     shareClientCheckBox.setBorderPaintedFlat(true);
315     shareClientCheckBox.addActionListener(new java.awt.event.ActionListener JavaDoc()
316     {
317       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
318       {
319         CheckBoxNoChangeAction(evt);
320       }
321     });
322
323     jPanel12.add(shareClientCheckBox);
324
325     shareClientPanel.setLayout(new java.awt.GridLayout JavaDoc(4, 0));
326
327     shareClientPanel.setBorder(new javax.swing.border.EtchedBorder JavaDoc());
328     managerLabel.setText(" Manager:");
329     shareClientPanel.add(managerLabel);
330
331     managerTextField.setEditable(false);
332     shareClientPanel.add(managerTextField);
333
334     jPanel12.add(shareClientPanel);
335
336     licenceButton.setText("Show Local Licence");
337     licenceButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
338     {
339       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
340       {
341         licenceButtonActionPerformed(evt);
342       }
343     });
344
345     licencePanel.add(licenceButton);
346
347     showBundleContentButton.setText("Show Bundle Content");
348     showBundleContentButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
349     {
350       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
351       {
352         showBundleContentButtonActionPerformed(evt);
353       }
354     });
355
356     licencePanel.add(showBundleContentButton);
357
358     jPanel12.add(licencePanel);
359
360     getContentPane().add(jPanel12, java.awt.BorderLayout.NORTH);
361
362     closeButton.setText("Close");
363     closeButton.addActionListener(new java.awt.event.ActionListener JavaDoc()
364     {
365       public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt)
366       {
367         closeButtonActionPerformed(evt);
368       }
369     });
370
371     jPanel5.add(closeButton);
372
373     getContentPane().add(jPanel5, java.awt.BorderLayout.SOUTH);
374
375     pack();
376   }//GEN-END:initComponents
377

378   private void showBundleContentButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_showBundleContentButtonActionPerformed
379
{//GEN-HEADEREND:event_showBundleContentButtonActionPerformed
380
List compList = bundleContent.getComponents();
381     Object JavaDoc[] components = compList.toArray();
382     ListDialog.showDialog(this, this, "Components:", "Content of bundle '" + localInfo.getName() + "'", components, null, null, false, false);
383   }//GEN-LAST:event_showBundleContentButtonActionPerformed
384

385   private void closeButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_closeButtonActionPerformed
386
{//GEN-HEADEREND:event_closeButtonActionPerformed
387
dispose();
388   }//GEN-LAST:event_closeButtonActionPerformed
389

390   private void licenceButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_licenceButtonActionPerformed
391
{//GEN-HEADEREND:event_licenceButtonActionPerformed
392
LicenceEditDialog.showDialog(this, localInfo.getLicence(), false, "Local Licence of '" + localInfo.getName() + "'");
393   }//GEN-LAST:event_licenceButtonActionPerformed
394

395   private void clientsButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_clientsButtonActionPerformed
396
{//GEN-HEADEREND:event_clientsButtonActionPerformed
397
List clients = localInfo.getSMClients().getList();
398     
399     ListDialog.showDialog(this, this, "Client nodes:", "Share Manager's Clients of '" + localInfo.getName() + "'", (String JavaDoc[])clients.toArray(new String JavaDoc[clients.size()]), null, null, false, false);
400   }//GEN-LAST:event_clientsButtonActionPerformed
401

402   private void shareGroupsButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_shareGroupsButtonActionPerformed
403
{//GEN-HEADEREND:event_shareGroupsButtonActionPerformed
404
List shareGroups = localInfo.getSMShareGroups().getList();
405     
406     ListDialog.showDialog(this, this, "Share Groups:", "Share Manager's Share Groups of '" + localInfo.getName() + "'", (String JavaDoc[])shareGroups.toArray(new String JavaDoc[shareGroups.size()]), null, null, false, false);
407   }//GEN-LAST:event_shareGroupsButtonActionPerformed
408

409   private void nodeFilterButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_nodeFilterButtonActionPerformed
410
{//GEN-HEADEREND:event_nodeFilterButtonActionPerformed
411
List patterns = localInfo.getSMNodeFilter().getPatterns();
412     
413     ListDialog.showDialog(this, this, "Node Name Patterns:", "Share Manager's Node Filter of '" + localInfo.getName() + "'", (String JavaDoc[])patterns.toArray(new String JavaDoc[patterns.size()]), null, null, false, false);
414   }//GEN-LAST:event_nodeFilterButtonActionPerformed
415

416   private void CheckBoxNoChangeAction(java.awt.event.ActionEvent JavaDoc evt)//GEN-FIRST:event_CheckBoxNoChangeAction
417
{//GEN-HEADEREND:event_CheckBoxNoChangeAction
418
JCheckBox checkBox = (JCheckBox)evt.getSource();
419     checkBox.setSelected(!checkBox.isSelected());
420   }//GEN-LAST:event_CheckBoxNoChangeAction
421

422   // Variables declaration - do not modify//GEN-BEGIN:variables
423
private javax.swing.JButton JavaDoc clientsButton;
424   private javax.swing.JCheckBox JavaDoc clientsCheckBox;
425   private javax.swing.JButton JavaDoc closeButton;
426   private javax.swing.JCheckBox JavaDoc equalityCheckBox;
427   private javax.swing.JCheckBox JavaDoc inMemoryCheckBox;
428   private javax.swing.JLabel JavaDoc inMemoryCounterLabel;
429   private javax.swing.JTextField JavaDoc inMemoryCounterTextField;
430   private javax.swing.JCheckBox JavaDoc installedCheckBox;
431   private javax.swing.JPanel JavaDoc installedPanel;
432   private javax.swing.JPanel JavaDoc jPanel12;
433   private javax.swing.JPanel JavaDoc jPanel5;
434   private javax.swing.JPanel JavaDoc jPanel6;
435   private javax.swing.JPanel JavaDoc jPanel7;
436   private javax.swing.JPanel JavaDoc jPanel8;
437   private javax.swing.JButton JavaDoc licenceButton;
438   private javax.swing.JPanel JavaDoc licencePanel;
439   private javax.swing.JLabel JavaDoc managerLabel;
440   private javax.swing.JTextField JavaDoc managerTextField;
441   private javax.swing.JButton JavaDoc nodeFilterButton;
442   private javax.swing.JCheckBox JavaDoc nodeFilterCheckBox;
443   private javax.swing.JCheckBox JavaDoc shareClientCheckBox;
444   private javax.swing.JPanel JavaDoc shareClientPanel;
445   private javax.swing.JButton JavaDoc shareGroupsButton;
446   private javax.swing.JCheckBox JavaDoc shareGroupsCheckBox;
447   private javax.swing.JCheckBox JavaDoc shareManagerCheckBox;
448   private javax.swing.JPanel JavaDoc shareManagerPanel;
449   private javax.swing.JButton JavaDoc showBundleContentButton;
450   // End of variables declaration//GEN-END:variables
451

452 }
453
Popular Tags