1 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 ; 17 import java.awt.Component ; 18 import java.awt.Frame ; 19 20 24 public class LocalInfoDialog extends javax.swing.JDialog 25 { 26 private LocalInfo localInfo; 27 private BundleContent bundleContent; 28 29 public static void showDialog(Component frameComp, LocalInfo localInfo, BundleContent bundleContent) 30 { 31 Frame frame = JOptionPane.getFrameForComponent(frameComp); 32 LocalInfoDialog dialog = new LocalInfoDialog(frame, true, localInfo, bundleContent); 33 dialog.setLocationRelativeTo(frameComp); 34 dialog.setVisible(true); 35 } 36 37 38 public LocalInfoDialog(java.awt.Frame 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 134 private void initComponents() { 136 jPanel12 = new javax.swing.JPanel (); 137 installedCheckBox = new javax.swing.JCheckBox (); 138 installedPanel = new javax.swing.JPanel (); 139 inMemoryCheckBox = new javax.swing.JCheckBox (); 140 inMemoryCounterLabel = new javax.swing.JLabel (); 141 inMemoryCounterTextField = new javax.swing.JTextField (); 142 shareManagerCheckBox = new javax.swing.JCheckBox (); 143 shareManagerPanel = new javax.swing.JPanel (); 144 jPanel6 = new javax.swing.JPanel (); 145 nodeFilterCheckBox = new javax.swing.JCheckBox (); 146 nodeFilterButton = new javax.swing.JButton (); 147 jPanel7 = new javax.swing.JPanel (); 148 shareGroupsCheckBox = new javax.swing.JCheckBox (); 149 shareGroupsButton = new javax.swing.JButton (); 150 jPanel8 = new javax.swing.JPanel (); 151 clientsCheckBox = new javax.swing.JCheckBox (); 152 clientsButton = new javax.swing.JButton (); 153 equalityCheckBox = new javax.swing.JCheckBox (); 154 shareClientCheckBox = new javax.swing.JCheckBox (); 155 shareClientPanel = new javax.swing.JPanel (); 156 managerLabel = new javax.swing.JLabel (); 157 managerTextField = new javax.swing.JTextField (); 158 licencePanel = new javax.swing.JPanel (); 159 licenceButton = new javax.swing.JButton (); 160 showBundleContentButton = new javax.swing.JButton (); 161 jPanel5 = new javax.swing.JPanel (); 162 closeButton = new javax.swing.JButton (); 163 164 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 165 jPanel12.setLayout(new java.awt.GridLayout (4, 0, 0, 5)); 166 167 jPanel12.setBorder(new javax.swing.border.EtchedBorder ()); 168 installedCheckBox.setText("Installed"); 169 installedCheckBox.setBorderPaintedFlat(true); 170 installedCheckBox.addActionListener(new java.awt.event.ActionListener () 171 { 172 public void actionPerformed(java.awt.event.ActionEvent evt) 173 { 174 CheckBoxNoChangeAction(evt); 175 } 176 }); 177 178 jPanel12.add(installedCheckBox); 179 180 installedPanel.setLayout(new java.awt.GridLayout (4, 0)); 181 182 installedPanel.setBorder(new javax.swing.border.EtchedBorder ()); 183 inMemoryCheckBox.setText("In Memory"); 184 inMemoryCheckBox.setBorderPaintedFlat(true); 185 inMemoryCheckBox.addActionListener(new java.awt.event.ActionListener () 186 { 187 public void actionPerformed(java.awt.event.ActionEvent 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 () 206 { 207 public void actionPerformed(java.awt.event.ActionEvent evt) 208 { 209 CheckBoxNoChangeAction(evt); 210 } 211 }); 212 213 jPanel12.add(shareManagerCheckBox); 214 215 shareManagerPanel.setLayout(new java.awt.GridLayout (4, 0)); 216 217 shareManagerPanel.setBorder(new javax.swing.border.EtchedBorder ()); 218 jPanel6.setLayout(new javax.swing.BoxLayout (jPanel6, javax.swing.BoxLayout.X_AXIS)); 219 220 nodeFilterCheckBox.setText("Node Filter"); 221 nodeFilterCheckBox.setBorderPaintedFlat(true); 222 nodeFilterCheckBox.addActionListener(new java.awt.event.ActionListener () 223 { 224 public void actionPerformed(java.awt.event.ActionEvent 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 () 234 { 235 public void actionPerformed(java.awt.event.ActionEvent 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 (jPanel7, javax.swing.BoxLayout.X_AXIS)); 246 247 shareGroupsCheckBox.setText("Share Groups"); 248 shareGroupsCheckBox.setBorderPaintedFlat(true); 249 shareGroupsCheckBox.addActionListener(new java.awt.event.ActionListener () 250 { 251 public void actionPerformed(java.awt.event.ActionEvent 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 () 261 { 262 public void actionPerformed(java.awt.event.ActionEvent 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 (jPanel8, javax.swing.BoxLayout.X_AXIS)); 273 274 clientsCheckBox.setText("Clients"); 275 clientsCheckBox.setBorderPaintedFlat(true); 276 clientsCheckBox.addActionListener(new java.awt.event.ActionListener () 277 { 278 public void actionPerformed(java.awt.event.ActionEvent 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 () 288 { 289 public void actionPerformed(java.awt.event.ActionEvent 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 () 302 { 303 public void actionPerformed(java.awt.event.ActionEvent 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 () 316 { 317 public void actionPerformed(java.awt.event.ActionEvent evt) 318 { 319 CheckBoxNoChangeAction(evt); 320 } 321 }); 322 323 jPanel12.add(shareClientCheckBox); 324 325 shareClientPanel.setLayout(new java.awt.GridLayout (4, 0)); 326 327 shareClientPanel.setBorder(new javax.swing.border.EtchedBorder ()); 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 () 338 { 339 public void actionPerformed(java.awt.event.ActionEvent 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 () 349 { 350 public void actionPerformed(java.awt.event.ActionEvent 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 () 364 { 365 public void actionPerformed(java.awt.event.ActionEvent 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 } 378 private void showBundleContentButtonActionPerformed(java.awt.event.ActionEvent evt) { List compList = bundleContent.getComponents(); 381 Object [] components = compList.toArray(); 382 ListDialog.showDialog(this, this, "Components:", "Content of bundle '" + localInfo.getName() + "'", components, null, null, false, false); 383 } 385 private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) { dispose(); 388 } 390 private void licenceButtonActionPerformed(java.awt.event.ActionEvent evt) { LicenceEditDialog.showDialog(this, localInfo.getLicence(), false, "Local Licence of '" + localInfo.getName() + "'"); 393 } 395 private void clientsButtonActionPerformed(java.awt.event.ActionEvent evt) { List clients = localInfo.getSMClients().getList(); 398 399 ListDialog.showDialog(this, this, "Client nodes:", "Share Manager's Clients of '" + localInfo.getName() + "'", (String [])clients.toArray(new String [clients.size()]), null, null, false, false); 400 } 402 private void shareGroupsButtonActionPerformed(java.awt.event.ActionEvent evt) { List shareGroups = localInfo.getSMShareGroups().getList(); 405 406 ListDialog.showDialog(this, this, "Share Groups:", "Share Manager's Share Groups of '" + localInfo.getName() + "'", (String [])shareGroups.toArray(new String [shareGroups.size()]), null, null, false, false); 407 } 409 private void nodeFilterButtonActionPerformed(java.awt.event.ActionEvent evt) { List patterns = localInfo.getSMNodeFilter().getPatterns(); 412 413 ListDialog.showDialog(this, this, "Node Name Patterns:", "Share Manager's Node Filter of '" + localInfo.getName() + "'", (String [])patterns.toArray(new String [patterns.size()]), null, null, false, false); 414 } 416 private void CheckBoxNoChangeAction(java.awt.event.ActionEvent evt) { JCheckBox checkBox = (JCheckBox)evt.getSource(); 419 checkBox.setSelected(!checkBox.isSelected()); 420 } 422 private javax.swing.JButton clientsButton; 424 private javax.swing.JCheckBox clientsCheckBox; 425 private javax.swing.JButton closeButton; 426 private javax.swing.JCheckBox equalityCheckBox; 427 private javax.swing.JCheckBox inMemoryCheckBox; 428 private javax.swing.JLabel inMemoryCounterLabel; 429 private javax.swing.JTextField inMemoryCounterTextField; 430 private javax.swing.JCheckBox installedCheckBox; 431 private javax.swing.JPanel installedPanel; 432 private javax.swing.JPanel jPanel12; 433 private javax.swing.JPanel jPanel5; 434 private javax.swing.JPanel jPanel6; 435 private javax.swing.JPanel jPanel7; 436 private javax.swing.JPanel jPanel8; 437 private javax.swing.JButton licenceButton; 438 private javax.swing.JPanel licencePanel; 439 private javax.swing.JLabel managerLabel; 440 private javax.swing.JTextField managerTextField; 441 private javax.swing.JButton nodeFilterButton; 442 private javax.swing.JCheckBox nodeFilterCheckBox; 443 private javax.swing.JCheckBox shareClientCheckBox; 444 private javax.swing.JPanel shareClientPanel; 445 private javax.swing.JButton shareGroupsButton; 446 private javax.swing.JCheckBox shareGroupsCheckBox; 447 private javax.swing.JCheckBox shareManagerCheckBox; 448 private javax.swing.JPanel shareManagerPanel; 449 private javax.swing.JButton showBundleContentButton; 450 452 } 453 | Popular Tags |