Apache JMeter

org.apache.jmeter.gui
Class ReportGuiPackage

java.lang.Object
  extended by org.apache.jmeter.gui.ReportGuiPackage
All Implemented Interfaces:
LocaleChangeListener

public final class ReportGuiPackage
extends Object
implements LocaleChangeListener

ReportGuiPackage is based on GuiPackage, but with changes for the reporting tool. Because of how the gui components work, it was safer to just make a new class, rather than braking existing JMeter gui code.


Method Summary
 HashTree addSubTree(HashTree subTree)
          Add a subtree to the currently selected node.
 TestElement createTestElement(Class<?> guiClass, Class<?> testClass)
          Create a TestElement corresponding to the specified GUI class.
 TestElement createTestElement(String objClass)
          Create a TestElement for a GUI or TestBean class.
 void displayPopUp(Component invoker, MouseEvent e, JPopupMenu popup)
          Display the specified popup menu at the location specified by a mouse event with the specified source component.
 void displayPopUp(MouseEvent e, JPopupMenu popup)
          Display the specified popup menu with the source component and location from the specified mouse event.
 TestElement getCurrentElement()
           
 JMeterGUIComponent getCurrentGui()
          Convenience method for grabbing the gui for the current node.
 ReportTreeNode getCurrentNode()
           
 HashTree getCurrentSubTree()
          Get the currently selected subtree.
 JMeterGUIComponent getGui(TestElement node)
          Get a JMeterGUIComponent for the specified test element.
 JMeterGUIComponent getGui(TestElement node, Class<?> guiClass, Class<?> testClass)
          Get a JMeterGUIComponent for the specified test element.
static ReportGuiPackage getInstance()
          Retrieve the singleton GuiPackage instance.
static ReportGuiPackage getInstance(ReportTreeListener listener, ReportTreeModel treeModel)
          When GuiPackage is requested for the first time, it should be given handles to JMeter's Tree Listener and TreeModel.
 ReportMainFrame getMainFrame()
          Get the main JMeter frame.
 ReportTreeNode getNodeOf(TestElement userObject)
          Find the JMeterTreeNode for a certain TestElement object.
 ValueReplacer getReplacer()
          Get a ValueReplacer for the test tree.
 String getReportPlanFile()
           
 ReportTreeListener getTreeListener()
          Get the listener for JMeter's test tree.
 ReportTreeModel getTreeModel()
          Get the model for JMeter's test tree.
 boolean isDirty()
          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.
 void localeChanged(LocaleChangeEvent event)
           
 void removeNode(TestElement node)
          Remove a test element from the tree.
 void setDirty(boolean dirty)
          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.
 void setMainFrame(ReportMainFrame newMainFrame)
          Set the main JMeter frame.
 void setReportPlanFile(String f)
          Sets the filepath of the current test plan.
 void setTreeListener(ReportTreeListener newTreeListener)
          Set the listener for JMeter's test tree.
 void setTreeModel(ReportTreeModel newTreeModel)
          Set the model for JMeter's test tree.
 void updateCurrentGui()
          Update the GUI for the currently selected node.
 void updateCurrentNode()
          This method should be called in order for GuiPackage to change the current node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ReportGuiPackage getInstance()
Retrieve the singleton GuiPackage instance.

Returns:
the GuiPackage instance

getInstance

public static ReportGuiPackage getInstance(ReportTreeListener listener,
                                           ReportTreeModel treeModel)
When GuiPackage is requested for the first time, it should be given handles to JMeter's Tree Listener and TreeModel.

Parameters:
listener - the TreeListener for JMeter's test tree
treeModel - the model for JMeter's test tree
Returns:
GuiPackage

getGui

public JMeterGUIComponent getGui(TestElement node)
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 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.

Parameters:
node - the test element which this GUI is being created for
Returns:
the GUI component corresponding to the specified test element

getGui

public JMeterGUIComponent getGui(TestElement node,
                                 Class<?> guiClass,
                                 Class<?> testClass)
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 UnsharedComponent, that shared component will be returned. Otherwise, a new instance of the component will be created.

Parameters:
node - the test element which this GUI is being created for
guiClass - the fully qualifed class name of the GUI component which will be created if it doesn't already exist
testClass - the fully qualifed class name of the test elements which have to be edited by the returned GUI component
Returns:
the GUI component corresponding to the specified test element

