@API(since="5.3",
status=INTERNAL)
public class StaticJMeterGUIComponent
extends Object
implements JMeterGUIComponent
JMeter needs component names to create menus, however, default GUIComponent implementations create UI elements in their constructors. This class implements just the minimal subset of the methods to make menu factory happy.
| Constructor and Description |
|---|
StaticJMeterGUIComponent(Class<?> c,
TestElementMetadata metadata) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearGui()
Clear the gui and return it to initial default values.
|
void |
configure(TestElement element)
The GUI must be able to extract the data from the TestElement and update
all GUI fields to represent those data.
|
JPopupMenu |
createPopupMenu()
When a user right-clicks on the component in the test tree, or selects
the edit menu when the component is selected, the component will be asked
to return a JPopupMenu that provides all the options available to the
user from this component.
|
TestElement |
createTestElement()
JMeter test components are separated into a model and a GUI
representation.
|
String |
getDocAnchor()
Get the component's document anchor name.
|
String |
getLabelResource()
Get the component's resource name, which getStaticLabel uses to derive
the component's label in the local language.
|
Collection<String> |
getMenuCategories()
This is the list of add menu categories this gui component will be
available under.
|
String |
getName()
Gets the name of the JMeter GUI component.
|
String |
getStaticLabel()
Get the component's label.
|
boolean |
isEnabled()
Test GUI elements can be disabled, in which case they do not become part
of the test when run.
|
void |
modifyTestElement(TestElement element)
GUI components are responsible for populating TestElements they create
with the data currently held in the GUI components.
|
void |
setEnabled(boolean enabled)
Set whether this component is enabled.
|
void |
setName(String name)
Sets the name of the JMeter GUI Component.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanBeAddedpublic StaticJMeterGUIComponent(Class<?> c, TestElementMetadata metadata)
public String getLabelResource()
JMeterGUIComponentgetLabelResource in interface JMeterGUIComponentpublic String getStaticLabel()
JMeterGUIComponentgetStaticLabel in interface JMeterGUIComponentJMeterGUIComponent.getLabelResource()public Collection<String> getMenuCategories()
JMeterGUIComponentgetMenuCategories in interface JMeterGUIComponentMenuFactorypublic void setName(String name)
JMeterGUIComponentsetName in interface JMeterGUIComponentname - the name of the componentpublic String getName()
JMeterGUIComponentgetName in interface JMeterGUIComponentpublic String getDocAnchor()
JMeterGUIComponentgetDocAnchor in interface JMeterGUIComponentpublic TestElement createTestElement()
JMeterGUIComponentThe canonical implementation looks like this:
public TestElement createTestElement() {
TestElementXYZ el = new TestElementXYZ();
modifyTestElement(el);
return el;
}
createTestElement in interface JMeterGUIComponentpublic void modifyTestElement(TestElement element)
JMeterGUIComponentThe canonical implementation looks like this:
public void modifyTestElement(TestElement element) {
element.clear(); // many implementations use this
configureTestElement(element);
// Using the element setters (preferred):
TestElementXYZ xyz = (TestElementXYZ) element;
xyz.setState(guiState.getText());
xyz.setCode(guiCode.getText());
... other GUI fields ...
// or directly (do not use unless there is no setter for the field):
element.setProperty(TestElementXYZ.STATE, guiState.getText())
element.setProperty(TestElementXYZ.CODE, guiCode.getText())
... other GUI fields ...
}
modifyTestElement in interface JMeterGUIComponentelement - the TestElement to modifypublic boolean isEnabled()
JMeterGUIComponentisEnabled in interface JMeterGUIComponentpublic void setEnabled(boolean enabled)
JMeterGUIComponentsetEnabled in interface JMeterGUIComponentenabled - true for enabled, false for disabled.public JPopupMenu createPopupMenu()
JMeterGUIComponentcreatePopupMenu in interface JMeterGUIComponentpublic void configure(TestElement element)
JMeterGUIComponentThe canonical implementation looks like this:
public void configure(TestElement element) {
super.configure(element);
// Using the element getter (preferred):
TestElementXYZ xyz = (TestElementXYZ) element;
guiState.setText(xyz.getState());
guiCode.setText(xyz.getCode());
... other GUI fields ...
// or using the element property names directly (do not use unless there is no getter for the field)
guiState.setText(element.getPropertyAsString(TestElementXYZ.STATE));
guiCode.setText(element.getPropertyAsString(TestElementXYZ.CODE));
... other GUI fields ...
}
configure in interface JMeterGUIComponentelement - the TestElement to configurepublic void clearGui()
ClearGuiCopyright © 1998-2019 Apache Software Foundation. All Rights Reserved.