Source Code Cross Referenced for StatisticsDesktopPanel.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » panels » loadtest » 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 » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl.panels.loadtest 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl.panels.loadtest;
014:
015:        import java.awt.Color;
016:        import java.awt.Component;
017:        import java.awt.Dimension;
018:        import java.awt.event.ItemEvent;
019:        import java.awt.event.ItemListener;
020:        import java.beans.PropertyChangeEvent;
021:        import java.beans.PropertyChangeListener;
022:
023:        import javax.swing.AbstractListModel;
024:        import javax.swing.ComboBoxModel;
025:        import javax.swing.DefaultListCellRenderer;
026:        import javax.swing.JButton;
027:        import javax.swing.JComboBox;
028:        import javax.swing.JComponent;
029:        import javax.swing.JLabel;
030:        import javax.swing.JList;
031:        import javax.swing.JPanel;
032:        import javax.swing.JScrollPane;
033:        import javax.swing.ScrollPaneConstants;
034:
035:        import com.eviware.soapui.impl.wsdl.actions.support.ShowOnlineHelpAction;
036:        import com.eviware.soapui.impl.wsdl.loadtest.WsdlLoadTest;
037:        import com.eviware.soapui.impl.wsdl.loadtest.data.actions.ExportStatisticsHistoryAction;
038:        import com.eviware.soapui.impl.wsdl.support.HelpUrls;
039:        import com.eviware.soapui.model.support.TestSuiteListenerAdapter;
040:        import com.eviware.soapui.model.testsuite.TestStep;
041:        import com.eviware.soapui.support.UISupport;
042:        import com.eviware.soapui.support.components.JXToolBar;
043:        import com.eviware.soapui.ui.support.DefaultDesktopPanel;
044:
045:        /**
046:         * DesktopPanel for Statistics Graphs
047:         * 
048:         * @author Ole.Matzura
049:         */
050:
051:        public class StatisticsDesktopPanel extends DefaultDesktopPanel {
052:            private JPanel panel;
053:            private final WsdlLoadTest loadTest;
054:            private JStatisticsGraph statisticsGraph;
055:            private JButton exportButton;
056:            private SelectStepComboBoxModel selectStepComboBoxModel;
057:            private InternalPropertyChangeListener propertyChangeListener = new InternalPropertyChangeListener();
058:            private JComboBox resolutionCombo;
059:
060:            public StatisticsDesktopPanel(WsdlLoadTest loadTest) {
061:                super ("Statistics for [" + loadTest.getName() + "]", null, null);
062:                this .loadTest = loadTest;
063:
064:                loadTest.addPropertyChangeListener(propertyChangeListener);
065:
066:                buildUI();
067:            }
068:
069:            private void buildUI() {
070:                statisticsGraph = new JStatisticsGraph(loadTest);
071:
072:                JScrollPane scrollPane = new JScrollPane(statisticsGraph);
073:                scrollPane.getViewport().setBackground(Color.WHITE);
074:                scrollPane
075:                        .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
076:
077:                panel = UISupport
078:                        .buildPanelWithToolbarAndStatusBar(buildToolbar(),
079:                                scrollPane, statisticsGraph.getLegend());
080:                panel.setPreferredSize(new Dimension(600, 400));
081:            }
082:
083:            private JComponent buildToolbar() {
084:                exportButton = UISupport
085:                        .createToolbarButton(new ExportStatisticsHistoryAction(
086:                                statisticsGraph));
087:
088:                JXToolBar toolbar = UISupport.createToolbar();
089:
090:                toolbar.addSpace(5);
091:                toolbar.addLabeledFixed("Select Step:", buildSelectStepCombo());
092:                toolbar.addUnrelatedGap();
093:                toolbar.addLabeledFixed("Resolution:", buildResolutionCombo());
094:                toolbar.addGlue();
095:                toolbar.addFixed(exportButton);
096:                toolbar.addFixed(UISupport
097:                        .createToolbarButton(new ShowOnlineHelpAction(
098:                                HelpUrls.STATISTICSGRAPH_HELP_URL)));
099:
100:                return toolbar;
101:            }
102:
103:            private JComponent buildResolutionCombo() {
104:                resolutionCombo = new JComboBox(new String[] { "data", "250",
105:                        "500", "1000" });
106:                resolutionCombo.setEditable(true);
107:                resolutionCombo
108:                        .setToolTipText("Sets update interval of graph in milliseconds");
109:                long resolution = statisticsGraph.getResolution();
110:                resolutionCombo.setSelectedItem(resolution == 0 ? "data"
111:                        : String.valueOf(resolution));
112:                resolutionCombo.addItemListener(new ItemListener() {
113:
114:                    public void itemStateChanged(ItemEvent e) {
115:                        try {
116:                            String value = resolutionCombo.getSelectedItem()
117:                                    .toString();
118:                            long resolution = value.equals("data") ? 0 : Long
119:                                    .parseLong(value);
120:                            if (resolution != statisticsGraph.getResolution()) {
121:                                statisticsGraph.setResolution(resolution);
122:                            }
123:                        } catch (Exception ex) {
124:                            long resolution = statisticsGraph.getResolution();
125:                            resolutionCombo
126:                                    .setSelectedItem(resolution == 0 ? "data"
127:                                            : String.valueOf(resolution));
128:                        }
129:                    }
130:                });
131:                return resolutionCombo;
132:            }
133:
134:            private JComponent buildSelectStepCombo() {
135:                selectStepComboBoxModel = new SelectStepComboBoxModel();
136:                JComboBox selectStepCombo = new JComboBox(
137:                        selectStepComboBoxModel);
138:                selectStepCombo.setRenderer(new TestStepCellRenderer());
139:                return selectStepCombo;
140:            }
141:
142:            public JComponent getComponent() {
143:                return panel;
144:            }
145:
146:            private final class InternalPropertyChangeListener implements 
147:                    PropertyChangeListener {
148:                public void propertyChange(PropertyChangeEvent evt) {
149:                    if (evt.getPropertyName()
150:                            .equals(WsdlLoadTest.NAME_PROPERTY)) {
151:                        setTitle("Statistics for [" + loadTest.getName() + "]");
152:                    }
153:                }
154:            }
155:
156:            private class SelectStepComboBoxModel extends AbstractListModel
157:                    implements  ComboBoxModel {
158:                private TestStep selectedStep;
159:                private InternalTestSuiteListener testSuiteListener = new InternalTestSuiteListener();
160:
161:                public SelectStepComboBoxModel() {
162:                    loadTest.getTestCase().getTestSuite().addTestSuiteListener(
163:                            testSuiteListener);
164:                }
165:
166:                public void setSelectedItem(Object anItem) {
167:                    if (anItem == selectedStep)
168:                        return;
169:
170:                    if (anItem == null || anItem.equals("Total"))
171:                        selectedStep = null;
172:
173:                    if (anItem instanceof  TestStep) {
174:                        selectedStep = (TestStep) anItem;
175:                    }
176:
177:                    statisticsGraph.setTestStep(selectedStep);
178:                }
179:
180:                public Object getSelectedItem() {
181:                    return selectedStep == null ? "Total" : selectedStep;
182:                }
183:
184:                public int getSize() {
185:                    return loadTest.getTestCase().getTestStepCount() + 1;
186:                }
187:
188:                public Object getElementAt(int index) {
189:                    return index == getSize() - 1 ? "Total" : loadTest
190:                            .getTestCase().getTestStepAt(index);
191:                }
192:
193:                private final class InternalTestSuiteListener extends
194:                        TestSuiteListenerAdapter {
195:                    public void testStepAdded(TestStep testStep, int index) {
196:                        if (testStep.getTestCase() == loadTest.getTestCase()) {
197:                            fireIntervalAdded(SelectStepComboBoxModel.this ,
198:                                    index, index);
199:                        }
200:                    }
201:
202:                    public void testStepRemoved(TestStep testStep, int index) {
203:                        if (testStep.getTestCase() == loadTest.getTestCase()) {
204:                            if (selectedStep == testStep) {
205:                                setSelectedItem(null);
206:                                fireContentsChanged(
207:                                        SelectStepComboBoxModel.this , -1, -1);
208:                            }
209:
210:                            fireIntervalRemoved(SelectStepComboBoxModel.this ,
211:                                    index, index);
212:                        }
213:                    }
214:                }
215:
216:                public void release() {
217:                    loadTest.getTestCase().getTestSuite()
218:                            .removeTestSuiteListener(testSuiteListener);
219:                }
220:            }
221:
222:            private final static class TestStepCellRenderer extends
223:                    DefaultListCellRenderer {
224:                public Component getListCellRendererComponent(JList list,
225:                        Object value, int index, boolean isSelected,
226:                        boolean cellHasFocus) {
227:                    JLabel label = (JLabel) super .getListCellRendererComponent(
228:                            list, value, index, isSelected, cellHasFocus);
229:
230:                    if (value instanceof  TestStep)
231:                        label.setText(((TestStep) value).getName());
232:
233:                    return label;
234:                }
235:            }
236:
237:            public boolean onClose(boolean canCancel) {
238:                selectStepComboBoxModel.release();
239:                loadTest.removePropertyChangeListener(propertyChangeListener);
240:                statisticsGraph.release();
241:
242:                return super.onClose(canCancel);
243:            }
244:        }
w___w___w___.___j__a__va__2___s___.__c___o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.