1 /* 2 * $Id$ 3 * 4 * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. 5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 * 7 * This code is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License version 2 only, as 9 * published by the Free Software Foundation. Oracle designates this 10 * particular file as subject to the "Classpath" exception as provided 11 * by Oracle in the LICENSE file that accompanied this code. 12 * 13 * This code is distributed in the hope that it will be useful, but WITHOUT 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16 * version 2 for more details (a copy is included in the LICENSE file that 17 * accompanied this code). 18 * 19 * You should have received a copy of the GNU General Public License version 20 * 2 along with this work; if not, write to the Free Software Foundation, 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 * 23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 24 * or visit www.oracle.com if you need additional information or have any 25 * questions. 26 */ 27 package com.sun.javatest.exec; 28 29 import java.awt.EventQueue; 30 import java.util.Enumeration; 31 import com.sun.javatest.tool.jthelp.ContextHelpManager; 32 import com.sun.javatest.TestResult; 33 import com.sun.javatest.tool.UIFactory; 34 35 /** 36 * A subpanel of TestPanel that displays the test result properties. 37 */ 38 39 class TP_ResultsSubpanel 40 extends TP_PropertySubpanel 41 { 42 43 TP_ResultsSubpanel(UIFactory uif) { 44 super(uif, "rslt"); 45 ContextHelpManager.setHelpIDString(this, "browse.resultPropertiesTab.csh"); 46 } 47 48 protected synchronized void updateSubpanel(TestResult currTest) { 49 if (subpanelTest != null) 50 subpanelTest.removeObserver(observer); 51 52 super.updateSubpanel(currTest); 53 updateEntries(); 54 55 // if it is mutable, track updates 56 if (subpanelTest.isMutable()) { 57 subpanelTest.addObserver(observer); 58 } 59 } 60 61 private void updateEntries() { 62 for (Enumeration e = subpanelTest.getPropertyNames(); e.hasMoreElements(); ) { 63 try { 64 String key = (String)(e.nextElement()); 65 String val = subpanelTest.getProperty(key); 66 updateEntry(key, val); 67 } 68 catch (TestResult.Fault f) { 69 } 70 } 71 } 72 73 private void updateEntriesLater(final TestResult tr) { 74 if (tr == subpanelTest) { 75 if (EventQueue.isDispatchThread()) 76 updateEntries(); 77 else { 78 EventQueue.invokeLater(new Runnable() { 79 public void run() { 80 if (tr == subpanelTest) 81 updateEntries(); 82 } 83 }); 84 } 85 } 86 } 87 88 private void updateEntryLater(final TestResult tr, final String name, final String value) { 89 if (tr == subpanelTest) { 90 if (EventQueue.isDispatchThread()) 91 updateEntry(name, value); 92 else { 93 EventQueue.invokeLater(new Runnable() { 94 public void run() { 95 if (tr == subpanelTest) 96 updateEntry(name, value); 97 } 98 }); 99 } 100 } 101 } 102 103 private TRObserver observer = new TRObserver(); 104 105 //------------------------------------------------------------------------------------ 106 107 private class TRObserver 108 implements TestResult.Observer 109 { 110 public void completed(TestResult tr) { 111 updateEntriesLater(tr); 112 tr.removeObserver(this); 113 } 114 115 public void createdSection(TestResult tr, TestResult.Section section) { 116 } 117 118 public void completedSection(TestResult tr, TestResult.Section section) { 119 } 120 121 public void createdOutput(TestResult tr, TestResult.Section section, 122 String outputName) { 123 } 124 125 public void completedOutput(TestResult tr, TestResult.Section section, 126 String outputName) { 127 } 128 129 public void updatedOutput(TestResult tr, TestResult.Section section, 130 String outputName, 131 int start, int end, String text) { 132 } 133 134 public void updatedProperty(TestResult tr, String name, String value) { 135 updateEntryLater(tr, name, value); 136 } 137 } 138 139 } 140