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
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.
addSubTree
public HashTree addSubTree(HashTree subTree)
throws IllegalUserActionException
Add a subtree to the currently selected node.
subTree
- the subtree to add.
- the resulting subtree starting with the currently selected node
clearTestPlan
public void clearTestPlan()
Clears the test plan and associated objects.
Clears the test plan file name.
clearTestPlan
public void clearTestPlan(TestElement element)
Clears the test plan element and associated object
createTestElement
public TestElement createTestElement(Class guiClass,
Class testClass)
Create a TestElement corresponding to the specified GUI class.
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.
- 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.
objClass
- the fully qualified class name of the GUI component or of the
TestBean subclass for which a TestBeanGUI is wanted.
- the test element corresponding to the specified GUI class.
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.
invoker
- the source componente
- the mouse event causing this popup to be displayedpopup
- the popup menu to display
displayPopUp
public void displayPopUp(MouseEvent e,
JPopupMenu popup)
Display the specified popup menu with the source component and location
from the specified mouse event.
e
- the mouse event causing this popup to be displayedpopup
- the popup menu to display
getCurrentElement
public TestElement getCurrentElement()
getCurrentGui
public JMeterGUIComponent getCurrentGui()
Convenience method for grabbing the gui for the current node.
- the GUI component associated with the currently selected node
getCurrentSubTree
public HashTree getCurrentSubTree()
Get the currently selected subtree.
- the subtree of the currently selected node
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.
node
- the test element which this GUI is being created for
- 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.
node
- the test element which this GUI is being created forguiClass
- the fully qualifed class name of the GUI component which will
be created if it doesn't already existtestClass
- the fully qualifed class name of the test elements which have
to be edited by the returned GUI component
- the GUI component corresponding to the specified test element
getInstance
public static GuiPackage getInstance()
Retrieve the singleton GuiPackage instance.
getInstance
public static GuiPackage getInstance(JMeterTreeListener listener,
JMeterTreeModel treeModel)
When GuiPackage is requested for the first time, it should be given
handles to JMeter's Tree Listener and TreeModel.
listener
- the TreeListener for JMeter's test treetreeModel
- the model for JMeter's test tree
getMainFrame
public MainFrame getMainFrame()
Get the main JMeter frame.
getNodeOf
public JMeterTreeNode getNodeOf(TestElement userObject)
Find the JMeterTreeNode for a certain TestElement object.
userObject
- the test element to search for
- the tree node associated with the test element
getReplacer
public ValueReplacer getReplacer()
Get a ValueReplacer for the test tree.
- a ValueReplacer configured for the test tree
getTestPlanFile
public String getTestPlanFile()
getTreeListener
public JMeterTreeListener getTreeListener()
Get the listener for JMeter's test tree.
- the JMeter test tree listener
getTreeModel
public JMeterTreeModel getTreeModel()
Get the model for JMeter's test tree.
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.
- true if some tree components have been modified since they were
last saved, false otherwise
removeNode
public void removeNode(TestElement node)
Remove a test element from the tree. This removes the reference to any
associated GUI component.
node
- the test element being removed
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.
dirty
- the new value of the dirty flag
setMainFrame
public void setMainFrame(MainFrame newMainFrame)
Set the main JMeter frame.
newMainFrame
- the new JMeter main frame
setTestPlanFile
public void setTestPlanFile(String f)
Sets the filepath of the current test plan. It's shown in the main frame
title and used on saving.
setTreeListener
public void setTreeListener(JMeterTreeListener newTreeListener)
Set the listener for JMeter's test tree.
newTreeListener
- the new JMeter test tree listener
setTreeModel
public void setTreeModel(JMeterTreeModel newTreeModel)
Set the model for JMeter's test tree.
newTreeModel
- the new JMeter tree model
showErrorMessage
public static void showErrorMessage(String message,
String title)
showInfoMessage
public static void showInfoMessage(String message,
String title)
showMessage
public static void showMessage(String message,
String title,
int type)
showWarningMessage
public static void showWarningMessage(String message,
String title)
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.