removeNode

public void removeNode(TestElement node)
Remove a test element from the tree. This removes the reference to any associated GUI component.

Parameters:
node - the test element being removed

getCurrentGui

public JMeterGUIComponent getCurrentGui()
Convenience method for grabbing the gui for the current node.

Returns:
the GUI component associated with the currently selected node

getNodeOf

public ReportTreeNode getNodeOf(TestElement userObject)
Find the JMeterTreeNode for a certain TestElement object.

Parameters:
userObject - the test element to search for
Returns:
the tree node associated with the test element

createTestElement

public TestElement createTestElement(Class<?> guiClass,
                                     Class<?> testClass)
Create a TestElement corresponding to the specified GUI class.

Parameters:
guiClass - the fully qualified class name of the GUI component or a TestBean class for TestBeanGUIs.
testClass - the fully qualified class name of the test elements edited by this GUI component.
Returns:
the test element corresponding to the specified GUI class.

createTestElement

public TestElement createTestElement(String objClass)
Create a TestElement for a GUI or TestBean class.

This is a utility method to help actions do with one single String parameter.

Parameters:
objClass - the fully qualified class name of the GUI component or of the TestBean subclass for which a TestBeanGUI is wanted.
Returns:
the test element corresponding to the specified GUI class.

updateCurrentGui

public void updateCurrentGui()
Update the GUI for the currently selected node. The GUI component is configured to reflect the settings in the current tree node.


updateCurrentNode

public void updateCurrentNode()
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.


getCurrentNode

public ReportTreeNode getCurrentNode()

getCurrentElement

public TestElement getCurrentElement()

setDirty

public void setDirty(boolean dirty)
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.

Parameters:
dirty - the new value of the dirty flag

isDirty

public boolean isDirty()
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.

Returns:
true if some tree components have been modified since they were last saved, false otherwise

addSubTree

public HashTree addSubTree(HashTree subTree)
                    throws IllegalUserActionException
Add a subtree to the currently selected node.

Parameters:
subTree - the subtree to add.
Returns:
the resulting subtree starting with the currently selected node
Throws:
IllegalUserActionException - if a subtree cannot be added to the currently selected node

getCurrentSubTree

public HashTree getCurrentSubTree()
Get the currently selected subtree.

Returns:
the subtree of the currently selected node

getTreeModel

public ReportTreeModel getTreeModel()
Get the model for JMeter's test tree.

Returns:
the JMeter tree model

setTreeModel

public void setTreeModel(ReportTreeModel newTreeModel)
Set the model for JMeter's test tree.

Parameters:
newTreeModel - the new JMeter tree model

getReplacer

public ValueReplacer getReplacer()
Get a ValueReplacer for the test tree.

Returns:
a ValueReplacer configured for the test tree

setMainFrame

public void setMainFrame(ReportMainFrame newMainFrame)
Set the main JMeter frame.

Parameters:
newMainFrame - the new JMeter main frame

getMainFrame

public ReportMainFrame getMainFrame()
Get the main JMeter frame.

Returns:
the main JMeter frame

setTreeListener

public void setTreeListener(ReportTreeListener newTreeListener)
Set the listener for JMeter's test tree.

Parameters:
newTreeListener - the new JMeter test tree listener

getTreeListener

public ReportTreeListener getTreeListener()
Get the listener for JMeter's test tree.

Returns:
the JMeter test tree listener

displayPopUp

public void displayPopUp(MouseEvent e,
                         JPopupMenu popup)
Display the specified popup menu with the source component and location from the specified mouse event.

Parameters:
e - the mouse event causing this popup to be displayed
popup - the popup menu to display

displayPopUp

public void displayPopUp(Component invoker,
                         MouseEvent e,
                         JPopupMenu popup)
Display the specified popup menu at the location specified by a mouse event with the specified source component.

Parameters:
invoker - the source component
e - the mouse event causing this popup to be displayed
popup - the popup menu to display

localeChanged

public void localeChanged(LocaleChangeEvent event)
Specified by:
localeChanged in interface LocaleChangeListener

setReportPlanFile

public void setReportPlanFile(String f)
Sets the filepath of the current test plan. It's shown in the main frame title and used on saving.

Parameters:
f -

getReportPlanFile

public String getReportPlanFile()

Apache JMeter

Copyright © 1998-2012 Apache Software Foundation. All Rights Reserved.