You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by wo...@apache.org on 2005/08/16 05:46:10 UTC
cvs commit: jakarta-jmeter/src/reports/org/apache/jmeter/testelement ReportPlan.java
woolfel 2005/08/15 20:46:10
Modified: src/reports/org/apache/jmeter/gui/tree ReportTreeModel.java
src/reports/org/apache/jmeter JMeterReport.java
src/reports/org/apache/jmeter/control/gui ReportGui.java
src/reports/org/apache/jmeter/testelement ReportPlan.java
Added: src/reports/org/apache/jmeter/gui ReportGuiPackage.java
ReportMainFrame.java
src/reports/org/apache/jmeter/report ReportPage.java
src/reports/org/apache/jmeter/gui/tree
ReportTreeListener.java
Log:
more updates to the report, may not be functional yet, but it's slowly getting there
peter
Revision Changes Path
1.1 jakarta-jmeter/src/reports/org/apache/jmeter/gui/ReportGuiPackage.java
Index: ReportGuiPackage.java
===================================================================
// $Header: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/gui/ReportGuiPackage.java,v 1.1 2005/08/16 03:46:10 woolfel Exp $
/*
* Copyright 2001,2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.gui;
import java.awt.Component;
import java.awt.event.MouseEvent;
import java.beans.Introspector;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JPopupMenu;
import org.apache.jmeter.engine.util.ValueReplacer;
import org.apache.jmeter.exceptions.IllegalUserActionException;
import org.apache.jmeter.gui.tree.ReportTreeListener;
import org.apache.jmeter.gui.tree.ReportTreeModel;
import org.apache.jmeter.gui.tree.ReportTreeNode;
import org.apache.jmeter.services.FileServer;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testbeans.gui.TestBeanGUI;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.TestPlan;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.util.LocaleChangeEvent;
import org.apache.jmeter.util.LocaleChangeListener;
import org.apache.jmeter.visualizers.gui.AbstractVisualizer;
import org.apache.jorphan.collections.HashTree;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
/**
* GuiPackage is a static class that provides convenient access to information
* about the current state of JMeter's GUI. Any GUI class can grab a handle to
* GuiPackage by calling the static method {@link #getInstance()} and then use
* it to query the GUI about it's state. When actions, for instance, need to
* affect the GUI, they typically use GuiPackage to get access to different
* parts of the GUI.
*
* @author Michael Stover
* @author <a href="mailto:jsalvata@apache.org">Jordi Salvat i Alabart</a>
* @version $Revision: 1.1 $ updated on $Date: 2005/08/16 03:46:10 $
*/
public final class ReportGuiPackage implements LocaleChangeListener {
/** Logging. */
private static transient Logger log = LoggingManager.getLoggerForClass();
/** Singleton instance. */
private static ReportGuiPackage guiPack;
/**
* Flag indicating whether or not parts of the tree have changed since they
* were last saved.
*/
private boolean dirty = false;
/**
* Map from TestElement to JMeterGUIComponent, mapping the nodes in the tree
* to their corresponding GUI components.
*/
private Map nodesToGui = new HashMap();
/**
* Map from Class to JMeterGUIComponent, mapping the Class of a GUI
* component to an instance of that component.
*/
private Map guis = new HashMap();
/**
* Map from Class to TestBeanGUI, mapping the Class of a TestBean to an
* instance of TestBeanGUI to be used to edit such components.
*/
private Map testBeanGUIs = new HashMap();
/** The currently selected node in the tree. */
private ReportTreeNode currentNode = null;
private boolean currentNodeUpdated = false;
/** The model for JMeter's test tree. */
private ReportTreeModel treeModel;
/** The listener for JMeter's test tree. */
private ReportTreeListener treeListener;
/** The main JMeter frame. */
private MainFrame mainFrame;
/**
* Private constructor to permit instantiation only from within this class.
* Use {@link #getInstance()} to retrieve a singleton instance.
*/
private ReportGuiPackage() {
JMeterUtils.addLocaleChangeListener(this);
}
/**
* Retrieve the singleton GuiPackage instance.
*
* @return the GuiPackage instance
*/
public static ReportGuiPackage getInstance() {
return guiPack;
}
/**
* When GuiPackage is requested for the first time, it should be given
* handles to JMeter's Tree Listener and TreeModel.
*
* @param listener
* the TreeListener for JMeter's test tree
* @param treeModel
* the model for JMeter's test tree
*
* @return GuiPackage
*/
public static ReportGuiPackage getInstance(ReportTreeListener listener, ReportTreeModel treeModel) {
if (guiPack == null) {
guiPack = new ReportGuiPackage();
guiPack.setTreeListener(listener);
guiPack.setTreeModel(treeModel);
}
return guiPack;
}
/**
* Get a JMeterGUIComponent for the specified test element. If the GUI has
* already been created, that instance will be returned. Otherwise, if a GUI
* component of the same type has been created, and the component is not
* marked as an {@link UnsharedComponent}, that shared component will be
* returned. Otherwise, a new instance of the component will be created. The
* TestElement's GUI_CLASS property will be used to determine the
* appropriate type of GUI component to use.
*
* @param node
* the test element which this GUI is being created for
*
* @return the GUI component corresponding to the specified test element
*/
public JMeterGUIComponent getGui(TestElement node) {
String testClassName = node.getPropertyAsString(TestElement.TEST_CLASS);
String guiClassName = node.getPropertyAsString(TestElement.GUI_CLASS);
try {
Class testClass;
if (testClassName.equals("")) {
testClass = node.getClass();
} else {
testClass = Class.forName(testClassName);
}
Class guiClass = null;
if (!guiClassName.equals("")) {
guiClass = Class.forName(guiClassName);
}
return getGui(node, guiClass, testClass);
} catch (ClassNotFoundException e) {
log.error("Could not get GUI for " + node, e);
return null;
}
}
/**
* Get a JMeterGUIComponent for the specified test element. If the GUI has
* already been created, that instance will be returned. Otherwise, if a GUI
* component of the same type has been created, and the component is not
* marked as an {@link UnsharedComponent}, that shared component will be
* returned. Otherwise, a new instance of the component will be created.
*
* @param node
* the test element which this GUI is being created for
* @param guiClass
* the fully qualifed class name of the GUI component which will
* be created if it doesn't already exist
* @param testClass
* the fully qualifed class name of the test elements which have
* to be edited by the returned GUI component
*
* @return the GUI component corresponding to the specified test element
*/
public JMeterGUIComponent getGui(TestElement node, Class guiClass, Class testClass) {
try {
JMeterGUIComponent comp = (JMeterGUIComponent) nodesToGui.get(node);
if (comp == null) {
comp = getGuiFromCache(guiClass, testClass);
nodesToGui.put(node, comp);
}
log.debug("Gui retrieved = " + comp);
return comp;
} catch (Exception e) {
log.error("Problem retrieving gui", e);
return null;
}
}
/**
* Remove a test element from the tree. This removes the reference to any
* associated GUI component.
*
* @param node
* the test element being removed
*/
public void removeNode(TestElement node) {
nodesToGui.remove(node);
}
/**
* Convenience method for grabbing the gui for the current node.
*
* @return the GUI component associated with the currently selected node
*/
public JMeterGUIComponent getCurrentGui() {
try {
updateCurrentNode();
TestElement curNode = treeListener.getCurrentNode().getTestElement();
JMeterGUIComponent comp = getGui(curNode);
if (!(comp instanceof AbstractVisualizer)) // TODO: a hack that
// needs to be fixed for
// 2.0
{
comp.clear();
}
log.debug("Updating gui to new node");
comp.configure(curNode);
currentNodeUpdated = false;
return comp;
} catch (Exception e) {
log.error("Problem retrieving gui", e);
return null;
}
}
/**
* Find the JMeterTreeNode for a certain TestElement object.
*
* @param userObject
* the test element to search for
* @return the tree node associated with the test element
*/
public ReportTreeNode getNodeOf(TestElement userObject) {
return treeModel.getNodeOf(userObject);
}
/**
* Create a TestElement corresponding to the specified GUI class.
*
* @param guiClass
* the fully qualified class name of the GUI component or a
* TestBean class for TestBeanGUIs.
* @param testClass
* the fully qualified class name of the test elements edited by
* this GUI component.
* @return the test element corresponding to the specified GUI class.
*/
public TestElement createTestElement(Class guiClass, Class testClass) {
try {
JMeterGUIComponent comp = getGuiFromCache(guiClass, testClass);
comp.clear();
TestElement node = comp.createTestElement();
nodesToGui.put(node, comp);
return node;
} catch (Exception e) {
log.error("Problem retrieving gui", e);
return null;
}
}
/**
* Create a TestElement for a GUI or TestBean class.
* <p>
* This is a utility method to help actions do with one single String
* parameter.
*
* @param objClass
* the fully qualified class name of the GUI component or of the
* TestBean subclass for which a TestBeanGUI is wanted.
* @return the test element corresponding to the specified GUI class.
*/
public TestElement createTestElement(String objClass) {
JMeterGUIComponent comp;
Class c;
try {
c = Class.forName(objClass);
if (TestBean.class.isAssignableFrom(c)) {
comp = getGuiFromCache(TestBeanGUI.class, c);
} else {
comp = getGuiFromCache(c, null);
}
comp.clear();
TestElement node = comp.createTestElement();
nodesToGui.put(node, comp);
return node;
} catch (NoClassDefFoundError e) {
log.error("Problem retrieving gui for " + objClass, e);
throw new RuntimeException(e.toString()); // Probably a missing
// jar
} catch (ClassNotFoundException e) {
log.error("Problem retrieving gui for " + objClass, e);
throw new RuntimeException(e.toString()); // Programming error:
// bail out.
} catch (InstantiationException e) {
log.error("Problem retrieving gui for " + objClass, e);
throw new RuntimeException(e.toString()); // Programming error:
// bail out.
} catch (IllegalAccessException e) {
log.error("Problem retrieving gui for " + objClass, e);
throw new RuntimeException(e.toString()); // Programming error:
// bail out.
}
}
/**
* Get an instance of the specified JMeterGUIComponent class. If an instance
* of the GUI class has previously been created and it is not marked as an
* {@link UnsharedComponent}, that shared instance will be returned.
* Otherwise, a new instance of the component will be created, and shared
* components will be cached for future retrieval.
*
* @param guiClass
* the fully qualified class name of the GUI component. This
* class must implement JMeterGUIComponent.
* @param testClass
* the fully qualified class name of the test elements edited by
* this GUI component. This class must implement TestElement.
* @return an instance of the specified class
*
* @throws InstantiationException
* if an instance of the object cannot be created
* @throws IllegalAccessException
* if access rights do not allow the default constructor to be
* called
* @throws ClassNotFoundException
* if the specified GUI class cannot be found
*/
private JMeterGUIComponent getGuiFromCache(Class guiClass, Class testClass) throws InstantiationException,
IllegalAccessException, ClassNotFoundException {
JMeterGUIComponent comp;
if (guiClass == TestBeanGUI.class) {
comp = (TestBeanGUI) testBeanGUIs.get(testClass);
if (comp == null) {
comp = new TestBeanGUI(testClass);
testBeanGUIs.put(testClass, comp);
}
} else {
comp = (JMeterGUIComponent) guis.get(guiClass);
if (comp == null) {
comp = (JMeterGUIComponent) guiClass.newInstance();
if (!(comp instanceof UnsharedComponent)) {
guis.put(guiClass, comp);
}
}
}
return comp;
}
/**
* Update the GUI for the currently selected node. The GUI component is
* configured to reflect the settings in the current tree node.
*
*/
public void updateCurrentGui() {
updateCurrentNode();
currentNode = treeListener.getCurrentNode();
TestElement element = currentNode.getTestElement();
JMeterGUIComponent comp = getGui(element);
comp.configure(element);
currentNodeUpdated = false;
}
/**
* This method should be called in order for GuiPackage to change the
* current node. This will save any changes made to the earlier node before
* choosing the new node.
*/
public void updateCurrentNode() {
try {
if (currentNode != null && !currentNodeUpdated) {
log.debug("Updating current node " + currentNode.getName());
JMeterGUIComponent comp = getGui(currentNode.getTestElement());
TestElement el = currentNode.getTestElement();
comp.modifyTestElement(el);
}
if (currentNode != treeListener.getCurrentNode()) {
currentNodeUpdated = true;
}
currentNode = treeListener.getCurrentNode();
} catch (Exception e) {
log.error("Problem retrieving gui", e);
}
}
public ReportTreeNode getCurrentNode() {
return treeListener.getCurrentNode();
}
public TestElement getCurrentElement() {
return getCurrentNode().getTestElement();
}
/**
* The dirty property is a flag that indicates whether there are parts of
* JMeter's test tree that the user has not saved since last modification.
* Various (@link Command actions) set this property when components are
* modified/created/saved.
*
* @param dirty
* the new value of the dirty flag
*/
public void setDirty(boolean dirty) {
this.dirty = dirty;
}
/**
* Retrieves the state of the 'dirty' property, a flag that indicates if
* there are test tree components that have been modified since they were
* last saved.
*
* @return true if some tree components have been modified since they were
* last saved, false otherwise
*/
public boolean isDirty() {
return dirty;
}
/**
* Add a subtree to the currently selected node.
*
* @param subTree
* the subtree to add.
*
* @return the resulting subtree starting with the currently selected node
*
* @throws IllegalUserActionException
* if a subtree cannot be added to the currently selected node
*/
public HashTree addSubTree(HashTree subTree) throws IllegalUserActionException {
return treeModel.addSubTree(subTree, treeListener.getCurrentNode());
}
/**
* Get the currently selected subtree.
*
* @return the subtree of the currently selected node
*/
public HashTree getCurrentSubTree() {
return treeModel.getCurrentSubTree(treeListener.getCurrentNode());
}
/**
* Get the model for JMeter's test tree.
*
* @return the JMeter tree model
*/
public ReportTreeModel getTreeModel() {
return treeModel;
}
/**
* Set the model for JMeter's test tree.
*
* @param newTreeModel
* the new JMeter tree model
*/
public void setTreeModel(ReportTreeModel newTreeModel) {
treeModel = newTreeModel;
}
/**
* Get a ValueReplacer for the test tree.
*
* @return a ValueReplacer configured for the test tree
*/
public ValueReplacer getReplacer() {
return new ValueReplacer((TestPlan) ((ReportTreeNode) getTreeModel().getTestPlan().getArray()[0])
.getTestElement());
}
/**
* Set the main JMeter frame.
*
* @param newMainFrame
* the new JMeter main frame
*/
public void setMainFrame(MainFrame newMainFrame) {
mainFrame = newMainFrame;
}
/**
* Get the main JMeter frame.
*
* @return the main JMeter frame
*/
public MainFrame getMainFrame() {
return mainFrame;
}
/**
* Set the listener for JMeter's test tree.
*
* @param newTreeListener
* the new JMeter test tree listener
*/
public void setTreeListener(ReportTreeListener newTreeListener) {
treeListener = newTreeListener;
}
/**
* Get the listener for JMeter's test tree.
*
* @return the JMeter test tree listener
*/
public ReportTreeListener getTreeListener() {
return treeListener;
}
/**
* Display the specified popup menu with the source component and location
* from the specified mouse event.
*
* @param e
* the mouse event causing this popup to be displayed
* @param popup
* the popup menu to display
*/
public void displayPopUp(MouseEvent e, JPopupMenu popup) {
displayPopUp((Component) e.getSource(), e, popup);
}
/**
* Display the specified popup menu at the location specified by a mouse
* event with the specified source component.
*
* @param invoker
* the source component
* @param e
* the mouse event causing this popup to be displayed
* @param popup
* the popup menu to display
*/
public void displayPopUp(Component invoker, MouseEvent e, JPopupMenu popup) {
if (popup != null) {
log.debug("Showing pop up for " + invoker + " at x,y = " + e.getX() + "," + e.getY());
popup.pack();
popup.show(invoker, e.getX(), e.getY());
popup.setVisible(true);
popup.requestFocus();
}
}
/*
* (non-Javadoc)
*
* @see org.apache.jmeter.util.LocaleChangeListener#localeChanged(org.apache.jmeter.util.LocaleChangeEvent)
*/
public void localeChanged(LocaleChangeEvent event) {
// FIrst make sure we save the content of the current GUI (since we
// will flush it away):
updateCurrentNode();
// Forget about all GUIs we've created so far: we'll need to re-created
// them all!
guis = new HashMap();
nodesToGui = new HashMap();
testBeanGUIs = new HashMap();
// BeanInfo objects also contain locale-sensitive data -- flush them
// away:
Introspector.flushCaches();
// Now put the current GUI in place. [This code was copied from the
// EditCommand action -- we can't just trigger the action because that
// would populate the current node with the contents of the new GUI --
// which is empty.]
MainFrame mf = getMainFrame(); // Fetch once
if (mf == null) // Probably caused by unit testing on headless system
{
log.warn("Mainframe is null");
} else {
mf.setMainPanel((javax.swing.JComponent) getCurrentGui());
mf.setEditMenu(getTreeListener().getCurrentNode().createPopupMenu());
}
}
private String testPlanFile;
/**
* Sets the filepath of the current test plan. It's shown in the main frame
* title and used on saving.
*
* @param f
*/
public void setTestPlanFile(String f) {
testPlanFile = f;
ReportGuiPackage.getInstance().getMainFrame().setTitle(JMeterUtils.getExtendedFrameTitle(testPlanFile));
try {
FileServer.getFileServer().setBasedir(testPlanFile);
} catch (IOException e1) {
log.error("Failure setting file server's base dir", e1);
}
}
public String getTestPlanFile() {
return testPlanFile;
}
}
1.1 jakarta-jmeter/src/reports/org/apache/jmeter/gui/ReportMainFrame.java
Index: ReportMainFrame.java
===================================================================
// $Header: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/gui/ReportMainFrame.java,v 1.1 2005/08/16 03:46:10 woolfel Exp $
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.gui;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.HashSet;
import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.MenuElement;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
import org.apache.jmeter.engine.event.LoopIterationEvent;
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jmeter.gui.action.GlobalMouseListener;
import org.apache.jmeter.gui.tree.JMeterCellRenderer;
import org.apache.jmeter.gui.tree.ReportTreeListener;
import org.apache.jmeter.gui.util.JMeterMenuBar;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.gui.ComponentUtil;
/**
* The main JMeter frame, containing the menu bar, test tree, and an area for
* JMeter component GUIs.
*
* @author Michael Stover
* @version $Revision: 1.1 $
*/
public class ReportMainFrame extends MainFrame {
/** An image which is displayed when a test is running. */
private ImageIcon runningIcon = JMeterUtils.getImage("thread.enabled.gif");
/** An image which is displayed when a test is not currently running. */
private ImageIcon stoppedIcon = JMeterUtils.getImage("thread.disabled.gif");
/** The button used to display the running/stopped image. */
private JButton runningIndicator;
/** The set of currently running hosts. */
private Set hosts = new HashSet();
/** A message dialog shown while JMeter threads are stopping. */
private JDialog stoppingMessage;
/**
* Create a new JMeter frame.
*
* @param actionHandler
* this parameter is not used
* @param treeModel
* the model for the test tree
* @param treeListener
* the listener for the test tree
*/
public ReportMainFrame(ActionListener actionHandler, TreeModel treeModel,
ReportTreeListener treeListener) {
super.tree = this.makeTree(treeModel,treeListener);
}
/**
* Default constructor for the JMeter frame. This constructor will not
* properly initialize the tree, so don't use it.
*/
public ReportMainFrame() {
// TODO: Can we remove this constructor? JMeter won't behave properly
// if it used.
}
// MenuBar related methods
// TODO: Do we really need to have all these menubar methods duplicated
// here? Perhaps we can make the menu bar accessible through GuiPackage?
/**
* Specify whether or not the File|Load menu item should be enabled.
*
* @param enabled
* true if the menu item should be enabled, false otherwise
*/
public void setFileLoadEnabled(boolean enabled) {
super.setFileLoadEnabled(enabled);
}
/**
* Specify whether or not the File|Save menu item should be enabled.
*
* @param enabled
* true if the menu item should be enabled, false otherwise
*/
public void setFileSaveEnabled(boolean enabled) {
super.setFileSaveEnabled(enabled);
}
/**
* Set the menu that should be used for the Edit menu.
*
* @param menu
* the new Edit menu
*/
public void setEditMenu(JPopupMenu menu) {
super.setEditMenu(menu);
}
/**
* Specify whether or not the Edit menu item should be enabled.
*
* @param enabled
* true if the menu item should be enabled, false otherwise
*/
public void setEditEnabled(boolean enabled) {
super.setEditEnabled(enabled);
}
/**
* Set the menu that should be used for the Edit|Add menu.
*
* @param menu
* the new Edit|Add menu
*/
public void setEditAddMenu(JMenu menu) {
super.setEditAddMenu(menu);
}
/**
* Specify whether or not the Edit|Add menu item should be enabled.
*
* @param enabled
* true if the menu item should be enabled, false otherwise
*/
public void setEditAddEnabled(boolean enabled) {
super.setEditAddEnabled(enabled);
}
/**
* Specify whether or not the Edit|Remove menu item should be enabled.
*
* @param enabled
* true if the menu item should be enabled, false otherwise
*/
public void setEditRemoveEnabled(boolean enabled) {
super.setEditRemoveEnabled(enabled);
}
/***************************************************************************
* !ToDoo (Method description)
*
* @return !ToDo (Return description)
**************************************************************************/
public JTree getTree() {
return super.getTree();
}
// TestListener implementation
/**
* Not sure if this should be in the ReportMainFrame, since the
* report component doesn't really test, it generates reports. for
* now, I will use it to trigger reporting. Later we can refactor
* MainFrame and create an abstract base class.
*/
public void testStarted() {
// super.testStarted();
}
/**
* Not sure if this should be in the ReportMainFrame, since the
* report component doesn't really test, it generates reports. for
* now, I will use it to trigger reporting. Later we can refactor
* MainFrame and create an abstract base class.
*/
public void testStarted(String host) {
// super.testStarted(host);
}
/**
* Not sure if this should be in the ReportMainFrame, since the
* report component doesn't really test, it generates reports. for
* now, I will use it to trigger reporting. Later we can refactor
* MainFrame and create an abstract base class.
*/
public void testEnded() {
// super.testEnded();
}
/**
* Not sure if this should be in the ReportMainFrame, since the
* report component doesn't really test, it generates reports. for
* now, I will use it to trigger reporting. Later we can refactor
* MainFrame and create an abstract base class.
*/
public void testEnded(String host) {
// super.testEnded(host);
}
/* Implements TestListener#testIterationStart(LoopIterationEvent) */
public void testIterationStart(LoopIterationEvent event) {
}
/**
* Create the GUI components and layout.
*/
protected void init() {
super.init();
/**
menuBar = new JMeterMenuBar();
setJMenuBar(menuBar);
JPanel all = new JPanel(new BorderLayout());
all.add(createToolBar(), BorderLayout.NORTH);
JSplitPane treeAndMain = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
treePanel = createTreePanel();
treeAndMain.setLeftComponent(treePanel);
mainPanel = createMainPanel();
treeAndMain.setRightComponent(mainPanel);
treeAndMain.setResizeWeight(.2);
treeAndMain.setContinuousLayout(true);
all.add(treeAndMain, BorderLayout.CENTER);
getContentPane().add(all);
tree.setSelectionRow(1);
addWindowListener(new WindowHappenings());
addMouseListener(new GlobalMouseListener());
*/
}
/**
* Create the JMeter tool bar pane containing the running indicator.
*
* @return a panel containing the running indicator
*/
protected Component createToolBar() {
return super.createToolBar();
}
/**
* Create the panel where the GUI representation of the test tree is
* displayed. The tree should already be created before calling this method.
*
* @return a scroll pane containing the test tree GUI
*/
protected JScrollPane createTreePanel() {
return super.createTreePanel();
}
/**
* Create the main panel where components can display their GUIs.
*
* @return the main scroll pane
*/
protected JScrollPane createMainPanel() {
return super.createMainPanel();
}
/**
* Create and initialize the GUI representation of the test tree.
*
* @param treeModel
* the test tree model
* @param treeListener
* the test tree listener
*
* @return the initialized test tree GUI
*/
private JTree makeTree(TreeModel treeModel, ReportTreeListener treeListener) {
JTree treevar = new JTree(treeModel);
treevar.setCellRenderer(getCellRenderer());
treevar.setRootVisible(false);
treevar.setShowsRootHandles(true);
treeListener.setJTree(treevar);
treevar.addTreeSelectionListener(treeListener);
treevar.addMouseListener(treeListener);
treevar.addMouseMotionListener(treeListener);
treevar.addKeyListener(treeListener);
return treevar;
}
}
1.1 jakarta-jmeter/src/reports/org/apache/jmeter/report/ReportPage.java
Index: ReportPage.java
===================================================================
// $Header: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/report/ReportPage.java,v 1.1 2005/08/16 03:46:10 woolfel Exp $
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.report;
import java.io.Serializable;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.jmeter.control.Controller;
import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.engine.event.LoopIterationListener;
import org.apache.jmeter.samplers.RemoteSampleListener;
import org.apache.jmeter.samplers.SampleEvent;
import org.apache.jmeter.samplers.SampleListener;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.testelement.AbstractTestElement;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.testelement.property.IntegerProperty;
import org.apache.jmeter.testelement.property.LongProperty;
import org.apache.jmeter.testelement.property.BooleanProperty;
import org.apache.jmeter.testelement.property.TestElementProperty;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
/**
* ThreadGroup
*
* @author Michael Stover
* @version $Id: ReportPage.java,v 1.1 2005/08/16 03:46:10 woolfel Exp $
*/
public class ReportPage extends AbstractTestElement implements Serializable {
private final static Logger log = LoggingManager.getLoggerForClass();
/**
* No-arg constructor.
*/
public ReportPage() {
}
}
1.2 +2 -4 jakarta-jmeter/src/reports/org/apache/jmeter/gui/tree/ReportTreeModel.java
Index: ReportTreeModel.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/gui/tree/ReportTreeModel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReportTreeModel.java 12 Aug 2005 23:58:48 -0000 1.1
+++ ReportTreeModel.java 16 Aug 2005 03:46:10 -0000 1.2
@@ -81,8 +81,6 @@
current = (ReportTreeNode) ((ReportTreeNode) getRoot()).getChildAt(0);
((TestElement) current.getUserObject()).addTestElement(item);
((ReportPlan) current.getUserObject()).setName(item.getPropertyAsString(TestElement.NAME));
- ((ReportPlan) current.getUserObject()).setFunctionalMode(item
- .getPropertyAsBoolean(ReportPlan.FUNCTIONAL_MODE));
((ReportPlan) current.getUserObject()).setSerialized(item
.getPropertyAsBoolean(ReportPlan.SERIALIZE_THREADGROUPS));
addSubTree(subTree.getTree(item), current);
1.1 jakarta-jmeter/src/reports/org/apache/jmeter/gui/tree/ReportTreeListener.java
Index: ReportTreeListener.java
===================================================================
// $Header: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/gui/tree/ReportTreeListener.java,v 1.1 2005/08/16 03:46:10 woolfel Exp $
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.gui.tree;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import org.apache.jmeter.control.gui.TestPlanGui;
import org.apache.jmeter.control.gui.WorkBenchGui;
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.MainFrame;
import org.apache.jmeter.gui.action.DragNDrop;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;
/**
* @author Michael Stover Created March 11, 2001
* @version $Revision: 1.1 $ Last updated: $Date: 2005/08/16 03:46:10 $
*/
public class ReportTreeListener implements TreeSelectionListener, MouseListener, KeyListener, MouseMotionListener {
transient private static Logger log = LoggingManager.getLoggerForClass();
// Container endWindow;
// JPopupMenu pop;
private TreePath currentPath;
private ActionListener actionHandler;
private ReportTreeModel model;
private JTree tree;
private boolean dragging = false;
private ReportTreeNode[] draggedNodes;
private JLabel dragIcon = new JLabel(JMeterUtils.getImage("leafnode.gif"));
/**
* Constructor for the JMeterTreeListener object.
*/
public ReportTreeListener(ReportTreeModel model) {
this.model = model;
dragIcon.validate();
dragIcon.setVisible(true);
}
public ReportTreeListener() {
dragIcon.validate();
dragIcon.setVisible(true);
}
public void setModel(ReportTreeModel m) {
model = m;
}
/**
* Sets the ActionHandler attribute of the JMeterTreeListener object.
*
* @param ah
* the new ActionHandler value
*/
public void setActionHandler(ActionListener ah) {
actionHandler = ah;
}
/**
* Sets the JTree attribute of the JMeterTreeListener object.
*
* @param tree
* the new JTree value
*/
public void setJTree(JTree tree) {
this.tree = tree;
}
/**
* Sets the EndWindow attribute of the JMeterTreeListener object.
*
* @param window
* the new EndWindow value
*/
public void setEndWindow(Container window) {
// endWindow = window;
}
/**
* Gets the JTree attribute of the JMeterTreeListener object.
*
* @return tree the current JTree value.
*/
public JTree getJTree() {
return tree;
}
/**
* Gets the CurrentNode attribute of the JMeterTreeListener object.
*
* @return the CurrentNode value
*/
public ReportTreeNode getCurrentNode() {
if (currentPath != null) {
if (currentPath.getLastPathComponent() != null) {
return (ReportTreeNode) currentPath.getLastPathComponent();
} else {
return (ReportTreeNode) currentPath.getParentPath().getLastPathComponent();
}
} else {
return (ReportTreeNode) model.getRoot();
}
}
public ReportTreeNode[] getSelectedNodes() {
TreePath[] paths = tree.getSelectionPaths();
if (paths == null) {
return new ReportTreeNode[] { getCurrentNode() };
}
ReportTreeNode[] nodes = new ReportTreeNode[paths.length];
for (int i = 0; i < paths.length; i++) {
nodes[i] = (ReportTreeNode) paths[i].getLastPathComponent();
}
return nodes;
}
public TreePath removedSelectedNode() {
currentPath = currentPath.getParentPath();
return currentPath;
}
public void valueChanged(TreeSelectionEvent e) {
log.debug("value changed, updating currentPath");
currentPath = e.getNewLeadSelectionPath();
actionHandler.actionPerformed(new ActionEvent(this, 3333, "edit"));
}
public void mouseClicked(MouseEvent ev) {
}
public void mouseReleased(MouseEvent e) {
if (dragging && isValidDragAction(draggedNodes, getCurrentNode())) {
dragging = false;
JPopupMenu dragNdrop = new JPopupMenu();
JMenuItem item = new JMenuItem(JMeterUtils.getResString("Insert Before"));
item.addActionListener(actionHandler);
item.setActionCommand(DragNDrop.INSERT_BEFORE);
dragNdrop.add(item);
item = new JMenuItem(JMeterUtils.getResString("Insert After"));
item.addActionListener(actionHandler);
item.setActionCommand(DragNDrop.INSERT_AFTER);
dragNdrop.add(item);
item = new JMenuItem(JMeterUtils.getResString("Add as Child"));
item.addActionListener(actionHandler);
item.setActionCommand(DragNDrop.ADD);
dragNdrop.add(item);
dragNdrop.addSeparator();
item = new JMenuItem(JMeterUtils.getResString("Cancel"));
dragNdrop.add(item);
displayPopUp(e, dragNdrop);
} else {
GuiPackage.getInstance().getMainFrame().repaint();
}
dragging = false;
}
public ReportTreeNode[] getDraggedNodes() {
return draggedNodes;
}
/**
* Tests if the node is being dragged into one of it's own sub-nodes, or
* into itself.
*/
private boolean isValidDragAction(ReportTreeNode[] source, ReportTreeNode dest) {
boolean isValid = true;
TreeNode[] path = dest.getPath();
for (int i = 0; i < path.length; i++) {
if (contains(source, path[i])) {
isValid = false;
}
}
return isValid;
}
public void mouseEntered(MouseEvent e) {
}
private void changeSelectionIfDragging(MouseEvent e) {
if (dragging) {
GuiPackage.getInstance().getMainFrame().drawDraggedComponent(dragIcon, e.getX(), e.getY());
if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
currentPath = tree.getPathForLocation(e.getX(), e.getY());
if (!contains(draggedNodes, getCurrentNode())) {
tree.setSelectionPath(currentPath);
}
}
}
}
private boolean contains(Object[] container, Object item) {
for (int i = 0; i < container.length; i++) {
if (container[i] == item) {
return true;
}
}
return false;
}
public void mousePressed(MouseEvent e) {
// Get the Main Frame.
MainFrame mainFrame = GuiPackage.getInstance().getMainFrame();
// Close any Main Menu that is open
mainFrame.closeMenu();
int selRow = tree.getRowForLocation(e.getX(), e.getY());
if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
log.debug("mouse pressed, updating currentPath");
currentPath = tree.getPathForLocation(e.getX(), e.getY());
}
if (selRow != -1) {
// updateMainMenu(((JMeterGUIComponent)
// getCurrentNode().getUserObject()).createPopupMenu());
if (isRightClick(e)) {
if (tree.getSelectionCount() < 2) {
tree.setSelectionPath(currentPath);
}
if (getCurrentNode() instanceof ReportTreeNode) {
log.debug("About to display pop-up");
displayPopUp(e);
}
}
}
}
public void mouseDragged(MouseEvent e) {
if (!dragging) {
dragging = true;
draggedNodes = getSelectedNodes();
if (draggedNodes[0].getUserObject() instanceof TestPlanGui
|| draggedNodes[0].getUserObject() instanceof WorkBenchGui) {
dragging = false;
}
}
changeSelectionIfDragging(e);
}
public void mouseMoved(MouseEvent e) {
}
public void mouseExited(MouseEvent ev) {
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
private boolean isRightClick(MouseEvent e) {
return (MouseEvent.BUTTON2_MASK & e.getModifiers()) > 0 || (MouseEvent.BUTTON3_MASK == e.getModifiers());
}
/*
* NOTUSED private void updateMainMenu(JPopupMenu menu) { try { MainFrame
* mainFrame = GuiPackage.getInstance().getMainFrame();
* mainFrame.setEditMenu(menu); } catch (NullPointerException e) {
* log.error("Null pointer: JMeterTreeListener.updateMenuItem()", e);
* log.error("", e); } }
*/
private void displayPopUp(MouseEvent e) {
JPopupMenu pop = getCurrentNode().createPopupMenu();
GuiPackage.getInstance().displayPopUp(e, pop);
}
private void displayPopUp(MouseEvent e, JPopupMenu popup) {
log.warn("Shouldn't be here");
if (popup != null) {
popup.pack();
popup.show(tree, e.getX(), e.getY());
popup.setVisible(true);
popup.requestFocus();
}
}
}
1.2 +7 -15 jakarta-jmeter/src/reports/org/apache/jmeter/JMeterReport.java
Index: JMeterReport.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/JMeterReport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMeterReport.java 12 Aug 2005 23:58:48 -0000 1.1
+++ JMeterReport.java 16 Aug 2005 03:46:10 -0000 1.2
@@ -34,12 +34,12 @@
import org.apache.jmeter.control.gui.ReportGui;
import org.apache.jmeter.control.gui.TestPlanGui;
import org.apache.jmeter.control.gui.WorkBenchGui;
-import org.apache.jmeter.gui.GuiPackage;
+import org.apache.jmeter.gui.ReportGuiPackage;
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jmeter.gui.action.CheckDirty;
import org.apache.jmeter.gui.action.Load;
-import org.apache.jmeter.gui.tree.JMeterTreeListener;
-import org.apache.jmeter.gui.tree.JMeterTreeModel;
+import org.apache.jmeter.gui.tree.ReportTreeListener;
+import org.apache.jmeter.gui.tree.ReportTreeModel;
import org.apache.jmeter.plugin.JMeterPlugin;
import org.apache.jmeter.plugin.PluginManager;
import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
@@ -136,14 +136,6 @@
"run JMeter in nongui mode"),
new CLOptionDescriptor("server", CLOptionDescriptor.ARGUMENT_DISALLOWED, SERVER_OPT,
"run the JMeter server"),
- new CLOptionDescriptor("proxyHost", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_HOST,
- "Set a proxy server for JMeter to use"),
- new CLOptionDescriptor("proxyPort", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_PORT,
- "Set proxy server port for JMeter to use"),
- new CLOptionDescriptor("username", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_USERNAME,
- "Set username for proxy server that JMeter is to use"),
- new CLOptionDescriptor("password", CLOptionDescriptor.ARGUMENT_REQUIRED, PROXY_PASSWORD,
- "Set password for proxy server that JMeter is to use"),
new CLOptionDescriptor("jmeterproperty", CLOptionDescriptor.DUPLICATES_ALLOWED
| CLOptionDescriptor.ARGUMENTS_REQUIRED_2, JMETER_PROPERTY, "Define additional JMeter properties"),
new CLOptionDescriptor("systemproperty", CLOptionDescriptor.DUPLICATES_ALLOWED
@@ -221,11 +213,11 @@
public void startGui(CLOption testFile) {
PluginManager.install(this, true);
- JMeterTreeModel treeModel = new JMeterTreeModel();
- JMeterTreeListener treeLis = new JMeterTreeListener(treeModel);
+ ReportTreeModel treeModel = new ReportTreeModel();
+ ReportTreeListener treeLis = new ReportTreeListener(treeModel);
treeLis.setActionHandler(ActionRouter.getInstance());
// NOTUSED: GuiPackage guiPack =
- GuiPackage.getInstance(treeLis, treeModel);
+ ReportGuiPackage.getInstance(treeLis, treeModel);
org.apache.jmeter.gui.ReportMainFrame main = new org.apache.jmeter.gui.ReportMainFrame(ActionRouter.getInstance(),
treeModel, treeLis);
main.setTitle("Apache JMeter Report");
@@ -240,7 +232,7 @@
FileInputStream reader = new FileInputStream(f);
HashTree tree = SaveService.loadTree(reader);
- GuiPackage.getInstance().setTestPlanFile(f.getAbsolutePath());
+ ReportGuiPackage.getInstance().setTestPlanFile(f.getAbsolutePath());
new Load().insertLoadedTree(1, tree);
} catch (Exception e) {
1.2 +3 -3 jakarta-jmeter/src/reports/org/apache/jmeter/control/gui/ReportGui.java
Index: ReportGui.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/control/gui/ReportGui.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReportGui.java 12 Aug 2005 23:58:48 -0000 1.1
+++ ReportGui.java 16 Aug 2005 03:46:10 -0000 1.2
@@ -106,7 +106,7 @@
}
public String getLabelResource() {
- return "test_plan";
+ return "report_plan";
}
/**
1.2 +11 -27 jakarta-jmeter/src/reports/org/apache/jmeter/testelement/ReportPlan.java
Index: ReportPlan.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/reports/org/apache/jmeter/testelement/ReportPlan.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ReportPlan.java 12 Aug 2005 23:58:48 -0000 1.1
+++ ReportPlan.java 16 Aug 2005 03:46:10 -0000 1.2
@@ -44,9 +44,7 @@
public class ReportPlan extends AbstractTestElement implements Serializable, TestListener {
private static Logger log = LoggingManager.getLoggerForClass();
- public final static String THREAD_GROUPS = "ReportPlan.thread_groups";
-
- public final static String FUNCTIONAL_MODE = "ReportPlan.functional_mode";
+ public final static String REPORT_PAGE = "ReportPlan.report_page";
public final static String USER_DEFINED_VARIABLES = "ReportPlan.user_defined_variables";
@@ -56,7 +54,7 @@
public final static String BASEDIR = "basedir";
- private transient List threadGroups = new LinkedList();
+ private transient List reportPages = new LinkedList();
private transient List configs = new LinkedList();
@@ -72,7 +70,7 @@
// returned in org.apache.jmeter.threads.ThreadGroup.getClassLabel()
// method. If it's not you will not be able to add a Thread Group
// element to a Test Plan.
- itemsCanAdd.add(JMeterUtils.getResString("threadgroup"));
+ itemsCanAdd.add(JMeterUtils.getResString("reportpage"));
}
public ReportPlan() {
@@ -85,16 +83,7 @@
setName(name);
// setFunctionalMode(false);
// setSerialized(false);
- setProperty(new CollectionProperty(THREAD_GROUPS, threadGroups));
- }
-
- /**
- * Fetches the functional mode property
- *
- * @return functional mode
- */
- public boolean isFunctionalMode() {
- return getPropertyAsBoolean(FUNCTIONAL_MODE);
+ setProperty(new CollectionProperty(REPORT_PAGE, reportPages));
}
public void setUserDefinedVariables(Arguments vars) {
@@ -123,11 +112,6 @@
return args;
}
- public void setFunctionalMode(boolean funcMode) {
- setProperty(new BooleanProperty(FUNCTIONAL_MODE, funcMode));
- functionalMode = funcMode;
- }
-
/**
* Gets the static copy of the functional mode
*
@@ -169,13 +153,13 @@
public void addTestElement(TestElement tg) {
super.addTestElement(tg);
if (tg instanceof ThreadGroup && !isRunningVersion()) {
- addThreadGroup((ThreadGroup) tg);
+ addReportPage((ThreadGroup) tg);
}
}
public void addJMeterComponent(TestElement child) {
if (child instanceof ThreadGroup) {
- addThreadGroup((ThreadGroup) child);
+ addReportPage((ThreadGroup) child);
}
}
@@ -184,8 +168,8 @@
*
* @return the ThreadGroups value
*/
- public Collection getThreadGroups() {
- return threadGroups;
+ public Collection getReportPages() {
+ return reportPages;
}
/**
@@ -204,8 +188,8 @@
* @param group
* the feature to be added to the ThreadGroup attribute
*/
- public void addThreadGroup(ThreadGroup group) {
- threadGroups.add(group);
+ public void addReportPage(ThreadGroup group) {
+ reportPages.add(group);
}
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org