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.JMenu;
025: import javax.swing.JPanel;
026: import javax.swing.JPopupMenu;
027:
028: import org.apache.jmeter.gui.util.ReportMenuFactory;
029: import org.apache.jmeter.gui.util.VerticalPanel;
030: import org.apache.jmeter.testelement.TestElement;
031: import org.apache.jmeter.testelement.ReportPage;
032: import org.apache.jmeter.util.JMeterUtils;
033: import org.apache.jorphan.gui.JLabeledTextArea;
034: import org.apache.jorphan.gui.JLabeledTextField;
035:
036: /**
037: * @author Peter Lin
038: *
039: */
040: public class ReportPageGui extends AbstractReportGui {
041:
042: private JLabeledTextField pageTitle = new JLabeledTextField(
043: JMeterUtils.getResString("report_page_title"));;
044:
045: private JCheckBox makeIndex = new JCheckBox(JMeterUtils
046: .getResString("report_page_index"));
047:
048: private JLabeledTextField cssURL = new JLabeledTextField(
049: JMeterUtils.getResString("report_page_style_url"));
050:
051: private JLabeledTextField headerURL = new JLabeledTextField(
052: JMeterUtils.getResString("report_page_header"));
053:
054: private JLabeledTextField footerURL = new JLabeledTextField(
055: JMeterUtils.getResString("report_page_footer"));
056:
057: private JLabeledTextArea introduction = new JLabeledTextArea(
058: JMeterUtils.getResString("report_page_intro"));
059:
060: /**
061: *
062: */
063: public ReportPageGui() {
064: init();
065: }
066:
067: /**
068: * Initialize the components and layout of this component.
069: */
070: private 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: VerticalPanel options = new VerticalPanel(Color.white);
081: pageTitle.setBackground(Color.white);
082: makeIndex.setBackground(Color.white);
083: cssURL.setBackground(Color.white);
084: headerURL.setBackground(Color.white);
085: footerURL.setBackground(Color.white);
086: introduction.setBackground(Color.white);
087: options.add(pageTitle);
088: options.add(makeIndex);
089: options.add(cssURL);
090: options.add(headerURL);
091: options.add(footerURL);
092: options.add(introduction);
093: add(pane, BorderLayout.NORTH);
094: add(options, BorderLayout.CENTER);
095: }
096:
097: public JPopupMenu createPopupMenu() {
098: JPopupMenu pop = new JPopupMenu();
099: JMenu addMenu = new JMenu(JMeterUtils.getResString("Add"));
100: addMenu.add(ReportMenuFactory.makeMenuItem(new TableGui()
101: .getStaticLabel(), TableGui.class.getName(), "Add"));
102: addMenu.add(ReportMenuFactory.makeMenuItem(new BarChartGui()
103: .getStaticLabel(), BarChartGui.class.getName(), "Add"));
104: addMenu
105: .add(ReportMenuFactory.makeMenuItem(new LineGraphGui()
106: .getStaticLabel(),
107: LineGraphGui.class.getName(), "Add"));
108: pop.add(addMenu);
109: ReportMenuFactory.addFileMenu(pop);
110: ReportMenuFactory.addEditMenu(pop, true);
111: return pop;
112: }
113:
114: /* (non-Javadoc)
115: * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
116: */
117: public TestElement createTestElement() {
118: ReportPage element = new ReportPage();
119: modifyTestElement(element);
120: return element;
121: }
122:
123: /* (non-Javadoc)
124: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
125: */
126: public void modifyTestElement(TestElement element) {
127: super .configureTestElement(element);
128: ReportPage page = (ReportPage) element;
129: page.setCSS(cssURL.getText());
130: page.setFooterURL(footerURL.getText());
131: page.setHeaderURL(headerURL.getText());
132: page.setIndex(String.valueOf(makeIndex.isSelected()));
133: page.setIntroduction(introduction.getText());
134: page.setTitle(pageTitle.getText());
135: }
136:
137: public void configure(TestElement element) {
138: super .configure(element);
139: ReportPage page = (ReportPage) element;
140: cssURL.setText(page.getCSS());
141: footerURL.setText(page.getFooterURL());
142: headerURL.setText(page.getHeaderURL());
143: makeIndex.setSelected(page.getIndex());
144: introduction.setText(page.getIntroduction());
145: pageTitle.setText(page.getTitle());
146: }
147: }
|