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.Color;
021: import java.awt.Component;
022: import java.awt.Container;
023: import java.awt.Font;
024: import java.util.Arrays;
025: import java.util.Collection;
026:
027: import javax.swing.JLabel;
028: import javax.swing.JMenu;
029: import javax.swing.JPopupMenu;
030:
031: import org.apache.jmeter.gui.AbstractJMeterGuiComponent;
032: import org.apache.jmeter.gui.NamePanel;
033: import org.apache.jmeter.gui.util.ReportMenuFactory;
034: import org.apache.jmeter.gui.util.VerticalPanel;
035: import org.apache.jmeter.testelement.TestElement;
036: import org.apache.jmeter.util.JMeterUtils;
037:
038: /**
039: *
040: * This is the abstract base for report gui's
041: */
042: public abstract class AbstractReportGui extends
043: AbstractJMeterGuiComponent {
044: /**
045: *
046: */
047: public AbstractReportGui() {
048: this .namePanel = new NamePanel();
049: this .namePanel.setBackground(Color.white);
050: setName(getStaticLabel());
051: }
052:
053: /* (non-Javadoc)
054: * @see org.apache.jmeter.gui.JMeterGUIComponent#getLabelResource()
055: */
056: public String getLabelResource() {
057: return "report_page";
058: }
059:
060: public void configureTestElement(TestElement element) {
061: super .configureTestElement(element);
062: }
063:
064: /* (non-Javadoc)
065: * @see org.apache.jmeter.gui.JMeterGUIComponent#createPopupMenu()
066: */
067: public JPopupMenu createPopupMenu() {
068: JPopupMenu pop = new JPopupMenu();
069: JMenu addMenu = new JMenu(JMeterUtils.getResString("Add"));
070: addMenu.add(ReportMenuFactory.makeMenu(
071: ReportMenuFactory.CONFIG_ELEMENTS, "Add"));
072: addMenu.add(ReportMenuFactory.makeMenu(
073: ReportMenuFactory.PRE_PROCESSORS, "Add"));
074: addMenu.add(ReportMenuFactory.makeMenu(
075: ReportMenuFactory.POST_PROCESSORS, "Add"));
076: pop.add(addMenu);
077: ReportMenuFactory.addFileMenu(pop);
078: return pop;
079: }
080:
081: /* (non-Javadoc)
082: * @see org.apache.jmeter.gui.JMeterGUIComponent#getMenuCategories()
083: */
084: public Collection getMenuCategories() {
085: return Arrays.asList(new String[] { ReportMenuFactory.TABLES });
086: }
087:
088: /**
089: * This implementaion differs a bit from the normal jmeter gui. it uses
090: * a white background instead of the default grey.
091: * @return a panel containing the component title and name panel
092: */
093: protected Container makeTitlePanel() {
094: VerticalPanel titlePanel = new VerticalPanel();
095: titlePanel.setBackground(Color.white);
096: titlePanel.add(createTitleLabel());
097: titlePanel.add(getNamePanel());
098: return titlePanel;
099: }
100:
101: /**
102: * This implementaion differs a bit from the normal jmeter gui. it uses
103: * a white background instead of the default grey.
104: */
105: protected Component createTitleLabel() {
106: JLabel titleLabel = new JLabel(getStaticLabel());
107: Font curFont = titleLabel.getFont();
108: titleLabel.setFont(curFont
109: .deriveFont((float) curFont.getSize() + 4));
110: titleLabel.setBackground(Color.white);
111: return titleLabel;
112: }
113: }
|