KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > reporters > gui > ResultSaverGui


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/reporters/gui/ResultSaverGui.java,v 1.4.2.1 2004/09/30 17:59:13 sebb Exp $
2
/*
3  * Copyright 2003-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.reporters.gui;
20
21 import java.awt.BorderLayout JavaDoc;
22
23 import javax.swing.Box JavaDoc;
24 import javax.swing.JCheckBox JavaDoc;
25 import javax.swing.JLabel JavaDoc;
26 import javax.swing.JPanel JavaDoc;
27 import javax.swing.JTextField JavaDoc;
28
29 import org.apache.jmeter.reporters.ResultSaver;
30 import org.apache.jmeter.processor.gui.AbstractPostProcessorGui;
31 import org.apache.jmeter.testelement.TestElement;
32 import org.apache.jmeter.util.JMeterUtils;
33 import org.apache.jorphan.util.JOrphanUtils;
34
35 /**
36  * Create a ResultSaver test element, which saves the sample information
37  * in set of files
38  *
39  * @version $Revision: 1.4.2.1 $ Last updated: $Date: 2004/09/30 17:59:13 $
40  */

41 public class ResultSaverGui extends AbstractPostProcessorGui
42 {
43    
44     private JTextField JavaDoc filename;
45     private JCheckBox JavaDoc errorsOnly;
46
47     public ResultSaverGui()
48     {
49         super();
50         init();
51     }
52
53     /**
54      * @see org.apache.jmeter.gui.JMeterGUIComponent#getStaticLabel()
55      */

56     public String JavaDoc getLabelResource()
57     {
58         return "resultsaver_title"; // $NON-NLS-1$
59
}
60     
61     /**
62      * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
63      */

64     public void configure(TestElement el)
65     {
66         super.configure(el);
67         filename.setText(el.getPropertyAsString(ResultSaver.FILENAME));
68         errorsOnly.setSelected(el.getPropertyAsBoolean(ResultSaver.ERRORS_ONLY));
69     }
70
71     /**
72      * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
73      */

74     public TestElement createTestElement()
75     {
76         ResultSaver ResultSaver = new ResultSaver();
77         modifyTestElement(ResultSaver);
78         return ResultSaver;
79     }
80
81     /**
82      * Modifies a given TestElement to mirror the data in the gui components.
83      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
84      */

85     public void modifyTestElement(TestElement te)
86     {
87         super.configureTestElement(te);
88         te.setProperty(ResultSaver.FILENAME, filename.getText());
89         te.setProperty(ResultSaver.ERRORS_ONLY,
90                 JOrphanUtils.booleanToString(errorsOnly.isSelected()));
91     }
92     
93     private void init()
94     {
95         setLayout(new BorderLayout JavaDoc());
96         setBorder(makeBorder());
97         Box JavaDoc box = Box.createVerticalBox();
98         box.add(makeTitlePanel());
99         box.add(createFilenamePanel());
100         errorsOnly =
101             new JCheckBox JavaDoc(JMeterUtils.getResString("resultsaver_errors")); // $NON-NLS-1$
102
box.add(errorsOnly);
103         add(box,BorderLayout.NORTH);
104         
105 // add(makeTitlePanel(),BorderLayout.NORTH);
106
}
107     private JPanel JavaDoc createFilenamePanel()//TODO ought to be a FileChooser ...
108
{
109         JLabel JavaDoc label =
110             new JLabel JavaDoc(JMeterUtils.getResString("resultsaver_prefix")); // $NON-NLS-1$
111

112         filename = new JTextField JavaDoc(10);
113         filename.setName(ResultSaver.FILENAME);
114         label.setLabelFor(filename);
115
116         JPanel JavaDoc filenamePanel = new JPanel JavaDoc(new BorderLayout JavaDoc(5, 0));
117         filenamePanel.add(label, BorderLayout.WEST);
118         filenamePanel.add(filename, BorderLayout.CENTER);
119         return filenamePanel;
120     }
121
122 }
123
Popular Tags