1 6 7 package SOFA.SOFAnet.Browser; 8 9 import javax.swing.*; 10 import SOFA.SOFAnet.Admin.RMI.*; 11 import SOFA.SOFAnet.Repository.LocalInfo; 12 import SOFA.SOFAnet.Repository.BundleContent; 13 import java.rmi.RemoteException ; 14 import java.util.Arrays ; 15 16 20 public class LocalInfosPanel extends javax.swing.JPanel 21 { 22 private RMIAdminInterface admin; 23 private DefaultListModel content; 24 25 26 public LocalInfosPanel(RMIAdminInterface admin) 27 { 28 this.admin = admin; 29 content = new DefaultListModel(); 30 initComponents(); 31 } 32 33 private void reload() 34 { 35 content.clear(); 36 37 LocalInfoDesc[] localInfoDescs = null; 38 try 39 { 40 localInfoDescs = admin.localInfoDescsList(); 41 } 42 catch (RemoteException e) 43 { 44 JOptionPane.showMessageDialog(this, "RMI Error occured while accessing SOFA net node:\n" + e, "Error", JOptionPane.ERROR_MESSAGE); 45 return; 46 } 47 48 Arrays.sort(localInfoDescs); 49 50 content.ensureCapacity(localInfoDescs.length); 51 for (int i = 0; i < localInfoDescs.length; i++) content.addElement(localInfoDescs[i]); 52 } 53 54 private String getSelectedBundleName() 55 { 56 String bundleName = ""; 57 58 int index = contentList.getSelectedIndex(); 59 if (index != -1) bundleName = ((LocalInfoDesc)content.getElementAt(index)).bundleName; 60 return bundleName; 61 } 62 63 68 private void initComponents() { 70 jPanel3 = new javax.swing.JPanel (); 71 installedCheckBox = new javax.swing.JCheckBox (); 72 shareManagerCheckBox = new javax.swing.JCheckBox (); 73 shareClientCheckBox = new javax.swing.JCheckBox (); 74 jPanel2 = new javax.swing.JPanel (); 75 jPanel4 = new javax.swing.JPanel (); 76 showButton = new javax.swing.JButton (); 77 installButton = new javax.swing.JButton (); 78 uninstallButton = new javax.swing.JButton (); 79 createBinaryBundleButton = new javax.swing.JButton (); 80 shareButton = new javax.swing.JButton (); 81 unshareBundleButton = new javax.swing.JButton (); 82 stopShareClientButton = new javax.swing.JButton (); 83 makeBundleInSharingPresentButton = new javax.swing.JButton (); 84 jPanel1 = new javax.swing.JPanel (); 85 jPanel5 = new javax.swing.JPanel (); 86 refreshButton = new javax.swing.JButton (); 87 install2Button = new javax.swing.JButton (); 88 share2Button = new javax.swing.JButton (); 89 acquireSharedBundleButton = new javax.swing.JButton (); 90 searchBundleButton = new javax.swing.JButton (); 91 createUserBundleButton = new javax.swing.JButton (); 92 createComponentBundleButton = new javax.swing.JButton (); 93 jScrollPane1 = new javax.swing.JScrollPane (); 94 contentList = new javax.swing.JList (); 95 96 setLayout(new java.awt.BorderLayout ()); 97 98 addComponentListener(new java.awt.event.ComponentAdapter () 99 { 100 public void componentShown(java.awt.event.ComponentEvent evt) 101 { 102 formComponentShown(evt); 103 } 104 }); 105 106 jPanel3.setLayout(new java.awt.GridLayout (1, 0)); 107 108 jPanel3.setBorder(new javax.swing.border.TitledBorder ("Bundle State Info")); 109 installedCheckBox.setText("Installed"); 110 installedCheckBox.setBorderPaintedFlat(true); 111 installedCheckBox.addActionListener(new java.awt.event.ActionListener () 112 { 113 public void actionPerformed(java.awt.event.ActionEvent evt) 114 { 115 CheckBoxNoChangeAction(evt); 116 } 117 }); 118 119 jPanel3.add(installedCheckBox); 120 121 shareManagerCheckBox.setText("Share Manager"); 122 shareManagerCheckBox.setBorderPaintedFlat(true); 123 shareManagerCheckBox.addActionListener(new java.awt.event.ActionListener () 124 { 125 public void actionPerformed(java.awt.event.ActionEvent evt) 126 { 127 CheckBoxNoChangeAction(evt); 128 } 129 }); 130 131 jPanel3.add(shareManagerCheckBox); 132 133 shareClientCheckBox.setText("Share Client"); 134 shareClientCheckBox.setBorderPaintedFlat(true); 135 shareClientCheckBox.addActionListener(new java.awt.event.ActionListener () 136 { 137 public void actionPerformed(java.awt.event.ActionEvent evt) 138 { 139 CheckBoxNoChangeAction(evt); 140 } 141 }); 142 143 jPanel3.add(shareClientCheckBox); 144 145 add(jPanel3, java.awt.BorderLayout.SOUTH); 146 147 jPanel2.setLayout(new java.awt.BorderLayout ()); 148 149 jPanel2.setPreferredSize(new java.awt.Dimension (200, 404)); 150 jPanel4.setLayout(new java.awt.GridLayout (8, 0)); 151 152 jPanel4.setBorder(new javax.swing.border.TitledBorder ("Local Info Specific")); 153 showButton.setText("Show Local Info"); 154 showButton.addActionListener(new java.awt.event.ActionListener () 155 { 156 public void actionPerformed(java.awt.event.ActionEvent evt) 157 { 158 showButtonActionPerformed(evt); 159 } 160 }); 161 162 jPanel4.add(showButton); 163 164 installButton.setText("Install Bundle"); 165 installButton.addActionListener(new java.awt.event.ActionListener () 166 { 167 public void actionPerformed(java.awt.event.ActionEvent evt) 168 { 169 installButtonActionPerformed(evt); 170 } 171 }); 172 173 jPanel4.add(installButton); 174 175 uninstallButton.setText("Uninstall Bundle"); 176 uninstallButton.addActionListener(new java.awt.event.ActionListener () 177 { 178 public void actionPerformed(java.awt.event.ActionEvent evt) 179 { 180 uninstallButtonActionPerformed(evt); 181 } 182 }); 183 184 jPanel4.add(uninstallButton); 185 186 createBinaryBundleButton.setText("Create Binary Bundle"); 187 createBinaryBundleButton.addActionListener(new java.awt.event.ActionListener () 188 { 189 public void actionPerformed(java.awt.event.ActionEvent evt) 190 { 191 createBinaryBundleButtonActionPerformed(evt); 192 } 193 }); 194 195 jPanel4.add(createBinaryBundleButton); 196 197 shareButton.setText("Share Bundle"); 198 shareButton.addActionListener(new java.awt.event.ActionListener () 199 { 200 public void actionPerformed(java.awt.event.ActionEvent evt) 201 { 202 shareButtonActionPerformed(evt); 203 } 204 }); 205 206 jPanel4.add(shareButton); 207 208 unshareBundleButton.setText("Unshare Bundle"); 209 unshareBundleButton.addActionListener(new java.awt.event.ActionListener () 210 { 211 public void actionPerformed(java.awt.event.ActionEvent evt) 212 { 213 unshareBundleButtonActionPerformed(evt); 214 } 215 }); 216 217 jPanel4.add(unshareBundleButton); 218 219 stopShareClientButton.setText("Stop Share Client"); 220 stopShareClientButton.addActionListener(new java.awt.event.ActionListener () 221 { 222 public void actionPerformed(java.awt.event.ActionEvent evt) 223 { 224 stopShareClientButtonActionPerformed(evt); 225 } 226 }); 227 228 jPanel4.add(stopShareClientButton); 229 230 makeBundleInSharingPresentButton.setText("Make Bundle In Sharing Present"); 231 makeBundleInSharingPresentButton.addActionListener(new java.awt.event.ActionListener () 232 { 233 public void actionPerformed(java.awt.event.ActionEvent evt) 234 { 235 makeBundleInSharingPresentButtonActionPerformed(evt); 236 } 237 }); 238 239 jPanel4.add(makeBundleInSharingPresentButton); 240 241 jPanel2.add(jPanel4, java.awt.BorderLayout.NORTH); 242 243 jPanel1.setLayout(new java.awt.BorderLayout ()); 244 245 jPanel1.setBorder(new javax.swing.border.TitledBorder ("General")); 246 jPanel5.setLayout(new java.awt.GridLayout (7, 0)); 247 248 refreshButton.setText("Refresh"); 249 refreshButton.addActionListener(new java.awt.event.ActionListener () 250 { 251 public void actionPerformed(java.awt.event.ActionEvent evt) 252 { 253 refreshButtonActionPerformed(evt); 254 } 255 }); 256 257 jPanel5.add(refreshButton); 258 259 install2Button.setText("Install Bundle"); 260 install2Button.addActionListener(new java.awt.event.ActionListener () 261 { 262 public void actionPerformed(java.awt.event.ActionEvent evt) 263 { 264 install2ButtonActionPerformed(evt); 265 } 266 }); 267 268 jPanel5.add(install2Button); 269 270 share2Button.setText("Share Bundle"); 271 share2Button.addActionListener(new java.awt.event.ActionListener () 272 { 273 public void actionPerformed(java.awt.event.ActionEvent evt) 274 { 275 share2ButtonActionPerformed(evt); 276 } 277 }); 278 279 jPanel5.add(share2Button); 280 281 acquireSharedBundleButton.setText("Acquire Shared Bundle"); 282 acquireSharedBundleButton.addActionListener(new java.awt.event.ActionListener () 283 { 284 public void actionPerformed(java.awt.event.ActionEvent evt) 285 { 286 acquireSharedBundleButtonActionPerformed(evt); 287 } 288 }); 289 290 jPanel5.add(acquireSharedBundleButton); 291 292 searchBundleButton.setText("Search Bundle"); 293 searchBundleButton.addActionListener(new java.awt.event.ActionListener () 294 { 295 public void actionPerformed(java.awt.event.ActionEvent evt) 296 { 297 searchBundleButtonActionPerformed(evt); 298 } 299 }); 300 301 jPanel5.add(searchBundleButton); 302 303 createUserBundleButton.setText("Create User Bundle"); 304 createUserBundleButton.addActionListener(new java.awt.event.ActionListener () 305 { 306 public void actionPerformed(java.awt.event.ActionEvent evt) 307 { 308 createUserBundleButtonActionPerformed(evt); 309 } 310 }); 311 312 jPanel5.add(createUserBundleButton); 313 314 createComponentBundleButton.setText("Create Component Bundle"); 315 createComponentBundleButton.addActionListener(new java.awt.event.ActionListener () 316 { 317 public void actionPerformed(java.awt.event.ActionEvent evt) 318 { 319 createComponentBundleButtonActionPerformed(evt); 320 } 321 }); 322 323 jPanel5.add(createComponentBundleButton); 324 325 jPanel1.add(jPanel5, java.awt.BorderLayout.NORTH); 326 327 jPanel2.add(jPanel1, java.awt.BorderLayout.CENTER); 328 329 add(jPanel2, java.awt.BorderLayout.EAST); 330 331 contentList.setModel(content); 332 contentList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); 333 contentList.setVisibleRowCount(-1); 334 contentList.addListSelectionListener(new javax.swing.event.ListSelectionListener () 335 { 336 public void valueChanged(javax.swing.event.ListSelectionEvent evt) 337 { 338 contentListValueChanged(evt); 339 } 340 }); 341 contentList.addMouseListener(new java.awt.event.MouseAdapter () 342 { 343 public void mouseClicked(java.awt.event.MouseEvent evt) 344 { 345 contentListMouseClicked(evt); 346 } 347 }); 348 349 jScrollPane1.setViewportView(contentList); 350 351 add(jScrollPane1, java.awt.BorderLayout.CENTER); 352 353 } 355 private void makeBundleInSharingPresentButtonActionPerformed(java.awt.event.ActionEvent evt) { String bundleName = ""; 358 boolean isShareManager = true; 359 360 int index = contentList.getSelectedIndex(); 361 if (index != -1) 362 { 363 LocalInfoDesc localInfoDesc = (LocalInfoDesc)content.getElementAt(index); 364 365 if (!localInfoDesc.isInSharing()) 366 { 367 JOptionPane.showMessageDialog(this, "Selected bundle has neither Share Manager nor Share Client active", "Warning", JOptionPane.WARNING_MESSAGE); 368 return; 369 } 370 371 bundleName = localInfoDesc.bundleName; 372 isShareManager = localInfoDesc.isShareManager(); 373 } 374 375 if (MakeBundleInSharingPresentDialog.showDialog(this, admin, bundleName, isShareManager)) reload(); 376 } 378 private void contentListMouseClicked(java.awt.event.MouseEvent evt) { if (evt.getClickCount() == 2) 381 { 382 showButton.doClick(); } 384 } 386 private void stopShareClientButtonActionPerformed(java.awt.event.ActionEvent evt) { if (StopShareClientDialog.showDialog(this, admin, getSelectedBundleName())) reload(); 389 } 391 private void unshareBundleButtonActionPerformed(java.awt.event.ActionEvent evt) { if (UnshareBundleDialog.showDialog(this, admin, getSelectedBundleName())) reload(); 394 } 396 private void shareButtonActionPerformed(java.awt.event.ActionEvent evt) { if (ShareBundleDialog.showDialog(this, admin, getSelectedBundleName())) reload(); 399 } 401 private void createComponentBundleButtonActionPerformed(java.awt.event.ActionEvent evt) { if (CreateComponentBundleDialog.showDialog(this, admin, "")) reload(); 404 } 406 private void createUserBundleButtonActionPerformed(java.awt.event.ActionEvent evt) { if (CreateUserBundleDialog.showDialog(this, admin, "", null)) reload(); 409 } 411 private void createBinaryBundleButtonActionPerformed(java.awt.event.ActionEvent evt) { if (CreateBinaryBundleDialog.showDialog(this, admin, getSelectedBundleName())) reload(); 414 } 416 private void uninstallButtonActionPerformed(java.awt.event.ActionEvent evt) { if (UninstallBundleDialog.showDialog(this, admin, getSelectedBundleName())) reload(); 419 } 421 private void installButtonActionPerformed(java.awt.event.ActionEvent evt) { if (InstallBundleDialog.showDialog(this, admin, getSelectedBundleName())) reload(); 424 } 426 private void showButtonActionPerformed(java.awt.event.ActionEvent evt) { String bundleName = getSelectedBundleName(); 429 430 if (bundleName.length() == 0) 431 { 432 JOptionPane.showMessageDialog(this, "No Local Info selected", "Warning", JOptionPane.WARNING_MESSAGE); 433 return; 434 } 435 436 LocalInfo localInfo = null; 437 BundleContent bundleContent = null; 438 try 439 { 440 localInfo = admin.getLocalInfo(bundleName); 441 if (localInfo.isInstalled()) bundleContent = admin.getInstalledBundleContent(bundleName); 442 else if (localInfo.isInSharing()) bundleContent = admin.getSharedBundleContent(bundleName); 443 } 444 catch (RemoteException e) 445 { 446 JOptionPane.showMessageDialog(this, "RMI Error occured while accessing SOFA net node:\n" + e, "Error", JOptionPane.ERROR_MESSAGE); 447 return; 448 } 449 450 if (localInfo == null) 451 { 452 JOptionPane.showMessageDialog(this, "Selected Local Info doesn't exist on the node anymore", "Error", JOptionPane.ERROR_MESSAGE); 453 return; 454 } 455 456 LocalInfoDialog.showDialog(this, localInfo, bundleContent); 457 } 459 private void searchBundleButtonActionPerformed(java.awt.event.ActionEvent evt) { SearchDialog.showDialog(this, admin); 462 reload(); 463 } 465 private void acquireSharedBundleButtonActionPerformed(java.awt.event.ActionEvent evt) { if (AcquireSharedBundleDialog.showDialog(this, admin, "", "")) reload(); 468 } 470 private void share2ButtonActionPerformed(java.awt.event.ActionEvent evt) { if (ShareBundleDialog.showDialog(this, admin, "")) reload(); 473 } 475 private void install2ButtonActionPerformed(java.awt.event.ActionEvent evt) { if (InstallBundleDialog.showDialog(this, admin, "")) reload(); 478 } 480 private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) { reload(); 483 } 485 private void formComponentShown(java.awt.event.ComponentEvent evt) { reload(); 488 } 490 private void contentListValueChanged(javax.swing.event.ListSelectionEvent evt) { int index = contentList.getSelectedIndex(); 493 LocalInfoDesc localInfoDesc = null; 494 if (index != -1) localInfoDesc = (LocalInfoDesc)content.getElementAt(index); 495 496 if (localInfoDesc != null) 497 { 498 installedCheckBox.setSelected(localInfoDesc.isInstalled()); 499 shareManagerCheckBox.setSelected(localInfoDesc.isShareManager()); 500 shareClientCheckBox.setSelected(localInfoDesc.isShareClient()); 501 } 502 else 503 { 504 installedCheckBox.setSelected(false); 505 shareManagerCheckBox.setSelected(false); 506 shareClientCheckBox.setSelected(false); 507 } 508 } 510 private void CheckBoxNoChangeAction(java.awt.event.ActionEvent evt) { JCheckBox checkBox = (JCheckBox)evt.getSource(); 513 checkBox.setSelected(!checkBox.isSelected()); 514 } 516 517 private javax.swing.JButton acquireSharedBundleButton; 519 private javax.swing.JList contentList; 520 private javax.swing.JButton createBinaryBundleButton; 521 private javax.swing.JButton createComponentBundleButton; 522 private javax.swing.JButton createUserBundleButton; 523 private javax.swing.JButton install2Button; 524 private javax.swing.JButton installButton; 525 private javax.swing.JCheckBox installedCheckBox; 526 private javax.swing.JPanel jPanel1; 527 private javax.swing.JPanel jPanel2; 528 private javax.swing.JPanel jPanel3; 529 private javax.swing.JPanel jPanel4; 530 private javax.swing.JPanel jPanel5; 531 private javax.swing.JScrollPane jScrollPane1; 532 private javax.swing.JButton makeBundleInSharingPresentButton; 533 private javax.swing.JButton refreshButton; 534 private javax.swing.JButton searchBundleButton; 535 private javax.swing.JButton share2Button; 536 private javax.swing.JButton shareButton; 537 private javax.swing.JCheckBox shareClientCheckBox; 538 private javax.swing.JCheckBox shareManagerCheckBox; 539 private javax.swing.JButton showButton; 540 private javax.swing.JButton stopShareClientButton; 541 private javax.swing.JButton uninstallButton; 542 private javax.swing.JButton unshareBundleButton; 543 545 } 546 | Popular Tags |