1 19 22 23 package org.netbeans.modules.j2ee.sun.ide.j2ee; 24 25 26 import javax.swing.SwingUtilities ; 27 import java.awt.BorderLayout ; 28 import java.awt.Color ; 29 import java.awt.Component ; 30 import java.awt.Dimension ; 31 import java.awt.event.ActionEvent ; 32 import java.awt.event.ActionListener ; 33 import java.awt.event.KeyEvent ; 34 import java.io.File ; 35 import java.io.FileInputStream ; 36 import java.io.IOException ; 37 import java.io.InputStreamReader ; 38 import java.io.OutputStream ; 39 import java.io.OutputStreamWriter ; 40 import java.util.EventObject ; 41 import java.util.Vector ; 42 import javax.swing.BorderFactory ; 43 import javax.swing.BoxLayout ; 44 import javax.swing.ButtonGroup ; 45 import javax.swing.DefaultCellEditor ; 46 import javax.swing.JComponent ; 47 import javax.swing.JLabel ; 48 import javax.swing.JPanel ; 49 import javax.swing.JRadioButton ; 50 import javax.swing.JScrollBar ; 51 import javax.swing.JScrollPane ; 52 import javax.swing.JSplitPane ; 53 import javax.swing.JTable ; 54 import javax.swing.JTextArea ; 55 import javax.swing.JTextField ; 56 import javax.swing.ListSelectionModel ; 57 import javax.swing.SwingConstants ; 58 import javax.swing.event.ListSelectionEvent ; 59 import javax.swing.event.ListSelectionListener ; 60 import javax.swing.table.DefaultTableModel ; 61 import javax.swing.table.TableCellRenderer ; 62 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Appclient; 63 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Application; 64 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Connector; 65 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Ejb; 66 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Failed; 67 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.NotApplicable; 68 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Passed; 69 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.StaticVerification; 70 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Test; 71 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Warning; 72 import org.netbeans.modules.j2ee.sun.dd.impl.verifier.Web; 73 import org.openide.ErrorManager; 74 import org.openide.windows.TopComponent; 75 import org.openide.windows.WindowManager; 76 import org.openide.windows.Mode; 77 import org.openide.util.NbBundle; 78 import org.netbeans.modules.j2ee.sun.ide.j2ee.db.ExecSupport; 79 80 84 public class VerifierSupport extends TopComponent{ 85 86 87 88 String _archiveName; 89 90 91 final static int FAIL = 0; 92 final static int WARN = 1; 93 final static int ALL = 2; 94 95 static String allString = NbBundle.getMessage(VerifierSupport.class,"All_Results"); static String failString = NbBundle.getMessage(VerifierSupport.class,"Failures_Only"); static String warnString = NbBundle.getMessage(VerifierSupport.class,"Failures_and_Warnings_only"); 99 static String radioButtonName =NbBundle.getMessage(VerifierSupport.class,"Radio_Button"); static String radioButtonDesc = NbBundle.getMessage(VerifierSupport.class,"RadioButtonToSelect"); static String panelName =NbBundle.getMessage(VerifierSupport.class,"Panel"); static String panelDesc =NbBundle.getMessage(VerifierSupport.class,"VerifierPanel"); 105 106 JRadioButton allButton ; 107 JRadioButton failButton ; 108 JRadioButton warnButton ; 109 RadioListener myListener ; 110 int statusLeveltoDisplay = ALL; boolean verifierIsStillRunning = true; JPanel controlPanel ; 114 JPanel resultPanel; 115 JTable table ; 116 DefaultTableModel tableModel; 117 ListSelectionListener tableSelectionListener; 118 JScrollPane tableScrollPane; 119 JScrollPane textScrollPane; 120 JTextArea detailText; 121 122 private static String STATUS_LIT = "Status"; 124 final String [] columnNames = { 125 NbBundle.getMessage(VerifierSupport.class,STATUS_LIT), 126 NbBundle.getMessage(VerifierSupport.class,"Test_Description"), NbBundle.getMessage(VerifierSupport.class,"Result")}; private Vector passResults = new Vector (); 129 private Vector failResults = new Vector (); 130 private Vector errorResults = new Vector (); 131 private Vector warnResults = new Vector (); 132 private Vector naResults = new Vector (); 133 private Vector notImplementedResults = new Vector (); 134 private Vector notRunResults = new Vector (); 135 private Vector defaultResults = new Vector (); 136 137 138 public static void launchVerifier(final String fileName, OutputStream outs){ 139 final File f = new File (fileName); 140 final File dir = f.getParentFile(); 141 final VerifierSupport verifierSupport=new VerifierSupport(fileName); 142 143 File irf = org.netbeans.modules.j2ee.sun.api.ServerLocationManager.getLatestPlatformLocation(); 144 if (null == irf || !irf.exists()) { 145 org.netbeans.modules.j2ee.sun.ide.j2ee.ui.Util.showWarning(NbBundle.getMessage(VerifierSupport.class, "ERR_CannotFind")); return; 148 } 149 String installRoot = irf.getAbsolutePath(); 150 SwingUtilities.invokeLater( new Runnable (){ 151 public void run() { 152 verifierSupport.initUI(); 153 verifierSupport.showInMode(); 154 } 155 }); 156 157 158 try{ 159 160 String cmd = installRoot+File.separator+"bin"+File.separator+"verifier"; if (File.separatorChar != '/') { 162 cmd =cmd + ".bat"; } 164 Runtime rt = Runtime.getRuntime(); 165 String arr[] = {cmd, "-ra", "-d" , dir.getAbsolutePath(), fileName}; 167 String cmdName=""; for (int j=0;j<arr.length;j++){ 169 cmdName= cmdName+arr[j]+" "; } 171 System.out.println(NbBundle.getMessage(VerifierSupport.class,"running_", cmdName)); final Process child = rt.exec(arr); 173 174 175 final Thread [] copyMakers = new Thread [2]; 179 OutputStreamWriter oss=null; 180 if (outs!=null) { 181 oss=new OutputStreamWriter (outs); 182 } 183 (copyMakers[0] = new ExecSupport.OutputCopier(new InputStreamReader (child.getInputStream()), oss, true)).start(); 184 (copyMakers[1] = new ExecSupport.OutputCopier(new InputStreamReader (child.getErrorStream()), oss, true)).start(); 185 try { 186 child.waitFor(); 188 Thread.sleep(1000); } catch (InterruptedException e) { 190 } finally { 191 try { 192 copyMakers[0].interrupt(); 193 copyMakers[1].interrupt(); 194 } catch (Exception e) { 195 } 196 } 197 198 199 200 } catch (Exception e) { 201 202 e.printStackTrace(); 203 } 204 205 206 207 String onlyJarFile = f.getName(); 208 File ff = new File (dir, onlyJarFile+".xml"); FileInputStream in = null; 210 StaticVerification sv = null; 211 org.netbeans.modules.j2ee.sun.dd.impl.verifier.Error err = null; 212 try { 213 in = new FileInputStream (ff); 214 215 sv = StaticVerification.createGraph(in); err = sv.getError(); 217 if (err!=null){ 218 verifierSupport.saveErrorResultsForDisplay( err); 219 220 } 221 Ejb e = sv.getEjb(); 222 if (e!=null){ 223 Failed fail= e.getFailed(); 224 if (fail!=null){ 225 Test t[] =fail.getTest(); 226 for (int i=0;i<t.length ;i++){ 227 verifierSupport.saveFailResultsForDisplay( t[i]); 228 } 229 } 230 Warning w= e.getWarning(); 231 if (w!=null){ 232 Test t[] =w.getTest(); 233 for (int i=0;i<t.length ;i++){ 234 verifierSupport.saveWarnResultsForDisplay( t[i]); 235 } 236 } 237 Passed p= e.getPassed(); 238 if (p!=null){ 239 Test t[] =p.getTest(); 240 for (int i=0;i<t.length ;i++){ 241 verifierSupport.savePassResultsForDisplay(t[i]); 242 } 243 } 244 NotApplicable na= e.getNotApplicable(); 245 if (na!=null){ 246 Test t[] =na.getTest(); 247 for (int i=0;i<t.length ;i++){ 248 verifierSupport.saveNaResultsForDisplay( t[i]); 249 } 250 } 251 } 252 Web we = sv.getWeb(); 253 if (we!=null){ 254 Failed fail= we.getFailed(); 255 if (fail!=null){ 256 Test t[] =fail.getTest(); 257 for (int i=0;i<t.length ;i++){ 258 verifierSupport.saveFailResultsForDisplay(t[i]); 259 } 260 } 261 Warning w= we.getWarning(); 262 if (w!=null){ 263 Test t[] =w.getTest(); 264 for (int i=0;i<t.length ;i++){ 265 verifierSupport.saveWarnResultsForDisplay(t[i]); 266 } 267 } 268 Passed p= we.getPassed(); 269 if (p!=null){ 270 Test t[] =p.getTest(); 271 for (int i=0;i<t.length ;i++){ 272 verifierSupport.savePassResultsForDisplay(t[i]); 273 } 274 } 275 NotApplicable na= we.getNotApplicable(); 276 if (na!=null){ 277 Test t[] =na.getTest(); 278 for (int i=0;i<t.length ;i++){ 279 verifierSupport.saveNaResultsForDisplay(t[i]); 280 } 281 } 282 } 283 Appclient ac = sv.getAppclient(); 284 if (ac!=null){ 285 Failed fail= ac.getFailed(); 286 if (fail!=null){ 287 Test t[] =fail.getTest(); 288 for (int i=0;i<t.length ;i++){ 289 verifierSupport.saveFailResultsForDisplay(t[i]); 290 } 291 } 292 Warning w= ac.getWarning(); 293 if (w!=null){ 294 Test t[] =w.getTest(); 295 for (int i=0;i<t.length ;i++){ 296 verifierSupport.saveWarnResultsForDisplay(t[i]); 297 } 298 } 299 Passed p= ac.getPassed(); 300 if (p!=null){ 301 Test t[] =p.getTest(); 302 for (int i=0;i<t.length ;i++){ 303 verifierSupport.savePassResultsForDisplay(t[i]); 304 } 305 } 306 NotApplicable na= ac.getNotApplicable(); 307 if (na!=null){ 308 Test t[] =na.getTest(); 309 for (int i=0;i<t.length ;i++){ 310 verifierSupport.saveNaResultsForDisplay(t[i]); 311 } 312 } 313 } 314 Application app = sv.getApplication(); 315 if (app!=null){ 316 Failed fail= app.getFailed(); 317 if (fail!=null){ 318 Test t[] =fail.getTest(); 319 for (int i=0;i<t.length ;i++){ 320 verifierSupport.saveFailResultsForDisplay(t[i]); 321 } 322 } 323 Warning w= app.getWarning(); 324 if (w!=null){ 325 Test t[] =w.getTest(); 326 for (int i=0;i<t.length ;i++){ 327 verifierSupport.saveWarnResultsForDisplay(t[i]); 328 } 329 } 330 Passed p= app.getPassed(); 331 if (p!=null){ 332 Test t[] =p.getTest(); 333 for (int i=0;i<t.length ;i++){ 334 verifierSupport.savePassResultsForDisplay(t[i]); 335 } 336 } 337 NotApplicable na= app.getNotApplicable(); 338 if (na!=null){ 339 Test t[] =na.getTest(); 340 for (int i=0;i<t.length ;i++){ 341 verifierSupport.saveNaResultsForDisplay(t[i]); 342 } 343 } 344 } 345 Connector rar = sv.getConnector(); 346 if (rar!=null){ 347 Failed fail= rar.getFailed(); 348 if (fail!=null){ 349 Test t[] =fail.getTest(); 350 for (int i=0;i<t.length ;i++){ 351 verifierSupport.saveFailResultsForDisplay(t[i]); 352 } 353 } 354 Warning w= rar.getWarning(); 355 if (w!=null){ 356 Test t[] =w.getTest(); 357 for (int i=0;i<t.length ;i++){ 358 verifierSupport.saveWarnResultsForDisplay(t[i]); 359 } 360 } 361 Passed p= rar.getPassed(); 362 if (p!=null){ 363 Test t[] =p.getTest(); 364 for (int i=0;i<t.length ;i++){ 365 verifierSupport.savePassResultsForDisplay(t[i]); 366 } 367 } 368 NotApplicable na= rar.getNotApplicable(); 369 if (na!=null){ 370 Test t[] =na.getTest(); 371 for (int i=0;i<t.length ;i++){ 372 verifierSupport.saveNaResultsForDisplay(t[i]); 373 } 374 } 375 } 376 } catch (RuntimeException rte) { 380 err = StaticVerification.createGraph().newError(); 381 err.setErrorName(NbBundle.getMessage(VerifierSupport.class,"ERR_PARSING_OUTPUT")); err.setErrorDescription(rte.getMessage()); 383 if (rte.getMessage().indexOf("error-name") > -1) { 384 err.setErrorDescription(NbBundle.getMessage(VerifierSupport.class,"READ_OUTPUT_WINDOW")); } 388 verifierSupport.saveErrorResultsForDisplay( err); 389 } catch (IOException ioe){ 390 ioe.printStackTrace(); 391 err = StaticVerification.createGraph().newError(); 392 err.setErrorName(NbBundle.getMessage(VerifierSupport.class,"ERR_PARSING_OUTPUT")); err.setErrorDescription(ioe.getMessage()); 394 verifierSupport.saveErrorResultsForDisplay( err); 395 } finally { 396 if (null != in) { 397 try { 398 in.close(); 399 } catch (IOException ioe) { 400 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, 402 ioe); 403 } 404 } 405 } 406 verifierSupport.verifierIsStillRunning = false; verifierSupport.updateDisplay(); 408 } 409 410 411 412 413 414 public VerifierSupport(String archiveName) { 415 _archiveName = archiveName; 416 } 417 418 419 public void initUI(){ 420 setLayout(new BorderLayout ()); 421 setName(NbBundle.getMessage(VerifierSupport.class,"LBL_Verifier", new File (_archiveName).getName())); 423 CreateResultsPanel(); 424 add(resultPanel); 425 426 } 427 public void componentActivated() { 428 super.componentActivated(); 429 } 430 431 432 437 protected void componentOpened() { 438 } 439 440 441 442 protected void componentClosed() { 443 clearResults(); 444 table.getSelectionModel().removeListSelectionListener(tableSelectionListener); 445 446 allButton.removeActionListener(myListener); 447 failButton.removeActionListener(myListener); 448 warnButton.removeActionListener(myListener); 449 remove(resultPanel); 450 resultPanel =null; 451 table=null; 452 allButton = null; 453 failButton = null; 454 warnButton=null; 455 myListener =null; 456 tableSelectionListener = null; 457 } 458 459 protected void componentDeactivated() { 460 super.componentDeactivated(); 461 462 } 463 public int getPersistenceType() { 464 return TopComponent.PERSISTENCE_NEVER; 465 } 466 469 public void showInMode() { 470 if (!isOpened()) { 471 Mode mode = WindowManager.getDefault().findMode("output"); if (mode != null) { 473 mode.dockInto(this); 474 } 475 } 476 open(); 477 requestVisible(); 478 requestActive(); 479 480 481 } 482 protected String preferredID() { 483 return NbBundle.getMessage(VerifierSupport.class,"verifierID"); } 485 486 487 488 489 public void CreateResultsPanel() { 490 resultPanel = new JPanel (); 491 resultPanel.setLayout(new BorderLayout ()); 492 resultPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), 493 _archiveName)); 494 495 resultPanel.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Panel")); resultPanel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_panel")); 499 500 tableModel = new DefaultTableModel (columnNames, 0); 502 table = new JTable (tableModel) { 503 public Component prepareRenderer(TableCellRenderer renderer, 504 int rowIndex, int vColIndex) { 505 Component c = super.prepareRenderer(renderer, rowIndex, vColIndex); 506 if (c instanceof JComponent ) { 507 JComponent jc = (JComponent )c; 508 jc.setToolTipText((String )getValueAt(rowIndex, vColIndex)); 509 } 510 return c; 511 } 512 }; 513 514 515 table.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Table")); table.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_table_of_items")); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 519 tableScrollPane = new JScrollPane (table); 520 Object [] row = {NbBundle.getMessage(VerifierSupport.class,"Wait"),NbBundle.getMessage(VerifierSupport.class,"Running_Verifier_Tool..."),NbBundle.getMessage(VerifierSupport.class,"Running...") }; tableModel.addRow(row); 522 table.sizeColumnsToFit(0); 523 tableScrollPane.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Scroll_Pane")); tableScrollPane.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(VerifierSupport.class,"ScrollArea")); sizeTableColumns(); 527 JTextField field = new JTextField (); 529 field.getAccessibleContext().setAccessibleName( 531 NbBundle.getMessage(VerifierSupport.class,"Text_Field")); field.getAccessibleContext().setAccessibleDescription( 533 NbBundle.getMessage(VerifierSupport.class,"This_is_a_text_field")); table.setDefaultEditor(Object .class, new DefaultCellEditor (field) { 535 public boolean isCellEditable(EventObject anEvent) { 536 return false; 537 } 538 }); 539 tableSelectionListener = new ListSelectionListener () { 541 public void valueChanged(ListSelectionEvent e){ 542 if (!e.getValueIsAdjusting()){ 543 if(table.getSelectionModel().isSelectedIndex(e.getLastIndex())){ 545 setDetailText( table.getModel().getValueAt(e.getLastIndex(),1)+ 546 "\n"+table.getModel().getValueAt(e.getLastIndex(),2)); }else if(table.getSelectionModel().isSelectedIndex(e.getFirstIndex())){ 548 setDetailText(table.getModel().getValueAt(e.getFirstIndex(),1)+ 549 "\n"+table.getModel().getValueAt(e.getFirstIndex(),2)); } 551 } 552 } 553 }; 554 table.getSelectionModel().addListSelectionListener(tableSelectionListener); 555 556 detailText = new JTextArea (4,50); 558 detailText.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Text_Area")); detailText.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"This_is_a_text_area")); detailText.setEditable(false); 562 textScrollPane = new JScrollPane (detailText); 563 textScrollPane.getAccessibleContext().setAccessibleName( NbBundle.getMessage(VerifierSupport.class,"Scroll_Pane")); textScrollPane.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage(VerifierSupport.class,"ScrollListPane")); textScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), NbBundle.getMessage(VerifierSupport.class,"Detail:"))); 568 CreateControlPanel(); 570 571 JSplitPane splitPane = new JSplitPane (JSplitPane.VERTICAL_SPLIT, 573 tableScrollPane, textScrollPane); 574 splitPane.setOneTouchExpandable(true); 575 splitPane.setDividerLocation(150); 576 577 Dimension minimumSize = new Dimension (100, 50); 579 tableScrollPane.setMinimumSize(minimumSize); 580 textScrollPane.setMinimumSize(minimumSize); 581 582 583 584 585 resultPanel.add("North", controlPanel); resultPanel.add("Center", splitPane); 588 } 589 590 class RadioListener implements ActionListener { 591 public void actionPerformed(ActionEvent e) { 592 if (verifierIsStillRunning==true){ 593 if(e.getSource() == allButton){ 594 statusLeveltoDisplay = ALL; 595 } 596 if(e.getSource() == failButton){ 597 statusLeveltoDisplay = FAIL; 598 599 } 600 601 if(e.getSource() == warnButton){ 602 statusLeveltoDisplay = WARN; 603 } 604 605 return; } 607 if(e.getSource() == allButton){ 608 statusLeveltoDisplay = ALL; 609 if ((getPassResultsForDisplay().size() > 0) || 610 (getFailResultsForDisplay().size() > 0) || 611 (getErrorResultsForDisplay().size() > 0) || 612 (getWarnResultsForDisplay().size() > 0) || 613 (getNaResultsForDisplay().size() > 0) || 614 (getNotImplementedResultsForDisplay().size() > 0) || 615 (getNotRunResultsForDisplay().size() > 0) || 616 (getDefaultResultsForDisplay().size() > 0)) { 617 updateDisplay(); 618 } else { 619 clearResults(); 620 } 621 } 622 if(e.getSource() == failButton){ 623 statusLeveltoDisplay = FAIL; 624 if (getFailResultsForDisplay().size() > 0 || getErrorResultsForDisplay().size() > 0) { 625 updateDisplay(); 626 } else { 627 clearResults(); 628 } 629 } 630 if(e.getSource() == warnButton){ 631 statusLeveltoDisplay = WARN; 632 if ((getFailResultsForDisplay().size() > 0) || 633 (getErrorResultsForDisplay().size() > 0) || 634 (getWarnResultsForDisplay().size() > 0)) { 635 updateDisplay(); 636 } else { 637 clearResults(); 638 } 639 } 640 } 641 } 642 643 public void setDetailText(String details) { 644 detailText.setText(details); 645 JScrollBar scrollBar = textScrollPane.getVerticalScrollBar(); 646 if (scrollBar != null){ 647 scrollBar.setValue(0); 648 } 649 } 650 651 652 public void clearResults() { 653 tableModel = new DefaultTableModel (columnNames, 0); 655 table.setModel(tableModel); 656 sizeTableColumns(); 657 setDetailText(""); 659 } 662 663 664 void sizeTableColumns() { 665 table.getColumn( NbBundle.getMessage(VerifierSupport.class,STATUS_LIT)).setMinWidth(30); 666 table.getColumn(NbBundle.getMessage(VerifierSupport.class,STATUS_LIT)).setMaxWidth(100); 667 table.getColumn( NbBundle.getMessage(VerifierSupport.class,STATUS_LIT)).setPreferredWidth(180); 668 table.getColumn(NbBundle.getMessage(VerifierSupport.class,"Test_Description")).setMinWidth(150); table.getColumn( NbBundle.getMessage(VerifierSupport.class,"Test_Description")).setPreferredWidth(180); table.getColumn( NbBundle.getMessage(VerifierSupport.class,"Result")).setMinWidth(120); table.getColumn( NbBundle.getMessage(VerifierSupport.class,"Result")).setPreferredWidth(160); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 674 table.sizeColumnsToFit(0); 675 } 676 677 678 679 688 689 690 691 694 public void CreateControlPanel() { 695 allButton = new JRadioButton (); org.openide.awt.Mnemonics.setLocalizedText(allButton, allString); failButton = new JRadioButton (); org.openide.awt.Mnemonics.setLocalizedText(failButton, failString); warnButton = new JRadioButton (); org.openide.awt.Mnemonics.setLocalizedText(warnButton, warnString); controlPanel = new JPanel (); 702 703 controlPanel.getAccessibleContext().setAccessibleName(panelName); 705 controlPanel.getAccessibleContext().setAccessibleDescription(panelDesc); 706 allButton.getAccessibleContext().setAccessibleName(radioButtonName); 707 allButton.getAccessibleContext().setAccessibleDescription(radioButtonDesc); 708 failButton.getAccessibleContext().setAccessibleName(radioButtonName); 709 failButton.getAccessibleContext().setAccessibleDescription(radioButtonDesc); 710 warnButton.getAccessibleContext().setAccessibleName(radioButtonName); 711 warnButton.getAccessibleContext().setAccessibleDescription(radioButtonDesc); 712 713 controlPanel.setLayout(new BoxLayout (controlPanel, BoxLayout.Y_AXIS)); 717 718 719 720 allButton.setActionCommand(allString); 722 allButton.setSelected(true); 724 failButton.setActionCommand(failString); 725 727 warnButton.setActionCommand(warnString); 728 730 ButtonGroup group = new ButtonGroup (); 732 group.add(allButton); 733 group.add(failButton); 734 group.add(warnButton); 735 736 737 JPanel radioPanel = new JPanel (); 739 radioPanel.getAccessibleContext().setAccessibleName(panelName); 741 radioPanel.getAccessibleContext().setAccessibleDescription(panelDesc); 742 radioPanel.setLayout(new BoxLayout (radioPanel, BoxLayout.X_AXIS)); 743 JLabel d = new JLabel ( 744 NbBundle.getMessage(VerifierSupport.class,"DisplayLabel")); d.setVerticalAlignment(SwingConstants.BOTTOM); 746 d.getAccessibleContext().setAccessibleName( 748 NbBundle.getMessage(VerifierSupport.class,"Label")); d.getAccessibleContext().setAccessibleDescription( 750 NbBundle.getMessage(VerifierSupport.class,"This_is_a_label")); radioPanel.add(d); 752 radioPanel.add(allButton); 753 radioPanel.add(failButton); 754 radioPanel.add(warnButton); 755 756 757 758 759 761 controlPanel.add(radioPanel); 762 763 764 myListener = new RadioListener(); 766 allButton.addActionListener(myListener); 767 failButton.addActionListener(myListener); 768 warnButton.addActionListener(myListener); 769 } 770 771 772 773 private void updateTableRows(String type, Vector results) { 774 for (int i = 0; i < results.size(); i++) { 777 Test t = ((Test)results.elementAt(i)); 778 Object [] row = {type, t.getTestAssertion(), t.getTestDescription() }; 779 tableModel.addRow(row); 780 781 } table.sizeColumnsToFit(0); 783 } 784 private void updateDisplayAll(){ 785 updateDisplayFail(); 786 updateDisplayWarn(); 787 updateDisplayPass(); 788 updateDisplayNa(); 789 updateDisplayNotImplemented(); 790 updateDisplayNotRun(); 791 updateDisplayDefault(); 792 updateDisplayError(); 793 } 794 private void updateDisplayPass(){ 795 updateTableRows(NbBundle.getMessage(VerifierSupport.class,"Pass"),getPassResultsForDisplay()); } 797 798 private void updateDisplayFail(){ 799 updateTableRows(NbBundle.getMessage(VerifierSupport.class,"Fail"),getFailResultsForDisplay()); } 801 802 private void updateDisplayError(){ 803 Vector errors = getErrorResultsForDisplay(); 804 for (int i = 0; i < errors.size(); i++) { 805 org.netbeans.modules.j2ee.sun.dd.impl.verifier.Error t = ((org.netbeans.modules.j2ee.sun.dd.impl.verifier.Error)errors.elementAt(i)); 806 Object [] row = {NbBundle.getMessage(VerifierSupport.class,"Error"), t.getErrorName(),t.getErrorDescription() }; 808 tableModel.addRow(row); 809 810 } 811 table.sizeColumnsToFit(0); 812 } 813 814 private void updateDisplayWarn(){ 815 updateTableRows(NbBundle.getMessage(VerifierSupport.class,"Warning"),getWarnResultsForDisplay()); } 817 818 private void updateDisplayNa(){ 819 updateTableRows(NbBundle.getMessage(VerifierSupport.class,"Not_Applicable"),getNaResultsForDisplay()); } 821 822 private void updateDisplayNotImplemented(){ 823 updateTableRows(NbBundle.getMessage(VerifierSupport.class,"Not_Implemented"),getNotImplementedResultsForDisplay()); } 825 826 private void updateDisplayNotRun(){ 827 updateTableRows(NbBundle.getMessage(VerifierSupport.class,"Not_Run"),getNotRunResultsForDisplay()); } 829 830 private void updateDisplayDefault(){ 831 updateTableRows("???",getDefaultResultsForDisplay()); } 833 834 842 843 public void updateDisplay(){ 844 clearResults(); 846 if (statusLeveltoDisplay == ALL){ 847 updateDisplayAll(); 848 } 849 if (statusLeveltoDisplay == FAIL){ 850 updateDisplayError(); 851 updateDisplayFail(); 852 } 853 if (statusLeveltoDisplay == WARN){ 854 updateDisplayError(); 855 updateDisplayFail(); 856 updateDisplayWarn(); 857 } 858 } 859 860 private void savePassResultsForDisplay(Test r){ 861 passResults.addElement(r); 862 } 863 864 private void saveWarnResultsForDisplay(Test r){ 865 warnResults.addElement(r); 866 } 867 868 private void saveFailResultsForDisplay(Test r){ 869 failResults.addElement(r); 870 } 871 872 public void saveErrorResultsForDisplay(org.netbeans.modules.j2ee.sun.dd.impl.verifier.Error r){ 873 errorResults.addElement(r); 874 } 875 876 private void saveNaResultsForDisplay(Test r){ 877 naResults.addElement(r); 878 } 879 880 private Vector getPassResultsForDisplay(){ 881 return passResults; 882 } 883 884 private Vector getWarnResultsForDisplay(){ 885 return warnResults; 886 } 887 888 private Vector getFailResultsForDisplay(){ 889 return failResults; 890 } 891 892 private Vector getErrorResultsForDisplay(){ 893 return errorResults; 894 } 895 896 private Vector getNaResultsForDisplay(){ 897 return naResults; 898 } 899 900 private Vector getNotImplementedResultsForDisplay(){ 901 return notImplementedResults; 902 } 903 904 private Vector getNotRunResultsForDisplay(){ 905 return notRunResults; 906 } 907 908 private Vector getDefaultResultsForDisplay(){ 909 return defaultResults; 910 } 911 912 924 925 926 } 927 928 929 | Popular Tags |