001: //$Header$
002: /*
003: * Licensed to the Apache Software Foundation (ASF) under one or more
004: * contributor license agreements. See the NOTICE file distributed with
005: * this work for additional information regarding copyright ownership.
006: * The ASF licenses this file to You under the Apache License, Version 2.0
007: * (the "License"); you may not use this file except in compliance with
008: * the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: *
018: */
019: package org.apache.jmeter.report.writers.gui;
020:
021: import java.awt.BorderLayout;
022: import java.awt.Color;
023:
024: import javax.swing.JPanel;
025: import javax.swing.JPopupMenu;
026:
027: import org.apache.jmeter.gui.util.ReportFilePanel;
028: import org.apache.jmeter.gui.util.ReportMenuFactory;
029: import org.apache.jmeter.report.gui.AbstractReportGui;
030: import org.apache.jmeter.report.writers.HTMLReportWriter;
031: import org.apache.jmeter.testelement.TestElement;
032: import org.apache.jmeter.util.JMeterUtils;
033:
034: /**
035: * @author Peter Lin
036: *
037: */
038: public class HTMLReportWriterGui extends AbstractReportGui {
039:
040: ReportFilePanel outputDirectory = new ReportFilePanel(JMeterUtils
041: .getResString("report_output_directory"), "*");
042:
043: public HTMLReportWriterGui() {
044: super ();
045: init();
046: }
047:
048: public String getLabelResource() {
049: return "report_writer_html";
050: }
051:
052: public JPopupMenu createPopupMenu() {
053: JPopupMenu pop = new JPopupMenu();
054: ReportMenuFactory.addFileMenu(pop);
055: ReportMenuFactory.addEditMenu(pop, true);
056: return pop;
057: }
058:
059: /**
060: * init creates the necessary gui stuff.
061: */
062: public void init() {
063: setLayout(new BorderLayout(10, 10));
064: setBorder(makeBorder());
065: setBackground(Color.white);
066:
067: JPanel pane = new JPanel();
068: pane.setLayout(new BorderLayout(10, 10));
069: pane.setBackground(Color.white);
070: pane.add(this .getNamePanel(), BorderLayout.NORTH);
071:
072: outputDirectory.setBackground(Color.white);
073:
074: pane.add(outputDirectory, BorderLayout.SOUTH);
075: add(pane, BorderLayout.NORTH);
076: }
077:
078: /* (non-Javadoc)
079: * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
080: */
081: public TestElement createTestElement() {
082: HTMLReportWriter element = new HTMLReportWriter();
083: modifyTestElement(element);
084: return element;
085: }
086:
087: /* (non-Javadoc)
088: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(org.apache.jmeter.testelement.TestElement)
089: */
090: public void modifyTestElement(TestElement element) {
091: this .configureTestElement(element);
092: HTMLReportWriter wr = (HTMLReportWriter) element;
093: wr.setTargetDirectory(outputDirectory.getFilename());
094: }
095:
096: public void configure(TestElement element) {
097: super .configure(element);
098: HTMLReportWriter wr = (HTMLReportWriter) element;
099: outputDirectory.setFilename(wr.getTargetDirectory());
100: }
101: }
|