Source Code Cross Referenced for TestSummaryPanel.java in  » Testing » MActor » org » mactor » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » MActor » org.mactor.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * Copyright (C) Lars Ivar Almli. All rights reserved.                        *
003:         * ---------------------------------------------------------------------------*
004:         * This file is part of MActor.                                               *
005:         *                                                                            *
006:         * MActor is free software; you can redistribute it and/or modify             *
007:         * it under the terms of the GNU General Public License as published by       *
008:         * the Free Software Foundation; either version 2 of the License, or          *
009:         * (at your option) any later version.                                        *
010:         *                                                                            *
011:         * MActor is distributed in the hope that it will be useful,                  *
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
014:         * GNU General Public License for more details.                               *
015:         *                                                                            *
016:         * You should have received a copy of the GNU General Public License          *
017:         * along with MActor; if not, write to the Free Software                      *
018:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *
019:         ******************************************************************************/package org.mactor.ui;
020:
021:        import java.awt.BorderLayout;
022:        import java.awt.Component;
023:        import java.io.IOException;
024:        import javax.swing.Icon;
025:        import javax.swing.JEditorPane;
026:        import javax.swing.JPanel;
027:        import javax.swing.JScrollPane;
028:        import javax.swing.JSplitPane;
029:        import javax.swing.JTable;
030:        import javax.swing.JTextArea;
031:        import javax.swing.ListSelectionModel;
032:        import javax.swing.event.ListSelectionEvent;
033:        import javax.swing.event.ListSelectionListener;
034:        import javax.swing.table.AbstractTableModel;
035:        import javax.swing.table.DefaultTableCellRenderer;
036:        import org.mactor.framework.TestSummary;
037:        import org.mactor.framework.TestSummary.MessageInfo;
038:
039:        public class TestSummaryPanel extends JPanel {
040:            private JTable summaryTable;
041:            private JEditorPane messagePane = new JEditorPane();
042:            private JTextArea summaryText = new JTextArea(20, 10);
043:            MessageHistoryTableModel model = new MessageHistoryTableModel();
044:
045:            public TestSummaryPanel() {
046:                super (new BorderLayout());
047:                summaryTable = new JTable(model);
048:                summaryTable.getColumnModel().getColumn(0).setCellRenderer(
049:                        new MessageTableCellRendere());
050:                summaryTable
051:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
052:                // summaryTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
053:                summaryTable.getColumnModel().getColumn(0).setMaxWidth(25);
054:                JScrollPane tableSp = new JScrollPane(summaryTable);
055:                JPanel topP = new JPanel(new BorderLayout());
056:                topP.add(new JScrollPane(summaryText), BorderLayout.NORTH);
057:                topP.add(tableSp, BorderLayout.CENTER);
058:
059:                JSplitPane splitPane = new JSplitPane(
060:                        JSplitPane.VERTICAL_SPLIT, topP, new JScrollPane(
061:                                messagePane));
062:                add(splitPane, BorderLayout.CENTER);
063:                summaryTable.getSelectionModel().addListSelectionListener(
064:                        new ListSelectionListener() {
065:                            public void valueChanged(ListSelectionEvent e) {
066:                                if (e.getValueIsAdjusting())
067:                                    return;
068:                                ListSelectionModel lsm = (ListSelectionModel) e
069:                                        .getSource();
070:                                if (!lsm.isSelectionEmpty()) {
071:                                    int selectedRow = lsm
072:                                            .getMinSelectionIndex();
073:                                    MessageInfo mi = model
074:                                            .getMessageInfo(selectedRow);
075:                                    if (mi != null) {
076:                                        try {
077:                                            messagePane.setPage("file:"
078:                                                    + mi.getArchivePath());
079:                                        } catch (IOException ioe) {
080:                                            messagePane
081:                                                    .setText("Unable show the archived file '"
082:                                                            + mi
083:                                                                    .getArchivePath()
084:                                                            + "'. Error: "
085:                                                            + ioe.getMessage());
086:                                        }
087:                                    } else {
088:                                        messagePane.setText("");
089:                                    }
090:                                }
091:                            }
092:                        });
093:            }
094:
095:            public void setTestSummary(TestSummary summary) {
096:                if (summary == null) {
097:                    model.setMessageHistory(null);
098:                } else {
099:                    int row = summaryTable.getSelectedRow();
100:                    summaryText
101:                            .setText((summary.isSuccess() ? "Test completed with SUCCESS!"
102:                                    : "Test FAILED. Details: "
103:                                            + summary.getFailedMessage())
104:                                    + "\nStart time:\t"
105:                                    + GUIUtil
106:                                            .format(summary.getTestStartTime())
107:                                    + "\nEnd time:\t"
108:                                    + GUIUtil.format(summary
109:                                            .getTestCompleteTime())
110:                                    + "\nVariables:\t "
111:                                    + summary.getContextValues().toString());
112:                    MessageInfo[] h = summary.getMessageHistory();
113:                    model.setMessageHistory(h);
114:                    if (row >= 0 && h != null & row < h.length)
115:                        summaryTable.setRowSelectionInterval(row, row);
116:                }
117:            }
118:
119:            private static class MessageHistoryTableModel extends
120:                    AbstractTableModel {
121:                private static final Icon INCOMING_ICON = GUIUtil
122:                        .loadIcon("/incoming_16.PNG");
123:                private static final Icon INCOMING_RESP_ICON = GUIUtil
124:                        .loadIcon("/incoming_resp_16.PNG");
125:                private static final Icon OUTGOING_ICON = GUIUtil
126:                        .loadIcon("/outgoing_16.PNG");
127:                private static final Icon OUTGOING_RESP_ICON = GUIUtil
128:                        .loadIcon("/outgoing_resp_16.PNG");
129:                MessageInfo[] history;
130:                String[] colums = new String[] { "", "Timestamp", "Channel",
131:                        "Node" };
132:
133:                @Override
134:                public String getColumnName(int col) {
135:                    return colums[col];
136:                }
137:
138:                public void setMessageHistory(MessageInfo[] history) {
139:                    this .history = history;
140:                    super .fireTableDataChanged();
141:                }
142:
143:                public int getColumnCount() {
144:                    return colums.length;
145:                }
146:
147:                public int getRowCount() {
148:                    if (history == null)
149:                        return 0;
150:                    return history.length;
151:                }
152:
153:                public MessageInfo getMessageInfo(int row) {
154:                    if (history == null || row < 0 || row >= history.length)
155:                        return null;
156:                    return history[row];
157:                }
158:
159:                public Object getValueAt(int row, int col) {
160:                    if (history == null)
161:                        return null;
162:                    MessageInfo mi = history[row];
163:                    if (col == 0)
164:                        return getCol_0(mi);
165:                    if (col == 1)
166:                        return getCol_1(mi);
167:                    if (col == 2)
168:                        return getCol_2(mi);
169:                    if (col == 3)
170:                        return getCol_3(mi);
171:                    throw new RuntimeException("Invalid column '" + col + "'");
172:                }
173:
174:                private Object getCol_0(MessageInfo mi) {
175:                    if (mi.isIncoming()) {
176:                        if (mi.isResponse())
177:                            return INCOMING_RESP_ICON;
178:                        return INCOMING_ICON;
179:                    }
180:                    if (mi.isResponse())
181:                        return OUTGOING_RESP_ICON;
182:                    return OUTGOING_ICON;
183:                }
184:
185:                private Object getCol_1(MessageInfo mi) {
186:                    return GUIUtil.format(mi.getCreatedTime());
187:                }
188:
189:                private Object getCol_2(MessageInfo mi) {
190:                    return mi.getChannel();
191:                }
192:
193:                private Object getCol_3(MessageInfo mi) {
194:                    if (mi.getNode() == null)
195:                        return "";
196:                    return mi.getNode().getName();
197:                }
198:            }
199:
200:            public class MessageTableCellRendere extends
201:                    DefaultTableCellRenderer {
202:                public Component getTableCellRendererComponent(JTable table,
203:                        Object value, boolean isSelected, boolean hasFocus,
204:                        int row, int column) {
205:                    // super.getTableCellRendererComponent(table, value, isSelected,
206:                    // hasFocus, row, column);
207:                    if (value instanceof  Icon)
208:                        setIcon((Icon) value);
209:                    else
210:                        setIcon(null);
211:                    setText(null);
212:                    return this;
213:                }
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.