001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.jmeter.report.gui;
019:
020: import java.awt.BorderLayout;
021: import java.awt.Color;
022:
023: import javax.swing.JCheckBox;
024: import javax.swing.JPanel;
025: import javax.swing.JPopupMenu;
026: import javax.swing.event.ChangeEvent;
027: import javax.swing.event.ChangeListener;
028:
029: import org.apache.jmeter.gui.ReportGuiPackage;
030: import org.apache.jmeter.gui.util.ReportMenuFactory;
031: import org.apache.jmeter.gui.util.VerticalPanel;
032: import org.apache.jmeter.testelement.Table;
033: import org.apache.jmeter.testelement.TestElement;
034: import org.apache.jmeter.util.JMeterUtils;
035:
036: public class TableGui extends AbstractReportGui implements
037: ChangeListener {
038:
039: private JCheckBox meanCheck = new JCheckBox(JMeterUtils
040: .getResString("average"));
041: private JCheckBox medianCheck = new JCheckBox(JMeterUtils
042: .getResString("graph_results_median"));
043: private JCheckBox maxCheck = new JCheckBox(JMeterUtils
044: .getResString("aggregate_report_max"));
045: private JCheckBox minCheck = new JCheckBox(JMeterUtils
046: .getResString("aggregate_report_min"));
047: private JCheckBox responseRateCheck = new JCheckBox(JMeterUtils
048: .getResString("aggregate_report_rate"));
049: private JCheckBox transferRateCheck = new JCheckBox(JMeterUtils
050: .getResString("aggregate_report_bandwidth"));
051: private JCheckBox fiftypercentCheck = new JCheckBox(JMeterUtils
052: .getResString("monitor_label_left_middle"));
053: private JCheckBox nintypercentCheck = new JCheckBox(JMeterUtils
054: .getResString("aggregate_report_90"));
055: private JCheckBox errorRateCheck = new JCheckBox(JMeterUtils
056: .getResString("aggregate_report_error"));
057:
058: public TableGui() {
059: super ();
060: init();
061: }
062:
063: public String getLabelResource() {
064: return "report_table";
065: }
066:
067: /**
068: * Initialize the components and layout of this component.
069: */
070: protected void init() {
071: setLayout(new BorderLayout(10, 10));
072: setBorder(makeBorder());
073: setBackground(Color.white);
074:
075: JPanel pane = new JPanel();
076: pane.setLayout(new BorderLayout(10, 10));
077: pane.setBackground(Color.white);
078: pane.add(this .getNamePanel(), BorderLayout.NORTH);
079:
080: meanCheck.addChangeListener(this );
081: VerticalPanel options = new VerticalPanel(Color.white);
082: meanCheck.setBackground(Color.white);
083: medianCheck.setBackground(Color.white);
084: maxCheck.setBackground(Color.white);
085: minCheck.setBackground(Color.white);
086: responseRateCheck.setBackground(Color.white);
087: transferRateCheck.setBackground(Color.white);
088: fiftypercentCheck.setBackground(Color.white);
089: nintypercentCheck.setBackground(Color.white);
090: errorRateCheck.setBackground(Color.white);
091: options.add(meanCheck);
092: options.add(medianCheck);
093: options.add(maxCheck);
094: options.add(minCheck);
095: options.add(responseRateCheck);
096: options.add(transferRateCheck);
097: options.add(fiftypercentCheck);
098: options.add(nintypercentCheck);
099: options.add(errorRateCheck);
100:
101: add(pane, BorderLayout.NORTH);
102: add(options, BorderLayout.CENTER);
103: }
104:
105: public JPopupMenu createPopupMenu() {
106: JPopupMenu pop = new JPopupMenu();
107: ReportMenuFactory.addFileMenu(pop);
108: ReportMenuFactory.addEditMenu(pop, true);
109: return pop;
110: }
111:
112: public TestElement createTestElement() {
113: Table element = new Table();
114: modifyTestElement(element);
115: return element;
116: }
117:
118: public void modifyTestElement(TestElement element) {
119: this .configureTestElement(element);
120: Table tb = (Table) element;
121: tb.set50Percent(String.valueOf(fiftypercentCheck.isSelected()));
122: tb.set90Percent(String.valueOf(nintypercentCheck.isSelected()));
123: tb.setErrorRate(String.valueOf(errorRateCheck.isSelected()));
124: tb.setMax(String.valueOf(maxCheck.isSelected()));
125: tb.setMean(String.valueOf(meanCheck.isSelected()));
126: tb.setMedian(String.valueOf(medianCheck.isSelected()));
127: tb.setMin(String.valueOf(minCheck.isSelected()));
128: tb.setResponseRate(String.valueOf(responseRateCheck
129: .isSelected()));
130: tb.setTransferRate(String.valueOf(transferRateCheck
131: .isSelected()));
132: }
133:
134: public void configure(TestElement element) {
135: super .configure(element);
136: Table tb = (Table) element;
137: meanCheck.setSelected(tb.getMean());
138: medianCheck.setSelected(tb.getMedian());
139: maxCheck.setSelected(tb.getMax());
140: minCheck.setSelected(tb.getMin());
141: fiftypercentCheck.setSelected(tb.get50Percent());
142: nintypercentCheck.setSelected(tb.get90Percent());
143: errorRateCheck.setSelected(tb.getErrorRate());
144: responseRateCheck.setSelected(tb.getResponseRate());
145: transferRateCheck.setSelected(tb.getTransferRate());
146: }
147:
148: public void stateChanged(ChangeEvent e) {
149: modifyTestElement(ReportGuiPackage.getInstance()
150: .getCurrentElement());
151: }
152: }
|